code-quality-plugin/skills/code-complexity/SKILL.md
Analyze code complexity metrics (cyclomatic, cognitive, function length, coupling). Use when identifying refactoring targets, tracking codebase health, or reviewing large changes.
npx skillsauth add laurigates/claude-plugins code-complexityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Measure and report code complexity metrics.
| Use this skill when... | Use something else when... | |---|---| | Identifying refactoring targets by complexity | Looking for specific anti-patterns → /code:antipatterns | | Tracking codebase health trends | Doing full code review → /code:review | | Reviewing large PRs for complexity hotspots | Finding duplicated code → /code:dry-consolidation | | Setting complexity budgets for the team | Configuring linting rules → /configure:linting |
find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.py" -o -name "*.rs" -o -name "*.go" \) -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*"find . -maxdepth 1 \( -name "package.json" -o -name "pyproject.toml" -o -name "Cargo.toml" -o -name "go.mod" \) -type f$1: Path to analyze (defaults to current directory)--threshold: Complexity threshold for flagging (default: 10)--format: Output format — summary (default), detailed, jsonExecute this complexity analysis:
Check for language-specific complexity tools:
eslint with complexity rule, or use manual AST analysisradon (cyclomatic + maintainability index)cargo clippy cognitive complexity warningsJavaScript/TypeScript:
Analyze files for:
npx eslint --rule '{"complexity": ["warn", 1]}' --format jsonPython (Radon):
radon cc ${1:-.} -s -a --min B
radon mi ${1:-.} -s
Rust:
cargo clippy -- -W clippy::cognitive_complexity
Manual analysis (all languages):
When dedicated tools are unavailable, scan source files directly:
Rank files and functions by complexity. Flag items exceeding the threshold:
| Metric | Green | Yellow | Red | |---|---|---|---| | Cyclomatic complexity | 1-5 | 6-10 | 11+ | | Cognitive complexity | 1-8 | 9-15 | 16+ | | Function length (lines) | 1-25 | 26-50 | 51+ | | Nesting depth | 1-3 | 4 | 5+ | | Parameters per function | 1-3 | 4-5 | 6+ |
For each source file:
Complexity Report
=================
Files analyzed: N
Functions analyzed: N
Average complexity: X.X
Hotspots (complexity > threshold):
File | Function | CC | Lines | Depth
src/auth/handler.ts | validateToken | 15 | 82 | 6
src/api/router.ts | handleRequest | 12 | 64 | 5
Distribution:
Low (1-5): NN% of functions
Medium (6-10): NN% of functions
High (11+): NN% of functions
Recommendations:
1. [file:function] Extract nested conditions into helper functions
2. [file:function] Split into smaller focused functions
3. [file:function] Replace switch with strategy pattern
/code:refactor for the worst offenderspip install radon or equivalent/configure:linting| Context | Command |
|---|---|
| Python cyclomatic | radon cc . -s -a --min B -j |
| Python maintainability | radon mi . -s -j |
| JS/TS complexity | npx eslint --rule '{"complexity":["warn",1]}' --format json . |
| Rust cognitive | cargo clippy -- -W clippy::cognitive_complexity 2>&1 |
| Quick file length scan | Glob for source files, Read and count function lengths |
tools
Scaffold a new ComfyUI custom-node repo (pyproject, CI, release-please, vitest+pytest, JS extension skeleton) in the picker/gesture vein. Use when bootstrapping or init-ing a comfyui node pack.
tools
Orchestrate a ComfyUI node pack from idea to registry: scaffold, create + seed the repo, open the gitops adoption PR. Use when releasing or spinning up a new comfyui node pack.
testing
macOS EndpointSecurity/EDR high CPU & battery drain. Use when Kandji ESF / XProtect pegs a core; trace the exec storm via powermetrics + eslogger.
development
odiff pixel-by-pixel image diffing. Use when comparing screenshots, detecting visual regressions, diffing before/after PNGs, asserting golden images.