| name | cloc |
| description | Count lines of code, analyze codebase size and composition, compare code between versions. Use when the user asks about lines of code, codebase size, language breakdown, or code statistics. |
| argument-hint | [path or git ref] |
Prerequisites
Before running cloc, check if it is installed:
which cloc
If not found, install it:
- macOS:
brew install cloc
- npm:
npm install -g cloc
- Debian/Ubuntu:
sudo apt install cloc
- Red Hat/Fedora:
sudo yum install cloc
About cloc
cloc counts blank lines, comment lines, and physical lines of source code in 200+ programming languages. It can analyze files, directories, archives (tar, zip, .whl, .ipynb), and git commits/branches.
Common Usage
Count a directory (default: current project):
cloc .
Count using git file list (respects .gitignore):
cloc --vcs=git
Count a specific path:
cloc $ARGUMENTS
Count by file (detailed breakdown):
cloc --by-file --vcs=git
Diff between two git refs:
cloc --git --diff <ref1> <ref2>
Exclude directories:
cloc --exclude-dir=node_modules,vendor,.git .