simplify
Simplify and refine code for clarity, consistency, and maintainability
What this skill does
# Code Simplification Skill
Multi-agent code analysis and simplification workflow.
## Execution Flow
```
┌─────────────────────────────────────────────────────────┐
│ 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 │
└─────────────────────────────────────────────────────────┘
```
## Step 1: Determine Scope
### With Arguments
Use provided file/directory path as scope.
### Without Arguments (Recent Changes)
```bash
git diff --name-only HEAD~3 2>/dev/null | grep -E '\.(ts|tsx|js|jsx|py|go|rs|java)$'
```
If no git changes, ask user for scope.
## Step 2: Phase 1 - Analysis Agents (Parallel)
Execute 4 agents in parallel (single message with 4 Task calls).
### Scope Context (Provide to all agents)
```
Scope:
- Files: [List of files to analyze]
- Recent changes: [git diff summary if available]
```
### Parallel Execution
```
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 |
## Step 3: Consolidate Issues
Merge results from all 4 agents into a unified issue list:
```markdown
## 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]
...
```
If no issues found, report "No improvements needed" and end.
## Step 4: Phase 2 - Issue Simplifiers (Parallel)
For each issue, run an issue-simplifier agent in parallel:
```
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
""")
```
**IMPORTANT:** Run ALL issue-simplifier agents in a single message with multiple Task calls.
## Step 5: Present Changes
Compile all proposed changes:
```markdown
## Proposed Simplifications
### 1. [File:Line] - [Issue Type]
**Original:**
```[lang]
[original code]
```
**Simplified:**
```[lang]
[simplified code]
```
**Reason:** [explanation]
---
### 2. [File:Line] - [Issue Type]
...
```
## Step 6: Action Selection
```
AskUserQuestion(
questions=[{
"question": "Which simplifications would you like to apply?",
"header": "Apply",
"multiSelect": true,
"options": [
{"label": "Apply all (Recommended)", "description": "Apply all proposed changes"},
{"label": "Select individually", "description": "Choose specific changes"},
{"label": "Skip", "description": "Don't apply any changes"}
]
}]
)
```
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
Related in Data & Analytics
clawarr-suite
IncludedComprehensive management for self-hosted media stacks (Sonarr, Radarr, Lidarr, Readarr, Prowlarr, Bazarr, Overseerr, Plex, Tautulli, SABnzbd, Recyclarr, Unpackerr, Notifiarr, Maintainerr, Kometa, FlareSolverr). Deep library exploration, analytics, dashboard generation, content management, request handling, subtitle management, indexer control, download monitoring, quality profile sync, library cleanup automation, notification routing, collection/overlay management, and media tracker integration (Trakt, Letterboxd, Simkl).
querying-soql
IncludedSOQL query generation, optimization, and analysis with 100-point scoring. Use this skill when the user needs SOQL/SOSL authoring or optimization: natural-language-to-query generation, relationship queries, aggregates, query-plan analysis, and performance or safety improvements for Salesforce queries. TRIGGER when: user writes, optimizes, or debugs SOQL/SOSL queries, touches .soql files, or asks about relationship queries, aggregates, or query performance. DO NOT TRIGGER when: bulk data operations (use handling-sf-data), Apex DML logic (use generating-apex), or report/dashboard queries.
app-store-optimization
IncludedApp Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklists, and tracking ranking changes.
habit-flow
IncludedAI-powered atomic habit tracker with natural language logging, streak tracking, smart reminders, and coaching. Use for creating habits, logging completions naturally ("I meditated today"), viewing progress, and getting personalized coaching.
app-store-optimization
IncludedApp Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklists, and tracking ranking changes.
visualizing-data
IncludedBuilds dashboards, reports, and data-driven interfaces requiring charts, graphs, or visual analytics. Provides systematic framework for selecting appropriate visualizations based on data characteristics and analytical purpose. Includes 24+ visualization types organized by purpose (trends, comparisons, distributions, relationships, flows, hierarchies, geospatial), accessibility patterns (WCAG 2.1 AA compliance), colorblind-safe palettes, and performance optimization strategies. Use when creating visualizations, choosing chart types, displaying data graphically, or designing data interfaces.