jig-harness/jig
Skill

code-stats

/jig:code-stats

Typed in Claude Code. In Codex, ask for the jig:code-stats skill by name.

Measures what the repository is made of: classifies every tracked file by area (what it is for), kind (what it is), language and module, counts its lines of code, and reports in the terminal, as JSON or as an interactive HTML report, with the share it could not classify. Detects without configuration; .config/jig.yaml corrects it, and --explain names the rule behind any file

Works with · Inspect and analyse Stands alone for now; its JSON is meant as measured evidence for audit

How much of a repository is shipped product code, and how much is tests, tooling, agent scaffolding, documentation, build or deployment files? In which languages, and in which modules? Without a tool, each team answers with a one-off script that counts everything as “code”, so a repository with a large generated client, a vendored library or a folder of test data looks bigger and less tested than it is, and nobody can tell how much of it is the agents’ instructions.

This skill answers with no setup. It classifies every file git tracks, counts its bytes and its lines, and reports the totals in the terminal, as JSON for other tools, or as one interactive HTML page. Where its detection is wrong for a repository, a few values in .config/jig.yaml fix it, and --explain shows which rule decided any file.

Jig’s own report is published at jig-harness.dev/stats/, rebuilt from every deploy: what Jig’s repository is made of, as an example of the output.

What it measures

