Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

complexity

verified

Analyze code complexity and find refactor targets using radon/gocyclo. Triggers: "complexity", "analyze complexity", "find complex code", "refactor targets", "cyclomatic complexity", "code metrics".

View on GitHub

Marketplace

agentops-marketplace

boshu2/agentops

Plugin

agentops

productivity

Repository

boshu2/agentops
7stars

skills/complexity/SKILL.md

Last Verified

February 1, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/boshu2/agentops/blob/main/skills/complexity/SKILL.md -a claude-code --skill complexity

Installation paths:

Claude
.claude/skills/complexity/
Powered by add-skill CLI

Instructions

# 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:
```bash
git diff --name-only HEAD~5 2>/dev/null | grep -E '\.(py|go)$' | head -10
```

### Step 2: Detect Language

```bash
# 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"
```

### Step 3: Run Complexity Analysis

**For Python (using radon):**
```bash
# 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):**
```bash
# Check if gocyclo is installed
which gocyclo || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest

# Run complexity analysis
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 | Very high risk |
| F | 31+ | Untestable, refactor now |

### Step 5: Identify Refactor Targets

List functions/methods that need attention:
- CC > 10: Should refactor
- CC > 20: Must refactor
- CC > 30: Critical, immediate action

### Step 6: Write Complexity Report

**Write to:** `.agents/complexity/YYYY-MM-DD-<target>.md`

```markdown
# 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

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3002 chars