Sloc, Cloc and Code. Count lines of code in a directory with complexity estimation.
Version 4.1.0
Ben Boyter <ben@boyter.org> + Contributors
https://github.com/boyter/scc
Usage:
scc [flags] [files or directories]
Examples:
Count the current directory:
scc
Count a specific folder or file:
scc myproject/
scc main.go
Count several paths at once:
scc src/ docs/ README.md
Show a per-file breakdown instead of the per-language summary:
scc --by-file
Output as CSV or JSON (e.g. for further processing):
scc --format csv
scc --format json -o counts.json
Count an unrecognised extension as a known language:
scc --count-as jsp:html
Count files matching a path pattern as a new category (glob by default):
scc --count-as-pattern '*_spec.rb:Ruby Spec:Ruby'
Generate a self-contained HTML infographic report:
scc --report
scc --report=out.html --report-title "myrepo" --report-skip cocomo
Use a project config file (./.sccconfig) or a global one (precedence: global < project < CLI):
export SCC_CONFIG_PATH=~/.sccconfig
scc --config team.sccconfig
Tune the COCOMO cost estimate, or turn it off (see https://en.wikipedia.org/wiki/COCOMO):
scc --avg-wage 75000 --cocomo-project-type semi-detached
scc --no-cocomo
Flags:
--avg-wage int average wage value used for basic COCOMO calculation (default 56286)
--binary disable binary file detection
--buckets int time-bucket resolution for the git timeline reports (default 60)
--by-author render the author rollup report (bus factor and last-toucher attribution over recent git history)
--by-file display output for every file
-m, --character calculate max and mean characters per line
--ci enable CI output settings where stdout is ASCII
--cocomo-project-type string change COCOMO model type [organic, semi-detached, embedded, "custom,1,1,1,1"] (default "organic")
--cognitive calculate cognitive (nesting-weighted) complexity
--config string load this file as the global config source; overrides SCC_CONFIG_PATH, honored even with --no-config
--cost-comparison show both COCOMO and LOCOMO estimates side by side
--count-as string count extension as language [e.g. jsp:htm,chead:"C Header" maps extension jsp to html and chead to C Header]
--count-as-pattern stringArray count files matching a path pattern as a new named category backed by a base language [repeatable; pattern is glob by default, prefix with re: for regex; e.g. *_spec.rb:"Ruby Spec":Ruby or re:\.test\.js$:"JavaScript Tests":JavaScript]
--count-ignore set to allow .gitignore and .ignore files to be counted
--count-unsupported count files with an unrecognised language under an "Unknown" category as plain text
--coupling render the change-coupling report (file pairs that change together over recent git history)
--coupling-for string blast-radius view: given a file path, show what tends to change with it over recent git history
--coupling-weighted weight coupling by file complexity so pairs of complex files rank above generated/data-file churn (implies --coupling)
--currency-symbol string set currency symbol (default "$")
--debug enable debug output
--depth int commit window size for git history reports; 0 means entire history (large repos may be slow) (default 1000)
--directory-walker-job-workers int controls the maximum number of workers which will walk the directory tree (default 8)
-a, --dryness calculate the DRYness of the project (implies --uloc)
--eaf float the effort adjustment factor derived from the cost drivers (1.0 if rated nominal) (default 1)
--exclude-dir strings directories to exclude (default [.git,.hg,.svn])
-x, --exclude-ext strings ignore file extensions (overrides include-ext) [comma separated list: e.g. go,java,js]
-n, --exclude-file strings ignore files with matching names (default [package-lock.json,Cargo.lock,yarn.lock,pubspec.lock,Podfile.lock,pnpm-lock.yaml])
--exp-per-language-counters experimental, may change or be removed: count with the scanner written for the file's language where there is one, currently C, C Header and Java
--file-gc-count int number of files to parse before turning the GC on (default 10000)
--file-list-job-workers int number of goroutine workers that turn a walked path into a job to be counted (default 64)
--file-list-queue-size int the size of the queue of files found and ready to be read into memory (default 64)
--file-process-job-workers int number of goroutine workers that process files collecting stats (default 64)
--file-summary-job-queue-size int the size of the queue used to hold processed file statistics before formatting (default 64)
--find-root-config discover the project .sccconfig by walking up to the repository root instead of using ./.sccconfig
-f, --format string set output format [tabular, wide, json, json2, csv, csv-stream, cloc-yaml, html, html-table, sql, sql-insert, openmetrics] (default "tabular")
--format-multi string have multiple format output overriding --format [e.g. tabular:stdout,csv:file.csv,json:file.json]
--gen identify generated files
--generated-markers strings string markers in head of generated files (default [do not edit,<auto-generated />])
-h, --help help for scc
--hotspots render the hotspots report (files ranked by complexity × change frequency over recent git history)
--ignore-file stringArray path to an additional gitignore-format ignore file, applied from the scan root; repeat to add more, later files and any in-tree ignore files take precedence
-i, --include-ext strings limit to file extensions [comma separated list: e.g. go,java,js]
--include-symlinks if set will count symlink files
-l, --languages print supported languages and extensions
--large-byte-count int number of bytes a file can contain before being removed from output (default 1000000)
--large-line-count int number of lines a file can contain before being removed from output (default 40000)
--locomo enable LOCOMO (LLM Output COst MOdel) cost estimation
--locomo-config string LOCOMO power-user config "tokensPerLine,inputPerLine,complexityWeight,iterations,iterationWeight"
--locomo-cycles float override estimated LLM iteration cycles (default: calculated from complexity)
--locomo-input-price float LOCOMO cost per 1M input tokens in dollars (overrides preset)
--locomo-output-price float LOCOMO cost per 1M output tokens in dollars (overrides preset)
--locomo-preset string LOCOMO model preset [large, medium, small, local] (default "medium")
--locomo-review float human review minutes per line of code for LOCOMO estimate (default 0.01)
--locomo-tps float LOCOMO output tokens per second (overrides preset)
--mcp start as an MCP (Model Context Protocol) server over stdio
--min identify minified files
-z, --min-gen identify minified or generated files
--min-gen-line-length int number of bytes per average line for file to be considered minified or generated (default 255)
--no-cocomo remove COCOMO calculation output
-c, --no-complexity skip calculation of code complexity
--no-config disable auto-discovery of the SCC_CONFIG_PATH global and the project ./.sccconfig config
-d, --no-duplicates remove duplicate files from stats and output
--no-fold-authors disable the name+email-domain identity folding fallback for git author reports (mailmap still applied)
--no-gen ignore generated files in output (implies --gen)
--no-gitignore disables .gitignore file logic
--no-gitmodule disables .gitmodules file logic
--no-hborder remove horizontal borders between sections
--no-ignore disables .ignore file logic
--no-large ignore files over certain byte and line size set by large-line-count and large-byte-count
--no-min ignore minified files in output (implies --min)
--no-min-gen ignore minified or generated files in output (implies --min-gen)
--no-scc-ignore disables .sccignore file logic
--no-size remove size calculation output
-M, --not-match stringArray ignore files and directories matching regular expression
-o, --output string output filename (default stdout)
--overhead float set the overhead multiplier for corporate overhead (facilities, equipment, accounting, etc.) (default 2.4)
-p, --percent include percentage values in output
--remap-all string inspect every file and remap by checking for a string and remapping the language [e.g. "-*- C++ -*-":"C Header"]
--remap-unknown string inspect files of unknown type and remap by checking for a string and remapping the language [e.g. "-*- C++ -*-":"C Header"]
--report string[="scc-report.html"] write a self-contained HTML report; bare flag writes scc-report.html and prompts before overwriting, --report=path/out.html overwrites silently
--report-skip string comma-separated sections to omit (cocomo,locomo,hotspots,coupling,authors,timeline,files,uloc,linelength,card)
--report-title string override the repo name shown in the report banner
--size-unit string set size unit [si, binary, mixed, xkcd-kb, xkcd-kelly, xkcd-imaginary, xkcd-intel, xkcd-drive, xkcd-bakers] (default "si")
--sloccount-format print a more SLOCCount like COCOMO calculation
-s, --sort string column to sort by [files, name, lines, blanks, code, comments, complexity] (default "files")
--sql-project string use supplied name as the project identifier for the current run. Only valid with the --format sql or sql-insert option
--timeline render an over-time view of recent git history; with --by-author runs the author timeline, alone runs the languages timeline
-t, --trace enable trace output (not recommended when processing multiple files)
-u, --uloc calculate the number of unique lines of code (ULOC) for the project
-v, --verbose verbose output
--version version for scc
-w, --wide wider output with additional statistics (implies --complexity)
Options (92)
| Option | Description | Source |
|---|---|---|
--avg-wage int | average wage value used for basic COCOMO calculation (default 56286) | help |
--binary | disable binary file detection | help |
--buckets int | time-bucket resolution for the git timeline reports (default 60) | help |
--by-author | render the author rollup report (bus factor and last-toucher attribution over recent git history) | help |
--by-file | display output for every file | help |
-m, --character | calculate max and mean characters per line | help |
--ci | enable CI output settings where stdout is ASCII | help |
--cocomo-project-type string | change COCOMO model type [organic, semi-detached, embedded, "custom,1,1,1,1"] (default "organic") | help |
--cognitive | calculate cognitive (nesting-weighted) complexity | help |
--config string | load this file as the global config source; | help |
--cost-comparison | show both COCOMO and LOCOMO estimates side by side | help |
--count-as string | count extension as language [e.g. jsp:htm,chead:"C Header" maps extension jsp to html and chead to C Header] | help |
--count-as-pattern stringArray | count files matching a path pattern as a new named category backed by a base language [repeatable; | help |
--count-ignore | set to allow .gitignore and .ignore files to be counted | help |
--count-unsupported | count files with an unrecognised language under an "Unknown" category as plain text | help |
--coupling | render the change-coupling report (file pairs that change together over recent git history) | help |
--coupling-for string | blast-radius view: given a file path, show what tends to change with it over recent git history | help |
--coupling-weighted | weight coupling by file complexity so pairs of complex files rank above generated/data-file churn (implies --coupling) | help |
--currency-symbol string | set currency symbol (default "$") | help |
--debug | enable debug output | help |
--depth int | commit window size for git history reports; | help |
--directory-walker-job-workers int | controls the maximum number of workers which will walk the directory tree (default 8) | help |
-a, --dryness | calculate the DRYness of the project (implies --uloc) | help |
--eaf float | the effort adjustment factor derived from the cost drivers (1.0 if rated nominal) (default 1) | help |
--exclude-dir strings | directories to exclude (default [.git,.hg,.svn]) | help |
-x, --exclude-ext strings | ignore file extensions (overrides include-ext) [comma separated list: e.g. go,java,js] | help |
-n, --exclude-file strings | ignore files with matching names (default [package-lock.json,Cargo.lock,yarn.lock,pubspec.lock,Podfile.lock,pnpm-lock.yaml]) | help |
--exp-per-language-counters | experimental, may change or be removed: count with the scanner written for the file's language where there is one, currently C, C Header and Java | help |
--file-gc-count int | number of files to parse before turning the GC on (default 10000) | help |
--file-list-job-workers int | number of goroutine workers that turn a walked path into a job to be counted (default 64) | help |
--file-list-queue-size int | the size of the queue of files found and ready to be read into memory (default 64) | help |
--file-process-job-workers int | number of goroutine workers that process files collecting stats (default 64) | help |
--file-summary-job-queue-size int | the size of the queue used to hold processed file statistics before formatting (default 64) | help |
--find-root-config | discover the project .sccconfig by walking up to the repository root instead of using ./.sccconfig | help |
-f, --format string | set output format [tabular, wide, json, json2, csv, csv-stream, cloc-yaml, html, html-table, sql, sql-insert, openmetrics] (default "tabular") | help |
--format-multi string | have multiple format output overriding --format [e.g. tabular:stdout,csv:file.csv,json:file.json] | help |
--gen | identify generated files | help |
--generated-markers strings | string markers in head of generated files (default [do not edit,<auto-generated />]) | help |
-h, --help | help for scc | help |
--hotspots | render the hotspots report (files ranked by complexity × change frequency over recent git history) | help |
--ignore-file stringArray | path to an additional gitignore-format ignore file, applied from the scan root; | help |
-i, --include-ext strings | limit to file extensions [comma separated list: e.g. go,java,js] | help |
--include-symlinks | if set will count symlink files | help |
-l, --languages | print supported languages and extensions | help |
--large-byte-count int | number of bytes a file can contain before being removed from output (default 1000000) | help |
--large-line-count int | number of lines a file can contain before being removed from output (default 40000) | help |
--locomo | enable LOCOMO (LLM Output COst MOdel) cost estimation | help |
--locomo-config string | LOCOMO power-user config "tokensPerLine,inputPerLine,complexityWeight,iterations,iterationWeight" | help |
--locomo-cycles float | override estimated LLM iteration cycles (default: calculated from complexity) | help |
--locomo-input-price float | LOCOMO cost per 1M input tokens in dollars (overrides preset) | help |
--locomo-output-price float | LOCOMO cost per 1M output tokens in dollars (overrides preset) | help |
--locomo-preset string | LOCOMO model preset [large, medium, small, local] (default "medium") | help |
--locomo-review float | human review minutes per line of code for LOCOMO estimate (default 0.01) | help |
--locomo-tps float | LOCOMO output tokens per second (overrides preset) | help |
--mcp | start as an MCP (Model Context Protocol) server over stdio | help |
--min | identify minified files | help |
-z, --min-gen | identify minified or generated files | help |
--min-gen-line-length int | number of bytes per average line for file to be considered minified or generated (default 255) | help |
--no-cocomo | remove COCOMO calculation output | help |
-c, --no-complexity | skip calculation of code complexity | help |
--no-config | disable auto-discovery of the SCC_CONFIG_PATH global and the project ./.sccconfig config | help |
-d, --no-duplicates | remove duplicate files from stats and output | help |
--no-fold-authors | disable the name+email-domain identity folding fallback for git author reports (mailmap still applied) | help |
--no-gen | ignore generated files in output (implies --gen) | help |
--no-gitignore | disables .gitignore file logic | help |
--no-gitmodule | disables .gitmodules file logic | help |
--no-hborder | remove horizontal borders between sections | help |
--no-ignore | disables .ignore file logic | help |
--no-large | ignore files over certain byte and line size set by large-line-count and large-byte-count | help |
--no-min | ignore minified files in output (implies --min) | help |
--no-min-gen | ignore minified or generated files in output (implies --min-gen) | help |
--no-scc-ignore | disables .sccignore file logic | help |
--no-size | remove size calculation output | help |
-M, --not-match stringArray | ignore files and directories matching regular expression | help |
-o, --output string | output filename (default stdout) | help |
--overhead float | set the overhead multiplier for corporate overhead (facilities, equipment, accounting, etc.) (default 2.4) | help |
-p, --percent | include percentage values in output | help |
--remap-all string | inspect every file and remap by checking for a string and remapping the language [e.g. "-*- C++ -*-":"C Header"] | help |
--remap-unknown string | inspect files of unknown type and remap by checking for a string and remapping the language [e.g. "-*- C++ -*-":"C Header"] | help |
--report string[="scc-report.html" | write a self-contained HTML report; | help |
--report-skip string | comma-separated sections to omit (cocomo,locomo,hotspots,coupling,authors,timeline,files,uloc,linelength,card) | help |
--report-title string | override the repo name shown in the report banner | help |
--size-unit string | set size unit [si, binary, mixed, xkcd-kb, xkcd-kelly, xkcd-imaginary, xkcd-intel, xkcd-drive, xkcd-bakers] (default "si") | help |
--sloccount-format | print a more SLOCCount like COCOMO calculation | help |
-s, --sort string | column to sort by [files, name, lines, blanks, code, comments, complexity] (default "files") | help |
--sql-project string | use supplied name as the project identifier for the current run. | help |
--timeline | render an over-time view of recent git history; | help |
-t, --trace | enable trace output (not recommended when processing multiple files) | help |
-u, --uloc | calculate the number of unique lines of code (ULOC) for the project | help |
-v, --verbose | verbose output | help |
--version | version for scc | help |
-w, --wide | wider output with additional statistics (implies --complexity) | help |