complexity-reduction

complexity-reduction is a skill for Claude Code, Codex from wefio/NodeMemoryGraph. It costs 50 tokens per session (1,519 once invoked), scanned A, original, MIT.

A guide and gate for lowering cyclomatic complexity, a measure of how many independent paths a method can take.

In plain words
What is it for?
Use it when a method is flagged as too complex or before adding more branching to large code.
Why use it?
Highly branching methods are harder to understand, test, and maintain, and may fail the project's quality checks.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when a method is flagged as too complex or before adding more branching to large code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wefio/nodememorygraph/complexity-reduction
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add wefio/NodeMemoryGraph --skill complexity-reduction
Clone the repo
git clone --depth 1 https://github.com/wefio/NodeMemoryGraph

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for complexity-reduction

README.md
[![agentmods](https://agentmods.dev/badge/skills/wefio/nodememorygraph/complexity-reduction/github.svg)](https://agentmods.dev/skills/wefio/nodememorygraph/complexity-reduction)
Your own site
<a href="https://agentmods.dev/skills/wefio/nodememorygraph/complexity-reduction"><img src="https://agentmods.dev/badge/skills/wefio/nodememorygraph/complexity-reduction/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for complexity-reduction

Your own site · 80×15
<a href="https://agentmods.dev/skills/wefio/nodememorygraph/complexity-reduction"><img src="https://agentmods.dev/badge/skills/wefio/nodememorygraph/complexity-reduction.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,519 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00050 $0.01519
Opus 5.5 $0.00020 $0.00608
Sonnet 5.5 $0.00010 $0.00304
Haiku 4.5 $0.00005 $0.00152

Measured 6d ago against content hash 58cc5de0a5bb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

complexity-reduction scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/complexity-reduction/SKILL.md · 169 lines

How it starts

The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Complexity reduction

简体中文 · Terms used

Cyclomatic complexity counts linearly independent paths through a method: every if, else if, for, while, case, catch, &&, ||, and ?: adds one. High complexity means many paths to test and maintain. CodeFactor enforces a threshold on the PR diff; the local complexity:gate does the same before push.

When to use

  • CodeFactor reports Complex Method on your PR.
  • npm run complexity:gate fails (a changed method grew, or a new method exceeds the cap).
  • You are about to add branching to an already-large method.

Diagnose first

Identify which methods are over the threshold and whether you introduced them:

npx eslint --no-config-lookup --format json \
  --rule '{"complexity": ["error", 15]}' <file>                 # per-method complexity

git show <base>:<file> | npx eslint --no-config-lookup --format json \
  --stdin --stdin-filename <file> --rule '{"complexity": ["error", 15]}'   # baseline (was it already complex?)

Rule-only runs must pass --no-config-lookup (ESLint 9 otherwise merges the repo config into the run) and --format json (the text formatters are not stable to parse).

Baseline gotcha: the gate is self-referential on main

complexity:gate defaults its baseline to the merge base with origin/main. That is correct on a feature branch, but on main itself the merge base is HEAD, so every violation reads "unchanged from baseline" and the gate always reports ok. When auditing on main, or after a merge, measure against the actually landed state:

git fetch origin
npm run complexity:gate -- --base origin/main

A failed gate names the skill to consult (this file); CodeFactor enforces the same cap on PR diffs even for methods unchanged from the baseline when their file is in the diff — reduce them anyway.

If a flagged method is unchanged from the baseline it is pre-existing debt, but CodeFactor still requires it under the threshold when the file is in the diff — reduce it anyway (it is a reviewable improvement, not a no-op).

Read the full file on GitHub · 169 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago Changed · +23 lines 58cc5de0a5bb
  2. 10d ago Changed · +2 lines 75a5896de8f0
  3. 1mo ago First seen · 144 lines · 50 tokens per session scan A 66faccfcf922

Subscribe to this mod's changes

complexity-reduction is a skill published in the GitHub repository wefio/NodeMemoryGraph (0 stars, last pushed today), licensed MIT. It adds 50 tokens to every session and 1,519 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.