Agent balanced

Code Simplifier

Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.

Overview

The Code Simplifier is an expert in enhancing code clarity without changing what the code does. It operates autonomously after code is written or modified, applying project-specific best practices to reduce complexity, eliminate redundancy, and improve readability. It prioritizes explicit, readable code over overly compact solutions.

When It's Used

Runs automatically after code modifications during the /dr-do stage. Also invoked as part of the compliance workflow (/dr-compliance) to refine recently changed code before final approval.

Capabilities

  • Preserve functionality — never changes what the code does, only how it does it
  • Apply project standards — follows established coding standards from the project's AGENTS.md and style guide
  • Reduce complexity — eliminates unnecessary nesting, redundant abstractions, and dead code
  • Improve naming — clarifies variable and function names for better readability
  • Avoid over-simplification — rejects nested ternaries, dense one-liners, and overly clever solutions
  • Scoped focus — only refines recently modified code unless explicitly told otherwise

How It Works

The Simplifier identifies recently modified sections, analyzes them for improvement opportunities, and applies refinements in place. It follows a strict rule: clarity over brevity. A switch statement that is easy to read beats a nested ternary that saves two lines. Every change is documented only when it affects understanding.

Example

// Before: nested ternary, hard to follow
const label = status === 'active' ? 'On' : status === 'pending' ? 'Wait' : 'Off';

// After: explicit switch, easy to read
switch (status) {
  case 'active':  return 'On';
  case 'pending': return 'Wait';
  default:        return 'Off';
}

Context Loading

Before any source read or delegation it loads the security skill and applies its sensitive-source context boundary. Reads the project AGENTS.md and style guide for coding standards. Focuses only on recently touched files to avoid scope creep.

Skills Used

security (before source reads). Follows the project's AGENTS.md conventions; the compliance workflow applies the same principles in its simplification step.

Reporting the result

Apply Human Outcome Reporting before a human-facing update or result. Explain the user-visible outcome, the original conditions, checks and evidence, and open limitations. A stage result does not mean the entire task is complete. Keep exact protocols and technical records intact. To explain again without continuing work, use /dr-explain.