Sandbox
@saurabhkumar8112/cyclomatic-complexity-skill

Claude skill for cyclomatic complexity refactors

This skill helps Claude measure cyclomatic complexity per function, then refactor the hardest parts first. It uses patterns like guard clauses, extracted functions, lookup tables, and named predicates, while refusing to hide complexity in clever one-liners.

383 stars10 forksUpdated 21d ago
Who it's for

Builders who want Claude to turn branch-heavy code into simpler, more maintainable functions.

What it delivers

You can keep complex code readable without losing behavior or gaming the complexity metric.

What it does

Measures function complexity

Checks cyclomatic complexity with tools like radon, eslint, gocyclo, lizard, or a manual count.

Uses project thresholds

Respects the linter thresholds already configured in the codebase.

Refactors the worst hotspots first

Targets the most complex functions and rewrites them with guard clauses, extracted functions, lookup tables, or named predicates.

Avoids metric gaming

Keeps complexity in well-named functions instead of hiding it in dense expressions.

Reports the before and after

Ends each refactor with a complexity table showing the change for each function.

How to get it

  1. 1Run
    /plugin marketplace add saurabhkumar8112/cyclomatic-complexity-skill
    /plugin install cyclomatic-complexity@cyclomatic-complexity-skill

README

cyclomatic-complexity

A Claude skill that refactors code to reduce cyclomatic complexity. Built for AI-generated code: it works, but branches like a jungle. This skill makes Claude measure complexity, refactor hotspots, and keep code maintainable for humans and the long-term vision of the codebase.

What it does

  • Measures cyclomatic complexity per function (radon, eslint, gocyclo, lizard, or manual count)
  • Respects your project's own linter thresholds when configured
  • Refactors worst hotspots first: guard clauses, extract function, lookup tables, named predicates
  • Refuses to game the metric. Complexity moves into well-named functions, not into clever one-liners
  • Ends every refactor with a before/after complexity table

Install

Claude Code

/plugin marketplace add saurabhkumar8112/cyclomatic-complexity-skill
/plugin install cyclomatic-complexity@cyclomatic-complexity-skill

Claude.ai

Download the .skill file from Releases (or zip the skills/cyclomatic-complexity folder) and upload it under Settings → Capabilities → Skills.

Claude API

Upload via the Skills API.

Usage

Triggers automatically on refactoring, cleanup, and code review requests. Or invoke directly:

"Use the cyclomatic complexity skill to refactor parser.py"

Example output

## Complexity report
| Function | Before | After |
|----------|--------|-------|
| parseOrder | 14 | 4 |

Extracted: validateHeader, resolveDiscount
Behavior verified: existing test suite passes

License

Apache 2.0

Files in the repo

Repository payload5 top-level entries
  • .claude-plugin
  • skills
  • .gitignore
  • LICENSE
  • README.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More skills

obra/
superpowers

An agentic skills framework & software development methodology that works.

285k
1 add

Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local deterministic AST parsing, every edge explained, no vector store.

117k
1 add
Vincentwei1021/
anything2explainer

Topic in, narrated explainer video out. A Claude Code / Codex skill that turns any topic into a black-canvas motion-graphics explainer video with TTS voiceover, subtitles and a chapter progress bar. Chinese or English; every frame drawn in code with Remotion.

666

Open-source AI job search: scan job portals, evaluate listings into a structured A-H report with a global 1-5 score, tailor your CV, track applications — runs locally in your AI coding CLI (Claude Code, Codex, OpenCode, Antigravity…)

71k