Codebase Analysis Skill
Analyze codebases systematically and create comprehensive CLAUDE.md/AGENTS.md files that help future AI instances understand the project.
When to use
Trigger this skill when:
- User asks "analyze this codebase" / "创建CLAUDE.md" / "create AGENTS.md"
- User wants to understand a project's structure and conventions
- User asks to create documentation for AI agents
- User says "Please analyze this codebase and create a CLAUDE.md file"
Workflow
1. Project Discovery
# List root directory
ls -la
# Check for existing docs
cat README.md
cat package.json
cat go.mod
cat Cargo.toml
# Find source directories
find . -type f -name "*.ts" -o -name "*.js" -o -name "*.go" -o -name "*.py" | head -20
2. Architecture Analysis
Identify:
- Language(s): TypeScript, Go, Python, etc.
- Framework(s): React, Express, Gin, etc.
- Structure: monorepo, single package, microservices
- Entry points: main files, CLI entry, API routes
- Key directories: src/, lib/, cmd/, internal/, tests/
3. Codebase Map
Create a mental map of:
- Core modules and their responsibilities
- Data flow (API → Service → Database)
- Configuration files and env vars
- Build/test/deploy pipeline
- Dependencies and their purposes
4. Conventions Detection
Look for:
- Naming: camelCase, snake_case, kebab-case
- Imports: relative, absolute, barrel files
- Error handling: try/catch, error boundaries, custom errors
- Testing: framework, patterns, coverage expectations
- Git: commit message format, branch naming
5. Create CLAUDE.md / AGENTS.md
Structure the file as:
# [Project Name]
[One-paragraph description]
## Quick Start
[How to run the project]
## Architecture
[High-level structure]
## Key Files
[Important files and their roles]
## Conventions
[Code style, naming, patterns]
## Common Tasks
[How to add features, fix bugs, etc.]
## Environment
[Required env vars, config files]
## Testing
[How to run tests, test conventions]
## Deployment
[How to deploy, CI/CD]
6. Validation
After creating the file:
- Verify all referenced paths exist
- Check that commands actually work
- Ensure examples are accurate
- Test any code snippets
Example Usage
User: Please analyze this codebase and create a CLAUDE.md file, which will be given to future instances of Codex working on this codebase.
Agent workflow:
1. ls -la (discover project structure)
2. cat package.json / go.mod (identify language/framework)
3. Find key source files
4. Analyze architecture
5. Create comprehensive CLAUDE.md
6. Validate references
Output Format
The CLAUDE.md should be:
- Concise: 200-500 lines max
- Actionable: Focus on what agents need to know
- Accurate: Only include verified information
- Bilingual: English primary, Chinese comments if helpful
Key Analysis Points
For TypeScript/Node.js Projects
- Check
package.json for scripts, dependencies
- Look for
tsconfig.json configuration
- Identify build output (
dist/, build/)
- Check for monorepo (lerna, nx, turborepo)
For Go Projects
- Check
go.mod for module name and dependencies
- Look for
cmd/ directory structure
- Identify internal packages
- Check for Makefile or build scripts
For Python Projects
- Check
pyproject.toml or setup.py
- Look for
requirements.txt or poetry.lock
- Identify package structure
- Check for virtual environments
Don't Use This Skill For
- Modifying code (use other skills)
- Deploying (use deployment workflows)
- PR review (use pr-review skill)
- Issue investigation (use issue-investigation skill)
1---2name: codebase-analysis3description: Analyze a codebase and create CLAUDE.md/AGENTS.md files for future AI instances. Use when the user asks to analyze a project, create agent instructions, or understand a codebase structure.4---56# Codebase Analysis Skill78Analyze codebases systematically and create comprehensive CLAUDE.md/AGENTS.md files that help future AI instances understand the project.910## When to use1112Trigger this skill when:13- User asks "analyze this codebase" / "创建CLAUDE.md" / "create AGENTS.md"14- User wants to understand a project's structure and conventions15- User asks to create documentation for AI agents16- User says "Please analyze this codebase and create a CLAUDE.md file"1718## Workflow1920### 1. Project Discovery2122```bash23# List root directory24ls -la2526# Check for existing docs27cat README.md28cat package.json29cat go.mod30cat Cargo.toml3132# Find source directories33find . -type f -name "*.ts" -o -name "*.js" -o -name "*.go" -o -name "*.py" | head -2034```3536### 2. Architecture Analysis3738Identify:39- **Language(s)**: TypeScript, Go, Python, etc.40- **Framework(s)**: React, Express, Gin, etc.41- **Structure**: monorepo, single package, microservices42- **Entry points**: main files, CLI entry, API routes43- **Key directories**: src/, lib/, cmd/, internal/, tests/4445### 3. Codebase Map4647Create a mental map of:48- Core modules and their responsibilities49- Data flow (API → Service → Database)50- Configuration files and env vars51- Build/test/deploy pipeline52- Dependencies and their purposes5354### 4. Conventions Detection5556Look for:57- **Naming**: camelCase, snake_case, kebab-case58- **Imports**: relative, absolute, barrel files59- **Error handling**: try/catch, error boundaries, custom errors60- **Testing**: framework, patterns, coverage expectations61- **Git**: commit message format, branch naming6263### 5. Create CLAUDE.md / AGENTS.md6465Structure the file as:6667```markdown68# [Project Name]6970[One-paragraph description]7172## Quick Start7374[How to run the project]7576## Architecture7778[High-level structure]7980## Key Files8182[Important files and their roles]8384## Conventions8586[Code style, naming, patterns]8788## Common Tasks8990[How to add features, fix bugs, etc.]9192## Environment9394[Required env vars, config files]9596## Testing9798[How to run tests, test conventions]99100## Deployment101102[How to deploy, CI/CD]103```104105### 6. Validation106107After creating the file:108- Verify all referenced paths exist109- Check that commands actually work110- Ensure examples are accurate111- Test any code snippets112113## Example Usage114115```116User: Please analyze this codebase and create a CLAUDE.md file, which will be given to future instances of Codex working on this codebase.117118Agent workflow:1191. ls -la (discover project structure)1202. cat package.json / go.mod (identify language/framework)1213. Find key source files1224. Analyze architecture1235. Create comprehensive CLAUDE.md1246. Validate references125```126127## Output Format128129The CLAUDE.md should be:130- **Concise**: 200-500 lines max131- **Actionable**: Focus on what agents need to know132- **Accurate**: Only include verified information133- **Bilingual**: English primary, Chinese comments if helpful134135## Key Analysis Points136137### For TypeScript/Node.js Projects138- Check `package.json` for scripts, dependencies139- Look for `tsconfig.json` configuration140- Identify build output (`dist/`, `build/`)141- Check for monorepo (lerna, nx, turborepo)142143### For Go Projects144- Check `go.mod` for module name and dependencies145- Look for `cmd/` directory structure146- Identify internal packages147- Check for Makefile or build scripts148149### For Python Projects150- Check `pyproject.toml` or `setup.py`151- Look for `requirements.txt` or `poetry.lock`152- Identify package structure153- Check for virtual environments154155## Don't Use This Skill For156157- Modifying code (use other skills)158- Deploying (use deployment workflows)159- PR review (use pr-review skill)160- Issue investigation (use issue-investigation skill)