cyclomatic-complexity

cyclomatic-complexity is a skill for Claude Code, Codex from saurabhkumar8112/cyclomatic-complexity-skill. It costs 103 tokens per session (727 once invoked), scanned A, original, Apache-2.0.

A guide for reducing cyclomatic complexity, which is a measure of how many decision paths a function has. It recommends ways to make code easier for people to read and maintain.

In plain words
What is it for?
Use it when refactoring, simplifying, or reviewing code quality. It covers complexity thresholds and techniques such as early returns, extracted functions, lookup tables, and named conditions.
Why use it?
Highly branched code is harder to understand, test, and change. Measuring complexity first helps focus refactoring on the functions most likely to cause problems.

Skill for Claude CodeCodex

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

Good fit Use it when refactoring, simplifying, or reviewing code quality. It covers complexity thresholds and techniques such as early returns, extracted functions, lookup tables, and named conditions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/saurabhkumar8112/cyclomatic-complexity-skill/cyclomatic-complexity
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 saurabhkumar8112/cyclomatic-complexity-skill --skill cyclomatic-complexity
Clone the repo
git clone --depth 1 https://github.com/saurabhkumar8112/cyclomatic-complexity-skill

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 cyclomatic-complexity

README.md
[![agentmods](https://agentmods.dev/badge/skills/saurabhkumar8112/cyclomatic-complexity-skill/cyclomatic-complexity/github.svg)](https://agentmods.dev/skills/saurabhkumar8112/cyclomatic-complexity-skill/cyclomatic-complexity)
Your own site
<a href="https://agentmods.dev/skills/saurabhkumar8112/cyclomatic-complexity-skill/cyclomatic-complexity"><img src="https://agentmods.dev/badge/skills/saurabhkumar8112/cyclomatic-complexity-skill/cyclomatic-complexity/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 cyclomatic-complexity

Your own site · 80×15
<a href="https://agentmods.dev/skills/saurabhkumar8112/cyclomatic-complexity-skill/cyclomatic-complexity"><img src="https://agentmods.dev/badge/skills/saurabhkumar8112/cyclomatic-complexity-skill/cyclomatic-complexity.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 103 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 727 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 43
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
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.00103 $0.00727
Opus 5.5 $0.00041 $0.00291
Sonnet 5.5 $0.00021 $0.00145
Haiku 4.5 $0.00010 $0.00073

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

Security

Grade A, and why

cyclomatic-complexity 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 1mo 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/cyclomatic-complexity/SKILL.md · 70 lines

How it starts

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

Cyclomatic Complexity

Purpose: AI-written code often works but branches like a jungle. This skill: measure complexity, refactor hotspots, keep code human-maintainable.

Measure first

CC = decision points + 1. Decision points: if, else if, case, loops, catch, ternary, &&, || in conditions.

Project linter config wins. If eslintrc, radon config, sonar config, or similar sets a complexity threshold, use that. No config: use defaults below.

Thresholds:

  • 1-5: fine, leave alone
  • 6-10: watch, refactor if touching anyway
  • 11-15: refactor now
  • 15+: must split, no debate

Prefer real tools over eyeballing when environment allows:

  • Python: radon cc -s -a <path>
  • JS/TS: eslint complexity rule
  • Go: gocyclo
  • Polyglot: lizard <path>

No tool available: count manually, per function, show the count.

Refactor tactics, in order of preference

  1. Guard clauses. Invert conditions, return early, kill nesting.
  2. Extract function. Each extracted piece gets a name that says what, not how. Names are documentation.
  3. Lookup table / map instead of if-else or switch chains.
  4. Named predicates. if (isEligibleForRefund(order)) beats a 4-clause boolean soup.
  5. Polymorphism / strategy for switch-on-type. Only when the switch appears in 2+ places.
  6. Flatten loops. Extract loop body, use continue instead of nested if.

Hard rules

  • Preserve behavior. Run tests before and after. No tests: say so, suggest adding, refactor conservatively.
  • Don't game the metric. A dense one-liner hiding 6 branches is worse than the honest if-chain it replaced. Complexity should move into well-named units, not disappear into cleverness.
  • Don't break public APIs or exported signatures without asking.
  • Small functions with clear names > few functions with comments explaining sections.
  • One responsibility per function. If the name needs "and", split.

Workflow

  1. Measure all touched functions, rank by CC descending.
  2. Report hotspots with numbers before touching anything.
  3. Refactor worst first, one function at a time.
  4. Re-measure. Show before/after table: function, CC before, CC after.
  5. Verify: tests pass, behavior unchanged, diff reviewable.

Read the full file on GitHub · 70 lines

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. 1mo ago First seen · 70 lines · 103 tokens per session scan A 6e8edae7a225

Subscribe to this mod's changes

cyclomatic-complexity is a skill published in the GitHub repository saurabhkumar8112/cyclomatic-complexity-skill (405 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 103 tokens to every session and 727 once invoked, about $0.0004 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-08-30.