From addlightness
Read-only code-weight report. Measures LOC, cyclomatic complexity, import count, function count, and nesting depth for one or more files and lists removable 'fat' candidates -- WITHOUT changing any code. Use when the user says "how heavy is this", "weight report", "what's the fat here", "review weight", "analyze complexity", "where can this be trimmed", "is this bloated", or invokes /addlightness-review. Triggers on /addlightness-review. Reports only, never edits; to actually apply trims use /addlightness.
How this skill is triggered — by the user, by Claude, or both
Slash command
/addlightness:addlightness-reviewThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Measure code weight and surface removable "fat" candidates. This is the
Measure code weight and surface removable "fat" candidates. This is the
diagnostic half of addlightness: it reports, it never edits. For actual
trimming use /addlightness; for performance numbers use /addlightness-bench.
This skill NEVER modifies files. It reads, measures, and reports. Period.
Edit, no Write, no in-place fixes, no "I went ahead and removed it"./addlightness <file...>
(which spawns the edit-capable code-trimmer agent behind an equivalence gate).Repeat this contract back to the user if they ask you to "just fix it" here --
review reports, /addlightness edits.
For each target file, get its weight metrics from the zero-dependency engine. Two equivalent paths -- prefer the agent for multi-file work, the direct call for a single quick read:
Via the agent (preferred for >1 file or a fat-candidate narrative):
spawn the weight-analyst agent. It is read-only by contract (its prompt
forbids mutating Bash commands; it has no Edit/Write) and returns the metrics
table plus a ranked fat list and a KEEP list. The agent analyzes one file per
invocation — spawn one weight-analyst invocation per file and aggregate the
JSON yourself.
Direct (single file, fastest):
node "${CLAUDE_PLUGIN_ROOT}/lib/weigh.js" path/to/file.js --json
The engine emits one JSON object per file with the scalar weight plus the
raw components (loc, cyclomatic, imports, functions, nesting,
tokens), an approx boolean (true = JS/TS regex approximation, false =
Python ast-accurate), and the weight_formula string. Parse the JSON line;
do not screen-scrape prose. The approx flag is the authoritative
accuracy signal — read it rather than guessing from the language.
weight = 1.0*loc + 2.0*cyclomatic + 1.5*imports + 1.0*functions + 3.0*nesting
JS/TS metrics are regex-on-stripped-source approximations (comments,
strings, and templates are stripped first). Python metrics come from the
stdlib ast module and are accurate. Say which is which when you report.
Aggregate across all targets into one report. Glob the user's pattern (e.g.
src/**/*.js) yourself, then weigh each match.
For every candidate, report a row -- never an edit:
| field | meaning |
|---|---|
| category | one of the categories below |
| location | file:line (or file:start-end) |
| current | the exact code as it stands |
| proposed | what a trim would look like (for the human, not applied) |
| why-safe | the specific reason removing it preserves behavior |
| risk | low / medium / high -- residual doubt after why-safe |
Categories:
Boolean(x) in a boolean context, String(x) in a
template, !!x where truthiness already suffices, +x on a known number.if (false), a return followed by code, an arm shadowed by an earlier one.async on a function that never awaits and whose
caller does not rely on the Promise wrapping. (Flag cautiously -- check call
sites; removing async changes the return type and turns sync throws into
thrown errors instead of rejected Promises.)// increment i
above i++). Why-comments are NOT fat -- never flag those.Produce three sections, in this order:
weight | loc | cyclomatic | imports | functions | nesting | tokens, with a total/average row. Note JS=approx,
Python=ast-accurate.A review with an empty KEEP list on real code is suspect -- you probably mislabeled a boundary check as fat.
The scalar is a relative before/after metric, not an industry standard. Lower = lighter. Read the ratios, not raw size:
Raw LOC alone is a weak signal -- a 200-line file of essential branching can be leaner than a 60-line file of wrappers. Always pair LOC with the complexity and nesting ratios.
ast may be
called accurate./addlightness, not
here.npx claudepluginhub 88plug/claude-code-plugins --plugin addlightnessSets up isolated workspaces using native worktree tools or git worktree fallback. Use before starting feature work to protect the current branch.