🔓 unclaimed — this page was auto-generated from GitHub. Are you the creator?
Claim this page →
scc
Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
git clone https://github.com/boyter/scc
Sloc Cloc and Code (scc)

A tool similar to cloc, sloccount and tokei. For counting the lines of code, blank lines, comment lines, and physical lines of source code in many programming languages.
Goal is to be the fastest code counter possible, but also perform COCOMO calculation like sloccount, LOCOMO estimation for LLM-based development costs, estimate code complexity similar to cyclomatic complexity calculators and produce unique lines of code or DRYness metrics. In short one tool to rule them all.
Also it has a very short name which is easy to type scc.
If you don't like sloc cloc and code feel free to use the name Succinct Code Counter.
Licensed under MIT licence.
scc for Teams & Enterprise
While scc will always be a free and open tool for individual developers, companies and businesses, we are exploring an enhanced version designed for teams and businesses. scc Enterprise will build on the core scc engine to provide historical analysis, team-level dashboards, and policy enforcement to help engineering leaders track code health, manage technical debt, and forecast project costs.
We are currently gathering interest for a private beta. If you want to visualize your codebase's evolution, integrate quality gates into your CI/CD pipeline, and get a big-picture view across all your projects, sign up for the early access list here
Install
Go Install
You can install scc by using the standard go toolchain.
To install the latest stable version of scc:
go install github.com/boyter/scc/v3@latest
To install a development version:
go install github.com/boyter/scc/v3@master
Note that scc needs go version >= 1.25.
Snap
A snap install exists thanks to Ricardo.
$ sudo snap install scc
NB Snap installed applications cannot run outside of /home https://askubuntu.com/questions/930437/permission-denied-error-when-running-apps-installed-as-snap-packages-ubuntu-17 so you may encounter issues if you use snap and attempt to run outside this directory.
Homebrew
Or if you have Homebrew installed
$ brew install scc
Fedora
Fedora Linux users can use a COPR repository:
$ sudo dnf copr enable lihaohong/scc && sudo dnf install scc
MacPorts
On macOS, you can also install via MacPorts
$ sudo port install scc
Scoop
Or if you are using Scoop on Windows
$ scoop install scc
Chocolatey
Or if you are using Chocolatey on Windows
$ choco install scc
WinGet
Or if you are using WinGet on Windows
winget install --id benboyter.scc --source winget
FreeBSD
On FreeBSD, scc is available as a package
$ pkg install scc
Or, if you prefer to build from source, you can use the ports tree
$ cd /usr/ports/devel/scc && make install clean
Run in Docker
Go to the directory you want to run scc from.
Run the command below to run the latest release of scc on your current working directory:
docker run --rm -it -v "$PWD:/pwd" ghcr.io/boyter/scc:master scc /pwd
Manual
Binaries for Windows, GNU/Linux and macOS for both i386 and x86_64 machines are available from the releases page.
GitLab
https://about.gitlab.com/blog/2023/02/15/code-counting-in-gitlab/
Other
If you would like to assist with getting scc added into apt/chocolatey/etc... please submit a PR or at least raise an issue with instructions.
Background
Read all about how it came to be along with performance benchmarks,
- https://boyter.org/posts/sloc-cloc-code/
- https://boyter.org/posts/why-count-lines-of-code/
- https://boyter.org/posts/sloc-cloc-code-revisited/
- https://boyter.org/posts/sloc-cloc-code-performance/
- https://boyter.org/posts/sloc-cloc-code-performance-update/
Some reviews of scc
- https://nickmchardy.com/2018/10/counting-lines-of-code-in-koi-cms.html
- https://www.feliciano.tech/blog/determine-source-code-size-and-complexity-with-scc/
- https://metaredux.com/posts/2019/12/13/counting-lines.html
Setting up scc in GitLab
A talk given at the first GopherCon AU about scc (press S to see speaker notes)
For performance see the Performance section
Other similar projects,
- SLOCCount the original sloc counter
- cloc, inspired by SLOCCount; implemented in Perl for portability
- gocloc a sloc counter in Go inspired by tokei
- loc rust implementation similar to tokei but often faster
- loccount Go implementation written and maintained by ESR
- polyglot ATS sloc counter
- tokei fast, accurate and written in rust
- sloc coffeescript code counter
- stto new Go code counter with a focus on performance
Interesting reading about other code counting projects tokei, loc, polyglot and loccount
- https://www.reddit.com/r/rust/comments/59bm3t/a_fast_cloc_replacement_in_rust/
- https://www.reddit.com/r/rust/comments/82k9iy/loc_count_lines_of_code_quickly/
- http://blog.vmchale.com/article/polyglot-comparisons
- http://esr.ibiblio.org/?p=8270
Further reading about processing files on the disk performance
Using scc to process 40 TB of files from GitHub/Bitbucket/GitLab
Pitch
Why use scc?
- It is very fast and gets faster the more CPU you throw at it
- Accurate
- Works very well across multiple platforms without slowdown (Windows, Linux, macOS)
- Large language support
- Can ignore duplicate files
- Has complexity estimations
- You need to tell the difference between Coq and Verilog in the same directory
- cloc yaml output support so potentially a drop in replacement for some users
- Can identify or ignore minified files
- Able to identify many #! files ADVANCED! https://github.com/boyter/scc/issues/115
- Can ignore large files by lines or bytes
- Can calculate the ULOC or unique lines of code by file, language or project
- Supports multiple output formats for integration, CSV, SQL, JSON, HTML and more
Why not use scc?
- You don't like Go for some reason
- It cannot count D source with different nested multi-line comments correctly https://github.com/boyter/scc/issues/27
Differences
There are some important differences between scc and other tools that are out there. Here are a few important ones for you to consider.
Blank lines inside comments are counted as comments. While the line is technically blank the decision was made that once in a comment everything there should be considered a comment until that comment is ended. As such the following,
/* blank lines follow
*/
Would be counted as 4 lines of comments. This is noticeable when comparing scc's output to other tools on large repositories.
scc is able to count verbatim strings correctly. For example in C# the following,
private const string BasePath = @"a:\";
// The below is returned to the user as a version
private const string Version = "1.0.0";
Because of the prefixed @ this string ends at the trailing " by ignoring the escape character \ and as such should be counted as 2 code lines and 1 comment. Some tools are unable to deal with this and instead count up to the "1.0.0" as a string which can cause the middle comment to be counted as code rather than a comment.
scc will also tell you the number of bytes it has processed (for most output formats) allowing you to estimate the
cost of running some static analysis tools.
Usage
Command line usage of scc is designed to be as simple as possible.
Full details can be found in scc --help or scc -h. Note that the below reflects the state of master not a release, as such
features listed below may be missing from your installation.
$ scc -h
Sloc, Cloc and Code. Count lines of code in a directory with complexity estimation.
Version 3.8.0 (beta)
Ben Boyter <[email protected]> + Contributors
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
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) (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")
--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
--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])
--file-gc-count int number of files to parse before turning the GC on (default 10000)
--file-list-queue-size int the size of the queue of files found and ready to be read into memory (default 8)
--file-process-job-workers int number of goroutine workers that process files collecting stats (default 8)
--file-summary-job-queue-size int the size of the queue used to hold processed file statistics before formatting (default 8)
-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)
-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
-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,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)
Output should look something like the below for the redis project
$ scc redis
───────────────────────────────────────────────────────────────────────────────
Language Files Lines Blanks Comments Code Complexity
───────────────────────────────────────────────────────────────────────────────
C 437 267,353 31,103 45,998 190,252 48,269
JSON 406 25,392 4 0 25,388 0
C Header 288 48,831 5,648 11,302 31,881 3,097
TCL 215 66,943 7,330 4,651 54,962 3,816
Shell 75 1,626 239 343 1,044 185
Python 34 4,802 694 498 3,610 621
Markdown 26 4,647 1,226 0 3,421 0
Autoconf 22 11,732 1,124 1,420 9,188 1,016
Lua 20 525 69 71 385 89
Makefile 20 1,956 368 170 1,418 85
YAML 20 2,696 147 53 2,496 0
MSBuild 11 1,995 2 0 1,993 160
Plain Text 10 1,773 313 0 1,460 0
Ruby 9 817 73 105 639 123
C++ 8 546 85 43 418 43
HTML 5 9,658 2,928 12 6,718 0
License 3 90 17 0 73 0
CMake 2 298 49 5 244 12
CSS 2 107 16 0 91 0
Systemd 2 80 6 0 74 0
BASH 1 143 16 5 122 38
Batch 1 28 2 0 26 3
C++ Header 1 9 1 3 5 0
Extensible Styleshe… 1 10 0 0 10 0
JavaScript 1 31 1 0 30 5
Module-Definition 1 11,375 2,116 0 9,259 167
SVG 1 1 0 0 1 0
Smarty Template 1 44 1 0 43 5
m4 1 951 218 64 669 0
───────────────────────────────────────────────────────────────────────────────
Total 1,624 464,459 53,796 64,743 345,920 57,734
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $12,517,562
Estimated Schedule Effort (organic) 35.93 months
Estimated People Required (organic) 30.95
───────────────────────────────────────────────────────────────────────────────
Processed 16601962 bytes, 16.602 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────
Note that you don't have to specify the directory you want to run against. Running scc will assume you want to run against the current directory.
You can also run against multiple files or directories scc directory1 directory2 file1 file2 with the results aggregated in the output.
Since scc writes to standard output, there are many ways to easily share the results. For example, using netcat
and one of many pastebins gives a public URL:
$ scc | nc paste.c-net.org 9999
https://paste.c-net.org/Example
Ignore Files
scc mostly supports .ignore files inside directories that it scans. This is similar to how ripgrep, ag and tokei work. .ignore files are 100% the same as .gitignore files with the same syntax, and as such scc will ignore files and directories listed in them. You can add .ignore files to ignore things like vendored dependency checked in files and such. The idea is allowing you to add a file or folder to git and have ignored in the count.
It also supports its own ignore file .sccignore if you want scc to ignore things while having ripgrep, ag, tokei and others support them.
Interesting Use Cases
Used inside Intel Nemu Hypervisor to track code changes between revisions https://github.com/intel/nemu/blob/topic/virt-x86/tools/cloc-change.sh#L9 Appears to also be used inside both http://codescoop.com/ https://pinpoint.com/ https://github.com/chaoss/grimoirelab-graal
It also is used to count code and guess language types in https://searchcode.com/ which makes it one of the most frequently run code counters in the world.
You can also hook scc into your gitlab pipeline https://gitlab.com/guided-explorations/ci-cd-plugin-extensions/ci-cd-plugin-extension-scc
Used by the following products and services,
- GitHub CodeQL - The CodeQL engine uses
sccfor line counting - JetBrains Qodana - The Qodana CLI leverages
sccas a command-line helper for code analysis - Scaleway - Cloud provider using
scc - Linux Foundation LFX Insights - COCOMO cost estimation
- OpenEMS
Features
scc uses a small state machine in order to determine what state the code is when it reaches a newline \n. As such it is aware of and able to count
- Single Line Comments
- Multi Line Comments
- Strings
- Multi Line Strings
- Blank lines
Because of this it is able to accurately determine if a comment is in a string or is actually a comment.
It also attempts to count the complexity of code. This is done by checking for branching operations in the code. For example, each of the following for if switch while else || && != == if encountered in Java would increment that files complexity by one.
Complexity Estimates
Let's take a minute to discuss the complexity estimate itself.
The complexity estimate is really just a number that is only comparable to files in the same language. It should not be used to compare languages directly without weighting them. The reason for this is that its calculated by looking for branch and loop statements in the code and incrementing a counter for that file.
Because some languages don't have loops and instead use recursion they can have a lower complexity count. Does this mean they are less complex? Probably not, but the tool cannot see this because it does not build an AST of the code as it only scans through it.
Generally though the complexity there is to help estimate between projects written in the same language, or for finding the most complex file in a project scc --by-file -s complexity which can be useful when you are estimating on how hard something is to maintain, or when looking for those files that should probably be refactored.
As for how it works.
It's my own definition, but tries to be an approximation of cyclomatic complexity https://en.wikipedia.org/wiki/Cyclomatic_complexity although done only on a file level.
The reason it's an approximation is that it's calculated almost for free from a CPU point of view (since its a cheap lookup when counting), whereas a real cyclomatic complexity count would need to parse the code. It gives a reasonable guess in practice though even if it fails to identify recursive methods. The goal was never for it to be exact.
In short when scc is looking through what it has identified as code if it notices what are usually branch conditions it will increment a counter.
The conditions it looks for are compiled into the code and you can get an idea for them by looking at the JSON inside the repository. See https://github.com/boyter/scc/blob/master/languages.json#L3869 for an example of what it's looking at for a file that's Java.
The increment happens for each of the matching conditions and produces the number you see.
Unique Lines of Code (ULOC)
ULOC stands for Unique Lines of Code and represents the unique lines across languages, files and the project itself. This idea was taken from
https://cmcenroe.me/2018/12/14/uloc.html where the calculation is presented using standard Unix tools sort -u *.h *.c | wc -l. This metric is
there to assist with the estimation of complexity within the project. Quoting the source
In my opinion, the number this produces should be a better estimate of the complexity of a project. Compared to SLOC, not only are blank lines discounted, but so are close-brace lines and other repetitive code such as common includes. On the other hand, ULOC counts comments, which require just as much maintenance as the code around them does, while avoiding inflating the result with license headers which appear in every file, for example.
You can obtain the ULOC by supplying the -u or --uloc argument to scc.
It has a corresponding metric DRYness % which is the percentage of ULOC to CLOC or DRYness = ULOC / SLOC. The
higher the number the more DRY (don't repeat yourself) the project can be considered. In general a higher value
here is a better as it indicates less duplicated code. The DRYness metric was taken from a comment by minimax https://lobste.rs/s/has9r7/uloc_unique_lines_code
To obtain the DRYness metric you can use the -a or --dryness argument to scc, which will implicitly set --uloc.
Note that there is a performance penalty when calculating the ULOC metrics which can double the runtime.
Running the uloc and DRYness calculations against C code a clone of redis produces an output as follows.
$ scc -a -i c redis
───────────────────────────────────────────────────────────────────────────────
Language Files Lines Blanks Comments Code Complexity
───────────────────────────────────────────────────────────────────────────────
C 437 267,353 31,103 45,998 190,252 48,269
(ULOC) 149892
───────────────────────────────────────────────────────────────────────────────
Total 437 267,353 31,103 45,998 190,252 48,269
───────────────────────────────────────────────────────────────────────────────
Unique Lines of Code (ULOC) 149892
DRYness % 0.56
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $6,681,762
Estimated Schedule Effort (organic) 28.31 months
Estimated People Required (organic) 20.97
───────────────────────────────────────────────────────────────────────────────
Processed 9390815 bytes, 9.391 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────
Further reading about the ULOC calculation can be found at https://boyter.org/posts/sloc-cloc-code-new-metic-uloc/
Interpreting Dryness,
- 75% (High Density): Very terse, expressive code. Every line counts. (Example: Clojure, Haskell)
- 60% - 70% (Standard): A healthy balance of logic and structural ceremony. (Example: Java, Python)
- < 55% (High Boilerplate): High repetition. Likely due to mandatory error handling, auto-generated code, or verbose configuration. (Example: C#, CSS)
See https://boyter.org/posts/boilerplate-tax-ranking-popular-languages-by-density/ for more details.
COCOMO
The COCOMO statistics displayed at the bottom of any command line run can be configured as needed.
Estimated Cost to Develop (organic) $664,081
Estimated Schedule Effort (organic) 11.772217 months
Estimated People Required (organic) 5.011633
To change the COCOMO parameters, you can either use one of the default COCOMO models.
scc --cocomo-project-type organic
scc --cocomo-project-type semi-detached
scc --cocomo-project-type embedded
You can also supply your own parameters if you are familiar with COCOMO as follows,
scc --cocomo-project-type "custom,1,1,1,1"
See below for details about how the model choices, and the parameters they use.
Organic – A software project is said to be an organic type if the team size required is adequately small, the problem is well understood and has been solved in the past and also the team members have a nominal experience regarding the problem.
scc --cocomo-project-type "organic,2.4,1.05,2.5,0.38"
Semi-detached – A software project is said to be a Semi-detached type if the vital characteristics such as team-size, experience, knowledge of the various programming environment lie in between that of organic and Embedded. The projects classified as Semi-Detached are comparatively less familiar and difficult to develop compared to the organic ones and require more experience and better guidance and creativity. Eg: Compilers or different Embedded Systems can be considered of Semi-Detached type.
scc --cocomo-project-type "semi-detached,3.0,1.12,2.5,0.35"
Embedded – A software project with requiring the highest level of complexity, creativity, and experience requirement fall under this category. Such software requires a larger team size than the other two models and also the developers need to be sufficiently experienced and creative to develop such complex models.
scc --cocomo-project-type "embedded,3.6,1.20,2.5,0.32"
LOCOMO
LOCOMO (LLM Output COst MOdel) estimates the cost to regenerate a codebase using a large language model. It is the LLM-era counterpart to COCOMO - a rough ballpark estimator, not a project planning tool.
Note: LOCOMO was developed as part of scc and is not an industry-standard model. Unlike COCOMO, which is based on decades of empirical research by Barry Boehm, LOCOMO is an experimental heuristic designed to give a useful order-of-magnitude estimate for LLM-assisted development costs. Treat its output as a conversation starter, not a definitive answer.
Important distinction: LOCOMO estimates the cost to regenerate known code - essentially "given this exact codebase, how much would it cost to have an LLM produce it?" This is fundamentally different from the cost to create something from scratch, which involves exploration, architectural decisions, dead ends, debugging, and iteration that can cost orders of magnitude more. COCOMO estimates the human creation cost; LOCOMO estimates the LLM regeneration cost. They answer different questions.
LOCOMO is opt-in. Enable it with --locomo or use --cost-comparison to display both COCOMO and LOCOMO side by side.
$ scc --locomo .
...
LOCOMO LLM Cost Estimate (medium)
Tokens Required (in/out) 3.0M / 0.7M
Cost to Generate $20
Estimated Cycles 2.1
Generation Time (serial) 3.9 hours
Human Review Time 5.9 hours
Disclaimer: rough ballpark for regenerating code using a LLM.
Does not account for context reuse, test generation, or heavy debugging.
How it works
LOCOMO uses SLOC and complexity data that scc already computes. The model works per-file and aggregates:
- Output tokens - each line of code maps to ~10 LLM output tokens (configurable).
- Input tokens - estimated prompting cost, scaled by code complexity. More complex code (higher branch density) requires more detailed prompts. Scales to prevent runaway estimates.
- Iteration factor - LLMs rarely produce correct code on the first try. A retry multiplier scales with complexity, also scales.
- Dollar cost - input and output tokens multiplied by per-token pricing.
- Generation time - total serial output tokens divided by tokens-per-second throughput.
- Human review time - estimated per-line overhead for planning, review, testing, and integration.
Model presets
Presets are tier-based rather than tied to specific models, so they don't go stale as models are retired or renamed. Use --locomo-preset to select a tier:
| Preset | Represents | Input $/1M | Output $/1M | TPS |
|---|---|---|---|---|
large | Frontier models (Opus, GPT-5.3, Gemini 3.1 Pro, etc.) | 10.00 | 30.00 | 30 |
medium (default) | Balanced models (Sonnet, Gemini Flash, etc.) | 3.00 | 15.00 | 50 |
small | Fast/cheap models (Haiku, GPT-4o-mini, etc.) | 0.50 | 2.00 | 100 |
local | Self-hosted models (Llama, Mistral, Qwen etc.) | 0.00 | 0.00 | 15 |
For local, cost is $0 but generation time is still reported to capture the compute/time investment. Preset pricing reflects approximate tier rates as of early 2026 and can be overridden with explicit flags.
scc --locomo --locomo-preset large .
scc --locomo --locomo-preset local .
Overriding preset values
You can override individual preset values for pricing or throughput:
scc --locomo --locomo-input-price 1.0 --locomo-output-price 5.0 .
scc --locomo --locomo-tps 100 .
Human review time
The --locomo-review flag controls estimated human review minutes per line of code (default: 0.01, i.e. 0.6 seconds per line). This is intentionally optimistic and assumes light oversight.
For mission-critical, security-sensitive, or complex algorithmic code you should increase this:
scc --locomo --locomo-review 0.05 .
scc --locomo --locomo-review 0.1 .
Power-user configuration
The five internal model parameters can be overridden with a single comma-separated config string:
scc --locomo --locomo-config "tokensPerLine,inputPerLine,complexityWeight,iterations,iterationWeight"
The defaults are "10,20,5,1.5,2". Here is what each parameter controls:
| Position | Name | Default | Description |
|---|---|---|---|
| 1 | tokensPerLine | 10 | Average LLM output tokens per line of code |
| 2 | inputPerLine | 20 | Base LLM input (prompt) tokens per output line |
| 3 | complexityWeight | 5 | How much complexity density scales input tokens: inputFactor = 1 + sqrt(density) * weight |
| 4 | iterations | 1.5 | Base iteration/retry cycles before complexity adjustment |
| 5 | iterationWeight | 2 | How much complexity density adds extra cycles: cycles = iterations + sqrt(density) * weight |
The iteration factor (cycles) scales both input and output tokens - it represents how many generation attempts the LLM needs. Simple code (~0.05 complexity density) produces ~1.9 cycles; complex code (~0.3 density) produces ~2.6 cycles. Use --locomo-cycles to override this with a fixed value.
For example, to model a cheaper/faster LLM that needs fewer tokens but more retries:
scc --locomo --locomo-config "8,15,3,2.0,1.5"
Comparing COCOMO and LOCOMO
Use --cost-comparison to show both estimates side by side. This enables COCOMO (if it was disabled) and LOCOMO together:
scc --cost-comparison .
What LOCOMO does not account for
LOCOMO is a rough estimator with known limitations:
- No context reuse. Real LLM-assisted development shares context across files. The per-file model overestimates input tokens for large projects with shared patterns.
- Boilerplate vs algorithmic code. A 500-line CRUD controller and a 500-line compression algorithm have very different real costs, but the model only differentiates them via complexity density.
- Code that LLMs can't write well. Complex concurrency, platform-specific edge cases, and security-critical crypto need human authoring, not just review.
- No test generation cost. The model estimates source code generation only, not test suites.
- Pricing changes. LLM pricing drops rapidly. Preset defaults will become stale - use explicit price flags for current estimates.
All LOCOMO flags
| Flag | Default | Description |
|---|---|---|
--locomo | false | Enable LOCOMO output |
--cost-comparison | false | Show COCOMO + LOCOMO side by side |
--locomo-preset | medium | Model tier preset for pricing and throughput |
--locomo-input-price | (preset) | Override: cost per 1M input tokens ($) |
--locomo-output-price | (preset) | Override: cost per 1M output tokens ($) |
--locomo-tps | (preset) | Override: output tokens per second |
--locomo-review | 0.01 | Human review minutes per line of code |
--locomo-cycles | (calculated) | Override estimated LLM iteration cycles |
--locomo-config | 10,20,5,1.5,2 | Power-user config: tokensPerLine, inputPerLine, complexityWeight, iterations, iterationWeight |
Git Insight Reports
In addition to counting the working tree, scc can run four git-aware reports over recent commit history. Each is selected by a flag and rendered as tabular (default), csv, or json via --format. All four are derived from one in-process walk of the repository - there is no exec("git"), so the git binary does not need to be on PATH.
Note: these reports are slower than a normal
sccrun. They walk the repository history (one diff per commit using pure-Go Myers diff via go-git) instead of just counting the current working tree. Runtime scales with--depth(the commit window size, default1000;0means entire history). On large repositories with deep history, expect runtimes measured in seconds to minutes rather than the millisecond-scale you get from a plainsccrun. Use--depthto bound the window.
When no report flag is set, scc behaves exactly as today, these flags are strictly opt-in.
| Flag | Report | Answers |
|---|---|---|
--hotspots | Hotspots | Which files are defect-prone - high complexity × high churn. |
--by-author | Author rollup | Bus factor - who last-touched the surviving code. |
--by-author --timeline | Author timeline | How each author's activity rises and falls over time. |
--timeline | Languages over time | How the language mix shifts - rewrites, migrations. |
Shared flags for these reports:
| Flag | Default | Purpose |
|---|---|---|
--depth N | 1000 | Commit window size (newest N commits). 0 walks the entire history (slow on big repos). Negative values are rejected. |
--buckets N | 60 | Time-bucket resolution for timeline reports. Must be >= 1 when --timeline is set. CSV/JSON always emit full-resolution; tabular sparklines downsample to fit. |
-w, --wide | - | 109-column variant of any report (extra columns where applicable). |
--no-fold-authors | off | Disable the name + email-domain identity folding fallback applied after .mailmap. |
--hotspots is mutually exclusive with --by-author / --timeline; combining them is an error. With --by-author set, --timeline switches from the author rollup to the author timeline. Alone, --timeline renders the languages timeline.
Hotspots - --hotspots
Ranks files by defect-proneness: complexity × change frequency over the window. Surfaces where to review, not a defect probability.
$ scc --hotspots
───────────────────────────────────────────────────────────────────────────────
Hotspots · last 500 commits · 2024-01-09 → 2026-05-20
───────────────────────────────────────────────────────────────────────────────
File Lang Cmplx Commits Lines± Authrs Hotspot
───────────────────────────────────────────────────────────────────────────────
processor/workers.go Go 488 62 7,240 9 100.0
processor/processor.go Go 402 41 3,910 7 71.4
processor/formatters.go Go 233 38 2,980 6 51.8
main.go Go 180 44 2,510 8 48.2
───────────────────────────────────────────────────────────────────────────────
complexity × change-frequency, normalised · 20 of 142 files shown
───────────────────────────────────────────────────────────────────────────────
Tabular output shows the top files (≈20). --wide adds a hotspot bar and an added-lines code-vs-comment split (+Code%). --format csv|json emits every file with a positive score along with the full per-file detail and window metadata.
Author rollup - --by-author
Bus factor and last-toucher attribution. Lines untouched in the window collect under the sentinel (before window) so percentages reconcile to 100%.
$ scc --by-author
───────────────────────────────────────────────────────────────────────────────
Authors · last 500 commits · 2024-01-09 → 2026-05-20
───────────────────────────────────────────────────────────────────────────────
Author Code Cmplx Files Owns Last seen
───────────────────────────────────────────────────────────────────────────────
Alice Smith 24,110 4,180 118 38.6% 2026-05-22
Bob Jones 15,447 1,902 74 24.7% 2026-03-14
Carol Lee 9,205 3,640 51 14.7% 2026-05-19
(before window) 6,540 810 29 10.4% -
others (12) 1,300 190 - 2.1% -
───────────────────────────────────────────────────────────────────────────────
Bus factor 2 · Alice + Bob last-touched 63% of in-window code
───────────────────────────────────────────────────────────────────────────────
Bus factor is the fewest authors whose combined share of in-window code exceeds 50%. The (before window) sentinel is excluded from that denominator so the footer reflects who could realistically pick up recent work, not who's stamped on long-frozen lines. The Owns column on each row still uses the share-of-all denominator (sentinel included; rows reconcile to 100%).
Identity folding is layered: .mailmap is honoured first; then, by default, two commits sharing a lowercased name and an email domain collapse to one author (a fallback for repos without a mailmap). Generic names (root, admin, unknown, …) are excluded from the heuristic to avoid false merges. Disable the fallback with --no-fold-authors if you'd rather see every email as its own row. --wide adds a Comment column.
Author timeline - --by-author --timeline
How each author's activity rises and falls across the window. The Activity column is a Unicode sparkline normalised per row; the trailing tag is quiet Nmo (recently silent) or ↑ (currently near peak).
$ scc --by-author --timeline
───────────────────────────────────────────────────────────────────────────────
Authors · last 500 commits · 2024-01-09 → 2026-05-20
───────────────────────────────────────────────────────────────────────────────
Author Activity Commits Code±
───────────────────────────────────────────────────────────────────────────────
Alice Smith ▂▃▅▇█▇▆▅▄▄▃▃ 210 +38k
Bob Jones ▇█▆▄▂▁▁▁▁▁▁▁ 142 +21k quiet 2mo
Carol Lee ▁▁▁▁▂▃▄▅▆▇██ 96 +14k ↑
───────────────────────────────────────────────────────────────────────────────
CSV is long format (one row per (author, bucket)); JSON includes per-author full-resolution series. Under --ci or non-TTY output the sparkline falls back to ASCII.
Languages over time - --timeline
How the language mix shifts: rewrites, migrations (e.g. JS → TS), gradual additions. The Trend sparkline plots each language's absolute trajectory, not deltas - so "rising" means "more code in this language now than at window-start".
$ scc --timeline
───────────────────────────────────────────────────────────────────────────────
Languages · last 500 commits · 2024-01-09 → 2026-05-20
───────────────────────────────────────────────────────────────────────────────
Language Trend Code Share Change
───────────────────────────────────────────────────────────────────────────────
TypeScript ▁▁▂▃▄▅▆▇████ 36,840 58.0% +36,840
Go ▃▃▄▄▅▅▅▆▆▆▆▆ 24,110 38.0% +9,205
JavaScript ██▇▆▅▄▃▂▁▁▁▁ 2,540 4.0% -18,300
Markdown ▂▃▃▄▄▅▅▆▆▆▇▇ 1,204 1.9% +994
───────────────────────────────────────────────────────────────────────────────
Totals reconcile with a plain scc against the current HEAD tree. CSV/JSON include every non-empty language with the full per-bucket series.
Output format and caveats
- Tabular is for humans (sparklines, bars, ASCII fallback under
--ci). CSV/JSON carry raw numbers only - no presentation glyphs - and include awindowobject (depth, commit count, date range) so downstream tools can reproduce the slice. .gitignoreis already applied by git when each commit was recorded;.ignore/.sccignoreare honoured by the engine (disable with--no-ignore/--no-scc-ignore).- Merge commits are diffed against their first parent (
git log --first-parentsemantics). - Rename detection uses go-git's similarity heuristic; large renames may inflate hotspot churn and reset blame attribution. Shallow clones produce a clear error rather than a panic.
Lines±is the sum of added and removed lines, so files rewritten in place count twice the displaced size.- Symlinks are skipped (v1). Binary detection is unchanged.
HTML Report
scc --report writes a self-contained, infographic-style HTML page summarising the codebase: overview metrics, language breakdown, line-length histogram, hotspots, author rollup, language and author timelines, COCOMO / LOCOMO cost estimates, and a per-file table. The page bundles its own CSS and inline SVG — no external network requests, no JavaScript runtime dependencies — so it can be opened locally, committed to a repo, attached to a release, or hosted as a static artifact.
$ scc --report # writes scc-report.html (prompts before overwriting)
$ scc --report=docs/code.html # explicit path; overwrites silently
A bare --report is non-destructive: if scc-report.html already exists in the current directory, scc prompts before clobbering it. Naming the file explicitly (--report=path/out.html) is treated as consent and overwrites without asking.
| Flag | Purpose |
|---|---|
--report[=path] | Write the HTML report. Bare flag writes scc-report.html; explicit path overwrites silently. |
--report-title NAME | Override the repo name shown in the report banner. Defaults to the origin remote name or the directory basename. |
// compatibility
| Platforms | cli, api, desktop |
|---|---|
| Operating systems | — |
| AI compatibility | claude |
| License | MIT |
| Pricing | open-source |
| Language | Go |
// faq
What is scc?
Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go. It is open-source on GitHub.
Is scc free to use?
scc is open-source under the MIT license, so it is free to use.
What category does scc belong to?
scc is listed under devtools in the Claudeers registry of Claude-compatible tools.
// embed badge
[](https://claudeers.com/scc)
// retro hit counter
[](https://claudeers.com/scc)
// reviews
// guestbook
// related in Developer Tools
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Curs…
Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
🙌 OpenHands: AI-Driven Development
Makes your AI agent think like the laziest senior dev in the room. The best code is the code you never wrote.