Principles

From melodic-software/claude-code-plugins · View interactive version

Principles is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. Metric literacy for what this plugin reports: what each measure means, where each reference value comes from, and what none of them can tell a reader. Use when: 'what does cyclomatic complexity mean', 'is CRAP a real metric', 'why is the cyclomatic reference 20', 'what is a good coverage number', 'w

How to use this skill

Skill file

Code metrics knowledge base

The audit skill and its audit-* siblings in this plugin print numbers with their provenance and

stop. This skill says what each number means, where its reference value came from, and where reading

it as a verdict goes wrong. It renders no verdict of its own, and neither does the plugin: a

reference is a value to count against, never a bar, and no skill here turns a measured number into a

finding, a severity, or an exit-code gate, because a finding needs a measured corpus sweep behind it

and none has been run. The one findings file the plugin writes, from

audit-suppressions --findings, holds suppressions missing a reason or a rule id, not measured

numbers. Reference files in reference/ are source-attributed; the sections below answer the

common questions without a load.

Routing table

| Query about... | Load |

|---|---|

| What a measure is, its formula, per-lane collector behavior, coverage artifact formats | measures.md |

| Where a reference value came from, which popular numbers have no source, how to set your own | thresholds.md |

| The CRAP formula, its two authorial names, the coverage join, what it does not predict | crap.md |

| Who published what, what a paper claims and does not claim, confidence per source | literature.md |

| The report vocabulary (cov_source, not-applicable, partial) and the JSON document shape | ${CLAUDE_PLUGIN_ROOT}/reference/report-schema.md |

Load the one file the question lands in. Load a second only when the first leaves the question open.

Quick decision guide (no file load needed)

testing a function needs is cyclomatic complexity: McCabe 1976 defines it as the size of a basis

set of paths, and NIST SP 500-235 makes that the number of tests a module needs. How hard a

function is to read is cognitive complexity: Campbell's measure penalizes nesting and charges a

switch and all its cases once. Whether a diff is too large or copied is lines per file and

duplication over the changed files, the two measures ISO/IEC 5055 files as weaknesses (CWE-1080

and CWE-1041). Whether the suite would catch a fault is not a coverage question: coverage records

which lines executed, the primary literature disagrees on how well that predicts fault detection,

and the owner of that question is behind the mutation-testing gate below. No measure here ranks

changes by risk.

bundled reference is 20, from ISO/IEC 5055:2021 §8.2.117, with 10 (McCabe 1976) and 15 (NIST SP

500-235) as the cited alternatives you can select.

reference. A percentage counts executed lines; it says nothing about whether anything was checked.

over. The percentage moves with duplication.min_tokens, so two runs compare only at the same

floor, and replication the repository declares in a registry is excluded rather than suppressed.

validated change-risk predictor. See crap.md before quoting a CRAP number.

of 1000, which is this plugin's own number. ISO/IEC 5055's normative clause for the same weakness

is a percentage on a function, not a line count on a file.

what makes it a testing measure. Cognitive weights nesting and forgives a flat switch, which is

what makes it a readability measure. They disagree on the same function by design.

operator variety times operand reuse, with no explicit length term, so it does not track size. A

split changes each half's operator count and reuse ratio, so per-file difficulty legitimately

moves on a split, in either direction. Check which collector produced the row: multimetric

reports Halstead per file and radon per function.

no external answer. The percentage also counts unknown as typed, so an any-to-unknown sweep

raises it without adding type information.

Cross-metric caveats

The whole plugin carries these once, here; the audit-* skills point at this section rather than

repeating it. Every one of them is a way a true number supports a false conclusion.

and a test that calls a function without an assertion executes it. Raising a coverage percentage is

therefore always possible without improving the suite, which is why no coverage reference ships and

why the number is reported beside the code rather than as a score.

cyclomatic 30 into six functions leaves roughly the same number of paths in the file and turns one

measured row into six smaller ones. Per-function complexity falls, the file's total does not, and

the reader who compares only the maximum sees an improvement that the sum of the rows denies.

counts repeated token runs and has no view of whether the two copies change for the same reason,

and the extraction leaves both call sites depending on the new helper. Some replication is

deliberate, which is why a declared registry excludes a cluster rather than suppressing it, and

whether the coupling that replaces it is an improvement is a question this plugin cannot measure.

falsely narrow annotation all count as typed. The TypeScript percentage and the Python

Any-expression figures are different measures over different populations and never compare.

that is the only combination this plugin computes. A function at 100% coverage and complexity 40

still has CRAP 40; a small function with three untested branches can outrank a large tested one.

There is no supported way to add or average these numbers into a quality score, and doing it is

the mistake this section exists to prevent.

Owners of the other measures

This plugin does not measure these. Each one has an owner, and each pointer is gated: when the

named plugin is not enabled, the concern is out of this plugin's scope and nothing here

substitutes for it, unless the bullet names its own fallback.

surviving mutant means, and /mutation-testing:audit (if enabled) to run one. Coverage cannot answer it: a covered line can still be unchecked.

every measure here.

treating a report whose status is empty on either side as INCONCLUSIVE; otherwise keep the

JSON beside your notes and compare by hand.

Sources

SE-2(4), December 1976, pp. 308-320.

understandability*, white paper version 1.7, 29 August 2023.

the Crap4j project FAQ.

Study", ICSE 2013.

Groce, ICSE 2014; Kochhar, Thung and Lo, SANER 2015; Jia and Harman, IEEE TSE 2011; Petrovic and

Ivankovic, ICSE-SEIP 2018; Petrovic, Ivankovic, Fraser and Just, IEEE TSE 2022.

by clause and version, never by page number. Pointer: when a later OMG ASCQM release matters,

fetch ASCQM: Formal Versions live.

Per-source annotation, including what each does not claim and the confidence behind it, is in

literature.md.

Scope boundary

This skill is knowledge, not workflow. It measures nothing, runs no collector, and reads no

repository. The audit-* skills in this plugin produce the numbers; this one explains them, and

deciding what to do about a number is the reader's call.

Spoke paths

The reference/ files write the plugin's root directory as <plugin-root>, which is

${CLAUDE_PLUGIN_ROOT}. Put that path in place of the placeholder before running a command or

writing it into a brief: 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>.

Next

audit action or audit-* skill for that measure.

Gotchas

standard; the file-line reference is this plugin's own number; cognitive, Halstead, CRAP, coverage,

and type debt ship null because nothing authoritative sets a value. Treating the four as one

tier is the error thresholds.md exists to prevent.

empirical literature does not support a fixed default that transfers across projects, and

literature.md records which studies say so.

definition with different parsers and different variants. The report names the collector per row

so the number is traceable, and comparing rows from different collectors is not supported.

Quoting one as canonical overstates the record; crap.md carries both.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.