Loading...
Loading...
Simplify and refine code for clarity, consistency, and maintainability
npx skill4agent add october-academy/agent-plugins simplify┌─────────────────────────────────────────────────────────┐
│ 1. Determine Scope (git diff or user input) │
├─────────────────────────────────────────────────────────┤
│ 2. Phase 1: 4 Analysis Agents (Parallel) │
│ ┌─────────────────┬─────────────────┐ │
│ │ complexity- │ pattern- │ │
│ │ analyzer │ checker │ │
│ ├─────────────────┼─────────────────┤ │
│ │ naming- │ readability- │ │
│ │ reviewer │ analyzer │ │
│ └─────────────────┴─────────────────┘ │
├─────────────────────────────────────────────────────────┤
│ 3. Consolidate Issues │
├─────────────────────────────────────────────────────────┤
│ 4. Phase 2: Issue Simplifiers (Parallel) │
│ ┌────────┬────────┬────────┬────────┐ │
│ │ issue1 │ issue2 │ issue3 │ ... │ │
│ └────────┴────────┴────────┴────────┘ │
├─────────────────────────────────────────────────────────┤
│ 5. Present Changes & AskUserQuestion │
├─────────────────────────────────────────────────────────┤
│ 6. Apply Selected Changes │
└─────────────────────────────────────────────────────────┘git diff --name-only HEAD~3 2>/dev/null | grep -E '\.(ts|tsx|js|jsx|py|go|rs|java)$'Scope:
- Files: [List of files to analyze]
- Recent changes: [git diff summary if available]Task(subagent_type="simplify:complexity-analyzer", ...)
Task(subagent_type="simplify:pattern-checker", ...)
Task(subagent_type="simplify:naming-reviewer", ...)
Task(subagent_type="simplify:readability-analyzer", ...)| Agent | Role | Output |
|---|---|---|
| complexity-analyzer | Nested ternary, deep nesting, over-abstraction | Issue list with locations |
| pattern-checker | Project standards violation, inconsistency | Issue list with locations |
| naming-reviewer | Variable/function naming improvements | Issue list with suggestions |
| readability-analyzer | Readability issues, unnecessary comments | Issue list with suggestions |
## Issues Found
### Issue 1: [Title]
- **File:** path/to/file.ts:42
- **Type:** complexity | pattern | naming | readability
- **Description:** [What's wrong]
- **Suggestion:** [How to fix]
### Issue 2: [Title]
...Task(subagent_type="simplify:issue-simplifier", prompt="""
Issue: [Issue title]
File: [file path]
Location: [line numbers]
Type: [issue type]
Description: [description]
Suggestion: [suggestion]
Read the file and provide the exact code change needed.
Output format:
- Original code block
- Simplified code block
- Brief explanation
""")## Proposed Simplifications
### 1. [File:Line] - [Issue Type]
**Original:**
```[lang]
[original code][simplified code]
## Step 6: Action Selection
If "Select individually", present each change for approval.
## Step 7: Apply Selected Changes
Use Edit tool to apply approved changes.
---
## Principles
- **Clarity over Brevity**: Explicit, readable code over compact one-liners
- **No Nested Ternaries**: Use switch/if-else for multiple conditions
- **Reduce Complexity**: Eliminate unnecessary nesting and redundant abstractions
- **Preserve Functionality**: Never change what code does, only how it's written
## Example Improvements
- Nested ternary operators → clear if/else chains
- Deep nesting → early returns or extracted functions
- Redundant abstractions → direct implementations
- Unclear names → descriptive identifiers