Skip to content

Commit 6104cfd

Browse files
committed
feat(skills): add simplify-implementation
1 parent e994d40 commit 6104cfd

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Readability Guide
2+
3+
**Good code reads like a good book — naturally, from left to right, top to bottom.**
4+
5+
## DO
6+
- **Linear flow**: Read top-to-bottom without jumping around.
7+
- **Explicit over implicit**: Clear code over clever shortcuts.
8+
- **Meaningful names**: Purpose obvious without comments.
9+
- **Consistent patterns**: Same patterns throughout the codebase.
10+
- **Single abstraction level**: One level of abstraction per function.
11+
- **Logical grouping**: Blank lines to separate logical blocks.
12+
13+
## AVOID: Over-Optimization for Brevity
14+
15+
These patterns harm readability — prefer the alternative:
16+
- **Nested ternaries** (`a ? b ? c : d : e`) → explicit if/else.
17+
- **Chained one-liners** (`.map().filter().reduce().flat()`) → named intermediate steps.
18+
- **Clever bitwise tricks** (`n & 1` for odd check) → readable arithmetic.
19+
- **Short variable names** (`x`, `y`, `z`) → descriptive names (`users`, `activeUsers`).
20+
- **Implicit returns everywhere** → explicit returns for complex logic.
21+
- **Magic one-liners** (regex/reduce that "do everything") → documented steps.
22+
- **Premature DRY** (abstraction to avoid 2-3 lines of duplication) → some duplication is clearer.
23+
24+
## The "Reading Test"
25+
26+
For each simplification, all four must be "yes":
27+
1. Can a new team member understand this in under 30 seconds?
28+
2. Does the code flow naturally without jumping to other files?
29+
3. Are there any "wait, what does this do?" moments?
30+
4. Would this code still be clear 6 months from now?

0 commit comments

Comments
 (0)