| name | codex-simplify |
| description | Review current code changes for reuse, quality, and efficiency, then fix the worthwhile issues without changing behavior. Use when the user asks to simplify, clean up, de-duplicate, polish, or make recent edits more maintainable, especially after a coding pass or before commit or review. In Codex, follow the same three-agent simplify workflow as the source simplify prompt: always launch three parallel explorer subagents with the full diff, using model gpt-5.4 and reasoning_effort xhigh, then aggregate findings and fix the worthwhile issues in the main thread. |
Simplify
Review all changed files for reuse, quality, and efficiency. Fix any worthwhile issues found without widening scope or changing behavior.
Phase 1: Identify Changes
Run git diff or git diff HEAD if there are staged changes to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.
Capture the diff text and keep it available for the three review agents so each agent sees the same full context.
Phase 2: Launch Three Review Agents in Parallel
Use Codex native agents to launch all three review agents concurrently in a single wave. This is the default path for this skill, not an optional optimization.
Use multi_tool_use.parallel to issue all three spawn_agent calls together so they start at the same time.
For each agent:
- Use
agent_type: "explorer".
- Use
model: "gpt-5.4".
- Use
reasoning_effort: "xhigh".
- Pass the full diff so the agent has complete context.
- Ask for findings only, not patches.
- Keep code edits in the main thread unless you later choose a clearly disjoint write scope and explicitly want a worker.
After spawning:
- Do not send nudges just to make an agent finish faster.
- Do not use
send_input or interrupt: true unless the task itself changed and you need to redirect the agent.
- Do not busy-poll with repeated short
wait_agent calls.
- If you are blocked on the results, use
wait_agent with a long timeout and let the agents finish at their own pace.
Agent 1: Code Reuse Review
For each change:
- Search for existing utilities and helpers that could replace newly written code. Look for similar patterns elsewhere in the codebase. Common locations are utility directories, shared modules, and files adjacent to the changed ones.
- Flag any new function that duplicates existing functionality. Suggest the existing function to use instead.
- Flag any inline logic that could use an existing utility. Hand-rolled string manipulation, manual path handling, custom environment checks, and ad-hoc type guards are common candidates.
Agent 2: Code Quality Review
Review the same changes for hacky patterns:
- Redundant state: state that duplicates existing state, cached values that could be derived, observers or effects that could be direct calls
- Parameter sprawl: adding new parameters to a function instead of generalizing or restructuring existing ones
- Copy-paste with slight variation: near-duplicate code blocks that should be unified with a shared abstraction
- Leaky abstractions: exposing internal details that should be encapsulated, or breaking existing abstraction boundaries
- Stringly-typed code: using raw strings where constants, enums, string unions, or branded types already exist in the codebase
- Unnecessary JSX nesting: wrapper elements that add no layout value when inner props already provide the needed behavior
Agent 3: Efficiency Review
Review the same changes for efficiency:
- Unnecessary work: redundant computations, repeated file reads, duplicate network or API calls, N+1 patterns
- Missed concurrency: independent operations run sequentially when they could run in parallel
- Hot-path bloat: new blocking work added to startup or per-request or per-render hot paths
- Recurring no-op updates: state or store updates inside polling loops, intervals, or event handlers that fire unconditionally. Add a change-detection guard so downstream consumers are not notified when nothing changed. Also verify wrapper helpers honor same-reference returns or the local no-change convention.
- Unnecessary existence checks: pre-checking file or resource existence before operating. Operate directly and handle the error instead.
- Memory: unbounded data structures, missing cleanup, event listener leaks
- Overly broad operations: reading entire files when only a portion is needed, loading all items when filtering for one
Phase 3: Fix Issues
Wait for all three agents to complete. Aggregate their findings and fix each worthwhile issue directly. If a finding is a false positive or not worth addressing, note it and move on. Do not argue with the finding, just skip it.
Run the narrowest meaningful verification for the touched area. Prefer targeted tests, lint, or type checks. If verification cannot be run, say so plainly.
When done, briefly summarize what was fixed, what you intentionally left alone, and what you ran to verify.