بنقرة واحدة
exec
// Execute plan tasks sequentially using subagents. Use when user says 'exec', 'execute plan', 'run plan', or wants to implement a plan file task by task with isolated subagents.
// Execute plan tasks sequentially using subagents. Use when user says 'exec', 'execute plan', 'run plan', or wants to implement a plan file task by task with isolated subagents.
| name | exec |
| description | Execute plan tasks sequentially using subagents. Use when user says 'exec', 'execute plan', 'run plan', or wants to implement a plan file task by task with isolated subagents. |
| allowed-tools | Read, Write, Edit, Glob, Grep, Bash(bash:*), Agent, AskUserQuestion, TaskCreate, TaskUpdate, EnterWorktree |
Execute plan file tasks sequentially, each in an isolated subagent.
$ARGUMENTS — path to plan file (optional; if omitted, ask user to pick from plans_dir userConfig directory, default: docs/plans/)ALWAYS use the resolve script to read prompt and agent files. NEVER construct the override chain manually:
bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/resolve-file.sh prompts/task.md ${CLAUDE_PLUGIN_DATA}
bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/resolve-file.sh agents/quality.txt ${CLAUDE_PLUGIN_DATA}
The script checks project overrides, user overrides, and bundled defaults automatically.
After reading a prompt file, replace ALL placeholders with actual values before passing to a subagent. Subagents run in fresh contexts without plugin env vars.
Always substitute: PLAN_FILE_PATH, PROGRESS_FILE_PATH, DEFAULT_BRANCH, ${CLAUDE_PLUGIN_ROOT} (resolve to actual absolute path), RESOLVE_SCRIPT (absolute path to ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/resolve-file.sh), PLUGIN_DATA_DIR (resolved ${CLAUDE_PLUGIN_DATA} path — passed as second argument to resolve-file.sh so it can find user overrides), USER_RULES (resolved custom rules content from the rules loading step, or empty string if no rules found), and phase-specific values (FINDINGS_LIST, REVIEW_PHASE, DIFF_COMMAND).
Before starting execution, run this command via Bash tool to check for user-provided custom rules:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/resolve-rules.sh planning-rules.md ${CLAUDE_PLUGIN_DATA}
If the output is non-empty, store it as the resolved custom rules content. When substituting USER_RULES in task prompts, wrap the content with a label so the subagent understands it: use "ADDITIONAL CUSTOM RULES:\n" as the substitution. If the output is empty, substitute an empty string for USER_RULES. See ${CLAUDE_PLUGIN_ROOT}/references/custom-rules.md for full documentation on the rules mechanism.
If $ARGUMENTS contains a file path, use it. Otherwise, list .md files in the plans_dir userConfig directory (default: docs/plans/), excluding completed/. If exactly one plan found, use it automatically. If multiple found, ask the user to pick one using AskUserQuestion.
Read the plan file. Count total Task sections (### Task N: or ### Iteration N:) to know the scope.
Determine the default branch: bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/detect-branch.sh
Note: in hg repos, detect-branch.sh returns remote/<name> (checking master, main, trunk in that order) in modern-Mercurial repos that expose upstream default via remote/<name> refs, and falls back to default in repos that use the traditional named-branch convention instead. The external-review prompt (prompts/codex-review.md) and the finalize prompt (prompts/finalizer.md) use git-specific commands and are not VCS-translated upstream. Both phases will be skipped (see step 9 and step 11, which re-detect VCS locally). Users who want hg-native review/finalize can override via .claude/exec-plan/prompts/codex-review.md and .claude/exec-plan/prompts/finalizer.md — any git rebase origin/DEFAULT_BRANCH in the bundled template must be replaced with the hg equivalent in the override, e.g. hg rebase -d remote/master when the repo exposes remote-tracking refs, or hg rebase -d default when it uses the traditional named-branch convention.
hg skip: Detect VCS with vcs=$(bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/detect-vcs.sh). If vcs is hg, skip the worktree question and proceed in current directory. The EnterWorktree tool is git-only (wraps git worktree add) and has no hg equivalent upstream; users who want isolation in hg repos can use hg share manually before invoking /exec.
First detect current branch state — run git branch --show-current and compare with the default branch detected earlier (from detect-branch.sh). Two cases:
Case A — currently on the default branch (master/main/trunk). Step 4 will create a new feature branch. Ask the user where it should live. Invoke the AskUserQuestion tool with this payload:
{
"questions": [{
"question": "Where should the feature branch be created?",
"header": "Branch location",
"options": [
{"label": "Worktree (isolated)", "description": "Create the feature branch in a new isolated git worktree (under .claude/worktrees/). Main working directory stays on the default branch."},
{"label": "In-place", "description": "Create the feature branch in this working directory. Main directory switches to the feature branch for the duration of the run."}
],
"multiSelect": false
}]
}
Case B — currently on a feature branch. Step 4 will keep using this branch. Ask whether to move it to an isolated worktree or stay here. Invoke the AskUserQuestion tool with this payload:
{
"questions": [{
"question": "You're already on a feature branch. Run the plan here, or in an isolated worktree?",
"header": "Isolation",
"options": [
{"label": "Stay here", "description": "Run the plan in this working directory, on the existing feature branch."},
{"label": "Move to worktree", "description": "Copy this branch into a new isolated git worktree (under .claude/worktrees/). Main directory stays untouched."}
],
"multiSelect": false
}]
}
In BOTH cases: invoke the AskUserQuestion tool now, do not generate text first, do not skip, do not assume. Auto mode does NOT exempt this question — the choice affects the user's working directory and the orchestrator cannot decide on their behalf.
If user picks "Worktree (isolated)" or "Move to worktree", use the EnterWorktree tool to create an isolated worktree before proceeding. All subsequent steps (branch creation, task execution, reviews, finalize, stats) happen inside the worktree. At completion, report the worktree path and branch so the user can review and merge.
If user picks "In-place" or "Stay here", proceed normally without worktree.
ALWAYS create tasks using TaskCreate before starting any work. Create one task per plan Task section plus review phases:
For each ### Task N: section in the plan:
TaskCreate(subject="Task N: <title>", description="<checkbox items>", activeForm="Executing task N...")Then add review tasks:
TaskCreate(subject="Review phase 1: comprehensive", description="5 parallel review agents + fixer", activeForm="Running review phase 1...")TaskCreate(subject="Review phase 2: code smells", description="smells agent + fixer", activeForm="Running smells review...")TaskCreate(subject="Review phase 3: codex external", description="adversarial codex/claude review loop", activeForm="Running codex review...")TaskCreate(subject="Review phase 4: critical only", description="2 review agents + fixer", activeForm="Running review phase 4...")TaskCreate(subject="Finalize", description="rebase, clean up commits, verify", activeForm="Finalizing...")TaskCreate(subject="Stats summary", description="aggregate token/duration/git stats from session log", activeForm="Summarizing stats...")Update tasks as you go: TaskUpdate(taskId, status="in_progress") when starting, TaskUpdate(taskId, status="completed") when done.
MANDATORY: Run the script below. Do NOT create the branch manually — the script strips the date prefix from the plan filename (e.g., 20260329-feature-name.md → branch feature-name).
bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/create-branch.sh <plan-file-path>
The script creates a feature branch if currently on main/master, or stays on the current branch if already on a feature branch. Capture and use the branch name it outputs.
Initialize the progress file: bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/init-progress.sh /tmp/progress-<plan-name>.txt <plan-file-path> <branch-name> (derive <plan-name> from the plan file stem, e.g., fix-issues.md → progress-fix-issues). The script creates the file with a header. Report the full progress file path to the user.
IMPORTANT: Always use ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/append-progress.sh to write to the progress file after initialization. Never write directly.
Repeat until no [ ] checkboxes remain in any Task section:
### Task N: or ### Iteration N:) that still has [ ] checkboxes### Task N: header)[ ] checkbox items in that task section--- Task 1: Fix error handling ---
- [ ] Handle the error from os.ReadFile
- [ ] Either log and exit or handle gracefully
mode: "bypassPermissions"subagent_type: "general-purpose"prompts/task.md, with all placeholders substituted as described in the Placeholder Substitution section above (including USER_RULES)[x]
task_retries times (userConfig, default: 1). If all retries fail, stop and report failure to userCRITICAL: Do NOT stop the loop based on subagent return text. The ONLY condition to stop is: no [ ] checkboxes remain in any Task section (### Task N: or ### Iteration N:). Always re-read the plan file to check.
CRITICAL: You are the ORCHESTRATOR. Never read code, debug errors, investigate diagnostics, or fix issues yourself. If a subagent leaves problems (compiler errors, test failures, lint issues), retry with a fresh subagent — pass the error details in the prompt so it can fix them. All code work happens inside subagents, not in the orchestrator.
Maximum iterations safety limit: 50. If reached, stop and report to user.
After all tasks complete, run a comprehensive code review on iteration 1, then narrow to critical-only re-checks on subsequent iterations to verify the fixer's work without re-running the full heavy sweep.
Report to user: "--- Review phase 1: comprehensive ---"
Loop up to review_iterations times (userConfig, default: 5). Track the current iteration number:
Read review.md as a playbook (NOT as a subagent prompt) — resolve prompts/review.md through the override chain and read it from this main session. It tells YOU (the orchestrator) which specialist agents to fan out for the current REVIEW_PHASE. Substitute DEFAULT_BRANCH, PLAN_FILE_PATH, PROGRESS_FILE_PATH, ${CLAUDE_PLUGIN_ROOT}, and REVIEW_PHASE in the resolved content. Then follow the playbook FROM THIS SESSION: launch the specified Agent tool calls in a single message for parallel execution. Subagents do not have Agent tool access, so the fanout MUST be initiated from the main orchestrator.
REVIEW_PHASE to comprehensive. Per the playbook, launch 5 parallel review agents (quality, implementation, testing, simplification, documentation).REVIEW_PHASE to critical. Per the playbook, launch 2 parallel review agents (quality, implementation) focused on critical/major issues only. Before this iteration, report to user: "--- Review phase 1: critical re-check (iteration N) ---"Collect findings — collect findings from ALL launched review agents. Pass the COMPLETE output (not a summary) to the fixer. Do NOT summarize, filter, or dismiss any findings. ALL findings are actionable. Report to user with a short list of findings. Log to progress file:
bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/append-progress.sh <progress-file> "review phase 1: findings"
Then pipe: echo "<findings>" | bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/append-progress.sh <progress-file>
If ALL agents reported zero issues → report "Review phase 1: clean" and proceed to the next phase.
Spawn a fixer agent — resolve prompts/fixer.md through the override chain. Launch with mode: "bypassPermissions", subagent_type: "general-purpose". Pass the FULL unedited review output as FINDINGS_LIST — the fixer decides what's real, not you.
After fixer returns → show the "FIXES:" section to the user. Report "Review phase 1: iteration N fixes applied". Loop back to step 1.
If review_iterations reached with issues still found, report "Review phase 1: max iterations reached, moving on" and continue.
Report to user: "--- Review phase 2: code smells analysis ---"
Run once (no loop):
Spawn a smells agent — resolve agents/smells.txt through the override chain. Launch one Agent tool call with mode: "bypassPermissions", subagent_type: "general-purpose", and the resolved agent prompt.
Collect findings — after the agent returns, report to user with a compact list of findings (one line per finding). Log findings to progress file:
bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/append-progress.sh <progress-file> "review phase 2: findings"
Then pipe the findings: echo "<findings>" | bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/append-progress.sh <progress-file>
If no issues found → report "Smells analysis: clean" and proceed to the next phase.
Spawn a fixer agent — resolve prompts/fixer.md through the override chain. Launch with mode: "bypassPermissions", subagent_type: "general-purpose". Pass the FULL smells output as FINDINGS_LIST.
After fixer returns → report fixes to user. Proceed to the next phase.
hg skip: Detect VCS with vcs=$(bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/detect-vcs.sh). If vcs is hg, skip this entire step. Report to user: "hg detected — skipping external review (git-only). Override prompts/codex-review.md via .claude/exec-plan/ to enable hg-native review." Proceed directly to step 10.
Report to user: "--- Review phase 3: codex external review ---"
Adversarial loop: codex reviews the code, fixer evaluates and fixes, codex re-reviews. The loop exits early once an iteration produces no CRITICAL or MAJOR findings — minor-only iterations still get fixed by the fixer, but no further codex round-trip happens. Subsequent phases (smells, critical-only) act as the final safety net.
Determine the external review command:
external_review_cmd userConfig is set, use that commandwhich codexLoop up to external_review_iterations times (userConfig, default: 10):
Resolve the codex prompt — read prompts/codex-review.md through the override chain. Replace DIFF_COMMAND using vcs=$(bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/detect-vcs.sh): for git, iteration 1 is git diff DEFAULT_BRANCH...HEAD and subsequent iterations are git diff; for hg, iteration 1 is hg diff -r 'ancestor(., DEFAULT_BRANCH)' and subsequent iterations are hg diff. Also replace PLAN_FILE_PATH (so codex can read the plan for intent) and PROGRESS_FILE_PATH (so codex can read prior review iterations and fixer responses and avoid re-reporting fixed issues).
Run codex — bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/run-codex.sh "<resolved prompt>" with run_in_background: true. You will be notified when done — do NOT poll or sleep.
Check codex output — if codex reports "NO ISSUES FOUND" or equivalent, phase is done. Proceed to step 10.
Classify severity — scan the codex output for CRITICAL or MAJOR markers (case-insensitive whole-word match). Set has_blocking = true if either is present, otherwise has_blocking = false. Findings without an explicit severity tag are treated as MINOR — has_blocking stays false in that case.
Report codex findings to user — show a compact list (one line per finding).
Spawn a fixer agent — same as other review phases. Resolve prompts/fixer.md, pass codex output as FINDINGS_LIST. Fixer verifies, fixes, commits, reports FIXES.
Report fixer results to user — show FIXES section. Log to progress file.
Decide whether to loop:
has_blocking is false → report "Codex review: only minor findings — fixes applied, stopping loop" and proceed to step 10.If external_review_iterations reached with critical/major issues still found, report "Codex review: max iterations reached, moving on" and continue.
Report to user: "--- Review phase 4: critical/major only (single pass) ---"
Same structure as step 7 but with REVIEW_PHASE set to critical. Resolve prompts/review.md and follow its playbook FROM THIS MAIN SESSION — launch 2 parallel review agents (quality, implementation) focusing on critical/major issues only. Subagents do not have Agent tool access, so the fanout MUST be initiated from the main orchestrator. Same fixer flow — pass findings to fixer, show FIXES to user.
hg skip: Detect VCS with vcs=$(bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/detect-vcs.sh). If vcs is hg, skip this entire step. Report to user: "hg detected — skipping finalize (git-only). Override prompts/finalizer.md via .claude/exec-plan/ to enable hg-native finalize." Note that DEFAULT_BRANCH substitutes as whatever detect-branch.sh returned — remote/master (or remote/main/remote/trunk) in modern-Mercurial repos that expose remote-tracking refs, default in repos that use the traditional named-branch convention — so any git rebase origin/DEFAULT_BRANCH in the bundled template must be replaced with the hg equivalent (e.g. hg rebase -d remote/master, or hg rebase -d default in the named-branch case) in the override. Proceed directly to step 12.
Check finalize_enabled userConfig (default: true). If false, skip this step.
After all reviews pass, rebase and clean up commits.
Report to user: "--- Finalize: rebase and clean up commits ---"
Spawn one Agent tool call with mode: "bypassPermissions", subagent_type: "general-purpose", and the prompt from prompts/finalizer.md. Replace DEFAULT_BRANCH, PLAN_FILE_PATH, and PROGRESS_FILE_PATH.
This is best-effort — if rebase fails, report the issue but don't block completion.
After finalize (or after step 11 was skipped on hg/disabled), spawn one Agent tool call with mode: "bypassPermissions", subagent_type: "general-purpose", and the prompt from prompts/stats.md. Replace DEFAULT_BRANCH and PROGRESS_FILE_PATH in the resolved content.
The stats agent reads this session's main log + subagent logs from ~/.claude/projects/<cwd-encoded>/, aggregates per-phase token/duration/tool-use counts, runs git diff --shortstat DEFAULT_BRANCH...HEAD for branch churn, and returns a compact markdown report.
Show the stats agent's full markdown output to the user verbatim. Do NOT summarize it further — the agent already produces a tight summary.
This step is best-effort — if the stats agent fails or the session log path can't be resolved, report the failure but do not block completion.
When stats summary is done (or skipped on failure):
bash ${CLAUDE_PLUGIN_ROOT}/skills/exec/scripts/append-progress.sh <progress-file> "completed"/tmp/progress-<plan-name>.txt) — see prompts/progress-file.md for format and when to writesubagent_type values must be general-purpose — agent files provide the specialized promptUpdate project CLAUDE.md with strategic knowledge discovered during this session — or CLAUDE.local.md when the discovery is per-developer/per-checkout and that file already exists. Defers to any project-defined memory-placement guidance instead of overriding it. Use when user says "learn", "save knowledge", "update claude.md", "capture learnings", or at end of significant work sessions. Also used by commit skill for pre-commit knowledge capture.
Consult OpenAI Codex for investigation, debugging, or code review. Use when user explicitly asks to "ask codex", "check with codex", "codex review", or as a last resort when stuck after 4+ failed attempts at debugging, investigation, or bug fix and completely out of ideas. Codex is slow (2-5 min), so only escalate when truly stuck. Codex runs in read-only mode with full project access — it analyzes, we implement.
Use before any creative work or significant changes. Activates on "brainstorm", "let's brainstorm", "deep analysis", "analyze this feature", "think through", "help me design", "explore options for", or when user asks for thorough analysis of changes, features, or architectural decisions. Guides collaborative dialogue to turn ideas into designs through one-at-a-time questions, approach exploration, and incremental validation.
Interactive git diff annotation review. Generates a cleaned-up diff, opens in editor for user annotations, and addresses feedback in a loop. Activates on "git review", "review changes", "review my changes", "annotate changes", "interactive review".
Show commits since the last tag in a formatted table. Use when user asks "what changed since last release", "commits since last tag", "last-tag", "what's new", or wants to see recent unreleased changes.
Use when user asks to create a release, cut a release, or publish a version. Auto-detects GitHub vs GitLab vs Gitea, calculates semantic version, generates release notes from PRs/MRs or commits, shows preview for confirmation before publishing.