A small CLI tool that summarizes codebases at blazing speed. Built for quick audits, comparisons, scripts, or just randomly getting curious how much source code is in your home directory.
- Counts files, lines, and bytes by language
- Respects
.gitignoreand.ignorewhen you want it to - Can follow symlinks and scan hidden files
- Filter by language: include only specific languages or exclude unwanted ones
- Exclude files and directories with glob patterns
- Optional per-file detail for drilling into hot spots
- Outputs in human-readable or machine-friendly formats
- Supports 440+ languages out of the box
- Fast on laptops and tiny boxes alike
- Works as a drop-in for dashboards or quick CLI reports
- Friendly defaults with easy overrides through CLI or config
cargo install codestatsgit clone https://github.com/trypsynth/codestats
cd codestats
cargo install --path .- Human-readable report of the current directory:
cs - Verbose per-file detail for
src/in JSON:cs -v src -o json - List supported languages:
cs -l - Ignore
.gitignorerules:cs -i - Follow symlinks and include hidden files:
cs -SH - Analyze only Rust files:
cs -L rust - Analyze everything except tests and documentation:
cs -e 'test_*' -e '*.md' - Exclude specific languages:
cs --exclude-lang markdown --exclude-lang toml
human(default) for terminalsjsonorjson-compactfor scriptscsvortsvfor spreadsheetsmarkdownorhtmlfor docs and dashboards
Usage: cs [OPTIONS] [PATH] (defaults to the current directory)
-v, --verboseShow per-file detail instead of just the summary-i, --no-gitignoreDo not respect.gitignore-H, --hiddenSearch hidden files and directories-S, --symlinksFollow symlinks (avoid cycles)-e, --exclude <PATTERN>Exclude files or directories matching glob patterns (can be specified multiple times)-L, --lang <LANGUAGE>Only analyze files of the specified language(s) (can be specified multiple times, cannot be used with--exclude-lang)--exclude-lang <LANGUAGE>Exclude files of the specified language(s) (can be specified multiple times, cannot be used with--lang)-n, --number-style <plain|comma|underscore|space>Number formatting style. Default:plain-u, --size-units <binary|decimal>Human-readable size units. Default:binary-p, --precision <0-6>Percentage precision. Default:1-s, --sort-by <lines|code|comments|blanks|files|size|name>Sort key for languages and per-file detail. Default:lines-d, --sort-dir <asc|desc>Sort direction. Default:desc-o, --output <human|json|json-compact|csv|tsv|markdown|html>Output format. Default:human-c, --config <PATH>Use a TOML config file-l, --langsList all supported languages and exit-h, --helpPrint help-V, --versionPrint version
Codestats can read settings from TOML while keeping full CLI compatibility. Search order:
--config <path>(errors if missing)./.codestats.toml./codestats.toml~/.config/codestats/config.toml~/.codestats.toml
[analysis]
verbose = true
respect_gitignore = true
include_hidden = true
follow_symlinks = false
exclude_patterns = ["*.tmp", "test_*", "node_modules/*"]
include_languages = ["rust", "python"] # Only analyze these languages
# exclude_languages = ["markdown", "toml"] # Or exclude these (cannot use both)
[display]
number_style = "comma"
size_units = "decimal"
precision = 4
sort_by = "files"
sort_direction = "desc"
output = "human"Run: hyperfine --warmup 1 "cs ~" "tokei ~"
| Command | Mean ± σ | Min … Max |
|---|---|---|
cs ~ |
1.952 s ± 0.034 s | 1.915 s … 1.997 s |
tokei ~ |
7.538 s ± 0.045 s | 7.466 s … 7.609 s |
Codestats ran 3.86 ± 0.07 times faster than tokei on a small Beelinks mini PC.
Codestats is licensed under the MIT License.