Codebase Onboarding Generator
Overview
This skill analyzes a codebase to automatically generate comprehensive CLAUDE.md documentation. It identifies common commands, build processes, test patterns, directory structure conventions, and key architectural decisions. The generated documentation follows best practices for Claude Code onboarding and enables efficient AI-assisted development.
When to Use
- Setting up Claude Code for a new project that lacks CLAUDE.md
- Generating initial project documentation for AI assistants
- Refreshing outdated CLAUDE.md files after significant project changes
- Creating standardized onboarding documentation for team codebases
- Analyzing unfamiliar codebases to understand structure and conventions
Prerequisites
- Python 3.9+
- No API keys required
- Standard library only (pathlib, json, os, re)
Workflow
Step 1: Analyze Codebase Structure
Run the codebase analyzer to detect project type, directory structure, and key files.
python3 scripts/analyze_codebase.py \
--path /path/to/project \
--output analysis.json
The analyzer detects:
- Project type (Python, Node.js, Java, Go, Rust, etc.)
- Package manager and dependency files
- Build and test configuration
- Directory conventions (src/, lib/, tests/, etc.)
- Key configuration files (.gitignore, CI configs, etc.)
Step 2: Extract Common Commands
Parse package.json, Makefile, pyproject.toml, or other build files to extract:
- Build commands
- Test commands
- Lint/format commands
- Development server commands
- Deployment commands
Step 3: Identify Architectural Patterns
Analyze code structure to identify:
- Framework usage (React, Django, Spring, etc.)
- Design patterns (MVC, microservices, monolith)
- API conventions (REST, GraphQL, gRPC)
- Database technologies (SQL, NoSQL, ORM)
- Testing frameworks and patterns
Step 4: Generate CLAUDE.md
Synthesize analysis results into a comprehensive CLAUDE.md file.
python3 scripts/analyze_codebase.py \
--path /path/to/project \
--generate-claude-md \
--output CLAUDE.md
Step 5: Review and Customize
Review the generated CLAUDE.md for:
- Accuracy of detected commands and patterns
- Missing project-specific conventions
- Security considerations (ensure no secrets are referenced)
- Team-specific guidelines to add manually
Output Format
JSON Analysis Report
{
"schema_version": "1.1",
"project_name": "example-project",
"project_type": "python",
"detected_at": "2024-01-15T10:30:00Z",
"structure": {
"root_files": ["README.md", "pyproject.toml", ".gitignore"],
"directories": {
"src": "Source code",
"tests": "Test files",
"docs": "Documentation"
}
},
"commands": {
"build": ["pip install -e ."],
"test": ["pytest tests/ -v"],
"lint": ["ruff check ."],
"format": ["black ."]
},
"architecture": {
"framework": "FastAPI",
"patterns": ["REST API", "Repository Pattern"],
"database": "PostgreSQL with SQLAlchemy"
},
"conventions": {
"naming": "snake_case for files and functions",
"testing": "pytest with fixtures in conftest.py",
"documentation": "Google-style docstrings"
}
}
Generated CLAUDE.md Structure
The generated CLAUDE.md follows this structure:
- Project Overview - Brief description and purpose
- Monorepo Structure - Workspace tools and packages (if detected)
- Common Commands - Build, test, lint, run commands with examples
- Directory Structure - Annotated directory tree
- Architecture - Framework, patterns, and design decisions
- Coding Conventions - Naming, style, and documentation standards
- Testing - Test framework, patterns, and how to run tests
- Key Files - Important configuration and entry points
Resources
scripts/analyze_codebase.py -- Main analysis script that detects project structure and generates documentation
references/claude-md-best-practices.md -- Guidelines for effective CLAUDE.md documentation
Key Principles
- Non-invasive analysis -- Only read files, never modify the target codebase
- Framework-agnostic -- Support multiple languages and build systems
- Security-conscious -- Never include secrets, credentials, or sensitive paths
- Incremental updates -- Support refreshing existing CLAUDE.md with new findings
- Human-in-the-loop -- Generate draft documentation for human review and customization
1---2name: codebase-onboarding-generator3description: Automatically analyze a codebase and generate comprehensive CLAUDE.md documentation for future Claude Code sessions. Use when onboarding to a new project, creating project documentation, or generating AI coding assistant context files.4---56# Codebase Onboarding Generator78## Overview910This skill analyzes a codebase to automatically generate comprehensive CLAUDE.md documentation. It identifies common commands, build processes, test patterns, directory structure conventions, and key architectural decisions. The generated documentation follows best practices for Claude Code onboarding and enables efficient AI-assisted development.1112## When to Use1314- Setting up Claude Code for a new project that lacks CLAUDE.md15- Generating initial project documentation for AI assistants16- Refreshing outdated CLAUDE.md files after significant project changes17- Creating standardized onboarding documentation for team codebases18- Analyzing unfamiliar codebases to understand structure and conventions1920## Prerequisites2122- Python 3.9+23- No API keys required24- Standard library only (pathlib, json, os, re)2526## Workflow2728### Step 1: Analyze Codebase Structure2930Run the codebase analyzer to detect project type, directory structure, and key files.3132```bash33python3 scripts/analyze_codebase.py \34 --path /path/to/project \35 --output analysis.json36```3738The analyzer detects:39- Project type (Python, Node.js, Java, Go, Rust, etc.)40- Package manager and dependency files41- Build and test configuration42- Directory conventions (src/, lib/, tests/, etc.)43- Key configuration files (.gitignore, CI configs, etc.)4445### Step 2: Extract Common Commands4647Parse package.json, Makefile, pyproject.toml, or other build files to extract:48- Build commands49- Test commands50- Lint/format commands51- Development server commands52- Deployment commands5354### Step 3: Identify Architectural Patterns5556Analyze code structure to identify:57- Framework usage (React, Django, Spring, etc.)58- Design patterns (MVC, microservices, monolith)59- API conventions (REST, GraphQL, gRPC)60- Database technologies (SQL, NoSQL, ORM)61- Testing frameworks and patterns6263### Step 4: Generate CLAUDE.md6465Synthesize analysis results into a comprehensive CLAUDE.md file.6667```bash68python3 scripts/analyze_codebase.py \69 --path /path/to/project \70 --generate-claude-md \71 --output CLAUDE.md72```7374### Step 5: Review and Customize7576Review the generated CLAUDE.md for:77- Accuracy of detected commands and patterns78- Missing project-specific conventions79- Security considerations (ensure no secrets are referenced)80- Team-specific guidelines to add manually8182## Output Format8384### JSON Analysis Report8586```json87{88 "schema_version": "1.1",89 "project_name": "example-project",90 "project_type": "python",91 "detected_at": "2024-01-15T10:30:00Z",92 "structure": {93 "root_files": ["README.md", "pyproject.toml", ".gitignore"],94 "directories": {95 "src": "Source code",96 "tests": "Test files",97 "docs": "Documentation"98 }99 },100 "commands": {101 "build": ["pip install -e ."],102 "test": ["pytest tests/ -v"],103 "lint": ["ruff check ."],104 "format": ["black ."]105 },106 "architecture": {107 "framework": "FastAPI",108 "patterns": ["REST API", "Repository Pattern"],109 "database": "PostgreSQL with SQLAlchemy"110 },111 "conventions": {112 "naming": "snake_case for files and functions",113 "testing": "pytest with fixtures in conftest.py",114 "documentation": "Google-style docstrings"115 }116}117```118119### Generated CLAUDE.md Structure120121The generated CLAUDE.md follows this structure:1221231. **Project Overview** - Brief description and purpose1242. **Monorepo Structure** - Workspace tools and packages (if detected)1253. **Common Commands** - Build, test, lint, run commands with examples1264. **Directory Structure** - Annotated directory tree1275. **Architecture** - Framework, patterns, and design decisions1286. **Coding Conventions** - Naming, style, and documentation standards1297. **Testing** - Test framework, patterns, and how to run tests1308. **Key Files** - Important configuration and entry points131132## Resources133134- `scripts/analyze_codebase.py` -- Main analysis script that detects project structure and generates documentation135- `references/claude-md-best-practices.md` -- Guidelines for effective CLAUDE.md documentation136137## Key Principles1381391. **Non-invasive analysis** -- Only read files, never modify the target codebase1402. **Framework-agnostic** -- Support multiple languages and build systems1413. **Security-conscious** -- Never include secrets, credentials, or sensitive paths1424. **Incremental updates** -- Support refreshing existing CLAUDE.md with new findings1435. **Human-in-the-loop** -- Generate draft documentation for human review and customization