Analyze any codebase to produce structured metrics: line counts by category (code, tests, docs, scripts, plans), language breakdown, comment analysis, test:code ratio, file-size distribution, TODO/FIXME tracking, and git churn hotspots. Use when the user asks to analyze a codebase, get code statistics, understand project structure or size, check test coverage ratios, find TODOs, see language breakdown, identify large files, or review git churn. Outputs in terminal (Rich), JSON, or Markdown format. Configurable via YAML.
Analyze any codebase and produce structured metrics with configurable patterns and multiple output formats.
Use this skill when the user wants to:
Before running any analysis, ensure:
No external services, API tokens, or credentials are required. This skill is entirely local and read-only.
Configuration is optional. The analyzer works out of the box with sensible defaults. To customize, create a .codebase-analysis.yaml file in the repository root. See references/CONFIG.md for the full schema.
If no config file exists, ask the user if they would like to create one before running the analysis. To help them decide:
.codebase-analysis.yaml based on what you find — for example, if the repo has a src/ directory with tests in __tests__/, or uses non-standard script directories, reflect that in the suggestionTo provide a starting config template, copy the default:
cp <skill_dir>/assets/default-config.yaml <repo_root>/.codebase-analysis.yaml
Before running ANY operation, run the preflight script once. It validates the entire environment in a single pass and reports a clear summary.
python3 <skill_dir>/scripts/analyzer_preflight.py
Optionally, pass --path to also validate the target repository:
python3 <skill_dir>/scripts/analyzer_preflight.py --path <repo_root>
The script checks:
<skill_dir>/.codebase-analyzer-venv/--path is provided)If the venv does not exist or dependencies are missing, run the setup script:
python3 <skill_dir>/scripts/analyzer_setup_env.py
After setup, all subsequent script commands must use the venv Python:
<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py --path . --output terminal
Run the preflight script and read the output. If any required check fails, resolve it before proceeding.
python3 <skill_dir>/scripts/analyzer_preflight.py --path <repo_root>
Check if a .codebase-analysis.yaml already exists in the repo root.
.codebase-analysis.yaml tailored to the codebase and present it to the user<repo_root>/.codebase-analysis.yamlAsk the user which output format they prefer:
Also ask:
web). Available sections: summary, categories, languages, file-distribution, large-files, todos, churn<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py \
--path <repo_root> \
--output <terminal|json|markdown|web> \
--sections <comma-separated-list-or-all>
Optional flags:
--config <path> — path to a custom config file (default: <repo_root>/.codebase-analysis.yaml)Note: When --output web is used, the script launches a Streamlit server and opens the dashboard in the browser. The --sections flag is ignored for web output (all sections are always shown). The command is non-blocking — the server runs until the user stops it (Ctrl+C).
After analysis, suggest relevant next steps:
.codebase-analysis.yaml<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py \
--path <repo_root> --output terminal
<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py \
--path <repo_root> --output terminal --sections summary,languages,todos
<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py \
--path <repo_root> --output json > analysis.json
<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py \
--path <repo_root> --output markdown > ANALYSIS.md
<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py \
--path <repo_root> --config custom-config.yaml --output terminal
<skill_dir>/.codebase-analyzer-venv/bin/python <skill_dir>/scripts/analyze.py \
--path <repo_root> --output web
This launches a Streamlit server and opens an interactive dashboard in the browser with:
The dashboard caches analysis results for 60 seconds. Stop the server with Ctrl+C.
| Section | What it shows |
|---|---|
| summary | Total files, lines, code, comments, blanks, TODOs, FIXMEs, test:code ratio |
| categories | Code vs tests comparison table + all categories breakdown |
| languages | Language breakdown by file count, code lines, and comment lines |
| file-distribution | File size distribution in buckets (1-50, 51-100, ..., 1000+ lines) |
| large-files | Code files exceeding the configured threshold (default: 500 lines) |
| todos | Files with the most TODO/FIXME annotations |
| churn | Most frequently changed files from recent git history |
See references/REPORT_FORMAT.md for sample outputs, section descriptions, and guidance on interpreting key metrics (test:code ratio thresholds, comment percentage guidelines, churn interpretation).
The scripts print descriptive error messages to stderr with fix instructions. Exit codes: 0 = success, 1 = dependency error, 2 = config/path error.
| Error | Cause | Fix |
|---|---|---|
| python3: command not found | Python not installed | macOS: brew install python3 / Linux: apt install python3 |
| ERROR: PyYAML is not installed | Dependencies not installed | Run python3 <skill_dir>/scripts/analyzer_setup_env.py then use the venv Python |
| ERROR: Rich library is not installed | Dependencies not installed | Run python3 <skill_dir>/scripts/analyzer_setup_env.py, or use --output json / --output markdown which need no extra deps |
| ERROR: Streamlit is not installed | Dependencies not installed | Run python3 <skill_dir>/scripts/analyzer_setup_env.py to install all dependencies including Streamlit |
| ERROR: Path does not exist | Invalid --path argument | Verify the path exists |
| ERROR: ... is a file, not a directory | --path points to a file | Provide a directory path |
| ERROR: Config file not found | --config points to missing file | Fix the path or omit --config to use defaults |
| ERROR: Invalid YAML in config file | Syntax error in .codebase-analysis.yaml | Fix the YAML syntax or delete the file to use defaults |
| ERROR: ... must contain a YAML mapping | Config file has wrong structure | Config must be key: value pairs — see references/CONFIG.md |
| WARNING: Config key '...' should be a list | Config has wrong type for a pattern key | Use list syntax: key: ["val1", "val2"] |
| WARNING: No files were analyzed | All files skipped or directory empty | Check skip patterns in config; verify the directory has source files |
| No churn data | Not a git repo or git not installed | Expected behavior — churn requires git history |
| Problem | Fix |
|---|---|
| python3: command not found | macOS: brew install python3 / Linux: apt install python3 |
| Venv not found | Run python3 <skill_dir>/scripts/analyzer_setup_env.py to create it |
| Missing dependencies after setup | Delete the venv directory and re-run the setup script |
| --output web shows blank page | Ensure Streamlit is installed: check preflight output for web dependencies |
| No churn data in results | Expected if not a git repo or git is not installed |
| All files skipped / 0 files analyzed | Check skip_dirs, skip_extensions, skip_files in config; verify target directory has source files |
| Config changes not reflected | The web dashboard caches results for 60 seconds; wait or restart the server |
| Capability | Description |
|---|---|
| Snapshot comparison | Diff two analysis runs to track codebase evolution over time |
| CI integration | Exit with non-zero code if metrics exceed configurable thresholds |
| Custom language mappings | Allow users to define additional file extension → language mappings in config |
| ~~Web dashboard~~ | Implemented — use --output web to launch the Streamlit dashboard |
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer