원클릭으로
refactor
Safely restructure code in an isolated git worktree with test-preserved, incremental transformations
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Safely restructure code in an isolated git worktree with test-preserved, incremental transformations
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Start a new feature in an isolated git worktree with proportional verification
Diagnose and fix a bug in an isolated git worktree with reproduce-first, test-first methodology
Create a pull request with cleanup, fmt, and test gates
Safely restructure code in an isolated git worktree with test-preserved, incremental transformations
Start a new feature in an isolated git worktree with proportional verification
Diagnose and fix a bug in an isolated git worktree with reproduce-first, test-first methodology
| name | refactor |
| description | Safely restructure code in an isolated git worktree with test-preserved, incremental transformations |
| disable-model-invocation | true |
| effort | max |
<codex_skill_must>
mkdir -p and git worktree add -b refactor/<name> ... main as separate exec_command calls.exec_command, apply_patch, spawn_agent, wait_agent.spawn_agent call must be followed by wait_agent.
</codex_skill_must>Safely refactor code while preserving all existing behavior.
Refactoring goal: $ARGUMENTS
Follow these phases in order. Each phase has a gate — do not proceed until the gate is satisfied. Apply all project rules and conventions that are in your context.
If the refactor touches browser UI, Playwright, dev-server ports, screenshots, or interactive Browser/Chrome inspection, apply ../_shared/ui-automation.md at scoping, environment setup, baseline, verification, delegation, and cleanup points.
Follow ../_shared/worktree-setup.md with branch prefix refactor.
Gate: Working directory is the new worktree on the correct branch, based on latest main. If .env* files existed in the source repo, they are all present in the worktree.
Start two tracks in parallel:
Background — Environment setup: First check for a reusable environment: if .env-setup-done exists in the worktree root AND every dependency manifest/lockfile present (package-lock.json, pnpm-lock.yaml, yarn.lock, requirements.txt, pyproject.toml, uv.lock, go.mod, go.sum) is older than the sentinel ([ "$f" -ot .env-setup-done ]), skip the launch and note the reuse — the setup from a prior run in this worktree is current. Otherwise, launch a background exec_command to set up the dev environment per ../_shared/env-setup.md.
Foreground — Scoping:
Gate: The scope is clear. Affected files and their test coverage are identified.
Pre-gate: Check for .env-setup-done in the worktree root.
node_modules/ exists, pip list succeeds, go env GOPATH works) and data symlinks resolve correctly..env-setup-failed exists: surface the error and halt.make test/make test-fast when the refactor crosses packages, touches shared infrastructure, or cannot be bounded.$agent-dashboard:fix first.For UI baselines, prefer headless Playwright with worktree-local resources. Use interactive Browser/Chrome inspection only when the shared policy says it is warranted.
Gate: The scoped baseline passes. The proof command is recorded.
Effort note: When launched via the agent-dashboard's New Agent flow, this skill starts at implementation effort. Use Codex Plan Mode for high-reasoning scoping when the refactor needs it, then return to proportional implementation effort for the mechanical transformation.
Delegation gate: Use Codex spawn_agent only if the user explicitly requested subagents OR the refactor touches 10+ files / ~3,000+ lines of implementation. Below that threshold, the orchestration overhead costs more tokens than implementing directly. If delegating, pass the scope (Phase 2), baseline (Phase 3), exact file paths, and a bounded write scope to a worker; then call wait_agent, review the result, and verify locally. Otherwise, proceed below.
Apply the refactoring in small, atomic steps. For each step:
git checkout -- <file1> <file2> ...)Do not batch multiple changes between proof runs. One change, one proof run.
Gate: All transformations applied. The scoped proof passes after each step.
make test/make test-fast only if the cleanup widened the scope.Gate: No dead code remains. The relevant proof passes.
refactor: conventional commit message that describes what was restructured and why.$agent-dashboard:pr. That skill owns conditional cleanup/formatting, final test gating when available, push, and gh pr create. Do not call gh pr create directly — a pr-skill-gate hook will block it.Gate: Clean commit with conventional message. Behavior is unchanged. No critical or high-severity review issues. PR opened via $agent-dashboard:pr.
Triggered when the user indicates the refactor has been merged upstream.
.env-setup-done/.env-setup-failed sentinel files