Every tracked file gets one value in each of the code-stats dimensions:

  • Area: what the file is for. The first area rule that matches wins; a file no rule matches falls to the default area, production.
  • Kind: what the file is: code, test, docs, config, data, generated, fixture (a test fixture: data a test reads), asset (binary or media), vendored (another project’s code kept in this one) or other.
  • Language: from the file’s extension; for a file without one, from its shebang line (#!/usr/bin/env python3); and a linguist-language git attribute in .gitattributes overrides both.
  • Module: the deepest module folder that holds the file, from the repository’s workspace manifests (below), or from code_stats.modules.

And its counts: bytes, all lines, blank lines, comment lines, and LOC (lines of code): lines that are neither blank nor only a comment. Binary and media files are sized but not line-counted; so is a text file over 20 MiB, which is still classified from its first 8 KiB.

Vendored files are left out of every total by default, since they are not the team’s code; --include-vendored counts them, and every output says how many were left out.

The unclassified share. A file is unclassified when its kind is other or no area rule matched it. Every output shows the share of files and of LOC, so a weak configuration is visible rather than silently counted as production. With the default areas, product code is not matched by any rule and counts as unclassified: give the repository’s own folders an area in code_stats.areas and the share drops to what really is unaccounted for.

Commands

Run from the repository’s root. <skill-dir> is this skill’s folder in the plugin.

sh
bun "<skill-dir>/scripts/code-stats.ts"                    # terminal summary
bun "<skill-dir>/scripts/code-stats.ts" --json             # aggregates as JSON
bun "<skill-dir>/scripts/code-stats.ts" --html [out.html]  # interactive report
bun "<skill-dir>/scripts/code-stats.ts" --explain <path>   # why one file counts where it does

--top N sets the number of modules in the terminal summary (15), and --include-vendored counts vendored files. The exit code is 0 on success, 1 when the report cannot be made, 2 for a command line the script cannot act on.

The terminal summary

The repository’s name and date, the files counted, the vendored files left out, the code and test LOC of the default area with their ratio, the unclassified share, each test-runner configuration that could not be read, then tables by area, kind, language and module.

The HTML report

One file that works offline, written to .context/code-stats/code-stats.html unless a path is given. It holds every file’s row and does its sums in the browser:

  • filters by area, kind, language, module and path (substring, or a regular expression written /like this/), each option showing its count;
  • a measure switch: LOC, lines, files or size;
  • headline tiles, the unclassified share among them;
  • bar charts by area, language and module, split by kind, with tooltips; clicking a bar filters to it;
  • a pivot of any dimension against any other, exported as CSV or copied as TSV;
  • a directory explorer that expands folder by folder, exported as CSV;
  • the largest files;
  • light and dark themes from a colour-blind-checked palette;
  • the current view kept in the address, so a filtered view can be bookmarked.

It lists every file path, so treat it like the repository itself before sharing it.

The JSON report

json
{
  "schema": "code-stats/v1",
  "generatedAt": "2026-01-01T00:00:00.000Z",
  "repository": "shop",
  "commit": "abc1234",
  "branch": "main",
  "totals": { "files": 0, "bytes": 0, "rawLines": 0, "codeLines": 0, "commentLines": 0, "blankLines": 0 },
  "unclassified": { "files": 0, "codeLines": 0, "filesShare": 0, "codeShare": 0, "kindOther": 0, "defaultArea": 0 },
  "vendored": { "included": false, "excludedFiles": 0, "excludedBytes": 0 },
  "missingFromWorkingTree": 0,
  "testRunners": {
    "configurations": [{ "reader": "jest", "file": "jest.config.js" }],
    "unreadable": [{ "reader": "vitest", "path": "web/vitest.config.ts", "why": "…" }]
  },
  "areas": [{ "name": "docs", "description": "…", "default": false }],
  "byArea": { "docs": { "files": 0, "bytes": 0, "raw": 0, "code": 0, "comment": 0, "blank": 0 } },
  "byKind": {},
  "byLanguage": {},
  "byModule": {},
  "byAreaKind": { "docs/docs": {} }
}
  • schema names the shape. A change that renames or removes a field, or changes what one means, is a new version; adding a field is not.
  • commit ends in -dirty when tracked files differ from it: the counts are the working tree’s.
  • Shares are fractions from 0 to 1. unclassified.files counts each file once; kindOther and defaultArea count each reason, and a file can have both.
  • missingFromWorkingTree counts tracked files deleted in the working tree, which are not counted.
  • testRunners lists each test-runner configuration that named tests, and each one that could not be read, with why.
  • Every by… value is a bucket: files, bytes, raw (all lines), code (LOC), comment, blank. byArea lists the areas in their rule order, byKind in the order of the kinds above, the others by name.

--explain

text
crates/core/build.rs
  area:     build — default area rule "build", build tool: Cargo (glob "**/build.rs")
  kind:     code — build tool: Cargo (glob "**/build.rs"), code
  language: Rust — extension .rs
  module:   crates/core — Cargo workspace members "crates/*"
  counts:   1.2 KB; 40 lines: 31 code, 5 comment, 4 blank

Every dimension names the rule that set it: a convention, an attribute, a banner, an extension or shebang, a test runner’s configuration file and key, a code_stats field with its position, a manifest, a fallback, or classify_command. Each test-runner configuration that could not be read is listed below. --json prints the same as an object.

How a file is classified

The layers, lowest precedence first; a later layer overrides an earlier one.

  1. Built-in detection, which needs no configuration (the rest of this section).
  2. Test-runner configuration: the test files jest, vitest, pytest, Gradle and Maven are configured to run are tests, read from their configuration files with no setup.
  3. The code_stats configuration: the areas, the default area, and kind globs checked before built-in detection and the test runners.
  4. The classify command, when the repository supplies one.

Kinds

In order, the first that applies:

  1. A submodule is vendored; a symbolic link is other, sized by the link, never followed.
  2. The attributes in .gitattributes, read with one git check-attr call: linguist-vendored makes a file vendored, linguist-generated generated, linguist-documentation docs. An unset attribute (-linguist-vendored, -linguist-generated) turns off the matching conventions below for that file.
  3. The vendored conventions.
  4. A media extension, or a zero byte in the first 8 kilobytes, makes a file asset.
  5. The generated conventions, then a generator banner in the file’s leading comment: @generated, DO NOT EDIT, or Go’s Code generated … DO NOT EDIT.. Only the comment that opens the file counts, so prose that merely mentions generation (“auto-generated IDs”, ”# Generated files”) does not. Nor does a comment that discusses the markers: one quoted in backticks or double quotes is not counted, and @generated counts only as a tag that opens a comment line or in “is/was @generated”.
  6. The fixture conventions.
  7. The test conventions. A file one matches is test when it is code; a file in a test folder that is not code is a fixture, or docs, never test LOC. The fixture and test conventions decide a build file’s kind too: a vite.config.ts in a fixture folder is a fixture, though its area is still build.
  8. A build tool’s file (the build tool table below) outside test and fixture folders is config, or code when it is code: a build.gradle is configuration, not other.
  9. The extension: code, documentation, data or configuration. YAML, JSON and other configuration files in an area with content: true are data. A file without an extension whose shebang names a programming language is code. Anything else is other.

The conventions:

KindEcosystemRule
vendoredAnyvendor/ folder
vendoredAnythird_party/ or third-party/ folder
vendoredJavaScriptnode_modules/ folder
generatedAnygenerated/ or _generated/ folder
generatedAny.gen/ folder, *.generated.* or *.gen.*
generatedProtocol Buffers*.pb.*, *_pb.*, *_pb2.py or *_connect.* output
generatedDrizzledrizzle/meta/ snapshots
generatedTypeScript*.d.ts under a dist/ folder
generatedJavaScriptlockfile (bun.lock, bun.lockb, package-lock.json, npm-shrinkwrap.json, pnpm-lock.yaml, yarn.lock, deno.lock)
generatedPythonlockfile (poetry.lock, uv.lock, Pipfile.lock, pdm.lock)
generatedGolockfile (go.sum)
generatedRustlockfile (Cargo.lock)
generatedRubylockfile (Gemfile.lock)
generatedPHPlockfile (composer.lock)
generatedJava/Kotlinlockfile (gradle.lockfile)
generated.NETlockfile (packages.lock.json)
generatedElixirlockfile (mix.lock)
generatedSwiftlockfile (Package.resolved)
generatedDartlockfile (pubspec.lock)
generatedNixlockfile (flake.lock)
fixtureGotestdata/ folder
fixtureAny__fixtures__/, fixtures/ or test-fixtures/ folder
fixtureJavaScript/TypeScript__snapshots__/ or snapshots/ folder, or *.snap
fixtureAnymocks/ or __mocks__/ folder
testJavaScript/TypeScript*.test.* or *.spec.*
testJavaScript/TypeScript__tests__/ folder
testPythontest_*.py or *_test.py
testPythonconftest.py
testGo*_test.go
testJava/Kotlinsrc/test/ or src/integrationTest/ folder
testRustbenches/ folder
testRubyspec/ folder or *_spec.rb
testPHP*Test.php
testC#*.Tests/ folder
testElixir*_test.exs
testShell*.bats
testPython, Rust, JavaScript/TypeScript and otherstests/ or test/ folder

Test-runner configuration

A repository whose tests do not follow a convention (checks named *.check.js, a qa/ folder of Java tests) still tells its test runner where they are. Code-stats reads what each runner’s configuration declares, so those files count as tests with no code_stats section. Each reader reads its files as text and never runs them: a configuration that exists only when it runs (a JavaScript file that exports a function, spreads another object over the keys it sets, changes or reuses the object it exports, or sets its export inside a function, a block or after an if; a Gradle script that builds its folders in code; a pom.xml value built from a property) is reported as unreadable: <path> (<why>), and nothing is claimed from that file. The built-in conventions still apply to it.

Two cases stop the run instead. A file code-stats opens that the file system refuses to read (its permissions, say) stops it with cannot read <path> (<code>) rather than leaving the file out. Every mode opens the configuration files these readers find and the workspace manifests that name the modules; a report also opens every tracked file it counts except an asset (an image, say), whose size is all it needs; --explain opens only the file it explains. And unless code_stats.modules is set, a pyproject.toml or package.json at the root that is not valid TOML or JSON stops every mode with cannot read <file> to find the repository's modules, since module detection reads it before the test runners do.

Any other configuration file a reader selects and finds invalid is reported unreadable like the rest. A file no reader selects is not parsed and not reported: a package.json with no jest key or beside a jest.config.*, or a pyproject.toml in a folder where an earlier pytest file holds the section.

RunnerFiles readWhat is readWhat is not read
jestjest.config.{js,ts,mjs,cjs,json}, else the jest key of the package.json beside ittestMatch (in order, a later pattern overriding an earlier ! exclusion), testRegex, roots (alone: jest’s default testMatch under them), rootDir, testPathIgnorePatternsprojects (each project’s own file is read), a preset; a testMatch pattern that is neither <rootDir>/… nor **/…, and a regular expression anchored with ^, since jest matches them against absolute paths
vitestvitest.config.{ts,mts,cts,js,mjs,cjs}, else vite.config.* in the same foldertest.include, test.exclude (vitest’s default exclusions when absent), relative to test.dir, test.root or root; a spread of configDefaults.include or configDefaults.excludetest.projects and workspace files (each project’s own file is read); an unreadable vite.config.* that mentions neither a test key nor vitest configures no tests and is never reported
pytestthe first of pytest.toml, .pytest.toml ([pytest]), pytest.ini, .pytest.ini, pyproject.toml ([tool.pytest] or [tool.pytest.ini_options]), tox.ini ([pytest]), setup.cfg ([tool:pytest]) in a folder that holds the section, decided from the parsed TOML as pytest decides it (an empty [tool.pytest] holds none, an empty [tool.pytest.ini_options] does)testpaths (globs too), python_files (pytest’s test_*.py and *_test.py when absent)nothing is computed; a TOML file that is not valid TOML (outside the root: see above), a native table ([pytest], [tool.pytest]) whose testpaths or python_files is not a list of strings, an ini_options one whose value is neither a string nor such a list, and a pyproject.toml that sets something in both [tool.pytest] and [tool.pytest.ini_options], are unreadable
Gradlebuild.gradle, build.gradle.ktsthe src/test/<language> convention (java, kotlin, groovy, scala); srcDir, srcDirs and setSrcDirs of the test source set, as string literals, through file, files or listOf; srcDirs = and setSrcDirs replace the convention and the folders added before themresources folders, other source sets; a variable, a $ in a string or a loop over the source sets makes the script unreadable
Mavenpom.xmlthe project’s own <build><testSourceDirectory> (${project.basedir} allowed), else the src/test/java default; a pom.xml with <packaging>pom</packaging> has no testsa value inside a <profile> or a plugin’s <configuration>, one inherited from a parent pom.xml, or one in a comment; another property, or a pom.xml that is not well-formed XML, makes the file unreadable: markup that is not one of XML’s productions or never closes, a closing tag that does not match the open element, an element still open at the end, a second root element or other content XML does not allow outside the root, or an & that is not one of XML’s predefined or numeric references (which are decoded). A pom.xml is decoded from its bytes by its byte order mark or declared encoding (UTF-8, UTF-16, Latin-1 or ASCII; another encoding, or bytes it does not decode, makes the file unreadable), and its line ends are read as XML normalizes them. The declarations inside a <!DOCTYPE … [ … ]> internal subset are read to their ends but not checked

A path in a configuration is relative to the file’s folder, as the runner reads it; one that is absolute or leaves the repository makes the file unreadable. A configuration file in a vendored or fixture folder is not read. A jest, vitest or pytest configuration that sets none of these keys claims nothing, since those runners’ defaults are what the conventions already say; a Gradle or Maven build claims its convention folder.

The layer makes a file a test only when it is code, and it overrides the conventions (a *.check.js jest names, or a code file in a fixtures/ folder under a test source folder), but not what makes a file vendored, generated, documentation or an asset. --explain names the reader, the file and the key:

text
src/cart.check.js
  kind:     test — test runner jest: jest.config.js testMatch "**/*.check.js"

Default areas

When code_stats.areas is absent. The first match wins, so the specific rules come first: agent files in .github/ are scaffolding before ci takes the workflows; a Makefile under tools/ is build, and tools/db/migrations/ is database, before tools takes the folder; repo-config takes the .github/ files no earlier area claims. Everything else falls to production.

AreaWhat it holdsPaths
scaffoldingAI agent scaffolding: agent instructions, skills, rules and agent tool settings.claude/**, .cursor/**, .codex/**, .windsurf/**, .agents/**, .gemini/**, .roo/**, .continue/**, .aider*, .cursorrules, .windsurfrules, .clinerules*, .mcp.json, **/AGENTS.md, **/CLAUDE.md, **/GEMINI.md, .github/copilot-instructions.md, .github/instructions/**, .github/prompts/**, .github/chatmodes/**, .github/agents/**
ciCI pipelines: workflow and pipeline definitions.github/workflows/**, .github/actions/**, .gitlab-ci.yml, .gitlab/ci/**, .circleci/**, .buildkite/**, **/Jenkinsfile*, azure-pipelines.yml, bitbucket-pipelines.yml, .travis.yml, .woodpecker*, .woodpecker/**
buildBuild definitions and build tooling: the files of a dedicated build tool (see the build tool table)every build tool below
databaseDatabase schema and migrations, by the tool or convention that writes them (see the database table)every database convention below, never a path under .github/
opsDeployment and infrastructure: Terraform, Helm, Kubernetes, Ansible, containers and compose filesdeploy*/**, infra/**, infrastructure/**, terraform/**, **/*.tf, **/*.tfvars, charts/**, helm/**, **/Chart.yaml, k8s/**, kubernetes/**, **/kustomization.y*ml, ansible/**, **/Dockerfile*, **/*.dockerfile, **/Containerfile*, **/.dockerignore, **/docker-compose*.y*ml, **/compose.y*ml, **/compose.*.y*ml
toolsInternal developer tooling that does not ship: tools/, scripts/, bin/, hack/tools/**, scripts/**, script/**, bin/**, hack/**
docsDocumentation: docs/, doc/, root-level documents and licence filesdocs/**, doc/**, *.md, *.rst, *.adoc, LICENSE*, LICENCE*, COPYING*
repo-configRepository configuration: root-level files that are not code (manifests, lockfiles, linter and editor settings) and the .github/ files no other area takes (CODEOWNERS, issue templates, dependency-update settings).github/**; a root-level file that is not code

Build tools

The build area takes the files of a dedicated build tool. A package manager’s manifest that is not a build tool’s (package.json, pyproject.toml, go.mod, Gemfile, composer.json, requirements*.txt) is not build: a root-level one is repo-config. Test configuration, such as vitest.config.*, is not build either.

ToolEcosystemPaths
GradleJVM**/build.gradle, **/build.gradle.kts, **/settings.gradle, **/settings.gradle.kts, **/gradle.properties, gradle/**, **/gradlew, **/gradlew.bat, buildSrc/**
MavenJVM**/pom.xml, .mvn/**, **/mvnw, **/mvnw.cmd
sbtJVM**/build.sbt, project/*.sbt, project/build.properties
AntJVM**/build.xml
MillJVM**/build.sc, **/build.mill
CargoRust**/Cargo.toml, **/build.rs, **/.cargo/**, **/rust-toolchain, **/rust-toolchain.toml, **/Cross.toml
GoReleaserGo**/.goreleaser.yml, **/.goreleaser.yaml
MageGo**/magefile.go, magefiles/**
ViteJavaScript/TypeScript**/vite.config.*
webpackJavaScript/TypeScript**/webpack.config.*, **/webpack.*.js
RollupJavaScript/TypeScript**/rollup.config.*
esbuildJavaScript/TypeScript**/esbuild.config.*
ParcelJavaScript/TypeScript**/.parcelrc
Rspack/RsbuildJavaScript/TypeScript**/rspack.config.*, **/rsbuild.config.*
tsupJavaScript/TypeScript**/tsup.config.*
SWCJavaScript/TypeScript**/.swcrc
BabelJavaScript/TypeScript**/babel.config.*, **/.babelrc, **/.babelrc.*
TypeScript compilerJavaScript/TypeScript**/tsconfig.json, **/tsconfig.*.json, **/tsconfig-*.json
TurborepoJavaScript/TypeScript**/turbo.json
NxJavaScript/TypeScriptnx.json
LernaJavaScript/TypeScriptlerna.json
GulpJavaScript/TypeScript**/gulpfile.*
GruntJavaScript/TypeScript**/Gruntfile.*
setuptoolsPython**/setup.py, **/setup.cfg, **/MANIFEST.in
HatchPython**/hatch.toml
noxPython**/noxfile.py
toxPython**/tox.ini
MSBuild.NET**/*.csproj, **/*.fsproj, **/*.vbproj, **/*.sln, **/Directory.Build.props, **/Directory.Build.targets, **/Directory.Packages.props, global.json, **/nuget.config, **/NuGet.Config
Cake.NET**/build.cake
MakeC/C++ and others**/Makefile, **/GNUmakefile, **/makefile, **/*.mk
CMakeC/C++**/CMakeLists.txt, **/*.cmake, **/CMakePresets.json
MesonC/C++**/meson.build, **/meson_options.txt
NinjaC/C++**/build.ninja
AutotoolsC/C++**/configure.ac, **/Makefile.am, **/Makefile.in
ConanC/C++**/conanfile.py, **/conanfile.txt
vcpkgC/C++**/vcpkg.json
Bazel or PantsMonorepo and polyglot**/BUILD, **/BUILD.bazel
BazelMonorepo and polyglotWORKSPACE, WORKSPACE.bazel, WORKSPACE.bzlmod, MODULE.bazel, **/*.bzl, .bazelrc, .bazelversion
Buck2Monorepo and polyglot**/BUCK, .buckconfig
PantsMonorepo and polyglotpants.toml
EarthlyMonorepo and polyglot**/Earthfile
NixMonorepo and polyglot**/flake.nix, **/default.nix, **/shell.nix
justTask runners**/justfile, **/Justfile, **/.justfile
TaskTask runners**/Taskfile.yml, **/Taskfile.yaml
RakeTask runners**/Rakefile
Swift Package ManagerSwift**/Package.swift
MixElixir**/mix.exs
Cabal or StackHaskell**/*.cabal, **/stack.yaml
build_runnerDart/Flutter**/build.yaml

Database

The database area takes schema definitions (DDL, data definition language) and migrations, by the tool or convention that writes them. The specific tools come first, so --explain names the most specific one. A plain .sql file is not schema by itself (it may be a query), so no rule takes every .sql file; and a migration’s kind is still what the kind rules say (a SQL or Python migration is code). The generic migrations/ rule can catch a migration that is not a database’s, such as a configuration migrator: give it its own area in code_stats.areas.

Tool or conventionEcosystemPaths
RailsRubydb/migrate/**, db/schema.rb, db/structure.sql, db/seeds.rb
LaravelPHPdatabase/migrations/**, database/seeders/**, database/factories/**
EctoElixirpriv/repo/migrations/**
Entity Framework Core.NET**/Migrations/*.cs
DjangoPython**/migrations/*.py
AlembicPython**/alembic.ini, **/alembic/**
PrismaJavaScript/TypeScript**/schema.prisma, **/prisma/migrations/**
DrizzleJavaScript/TypeScript**/drizzle.config.*, **/drizzle/**
KnexJavaScript/TypeScript**/knexfile.*
SequelizeJavaScript/TypeScript**/.sequelizerc
SupabasePostgressupabase/migrations/**
HasuraGraphQLhasura/migrations/**, hasura/metadata/**
FlywayJVM and others**/db/migration/**, **/flyway.conf, **/flyway.toml
LiquibaseJVM and others**/db/changelog/**, **/liquibase.properties
AtlasAny**/atlas.hcl
SqitchAny**/sqitch.plan, **/sqitch.conf
golang-migrate or dbmateAny**/*.up.sql, **/*.down.sql
generic migrations folderAny**/migrations/**, **/migration/**, **/db/migrate/**
generic schema fileAny**/*.ddl, **/schema.sql, **/structure.sql
generic seed folderAny**/db/seeds/**, **/db/seeders/**, **/database/seeds/**, **/database/seeders/**

Modules

From the workspace manifests at the root: pnpm-workspace.yaml (packages, with ! exclusions), package.json workspaces (a list or {packages}), go.work (use), Cargo’s [workspace] members and exclude (and a root package), Gradle’s settings.gradle or settings.gradle.kts (include, :a:b meaning a/b) and uv’s [tool.uv.workspace] members and exclude in pyproject.toml. A member glob matches tracked folders; for pnpm, npm, Cargo and uv the folder must hold that tool’s manifest. A file belongs to the deepest member folder that holds it. Without a manifest, or for a file outside every member, the module is the first two folders under a common container folder (apps, packages, services, libs, crates, cmd, internal, modules, plugins, tools, projects, components, examples, extensions), else the first folder, and <root> for a file at the root.

Lines

Comment lines are recognised per language: // and /* … */ (C, Java, Kotlin, C#, C++, Swift, PHP, Go, Rust, JavaScript, TypeScript, CSS), # (Python, shell, Ruby, Elixir, R, Perl, PowerShell, YAML, TOML, Terraform, Dockerfiles), -- and /* … */ (SQL) and <!-- … --> (HTML, XML, Markdown, Vue, Svelte, Astro). Code after a closing */ on the same line makes the line code, and a block comment opened after code continues onto the lines below. Block comments nest in Rust, Kotlin, Swift, Scala and Dart, as those languages nest them. Comment markers inside a string are code: a "…" or '…' string ends on its line, a `…` or """…""" string runs across lines, as do Python’s '''…''' and SQL’s quoted strings; markup takes no strings. A backslash escapes a quote, except in SQL, which doubles it ('it''s') outside an escape string (E'it\'s'); an escape string stays one across a doubled quote and into a fragment continued on the next line, after whitespace and -- comments. In JavaScript and TypeScript a regular-expression literal (/[/*]/) is code too, recognised where an expression may start: after an operator, an opening bracket or a keyword such as return, never after a closing bracket or a name. The counter reads each language’s lexical rules as one table and does not parse, so rarer forms count as their markers suggest: Rust raw strings, shell strings across lines, heredocs, a division right after ++ or -- (read as a regular expression), and a regular expression right after if (…) or while (…) (read as a division). A file without an extension takes the comment syntax of the language its shebang names, and an extension without one takes that of the language a linguist-language attribute or the classify command names. Other files count every non-blank line as code.

Configuration

All optional, in the repository’s .config/jig.yaml; every field is in the configuration reference.

yaml
code_stats:
  areas:                  # ordered, first match wins; replaces the default list
    - name: scaffolding
      description: Agent instructions and skills
      paths: [".claude/**", "**/AGENTS.md", "**/CLAUDE.md"]
    - name: content
      description: Structured content the product loads
      paths: ["content/**"]
      content: true       # YAML and JSON here count as data, not configuration
    - name: product
      paths: ["apps/**", "packages/**"]
  default_area: production
  kinds:                  # checked before built-in detection, in this order
    fixture: ["acceptance/fixtures/**"]
    test: ["scripts/smoke-*.sh"]
    generated: ["docs/catalogue.md"]
  modules: ["apps/*", "packages/*"]   # default: from the workspace manifests
  classify_command: null

A repository that sets areas writes its whole list: copy the default areas it wants to keep.

The classify command

When globs cannot say it, code_stats.classify_command names a command of the repository’s own. It runs once, from the repository root, with every tracked path on standard input, one per line. It prints one JSON object per line, {"path": "…", "area": "…", "kind": "…", "language": "…", "module": "…"}, with any of the values left out; the values it gives override every other layer. It must exit 0 within 300 seconds (JIG_CODE_STATS_COMMAND_TIMEOUT_SEC changes that). A non-zero exit, a line that is not such an object, a path that is not tracked, an area the report does not know (one of code_stats.areas, or the default area) or an unknown kind is an error naming the problem, and no report is made. Because paths reach the command one per line, a repository with a tracked path that holds a newline cannot use a command: the report refuses to start rather than classify that file wrongly.

Fails closed

A failed git ls-files or git check-attr, or a failed classify command, is an error, never an empty report. A configuration value the skill cannot use (an unknown kind, a malformed glob, a duplicate area name, a value of the wrong type) is refused with a message naming the field and the file that set it. A report template without exactly one data placeholder is refused.

Known limit

Tests written inside production files (Rust #[cfg(test)] modules, Python and Elixir doctests) count as production code. Splitting them out would mean parsing each language.

Source: plugin/skills/code-stats/README.mdThe agent's contract (SKILL.md)