Skip to main content
ClaudeWave
Slash Command1.4k repo starsupdated 3d ago

code-simplifier

The code-simplifier command analyzes recent code changes to identify opportunities for reducing complexity without altering functionality. It examines patterns like duplicate logic, dead code, over-engineering, complex conditionals, lengthy functions, and unnecessary defensive code. Use this command after implementing features to refactor code into cleaner, more maintainable form through guided simplifications that preserve all existing behavior.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/CloudAI-X/claude-workflow-v2/HEAD/commands/code-simplifier.md -o ~/.claude/commands/code-simplifier.md
Then start a new Claude Code session; the slash command loads automatically.

code-simplifier.md

# 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~1
```

## Phase 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):
```[lang]
[code block]
````

**Simplified** (Y lines):

```[lang]
[code block]
```

**Benefit**: [Why this is better]
**Risk**: Low - behavior unchanged

```

## Phase 4: Apply Simplifications

After user approval:
1. Make one change at a time
2. Run tests after each change
3. Commit with clear message: `refactor: simplify [description]`
4. 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

1. **Never change behavior** - only structure
2. **Run tests after every change** - verify nothing broke
3. **Keep changes atomic** - one simplification per commit
4. **Document what was simplified** - clear commit messages
5. **Preserve public APIs** - internal refactoring only

## Usage

This command ships with the project-starter plugin. Invoke with: `/project-starter:code-simplifier`
```
code-reviewerSubagent

Expert code review specialist. Use PROACTIVELY after writing or modifying code, before commits, when asked to review changes, PR review, code quality check, lint, or standards audit. Focuses on quality, security, performance, and maintainability.

debuggerSubagent

Expert debugging specialist for errors, test failures, crashes, segmentation faults, memory leaks, timeouts, race conditions, deadlocks, and unexpected behavior. Use PROACTIVELY when encountering any error, exception, or failing test. Performs systematic root cause analysis.

docs-writerSubagent

Technical documentation specialist. Use for creating README files, API documentation, architecture docs, inline comments, user guides, changelogs, migration guides, release notes, FAQs, and troubleshooting docs. MUST BE USED when documentation is needed or when code changes require doc updates.

orchestratorSubagent

Master coordinator for complex multi-step tasks. Use PROACTIVELY when a task involves 2+ modules, requires delegation to specialists, needs architectural planning, or involves GitHub PR workflows. MUST BE USED for open-ended requests like "improve", "enhance", "build", "scale", "refactor", "add feature", "system design", "architecture", "complex task", or when implementing features from GitHub issues.

refactorerSubagent

Code refactoring specialist for improving code quality, reducing technical debt, eliminating code smells, reducing complexity, and applying design patterns. Use PROACTIVELY when code needs restructuring, simplification, tech debt reduction, or when applying DRY/SOLID principles.

security-auditorSubagent

Security specialist for vulnerability detection, secure coding review, and security hardening. Use PROACTIVELY when handling authentication, authorization, encryption, secrets, credentials, OAuth, JWT, CORS, headers, user input, API keys, or sensitive data. Checks for OWASP Top 10 and common vulnerabilities.

test-architectSubagent

Testing strategy specialist for designing test suites, writing tests, and ensuring comprehensive coverage. Use PROACTIVELY when adding new features, fixing bugs, improving test coverage, creating test plans, mocking strategies, handling flaky tests, or writing integration/E2E tests.

add-testsSlash Command

Add tests for recently changed files or specified code