|
| 1 | +--- |
| 2 | +name: simplify-implementation |
| 3 | +description: Analyze and simplify existing implementations to reduce complexity, improve maintainability, and enhance scalability. Use when users ask to simplify code, reduce complexity, refactor for readability, clean up implementations, improve maintainability, reduce technical debt, or make code easier to understand. |
| 4 | +--- |
| 5 | + |
| 6 | +# Simplify Implementation Assistant |
| 7 | + |
| 8 | +Reduce complexity with an analysis-first approach before changing code. |
| 9 | + |
| 10 | +## Hard Rules |
| 11 | +- Do not modify code until the user approves a simplification plan. |
| 12 | +- Readability over brevity. Some duplication beats the wrong abstraction. |
| 13 | + |
| 14 | +## Workflow |
| 15 | + |
| 16 | +1. Gather Context |
| 17 | +- Confirm targets, pain points, and constraints (compatibility, API stability, deadlines). |
| 18 | + |
| 19 | +2. Analyze Complexity |
| 20 | +- Identify sources (nesting, duplication, coupling, over-engineering, magic values). |
| 21 | +- Assess impact (LOC, dependencies, cognitive load, scalability blockers). |
| 22 | + |
| 23 | +3. Apply Readability Principles |
| 24 | +- Apply the [readability guide](references/readability-guide.md) and its "Reading Test". |
| 25 | + |
| 26 | +4. Propose Simplifications |
| 27 | +For each issue, apply a pattern: |
| 28 | +- **Extract**: Long functions → smaller, focused functions. |
| 29 | +- **Consolidate**: Duplicate code → shared utilities. |
| 30 | +- **Flatten**: Deep nesting → early returns, guard clauses. |
| 31 | +- **Decouple**: Tight coupling → dependency injection, interfaces. |
| 32 | +- **Remove**: Dead code, unused features, excessive abstractions. |
| 33 | +- **Replace**: Complex logic → built-in language/library features. |
| 34 | +- **Defer**: Premature optimization → measure-first approach. |
| 35 | + |
| 36 | +5. Prioritize and Plan |
| 37 | +- Rank by impact/risk. Present plan with before/after snippets. Request approval. |
| 38 | + |
| 39 | +## Validation |
| 40 | +- Verify no regressions, add tests for new helpers, update docs if interfaces changed. |
| 41 | + |
| 42 | +## Output Template |
| 43 | +- Target and Context |
| 44 | +- Complexity Analysis |
| 45 | +- Simplification Proposals (prioritized) |
| 46 | +- Recommended Order and Plan |
| 47 | +- Scalability Recommendations |
| 48 | +- Validation Checklist |
0 commit comments