A small CLI tool that summarizes codebases at blazing speed. Built for quick audits, comparisons, scripts, or randomly being 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 460+ languages out of the box
- Fully encoding-aware
- Runs insanely quickly on anything from a tiny laptop to a large desktop
Download the latest binary for your platform from GitHub Releases:
| Platform | Download |
|---|---|
| Linux x86_64 | cs-x86_64-unknown-linux-musl |
| Linux ARM64 | cs-aarch64-unknown-linux-musl |
| macOS Intel | cs-x86_64-apple-darwin |
| macOS Apple Silicon | cs-aarch64-apple-darwin |
| Windows x86_64 | cs-x86_64-pc-windows-gnu.exe |
| Windows ARM64 | cs-aarch64-pc-windows-gnullvm.exe |
On Linux and macOS, make the binary executable and move it somewhere on your PATH:
chmod +x cs-*
sudo mv cs-* /usr/local/bin/cscargo install codestatsgit clone https://github.com/trypsynth/codestats
cd codestats
cargo install --path .cscs -v src -o jsoncs -t 10cs -L rustcs -e 'test_*' -e '*.md'cs --exclude-lang markdown --exclude-lang tomlFollow symlinks and include hidden files
cs --symlinks -Hcs -ics langscs -Dcs completions <shell>human(default) for terminalsjsonorjson-compactfor scriptscsvortsvfor spreadsheetsmarkdownorhtmlfor docs and dashboards
Usage: cs [OPTIONS] [PATH] (defaults to the current directory)
-q, --quietShow totals only, no language breakdown-v, --verboseShow per-file details in addition to the language breakdown--no-gitignoreDo not respect.gitignore--include-generatedCount generated files (lockfiles, minified assets) which are excluded by default--max-depth <N>Limit directory traversal to N levels deep--min-lines <N>Hide languages with fewer than N total lines-H, --hiddenSearch hidden files and directories--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-direction <asc|desc>Sort direction. Default:desc-t, --top-languages <N>Limit the language breakdown to the top N languages-D, --by-dirShow a breakdown by directory instead of by language-o, --output <human|json|json-compact|csv|tsv|markdown|html>Output format. Default:human--fail-on-errorExit with a non-zero status code if any files are skipped due to errors-c, --config <PATH>Use a TOML config file-h, --helpPrint help-V, --versionPrint version
langsList all supported languagescompletions <shell>Generate shell completions (e.g.bash,zsh,fish)
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]
verbosity = "verbose"
respect_gitignore = true
include_hidden = true
follow_symlinks = false
exclude_patterns = ["languages.json5", "*.tmp", "node_modules/*"] # filenames or globs
include_languages = ["rust", "python"] # Only analyze these languages
# exclude_languages = ["markdown", "toml"] # Or exclude these (cannot use both)
fail_on_error = false
[display]
number_style = "comma"
size_units = "decimal"
precision = 4
sort_by = "files"
sort_direction = "desc"
output = "human"
top_languages = 10
by_dir = falseFor performance, Codestats uses memory-mapped I/O for files >=256KB. This provides significant speedups but requires that files remain stable during analysis.
Codestats uses parallel processing to maximize performance. Each worker thread maintains its own statistics which are merged at the end, minimizing lock contention. The tool is safe for concurrent execution on different directories, but should not analyze the same directory simultaneously from multiple processes.
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 over a massive home directory.
Codestats is licensed under the MIT License.