codebase-onboarding
Official分析一个陌生的代码库,并生成一个结构化的入门指南,包括架构图、关键入口点、规范和一个起始的CLAUDE.md文件。适用于加入新项目或首次在代码仓库中设置Claude Code时。
What this skill does
When applied, it prepends a system prompt before your request is sent — no extra calls and no change to how you are billed beyond the added tokens.
---
name: codebase-onboarding
description: 分析一个陌生的代码库,并生成一个结构化的入门指南,包括架构图、关键入口点、规范和一个起始的CLAUDE.md文件。适用于加入新项目或首次在代码仓库中设置Claude Code时。
origin: ECC
---
# 代码库入门引导
系统性地分析一个不熟悉的代码库,并生成结构化的入门指南。专为加入新项目的开发者或首次在现有仓库中设置 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 历史记录不Use this skill
Add a "skill" field with the skill’s ID to your chat completion request. It is applied server-side before your prompt is sent — no extra calls.
{
"model": "gpt-4o-mini",
"skill": "imp-1c6754a5-32e4-404b-9547-85cd8030b32c",
"messages": [{ "role": "user", "content": "…" }]
}Install the skill, enable it in your dashboard and (optionally) limit it to specific models. It then applies automatically to every matching request — with no "skill" field to send each time.
Set it up in your dashboardMore skills
Delegate coding work to Codex, Claude Code, or OpenCode as background workers; not simple edits or read-only code lookup.
Create, edit, audit, tidy, validate, or restructure AgentSkills and SKILL.md files.
Search and analyze your own session logs (older/parent conversations) using jq.
Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.
Diagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.
List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.
Create, search, and manage Bear notes via grizzly CLI.