/code-metrics:audit <size|complexity|type-debt> [--json] [--all] [--base <ref>] [--check] [<path>...] [--repo <repo>...]from code-metrics
Measures code size (lines per file), complexity (cyclomatic, cognitive, Halstead), and type-debt (typed ratio, mypy) against a reference. Useful for identifying oversized files, complex functions, or untyped code.
Ships in code-metrics. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Current branch: !git branch --show-current 2>/dev/null || echo "unknown"
Arguments: $ARGUMENTS
The first word names the action; the rest passes to its script unchanged, except the target
forms, which the skill resolves and never passes to a script.
${CLAUDE_PLUGIN_ROOT}/reference/several-repositories.md says which scope argument a
multi-repository run adds.
| Argument | Measures | Script | Full process |
|---|---|---|---|
size | Lines per file, every text file in every language | ${CLAUDE_SKILL_DIR}/scripts/audit-size.sh | actions/size.md |
complexity | Per-function cyclomatic and cognitive complexity and Halstead difficulty | ${CLAUDE_SKILL_DIR}/scripts/audit-complexity.sh | actions/complexity.md |
type-debt | Typed-code percentage per file and per language (TypeScript, Python) | ${CLAUDE_SKILL_DIR}/scripts/audit-type-debt.sh | actions/type-debt.md |
With no action word, take the action from the request: file length or lines is size,
complexity is complexity, typing or any is type-debt. When the request names none of them,
list the three actions and ask which to run. Read the action's file before running its script; one
action per invocation. Append --user-file '${user_config.config_file}' to every script call, exactly as written:
it names the file holding your userConfig layer, and an empty or unsubstituted value means none
(${CLAUDE_PLUGIN_ROOT}/reference/config.md).
size --check in a
repository whose config sets size.check (off by default): it fails a changed file that crossed
the reference, for a pre-commit hook or CI step the repository wires itself (actions/size.md,
"Check mode").--all widen it, and --json prints the code-metrics/v3 document instead of markdown.--repo <repo> and the others) runs the action once per repository, as
${CLAUDE_PLUGIN_ROOT}/reference/several-repositories.md says; each repository gets its own
section. size --check is a gate for one repository's hook or CI step, so it takes no target
form.ISO/IEC 5055:2021 §8.2.117, or that the value is the plugin's own number); and, for a
measure with no reference, that no standard sets one. Keep the --json document when the numbers feed a
comparison: /verification:measure metrics (if enabled) consumes it (treat status: empty on either side as INCONCLUSIVE); otherwise keep it beside your
notes and compare by hand.null value is a number the collector did not produce, never zero.The actions/ files write this skill's directory as <skill-dir>, which is ${CLAUDE_SKILL_DIR},
and the plugin's root directory as <plugin-root>, which is ${CLAUDE_PLUGIN_ROOT}. Put those
paths in place of the placeholders before running a command: a ${…} token in a supporting file
is not one this plugin can rely on being expanded, either in the file or in the Bash tool. Where
each plugin variable resolves, and where it is exported: the plugins reference,
https://code.claude.com/docs/en/plugins/manifest-reference#where-each-variable-resolves.
size has a check mode, opt-in through
size.check.audit-*
skills in this plugin, and /code-metrics:principles explains what each number can and cannot
tell you./verification:measure metrics./code-metrics:audit-coverage./code-metrics:principles.--all (the usage error says which).skill field and the dispatcher id are audit-size, audit-complexity and
audit-type-debt, not this skill's name: they name the producing script, so a saved report
and a new one from the same script compare.actions/.actions/complexity.md (opens in a new tab)actions/size.md (opens in a new tab)actions/type-debt.md (opens in a new tab)evals/evals.json (opens in a new tab)scripts/audit-complexity.sh (opens in a new tab)scripts/audit-complexity.test.sh (opens in a new tab)scripts/audit-size.sh (opens in a new tab)scripts/audit-size.test.sh (opens in a new tab)scripts/audit-type-debt.sh (opens in a new tab)scripts/audit-type-debt.test.sh (opens in a new tab)scripts/size_check.py (opens in a new tab)scripts/size_commits.py (opens in a new tab)scripts/test_size_check.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
bashThree short reads, in order
npx claudepluginhub melodic-software/claude-code-plugins --plugin code-metrics6 skills in this plugin
/audit-coverageAudit coverageRead coverage artifacts a build already wrote (lcov, Cobertura, coverage.py JSON, Go cover profile) to report line coverage and CRAP per file and function for a change, path, or tree; runs no tests, never gates. Use when 'coverage per function', 'CRAP score', 'read the lcov report'. Not for complexity alone: /code-metrics:audit./audit-duplicationAudit duplicationMeasure duplicated code and redundant copy-paste clone classes (DRY) across a change, path, or tree with instance spans, excluding repo-sanctioned replication. Reports, never gates. Use when 'find copy-paste code', 'clone detection', 'duplication report'. Not for file length: /code-metrics:audit size./audit-suppressionsportability-ok: R6 kept-adapter operation - audit-suppressions.sh C# patternsOther plugins' skills for the same job