| name | complexity |
| description | Find focused refactor hotspots. |
| practices | ["code-complete","refactoring"] |
| hexagonal_role | domain |
| consumes | ["doc","standards"] |
| produces | ["stdout"] |
| context_rel | [{"kind":"shared-kernel","with":"standards"}] |
| skill_api_version | 1 |
| context | {"window":"fork","intent":{"mode":"task"},"sections":{"exclude":["HISTORY"]},"intel_scope":"topic"} |
| metadata | {"tier":"execution","dependencies":["standards","doc"]} |
| output_contract | stdout: complexity metrics report |
Complexity Skill
YOU MUST EXECUTE THIS WORKFLOW. Do not just describe it.
Analyze code complexity to identify refactoring targets.
Execution Steps
Given /complexity [path]:
Step 1: Determine Target
If path provided: Use it directly.
If no path: Use current directory or recent changes:
git diff --name-only HEAD~5 2>/dev/null | grep -E '\.(py|go)$' | head -10
Step 2: Detect Language
ls *.py **/*.py 2>/dev/null | head -1 && echo "Python detected"
ls *.go **/*.go 2>/dev/null | head -1 && echo "Go detected"
Step 3: Run Complexity Analysis
For Python (using radon):
which radon || pip install radon
radon cc <path> -a -s
radon mi <path> -s
For Go (using gocyclo):
which gocyclo || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
gocyclo -over 10 <path>
Step 4: Interpret Results
Cyclomatic Complexity Grades:
| Grade | CC Score | Meaning |
|---|
| A | 1-5 | Low risk, simple |
| B | 6-10 | Moderate, manageable |
| C | 11-20 | High risk, complex |
| D | 21-30 |