ce-simplify-code
Simplify recently changed code for clarity, reuse, quality, and efficiency while preserving exact behavior. Prioritize readable, explicit code over compact code — fewer lines is not the goal.
Step 1: Identify scope
Resolve the simplification scope in this order:
- If the user explicitly named a scope (a file, a directory, "the function I just wrote", "the changes from this morning"), use that scope. Treat user-named scope as authoritative — do not widen it.
- Otherwise, in a git repository, default to the diff between the current branch and its base branch (e.g.,
git diff origin/main...or against the configured upstream). This covers the common case of "simplify everything I've added on this feature branch before opening a PR." If the branch has no upstream or base ref, fall back to staged + unstaged changes (git diff HEAD). - Outside a git repository or when no diff is available, review the most recently modified files mentioned by the user or edited earlier in this conversation.
If none of the above produces a non-empty scope, stop and ask the user what to simplify rather than guessing. Use the platform's blocking question tool: AskUserQuestion in Claude Code (call ToolSearch with select:AskUserQuestion first if its schema isn't loaded), request_user_input in Codex, ask_question in Antigravity CLI (agy), ask_user in Pi (requires the pi-ask-user extension). Fall back to numbered options in chat only when no blocking tool exists in the harness or the call errors (e.g., Codex edit modes) — not because a schema load is required. Never silently skip the question.
Step 2: Launch 3 review agents in parallel
Dispatch three generic subagents — code-reuse, code-quality, and efficiency reviewers — via the platform's subagent primitive (Agent/Task in Claude Code, spawn_agent in Codex) where available; otherwise run the reviews inline or serially. For each reviewer, read its prompt asset from this skill's directory and pass the full file content as the subagent's prompt, together with the resolved scope (the full diff or file set) so it has complete context:
references/personas/code-reuse-reviewer.md— existing utilities, duplicated functionality, reimplemented stdlib/runtime primitives.references/personas/code-quality-reviewer.md— redundant state, parameter sprawl, copy-paste, leaky abstractions, stringly-typed code, dead code, over-nesting, and the over-simplification balance guard.references/personas/efficiency-reviewer.md— unnecessary work, missed concurrency, hot-path bloat, no-op updates, memory leaks.