Code Simplification
Simplify and refine code for clarity and maintainability while preserving functionality.
Argument Routing
Parse the argument to determine execution mode:
| Argument | Mode |
|---|---|
<prompt> | Claude-native (default) |
--codex | Codex delegation (scope from conversation context) |
--codex <prompt> | Codex delegation |
Strip the --codex flag before passing the prompt to the execution path.
Claude-native Execution (default)
- •Load protocol: Read
agents/code-simplifier.mdto load the full code-simplifier protocol. You execute it directly - do NOT spawn a code-simplifier agent. - •Identify scope: Use the provided argument or conversation context (files discussed, recently edited)
- •Read standards: Check the project's CLAUDE.md for coding conventions
- •Apply simplifications: Follow the protocol's
<Investigation_Protocol>steps - •Self-review: Re-read each change and confirm it is purely structural with zero logic alteration. If a change could affect behavior under any edge case, revert it. If the git diff is not excessively large and appears to be simplification work, use it as a reference for before/after comparison
- •Verify: Run build and tests to confirm no regressions. Note: uncommitted changes beyond simplification are expected - the user may have pending work that was never committed
- •Report: Summarize changes applied and any skipped opportunities
Codex Delegation
- •Load protocols: Read
agents/code-simplifier.mdfor the simplification protocol, andagents/codex-proxy.mdfor the Codex prompt template. Use the ralph role's prompt template (### Role: ralphsection). - •Gather context: Collect scope, file paths, and the code-simplifier protocol content
- •Call Codex: Use
codex({ op: "exec", ... })with the code-simplifier protocol as task context. Passworking_directoryandreasoning_effort: "xhigh". - •Verify: Read all changed files, compare against the protocol's
<Success_Criteria>. Confirm each change is purely structural with zero logic alteration - revert any that could affect behavior under any edge case. If the git diff is not excessively large, use it as a reference for before/after comparison - •Fix discrepancies: If Codex violated the protocol (behavior changes, scope creep), fix directly
- •Post-implementation sequence: Lint → Build → Test
Sandbox bypass
Pass bypass: true only when the user explicitly requests bypass mode. Otherwise, omit the field.
Context Enhancement
From the current conversation, identify and include:
- •Files recently modified or discussed
- •Coding standards or conventions mentioned
- •Specific areas the user wants simplified
Error Policy
If agents/code-simplifier.md cannot be read, report the error to the user. Do not fall back to inline execution - the agent protocol is a required dependency.