Debugging et maintenancesource GitHub
Simplificateur de code
/code-simplifierSimplifiez le code après l’implémentation. Trouvez comment rendre le code plus propre et plus simple sans changer son comportement.
// contenu du skill
description: Simplifies code after implementation. Reviews recent changes and suggests/applies simplifications while preserving behavior.
Code Simplifier
Simplify code after implementation. Find ways to make code cleaner and simpler without changing behavior.
Philosophy
- Simpler is better
- Less code = fewer bugs
- Clarity over cleverness
- Don't change behavior, only structure
- Delete code when possible
Phase 1: Identify Recent Changes
bash
git diff HEAD~1 --name-only
git log -1 --stat
git diff HEAD~1Phase 2: Analyze for Simplification
Look for these patterns:
1. Duplicate Code
- Repeated logic that can be extracted
- Similar functions that can be merged
- Copy-pasted code with minor variations
2. Over-Engineering
- Abstractions used only once
- Unnecessary wrapper functions
- Over-parameterized functions (too many options)
- Premature generalization
3. Dead Code
- Unused variables
- Unreachable branches
- Commented-out code
- Unused imports/dependencies
4. Complex Conditionals
- Nested if-else chains (flatten with early returns)
- Complex boolean expressions (extract to named variables)
- Guard clauses that can be simplified
5. Long Functions
- Functions > 20 lines (consider splitting)
- Multiple responsibilities (single responsibility)
- Too many parameters (use objects)
6. Unnecessary Complexity
- Try-catch around code that can't fail
- Null checks on values that can't be null
- Defensive code for impossible cases
Phase 3: Propose Simplifications
For each finding, present:
`
### Simplification: [Short description]
**Location**: `file:line`
**Type**: [Duplicate/Over-engineering/Dead code/etc.]
**Current** (X lines):[code block]
`
**Simplified** (Y lines):
[code block]
**Benefit**: [Why this is better]
**Risk**: Low - behavior unchanged
Phase 4: Apply Simplifications
After user approval:
- Make one change at a time
- Run tests after each change
- Commit with clear message:
refactor: simplify [description] - Move to next simplification
Output Format
## Simplification Report
### Changes Analyzed
- Files: [count]
- Lines added: [count]
- Lines removed: [count]
### Simplification Opportunities
[List each opportunity with current/simplified code]
### Summary
- Simplifications found: X
- Estimated lines reducible: Y
- Complexity reduction: [High/Medium/Low]
### Recommended Actions
1. [ ] Apply simplification #1 (highest impact)
2. [ ] Apply simplification #2
...
### Tests to Run After
- [List of test commands to verify no behavior change]
Safety Rules
- Never change behavior - only structure
- Run tests after every change - verify nothing broke
- Keep changes atomic - one simplification per commit
- Document what was simplified - clear commit messages
- Preserve public APIs - internal refactoring only
Usage
This command ships with the project-starter plugin. Invoke with: /project-starter:code-simplifier
// source originale publique
CloudAI-X/claude-workflow-v2/commands/code-simplifier.md
Licence : MIT License
Projet indépendant, non affilié à Anthropic. Ce skill reste la propriété de son auteur original.