Skip to content
Development
Command

/simplify

Ultra-fast parallel code simplification using 10 sub-agents for 10x speedup

From plugin
claude-cmd
313180 skills180 commands

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/simplify

Context preview

What this command does when you run it.

Ultra-fast parallel code simplification using 10 sub-agents for 10x speedup

Command definition

simplify.md
allowed-tools: Read, Write, Edit, MultiEdit, Bash(rg:*), Bash(fd:*), Bash(git:*), Bash(wc:*), Bash(gdate:*), Bash(head:*), Bash(grep:*), Bash(xargs:*), Task
name: "Simplify"
description: "Ultra-fast parallel code simplification using 10 sub-agents for 10x speedup"
author: "wcygan"
tags: ["code","refactor"]
version: "1.0.0"
created_at: "2025-07-14T00:00:00Z"
updated_at: "2025-07-14T00:00:00Z"

/simplify

Context

  • Session ID: !`gdate +%s%N`
  • Current directory: !`pwd`
  • Target file/directory: $ARGUMENTS
  • Code complexity hotspots: !`rg "if.*if.*if|for.*for|while.*while" . | wc -l | tr -d ' '` nested structures found
  • Complex conditionals: !`rg "&&.*&&|\\|\\|.*\\|\\|" . | wc -l | tr -d ' '` complex conditions found
  • Nested functions: !`rg "function.*{.*function|=>.*=>" . | wc -l | tr -d ' '` nested functions found
  • Test coverage gaps: !`fd "test" --type f | xargs rg -l "skip|todo" | wc -l | tr -d ' '` untested code blocks
  • File count: !`fd . -t f | wc -l | tr -d ' '` files in scope
  • Technology stack: !`fd "(deno\.json|package\.json|Cargo\.toml|go\.mod|pom\.xml)" --max-depth 2 | head -3 || echo "No framework files detected"`
  • Git status: !`git status --porcelain | wc -l | tr -d ' '` changes pending

Your Task

**IMMEDIATELY DEPLOY 10 PARALLEL SUB-AGENTS** for instant comprehensive simplification

STEP 1: Initialize Simplification Session

  • Create session state file: `/tmp/simplify-$SESSION_ID.json`
  • Initialize results directory: `/tmp/simplify-results-$SESSION_ID/`

STEP 2: **LAUNCH ALL 10 AGENTS SIMULTANEOUSLY**

**NO SEQUENTIAL ANALYSIS** - All agents work in parallel:

1. **Complexity Analysis Agent**: Identify cyclomatic complexity hotspots 2. **Method Extraction Agent**: Find long functions to decompose 3. **Conditional Logic Agent**: Simplify complex boolean expressions 4. **Loop Modernization Agent**: Convert imperative to functional patterns 5. **Naming Analysis Agent**: Identify cryptic names and abbreviations 6. **Code Duplication Agent**: Find repeated patterns for extraction 7. **Nesting Reduction Agent**: Eliminate deep nesting structures 8. **Dead Code Agent**: Find unused code and redundant logic 9. **Test Coverage Agent**: Identify untested complex code 10. **Architecture Agent**: Analyze module coupling and cohesion

Each agent saves findings to: `/tmp/simplify-results-$SESSION_ID/agent-N.json`

Think deeply about code complexity patterns while maximizing parallel execution.

**Expected speedup: 10x faster analysis and refactoring planning**

IF $ARGUMENTS specifies file or directory:

  • Focus analysis on specified target
  • Create detailed complexity profile for target code

ELSE:

  • Perform project-wide complexity analysis
  • Identify highest-impact simplification targets
  • Prioritize files by complexity metrics

TRY:

  • Initialize simplification session: /tmp/simplify-$SESSION_ID.json
  • Analyze complexity hotspots using multiple metrics:
  • Cyclomatic complexity: nested conditionals and loops
  • Function length and parameter counts
  • Code duplication patterns
  • Naming quality and clarity
  • Test coverage and maintainability
  • Create complexity baseline and improvement targets
  • Save checkpoint: complexity_analysis_complete

CATCH (analysis_scope_too_large):

  • Limit analysis to top 10 most complex files
  • Focus on files with highest change frequency
  • Prioritize user-specified targets over automatic detection
  • Document scope limitations in session state

STEP 2: Simplification Strategy Planning

Think harder about optimal refactoring approach and risk assessment.

  • Create systematic simplification plan with phases:
  • **Phase 1**: Extract methods and reduce function complexity
  • **Phase 2**: Simplify conditional logic and eliminate nesting
  • **Phase 3**: Replace imperative loops with functional constructs
  • **Phase 4**: Improve naming and eliminate magic numbers
  • **Phase 5**: Restructure classes and modules for separation of concerns
  • Assess refactoring risks and create rollback strategy
  • Identify prerequisite changes and dependencies
  • Plan validation checkpoints throughout process
  • Update session state with comprehensive plan

STEP 3: Method Extraction and Function Decomposition

FOR EACH complex function IN analysis_targets:

Think about optimal decomposition strategy for each function.

  • Identify distinct responsibilities and concerns
  • Extract helper methods with clear, descriptive names
  • Reduce parameter counts through object encapsulation
  • Eliminate deep nesting through early returns
  • Create focused, single-purpose functions

Example transformation pattern:

BEFORE: 50-line function with mixed concerns
AFTER: 5-10 line orchestrator + 3-5 focused helper methods

Update files using MultiEdit for batch refactoring operations.

STEP 4: Conditional Logic Simplification

  • Identify complex boolean expressions and nested conditionals
  • Extract boolean logic into descriptive predicate functions
  • Replace nested if-else chains with guard clauses
  • Use early returns to reduce nesting depth
  • Combine related conditions into semantic groups

Apply transformations:

  • Complex conditionals → Named boolean functions
  • Nested if-else → Early return patterns
  • Magic numbers → Named constants
  • Complex expressions → Intermediate variables with descriptive names

STEP 5: Loop and Iteration Modernization

  • Replace imperative loops with functional constructs where appropriate
  • Use language-specific higher-order functions (map, filter, reduce)
  • Eliminate manual index management and mutation
  • Convert accumulator patterns to functional equivalents
  • Maintain performance characteristics while improving readability

Framework-specific optimizations:

  • JavaScript/TypeScript: Array methods, async/await patterns
  • Python: List comprehensions, generator expressions
  • Rust: Iterator chains, functional transformations
  • Go: Range loops, slice operations
  • Java: Stream API, functional interfaces

STEP 6: Naming and Documentation Enhan

Read more
Ships withclaude-cmd

A lightweight (~46kB) and comprehensive CLI tool for managing Claude commands, configurations, and workflows.

Get the whole plugin