codebase-onboarding
分析一个陌生的代码库,并生成一个结构化的入门指南,包括架构图、关键入口点、规范和一个起始的CLAUDE.md文件。适用于加入新项目或首次在代码仓库中设置Claude Code时。
About this skill
This AI skill empowers Claude to systematically analyze any unfamiliar codebase and generate a comprehensive, structured onboarding guide. It's meticulously designed to accelerate developer integration into new projects or to facilitate the initial setup of Claude Code within an existing repository. The generated guide encompasses essential components such as high-level architecture diagrams or descriptions, identification of critical application entry points, detected coding conventions and project norms, and a foundational `CLAUDE.md` file to streamline future AI interactions. By performing an intelligent initial reconnaissance of package manifests, framework configurations, and directory structure, Claude efficiently gathers crucial project information without the need for exhaustive file-by-file reading, providing immediate and actionable insights for developers aiming to quickly grasp a new project's intricacies.
Best use case
Streamlining developer onboarding for new projects or teams, and preparing a codebase for effective interaction with the Claude AI agent.
分析一个陌生的代码库,并生成一个结构化的入门指南,包括架构图、关键入口点、规范和一个起始的CLAUDE.md文件。适用于加入新项目或首次在代码仓库中设置Claude Code时。
A structured onboarding document presented in Markdown format, which includes: * A high-level architecture diagram or descriptive overview. * Clearly identified key entry points for the application or service. * Detected coding conventions, project norms, and recommended development practices. * A summary of the project's detected frameworks, languages, and core dependencies. * An initial `CLAUDE.md` file pre-configured with suggestions for future AI interactions within the repository.
Practical example
Example input
Claude, analyze this codebase and generate a comprehensive onboarding guide for me, including a CLAUDE.md file.
Example output
```markdown
# Project Onboarding Guide: [Your Project Name]
## Overview
This project is a [brief description, e.g., 'React-based web application with a Node.js backend'] primarily focused on [core functionality]. It utilizes [key technologies like TypeScript, Express, PostgreSQL].
## Architecture Sketch
```mermaid
graph TD
A[User Browser] --> B(Frontend: React/Next.js)
B --> C(API Gateway/Backend: Node.js/Express)
C --> D(Database: PostgreSQL)
C --> E(External Services: Auth0, Stripe)
```
* **Key Components:** Frontend (`/src/frontend`), Backend (`/src/backend`), Database interactions (`/src/backend/db`).
* **Data Flow:** User requests hit the frontend, which communicates with the backend API. The backend handles business logic, interacts with the PostgreSQL database, and integrates with external services.
## Key Entry Points
* **Frontend Application:** `frontend/src/index.tsx` (main React app entry)
* **Backend API Server:** `backend/src/server.ts` (Express server initialization)
* **Database Migrations:** `backend/src/db/migrations/` (migration scripts)
* **CLI Tools:** `scripts/cli.js` (example custom CLI)
## Detected Frameworks & Dependencies
* **Frontend:** React 18, Next.js 13, TypeScript
* **Backend:** Node.js 18, Express 4, TypeORM
* **Database:** PostgreSQL
* **Package Management:** npm (for both frontend and backend)
## Conventions & Style
* **Language:** TypeScript (strict mode)
* **Formatting:** Prettier (configured via `.prettierrc`)
* **Linting:** ESLint (via `.eslintrc.js`)
* **Tests:** Jest for unit tests, Cypress for E2E tests.
* **Commit Messages:** Conventional Commits standard.
## Initial CLAUDE.md
```markdown
# Welcome to [Your Project Name] with Claude Code!
This repository is a [brief description, e.g., 'full-stack web application for task management'].
**Key areas Claude can help you with:**
* **Code Navigation:** "Show me where user authentication is handled in the backend."
* **Feature Development:** "Help me implement a new 'dark mode' feature in the frontend."
* **Debugging Assistance:** "Explain the error in `backend/src/services/userService.ts` on line 45."
* **Refactoring Suggestions:** "Suggest improvements for the `ProductController` in `backend/src/controllers/productController.ts`."
* **Documentation Generation:** "Generate JSDoc comments for the `frontend/src/utils/helpers.ts` file."
**To get started with Claude in this project:**
1. **Understand the project:** Use the `codebase-onboarding` skill again anytime you need a refresh on the project structure.
2. **Explore specific files:** "Read the contents of `frontend/src/components/Dashboard.tsx`."
3. **Ask for help:** "What are the main API endpoints available in this application?"
```When to use this skill
- When a developer joins a new team or repository and needs a quick overview.
- When opening a project with Claude Code for the very first time.
- When the user asks the AI to 'help me understand this codebase' or 'walk me through this repository'.
- When the user specifically requests an onboarding guide or a `CLAUDE.md` file for the project.
When not to use this skill
- For very small, extremely simple projects where a detailed onboarding guide might be overkill.
- When the developer is already intimately familiar with every aspect of the codebase.
- If the primary goal is a deep-dive into a specific bug or a very granular code review, rather than a high-level overview.
- In situations where the codebase is highly fragmented or lacks standard project structures, which might reduce the effectiveness of automated analysis (though the skill is designed to handle common patterns).
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/codebase-onboarding/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How codebase-onboarding Compares
| Feature / Agent | codebase-onboarding | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
分析一个陌生的代码库,并生成一个结构化的入门指南,包括架构图、关键入口点、规范和一个起始的CLAUDE.md文件。适用于加入新项目或首次在代码仓库中设置Claude Code时。
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# 代码库入门引导
系统性地分析一个不熟悉的代码库,并生成结构化的入门指南。专为加入新项目的开发者或首次在现有仓库中设置 Claude Code 的用户设计。
## 使用时机
* 首次使用 Claude Code 打开项目时
* 加入新团队或新仓库时
* 用户询问“帮我理解这个代码库”
* 用户要求为项目生成 CLAUDE.md 文件
* 用户说“带我入门”或“带我浏览这个仓库”
## 工作原理
### 阶段 1:初步侦察
在不阅读每个文件的情况下,收集关于项目的原始信息。并行运行以下检查:
```
1. 包清单检测
→ package.json、go.mod、Cargo.toml、pyproject.toml、pom.xml、build.gradle、
Gemfile、composer.json、mix.exs、pubspec.yaml
2. 框架指纹识别
→ next.config.*、nuxt.config.*、angular.json、vite.config.*、
django 设置、flask 应用工厂、fastapi 主程序、rails 配置
3. 入口点识别
→ main.*、index.*、app.*、server.*、cmd/、src/main/
4. 目录结构快照
→ 目录树的前 2 层,忽略 node_modules、vendor、
.git、dist、build、__pycache__、.next
5. 配置与工具检测
→ .eslintrc*、.prettierrc*、tsconfig.json、Makefile、Dockerfile、
docker-compose*、.github/workflows/、.env.example、CI 配置
6. 测试结构检测
→ tests/、test/、__tests__/、*_test.go、*.spec.ts、*.test.js、
pytest.ini、jest.config.*、vitest.config.*
```
### 阶段 2:架构映射
根据侦察数据,识别:
**技术栈**
* 语言及版本限制
* 框架及主要库
* 数据库及 ORM
* 构建工具和打包器
* CI/CD 平台
**架构模式**
* 单体、单体仓库、微服务,还是无服务器
* 前端/后端分离,还是全栈
* API 风格:REST、GraphQL、gRPC、tRPC
**关键目录**
将顶级目录映射到其用途:
<!-- Example for a React project — replace with detected directories -->
```
src/components/ → React UI 组件
src/api/ → API 路由处理程序
src/lib/ → 共享工具库
src/db/ → 数据库模型和迁移文件
tests/ → 测试套件
scripts/ → 构建和部署脚本
```
**数据流**
追踪一个请求从入口到响应的路径:
* 请求从哪里进入?(路由器、处理器、控制器)
* 如何进行验证?(中间件、模式、守卫)
* 业务逻辑在哪里?(服务、模型、用例)
* 如何访问数据库?(ORM、原始查询、存储库)
### 阶段 3:规范检测
识别代码库已遵循的模式:
**命名规范**
* 文件命名:kebab-case、camelCase、PascalCase、snake\_case
* 组件/类命名模式
* 测试文件命名:`*.test.ts`、`*.spec.ts`、`*_test.go`
**代码模式**
* 错误处理风格:try/catch、Result 类型、错误码
* 依赖注入还是直接导入
* 状态管理方法
* 异步模式:回调、Promise、async/await、通道
**Git 规范**
* 根据最近分支推断分支命名
* 根据最近提交推断提交信息风格
* PR 工作流(压缩合并、合并、变基)
* 如果仓库尚无提交记录或历史记录很浅(例如 `git clone --depth 1`),则跳过此部分并注明“Git 历史记录不可用或过浅,无法检测规范”
### 阶段 4:生成入门工件
生成两个输出:
#### 输出 1:入门指南
```markdown
# 新手上路指南:[项目名称]
## 概述
[2-3句话:说明本项目的作用及服务对象]
## 技术栈
<!-- Example for a Next.js project — replace with detected stack -->
| 层级 | 技术 | 版本 |
|-------|-----------|---------|
| 语言 | TypeScript | 5.x |
| 框架 | Next.js | 14.x |
| 数据库 | PostgreSQL | 16 |
| ORM | Prisma | 5.x |
| 测试 | Jest + Playwright | - |
## 架构
[组件连接方式的图表或描述]
## 关键入口点
<!-- Example for a Next.js project — replace with detected paths -->
- **API 路由**: `src/app/api/` — Next.js 路由处理器
- **UI 页面**: `src/app/(dashboard)/` — 经过身份验证的页面
- **数据库**: `prisma/schema.prisma` — 数据模型的单一事实来源
- **配置**: `next.config.ts` — 构建和运行时配置
## 目录结构
[顶级目录 → 用途映射]
## 请求生命周期
[追踪一个 API 请求从入口到响应的全过程]
## 约定
- [文件命名模式]
- [错误处理方法]
- [测试模式]
- [Git 工作流程]
## 常见任务
<!-- Example for a Node.js project — replace with detected commands -->
- **运行开发服务器**: `npm run dev`
- **运行测试**: `npm test`
- **运行代码检查工具**: `npm run lint`
- **数据库迁移**: `npx prisma migrate dev`
- **生产环境构建**: `npm run build`
## 查找位置
<!-- Example for a Next.js project — replace with detected paths -->
| 我想... | 查看... |
|--------------|-----------|
| 添加 API 端点 | `src/app/api/` |
| 添加 UI 页面 | `src/app/(dashboard)/` |
| 添加数据库表 | `prisma/schema.prisma` |
| 添加测试 | `tests/` (与源路径匹配) |
| 更改构建配置 | `next.config.ts` |
```
#### 输出 2:初始 CLAUDE.md
根据检测到的规范,生成或更新项目特定的 CLAUDE.md。如果 `CLAUDE.md` 已存在,请先读取它并进行增强——保留现有的项目特定说明,并明确标注新增或更改的内容。
```markdown
# 项目说明
## 技术栈
[检测到的技术栈摘要]
## 代码风格
- [检测到的命名规范]
- [检测到的应遵循的模式]
## 测试
- 运行测试:`[detected test command]`
- 测试模式:[检测到的测试文件约定]
- 覆盖率:[如果已配置,覆盖率命令]
## 构建与运行
- 开发:`[detected dev command]`
- 构建:`[detected build command]`
- 代码检查:`[detected lint command]`
## 项目结构
[关键目录 → 用途映射]
## 约定
- [可检测到的提交风格]
- [可检测到的 PR 工作流程]
- [错误处理模式]
```
## 最佳实践
1. **不要通读所有内容** —— 侦察阶段应使用 Glob 和 Grep,而非读取每个文件。仅在信号不明确时有选择性地读取。
2. **验证而非猜测** —— 如果从配置文件中检测到某个框架,但实际代码使用了不同的东西,请以代码为准。
3. **尊重现有的 CLAUDE.md** —— 如果文件已存在,请增强它而不是替换它。明确标注哪些是新增内容,哪些是原有内容。
4. **保持简洁** —— 入门指南应在 2 分钟内可快速浏览。细节应留在代码中,而非指南里。
5. **标记未知项** —— 如果无法自信地检测到某个规范,请如实说明而非猜测。“无法确定测试运行器”比给出错误答案更好。
## 应避免的反模式
* 生成超过 100 行的 CLAUDE.md —— 保持其聚焦
* 列出每个依赖项 —— 仅突出那些影响编码方式的依赖
* 描述显而易见的目录名 —— `src/` 不需要解释
* 复制 README —— 入门指南应提供 README 所缺乏的结构性见解
## 示例
### 示例 1:首次进入新仓库
**用户**:“带我入门这个代码库”
**操作**:运行完整的 4 阶段工作流 → 生成入门指南 + 初始 CLAUDE.md
**输出**:入门指南直接打印到对话中,并在项目根目录写入一个 `CLAUDE.md`
### 示例 2:为现有项目生成 CLAUDE.md
**用户**:“为这个项目生成一个 CLAUDE.md”
**操作**:运行阶段 1-3,跳过入门指南,仅生成 CLAUDE.md
**输出**:包含检测到的规范的项目特定 `CLAUDE.md`
### 示例 3:增强现有的 CLAUDE.md
**用户**:“用当前项目规范更新 CLAUDE.md”
**操作**:读取现有 CLAUDE.md,运行阶段 1-3,合并新发现
**输出**:更新后的 `CLAUDE.md`,并明确标记了新增内容Related Skills
workspace-surface-audit
Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then recommend the highest-value ECC-native skills, hooks, agents, and operator workflows. Use when the user wants help setting up Claude Code or understanding what capabilities are actually available in their environment.
safety-guard
Use this skill to prevent destructive operations when working on production systems or running agents autonomously.
repo-scan
Cross-stack source code asset audit — classifies every file, detects embedded third-party libraries, and delivers actionable four-level verdicts per module with interactive HTML reports.
project-flow-ops
Operate execution flow across GitHub and Linear by triaging issues and pull requests, linking active work, and keeping GitHub public-facing while Linear remains the internal execution layer. Use when the user wants backlog control, PR triage, or GitHub-to-Linear coordination.
manim-video
Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider ECC video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.
laravel-plugin-discovery
Discover and evaluate Laravel packages via LaraPlugins.io MCP. Use when the user wants to find plugins, check package health, or assess Laravel/PHP compatibility.
design-system
Use this skill to generate or audit design systems, check visual consistency, and review PRs that touch styling.
click-path-audit
Trace every user-facing button/touchpoint through its full state change sequence to find bugs where functions individually work but cancel each other out, produce wrong final state, or leave the UI in an inconsistent state. Use when: systematic debugging found no bugs but users report broken buttons, or after any major refactor touching shared state stores.
ck
Persistent per-project memory for Claude Code. Auto-loads project context on session start, tracks sessions with git activity, and writes to native memory. Commands run deterministic Node.js scripts — behavior is consistent across model versions.
canary-watch
Use this skill to monitor a deployed URL for regressions after deploys, merges, or dependency upgrades.
benchmark
Use this skill to measure performance baselines, detect regressions before/after PRs, and compare stack alternatives.
swiftui-patterns
SwiftUI 架构模式,使用 @Observable 进行状态管理,视图组合,导航,性能优化,以及现代 iOS/macOS UI 最佳实践。