Code Stats Skill
Analyzes code files and generates statistics about a codebase.
Usage
When invoked, this skill will:
- Scan the specified directory (defaults to current directory)
- Count total lines and files by extension
- Report the largest files
- Output results in a structured format
- Sort extension summaries by total line count in descending order
Prefer the bundled script scripts/count_stats.py over re-implementing find /
wc by hand. Pass the target directory as the first argument.
Output Format
Always use this exact format for the output:
# Code Statistics
## Summary
- Total Files: <count>
- Total Lines: <count>
- Total Size: <size_bytes> bytes
## Files by Extension
| Extension | Files | Lines |
|-----------|-------|-------|
| .go | 12 | 1500 |
| .md | 5 | 200 |
## Top 5 File Extensions by Line Count
1. .go — 1500 lines
2. .md — 200 lines
## Largest Files (top 5)
1. main.go (500 lines)
2. util.go (300 lines)
If a file has no extension, group it under (no ext) in both extension sections.
Process
- Run
python3 scripts/count_stats.py <dir>when the script is available - Otherwise locate files, count lines, and aggregate locally
- Group files with no extension under
(no ext) - Sort both extension summaries by total line count in descending order
- Aggregate the results into the output format above
- If no directory is specified, analyze the current working directory
Examples
- "Analyze the current directory"
- "Run code-stats on ./src"
- "Show me file type distribution"
- "How many lines of Python do we have?"