Measure code for changed file/diff, path, or tree (`--all`) vs reference (size `--check`): size (lines per file), complexity (per-function cyclomatic complexity, cognitive, Halstead), type-debt (typed ratio, mypy). Use when 'which files are too big', 'how complex is this code', 'how many anys'. Not for CRAP: /code-metrics:audit-coverage.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Audit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/melodic-software-audit-645fde12)
---
description: "Measure code for changed file/diff, path, or tree (`--all`) vs reference (size `--check`): size (lines per file), complexity (per-function cyclomatic complexity, cognitive, Halstead), type-debt (typed ratio, mypy). Use when 'which files are too big', 'how complex is this code', 'how many anys'. Not for CRAP: /code-metrics:audit-coverage."
argument-hint: "<size|complexity|type-debt> [--json] [--all] [--base <ref>] [--check] [<path>...] [--repo <repo>...]"
user-invocable: true
disable-model-invocation: false
allowed-tools: ["Bash(${CLAUDE_SKILL_DIR}/scripts/audit-size.sh:*)", "Bash(${CLAUDE_SKILL_DIR}/scripts/audit-complexity.sh:*)", "Bash(${CLAUDE_SKILL_DIR}/scripts/audit-type-debt.sh:*)", "Bash(git branch --show-current:*)"]
shell: bash
metadata:
workflow-stage: anytime
summary: Lines, complexity and typed-code numbers beside cited references, no verdict
---
# Audit
## Pre-computed context
Current branch: !`git branch --show-current 2>/dev/null || echo "unknown"`
## Variables
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.
## Actions
| 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`).
## Standing rules
- Every action reports: each number sits beside a reference with its provenance, and nothing
here is a pass, a fail, a finding or a severity. The one exception is `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").
- Run the action's bundled script; never count, estimate or grep the measure by hand.
- Scope is the change by default (the merge-base diff plus uncommitted files); explicit paths or
`--all` widen it, and `--json` prints the `code-metrics/v3` document instead of markdown.
- A target form (`--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.
- Present the markdown report as printed, whole, with your notes after it, never in place of a
part of it. Above all, never drop or reword these three: the "Coverage of this run" table, as a
table, never a sentence about it; each reference's provenance line, section number included
(such as `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.
- A `null` value is a number the collector did not produce, never zero.
- Nothing is installed; a missing collector is a row in the run table with its install hint.
## Spoke paths
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>.
## What this skill does not do
- It does not run tests, edit files, or install a collector.
- It does not judge: no reference is a bar, and only `size` has a `check` mode, opt-in through
`size.check`.
- It does not measure duplication, coverage or suppressions; those are the sibling `audit-*`
skills in this plugin, and `/code-metrics:principles` explains what each number can and cannot
tell you.
## Next
- A long file that also changes often needs a tracker item: /work-items:track add.
- The numbers feed a before-and-after comparison: `/verification:measure metrics`.
- A complex function's coverage and CRAP score are the real question:
`/code-metrics:audit-coverage`.
- A number is about to be quoted or read as a bar: `/code-metrics:principles`.
## Gotchas
- Change scope needs a merge-base with the default branch; outside a git repository, or on a
branch with no default-branch ancestor, pass paths or `--all` (the usage error says which).
- The report `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.
- Each action's own gotchas are in its file under `actions/`.