Communitygithub.com

代码库入职指南

分析不熟悉的代码库,生成结构化入职指南,包含架构图、关键入口点、约定和入门版 CLAUDE.md。适合加入新项目或首次在仓库中设置 Claude Code 时使用。

代码库入职指南 是什么?

该技能旨在帮助开发者在首次接触不熟悉代码库时快速上手,或为现有仓库配置 Claude Code。技能通过四个阶段(侦察、架构映射、约定检测、生成入职文档)系统化地分析项目,然后输出两份关键产物:一份结构化入职指南(包含技术栈、架构、目录映射、请求生命周期、约定和常见任务),以及一份针对项目的 CLAUDE.md 文件。该技能支持大多数主流编程语言和框架(如 JavaScript/TypeScript、Python、Go、Rust、Java 等),并能在 Claude Code、Cursor 和其他支持技能定义的 AI 编码代理中使用。其核心优势在于无需逐个文件阅读即可提取项目架构和约定,大幅降低新项目的学习曲线。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/codebase-onboarding

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

代码库入职指南 是做什么的?

系统分析不熟悉的代码库,并生成结构化的入职指南。专为加入新项目或首次在现有仓库中设置 Claude Code 的开发者设计。

使用时机

  • 首次用 Claude Code 打开项目时
  • 加入新团队或仓库时
  • 用户要求“帮我了解这个代码库”时
  • 用户要求为项目生成 CLAUDE.md 时
  • 用户说“帮我入职”或“带我了解这个仓库”时

工作原理

第一阶段:侦察

在不读取每个文件的情况下收集项目的原始信号。并行执行以下检查:

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 settings, flask app factory, fastapi main, rails config

3. 入口点识别
   → main.*, index.*, app.*, server.*, cmd/, src/main/

4. 目录结构快照
   → 目录树的前两层,忽略 node_modules, vendor,
     .git, dist, build, __pycache__, .next

5. 配置和工具检测
   → .eslintrc*, .prettierrc*, tsconfig.json, Makefile, Dockerfile,
     docker-compose*, .github/workflows/, .env.example, CI configs

6. 测试结构检测
   → tests/, test/, __tests__/, *_test.go, *.spec.ts, *.test.js,
     pytest.ini, jest.config.*, vitest.config.*

第二阶段:架构映射

根据侦察数据识别:

技术栈

  • 语言及版本约束
  • 框架和主要库
  • 数据库和 ORM
  • 构建工具和打包器
  • CI/CD 平台

架构模式

  • 单体、单仓库、微服务或无服务器
  • 前后端分离或全栈
  • API 风格:REST、GraphQL、gRPC、tRPC

关键目录 将顶层目录映射到其用途:

src/components/  → React UI 组件
src/api/         → API 路由处理
src/lib/         → 共享工具
src/db/          → 数据库模型和迁移
tests/           → 测试套件
scripts/         → 构建和部署脚本

数据流 追踪一次请求从入口到响应的过程:

  • 请求从哪里进入?(路由器、处理程序、控制器)
  • 如何验证?(中间件、模式、守卫)
  • 业务逻辑在哪里?(服务、模型、用例)
  • 如何到达数据库?(ORM、原始查询、仓库)

第三阶段:约定检测

识别代码库已遵循的模式:

命名约定

  • 文件命名:kebab-case、camelCase、PascalCase、snake_case
  • 组件/类命名模式
  • 测试文件命名:*.test.ts、*.spec.ts、*_test.go

代码模式

  • 错误处理风格:try/catch、Result 类型、错误码
  • 依赖注入或直接导入
  • 状态管理方法
  • 异步模式:回调、Promise、async/await、channel

Git 约定

  • 从最近分支分析分支命名
  • 从最近提交分析提交消息风格
  • PR 工作流(Squash、Merge、Rebase)
  • 如果仓库没有提交记录或只有浅层历史(如 git clone --depth 1),跳过此部分并注明“Git 历史不可用或过于浅层,无法检测约定”

第四阶段:生成入职文档

生成两个输出:

输出 1:入职指南

# 入职指南:[项目名称]

## 概述
[2-3 句:该项目做什么,为谁服务]

## 技术栈
<!-- 示例使用 Next.js 项目 — 根据检测到的栈替换 -->
| 层 | 技术 | 版本 |
|-------|-----------|---------|
| 语言 | TypeScript | 5.x |
| 框架 | Next.js | 14.x |
| 数据库 | PostgreSQL | 16 |
| ORM | Prisma | 5.x |
| 测试 | Jest + Playwright | - |

## 架构
[组件连接方式的图表或描述]

## 关键入口点
<!-- 示例使用 Next.js 项目 — 根据检测到的路径替换 -->
- **API 路由**:`src/app/api/` — Next.js 路由处理
- **UI 页面**:`src/app/(dashboard)/` — 已验证页面
- **数据库**:`prisma/schema.prisma` — 数据模型源头
- **配置**:`next.config.ts` — 构建和运行时配置

## 目录映射
[顶层目录 → 用途映射]

## 请求生命周期
[追踪一次 API 请求从入口到响应的过程]

## 约定
- [文件命名模式]
- [错误处理方法]
- [测试模式]
- [Git 工作流]

## 常见任务
<!-- 示例使用 Node.js 项目 — 根据检测到的命令替换 -->
- **运行开发服务器**:`npm run dev`
- **运行测试**:`npm test`
- **运行 linter**:`npm run lint`
- **数据库迁移**:`npx prisma migrate dev`
- **生产构建**:`npm run build`

## 查看位置
<!-- 示例使用 Next.js 项目 — 根据检测到的路径替换 -->
| 我想…… | 查看…… |
|--------------|-----------|
| 添加 API 端点 | `src/app/api/` |
| 添加 UI 页面 | `src/app/(dashboard)/` |
| 添加数据库表 | `prisma/schema.prisma` |
| 添加测试 | `tests/` 匹配源路径 |
| 修改构建配置 | `next.config.ts` |

输出 2:入门版 CLAUDE.md

根据检测到的约定生成或更新项目专属的 CLAUDE.md。如果 CLAUDE.md 已存在,先读取它并增强——保留现有的项目专属指令,并清楚标注新增或更改的内容。

# 项目说明

## 技术栈
[检测到的技术栈摘要]

## 代码风格
- [检测到的命名约定]
- [检测到的要遵循的模式]

## 测试
- 运行测试:`[检测到的测试命令]`
- 测试模式:[检测到的测试文件约定]
- 覆盖率:[如果已配置,覆盖率命令]

## 构建与运行
- 开发:`[检测到的开发命令]`
- 构建:`[检测到的构建命令]`
- Lint:`[检测到的 lint 命令]`

## 项目结构
[关键目录 → 用途映射]

## 约定
- [如果可检测,提交风格]
- [如果可检测,PR 工作流]
- [错误处理模式]

最佳实践

  1. 不要读取所有内容——侦察应使用 Glob 和 Grep,而不是对每个文件进行 Read。仅在信号不明确时选择性读取。
  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

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能