npx skills add ...
npx skills add boshu2/agentops --skill complexity
Find focused refactor hotspots.
npx skills add boshu2/agentops --skill complexity
YOU MUST EXECUTE THIS WORKFLOW. Do not just describe it.
Analyze code complexity to identify refactoring targets.
Given /complexity [path]:
If path provided: Use it directly.
If no path: Use current directory or recent changes:
For Python (using radon):
For Go (using gocyclo):
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 | Very high risk |
| F | 31+ | Untestable, refactor now |
List functions/methods that need attention:
Write to: .agents/complexity/YYYY-MM-DD-<target>.md
Tell the user:
/refactor <function> to address critical complexity targetsSimplifying High Complexity:
User says: /complexity src/
What happens:
src/ directoryradon cc src/ -a -s for cyclomatic complexityradon mi src/ -s for maintainability index.agents/complexity/2026-02-13-src.mdprocess_request() functionResult: Complexity report identifies process_request() (CC: 28) as critical refactor target with specific extraction recommendations.
User says: /complexity
What happens:
git diff --name-only HEAD~5gocyclo -over 10 ./... on projectHandleWebhook() function with complexity 34Result: Critical function identified for immediate refactoring with actionable extraction plan.
| Problem | Cause | Solution |
|---|---|---|
| Tool not installed (radon/gocyclo) | Missing dependency | Agent auto-installs: pip install radon for Python or go install github.com/fzipp/gocyclo/cmd/gocyclo@latest for Go. Verify install path in $PATH. |
| No complexity issues found | Threshold too high or genuinely simple code | Lower threshold: try gocyclo -over 5 or check if path includes actual implementation files vs tests. |
| Report shows functions without recommendations | Generic analysis without codebase context | Read the high-CC functions to understand structure, then provide specific refactoring suggestions based on actual code patterns. |
| Mixed language project | Multiple languages in target path | Run analysis separately per language: /complexity src/python/ then /complexity src/go/, combine reports manually. |
# Check if radon is installed
which radon || pip install radon
# Run cyclomatic complexity
radon cc <path> -a -s
# Run maintainability index
radon mi <path> -s# Check if gocyclo is installed
which gocyclo || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
# Run complexity analysis
gocyclo -over 10 <path># Complexity Report: <Target>
**Date:** YYYY-MM-DD
**Language:** <Python/Go>
**Files Analyzed:** <count>
## Summary
- Average CC: <score>
- Highest CC: <score> in <function>
- Functions over threshold: <count>
## Refactor Targets
### Critical (CC > 20)
| Function | File | CC | Recommendation |
|----------|------|-----|----------------|
| <name> | <file:line> | <score> | <how to simplify> |
### High (CC 11-20)
| Function | File | CC | Recommendation |
|----------|------|-----|----------------|
| <name> | <file:line> | <score> | <how to simplify> |
## Refactoring Recommendations
1. **<Function>**: <specific suggestion>
- Extract: <what to extract>
- Simplify: <how to simplify>
## Next Steps
- [ ] Address critical complexity first
- [ ] Create issues for high complexity
- [ ] Consider refactoring sprint