Loading...
Loading...
Detect and simplify overly complex code. Apply KISS principle - less is more.
npx skill4agent add nguyenthienthanh/aura-frog code-simplifierrules/kiss-avoid-over-engineering.mdrules/kiss-avoid-over-engineering.md| Signal | Action |
|---|---|
| Deep nesting (>3 levels) | Flatten with early returns |
| Long function (>30 lines) | Extract smaller functions |
| Complex conditionals | Use lookup tables |
| Over-abstraction | Inline single-use code |
| Premature optimization | Remove unless profiled |
| Metric | Target |
|---|---|
| Cyclomatic complexity | ≤10 |
| Nesting depth | ≤3 |
| Function length | ≤30 lines |
| File length | ≤300 lines |
| Parameters | ≤3 |
| Command | Purpose |
|---|---|
| Analyze and simplify a file |
| Check complexity metrics |
| Full complexity report |
User: This function is too complex, simplify it
Claude: Let me analyze the complexity...
Complexity Analysis:
- Cyclomatic complexity: 15 (target: ≤10)
- Nesting depth: 5 (target: ≤3)
- Lines: 87 (target: ≤30)
Simplification Plan:
1. Convert nested ifs to early returns (-3 nesting)
2. Extract validation logic to separate function (-20 lines)
3. Replace switch with lookup table (-15 lines, -5 complexity)
4. Remove unused error handling branch
Applying changes...
Result:
- Cyclomatic complexity: 6 ✓
- Nesting depth: 2 ✓
- Lines: 28 ✓rules/kiss-avoid-over-engineering.mdcommands/quality/complexity.mdcommands/refactor.mdskills/code-reviewer/SKILL.md