code-stats
Code Statistics
Quickly analyze codebase size, composition, and changes.
tokei - Line Counts
# Count all code
tokei
# Compact output sorted by code
tokei --compact --sort code
# Specific languages
tokei --type=TypeScript,JavaScript
# Exclude directories
tokei --exclude node_modules --exclude dist
# JSON output for scripting
tokei --output json | jq '.Total.code'
Sample Output
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
TypeScript 45 12847 9823 1456 1568
JavaScript 12 2341 1876 234 231
-------------------------------------------------------------------------------
Total 57 15188 11699 1690 1799
===============================================================================
difft - Semantic Diffs
# Compare files
difft old.ts new.ts
# Inline mode
difft --display=inline old.ts new.ts
# With git
GIT_EXTERNAL_DIFF=difft git diff
GIT_EXTERNAL_DIFF=difft git show HEAD~1
Why Semantic?
| Traditional diff | difft |
|---|---|
| Line-by-line | AST-aware |
| Shows moved as delete+add | Recognizes moves |
| Whitespace sensitive | Ignores formatting |
Quick Reference
| Task | Command |
|---|---|
| Count all code | tokei |
| Compact output | tokei --compact |
| Sort by code | tokei --sort code |
| TypeScript only | tokei -t TypeScript |
| JSON output | tokei --output json |
| Exclude dir | tokei --exclude node_modules |
| Semantic diff | difft file1 file2 |
| Git diff | GIT_EXTERNAL_DIFF=difft git diff |
When to Use
- Getting quick codebase overview
- Comparing code changes semantically
- Understanding project composition
- Reviewing refactoring impact
- Tracking codebase growth
Additional Resources
For detailed patterns, load:
./references/tokei-advanced.md- Filtering, output formats, CI integration./references/difft-advanced.md- Display modes, git integration, language support
More from 0xdarkmatter/claude-mods
file-search
Modern file and content search using fd, ripgrep (rg), and fzf. Triggers on: fd, ripgrep, rg, find files, search code, fzf, fuzzy find, search codebase.
160container-orchestration
Docker and Kubernetes patterns. Triggers on: Dockerfile, docker-compose, kubernetes, k8s, helm, pod, deployment, service, ingress, container, image.
76python-pytest-patterns
pytest testing patterns for Python. Triggers on: pytest, fixture, mark, parametrize, mock, conftest, test coverage, unit test, integration test, pytest.raises.
60python-env
Fast Python environment management with uv (10-100x faster than pip). Triggers on: uv, venv, pip, pyproject, python environment, install package, dependencies.
50data-processing
Process JSON with jq and YAML/TOML with yq. Filter, transform, query structured data efficiently. Triggers on: parse JSON, extract from YAML, query config, Docker Compose, K8s manifests, GitHub Actions workflows, package.json, filter data.
49sqlite-ops
Patterns for SQLite databases in Python projects - state management, caching, and async operations. Triggers on: sqlite, sqlite3, aiosqlite, local database, database schema, migration, wal mode.
48