From agentops
Analyzes cyclomatic complexity in Python and Go code using radon and gocyclo, identifies refactor targets with grades (A-F), and generates Markdown reports.
npx claudepluginhub boshu2/agentops --plugin agentopsThis skill uses the workspace's default tool permissions.
**YOU MUST EXECUTE THIS WORKFLOW. Do not just describe it.**
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
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:
git diff --name-only HEAD~5 2>/dev/null | grep -E '\.(py|go)$' | head -10
# Check for Python files
ls *.py **/*.py 2>/dev/null | head -1 && echo "Python detected"
# Check for Go files
ls *.go **/*.go 2>/dev/null | head -1 && echo "Go detected"
For Python (using radon):
# 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
For Go (using gocyclo):
# Check if gocyclo is installed
which gocyclo || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
# Run complexity analysis
gocyclo -over 10 <path>
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
# 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
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. |