/groundwork:work-on [task-number] [--take-over] [--on-unrelated-failure stop-and-ask|expand-and-fix|ignore-and-merge]from groundwork
Orchestrates task execution across plan, implement (TDD in isolated worktree), and validate phases. Delegates to sub-skills and manages phase transitions.
Ships in groundwork. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Thin orchestrator that delegates to plan-task, implement-task, and validate skills for the three phases of task execution.
This skill orchestrates long multi-agent workflows. Every turn re-reads the full context window, so unnecessary turns are expensive.
Keep implementation and validation delegated to fresh, isolated contexts. The executor owns implementation and test monitoring; the validation coordinator owns its reviewer/fixer loop. The root owns dispatch, required decisions, and phase transitions.
Wait for completion, a concrete blocker, or a required decision. Do not request periodic progress, repeat the executor's checks, or independently monitor its test processes. Use existing runner status and heartbeats for routine visibility; intervene only on concrete failure or loss of liveness. Executors send exception reports and their terminal result, not periodic progress messages. Delegation for context isolation remains required.
Your current effort level is {{effort_level}}. Skip this step silently if effort is high, xhigh, or max (the scale is low < medium < high < xhigh < max, so xhigh and max are already above high) AND you are Sonnet or Opus. Otherwise ask via AskUserQuestion (header "Model check"; options "Continue anyway" / "Cancel — I'll switch first"):
"Do you want to switch? Task execution benefits from consistent multi-domain reasoning.
Recommended: Sonnet or Opus at high effort.
To switch: cancel, run
/effort high(and/model sonnetif on Haiku), then re-invoke this skill."
If the user selects "Cancel — I'll switch first": output the switching commands and stop. Do not proceed with the skill. Ask once per conversation: a skill invoked by another skill skips this step when the recommendation was already shown. In a non-interactive run (--noninteractive, GROUNDWORK_RUNNER_MODE=true, or GROUNDWORK_BATCH_MODE=true), skip the prompt and continue on the current model.
Execute Steps 0-2 below as normal (they are read-only — planning produces a plan file).
After Step 2 produces the plan file, write the plan mode output:
## Task: [TASK-NNN] [Title]
### Execution Context
**Working Directory:** [run `node ${CLAUDE_PLUGIN_ROOT}/lib/worktree-identity.js <TASK-NNN>` and use its `path` value — project-qualified in monorepos]
**Branch:** [use the same helper output's `branch` value]
**Base Branch:** [current branch]
## Implementation Plan
**IMPORTANT: DO NOT just execute the plan below.** Re-invoke `groundwork:work-on` which will use the saved plan. Set:
- `GROUNDWORK_EXECUTE_SKIP_TO_STEP_SEVEN=true`
- `GROUNDWORK_EXECUTE_PLAN_FILE=<absolute path to plan file>`
Then invoke `groundwork:work-on` with the same task ID.
Call ExitPlanMode()
Check skip flag: If session context contains GROUNDWORK_EXECUTE_SKIP_TO_STEP_SEVEN=true, set plan_file_path = $GROUNDWORK_EXECUTE_PLAN_FILE and treat Steps 1-2 as done (the plan already exists; see Plan Mode Handling): run the rest of this step, then go straight to Step 3 (Implementation). Do NOT read the plan file's contents into this orchestrator's context — the implement-task skill will pass the path to the executor agent.
Run the resume gate: node ${CLAUDE_PLUGIN_ROOT}/lib/task-resume.js check <TASK-NNN> (add --project <name> in monorepos; append --take-over when the invocation carried it; run it after the task identifier is known from Step 1 if the ID was not supplied). The one-line JSON classifies any existing work-in-progress for this task. Act on it exactly as ${CLAUDE_PLUGIN_ROOT}/references/task-resume-protocol.md specifies:
live_owner_reason: heartbeat-worker-alive → hard standdown: report and stop (not overridable). If the evidence includes a paste-ready heartbeat-stop command, offer it to the user — the owning session may be dead with its worker leaked.live_owner_reason: heartbeat-orphaned → not a standdown: the heartbeat worker beats on but its owning session is provably dead; proceed with the classification (reclaiming revokes the orphan's capability and it exits on its next beat).live_owner values → soft standdown: stop and ask unless --take-over was supplied, in which case proceed.resume_at: conflict → surface the evidence, preserve the worktree, and stop for a user decision.skip_phases: reuse plan.file instead of Step 2 when plan.present; jump to Step 4 (validation) or Step 5 (merge) when that much is already done.resume_at: done → run the clear-checkpoint action and report the task complete.actions command verbatim at its annotated moment. One check returns only the next action, so re-run it after each recorded phase to fetch the one after: on a fresh run it returns record … --phase plan (run it right after the plan file is persisted); that re-run returns record … --phase implemented (run it right after Step 3 returns RESULT: IMPLEMENTED); once Step 5's merge lands, the last re-run returns clear.resume_existing_worktree is true, forward WORKTREE PATH: <expected_worktree>, TASK BRANCH: <expected_branch>, and RESUME EXISTING WORKTREE=true into the Step 3 dispatch.Monorepo check: Does .groundwork.yml exist at the repo root?
{{project_name}} non-empty?
Skill(skill="groundwork:select-project") to select a project, then restart this skill.{{project_name}}, specs at {{specs_dir}}/.CWD mismatch check (monorepo only): skip it when the project was just selected or the invocation carried an explicit --project.
.groundwork.yml: the repo root or the selected project's path → fine, proceed; no project's path → proceed without warning (shared directory).--noninteractive, keep the selected project and continue; otherwise warn via AskUserQuestion:
"You're working from
<cwd>(inside [cwd-project]), but the selected Groundwork project is [selected-project] ([selected-project-path]/). What would you like to do?"
- "Switch to [cwd-project]"
- "Stay with [selected-project]" If the user switches, invoke
Skill(skill="groundwork:select-project").
Parse the task identifier from the argument:
4): Interpret as TASK-004 (zero-padded to 3 digits)TASK-004): Use as-isSkill(skill="groundwork:work-on-next-task") and stop — that skill selects the next workable task and runs this whole workflow for it inside its own call. Continuing this invocation after it returns would run the same task a second time.Flags: --take-over (also accepted anywhere in the argument) authorizes the resume gate to proceed past soft standdowns; thread it into the Step 0 gate invocation. --on-unrelated-failure <mode> (also accepted anywhere in the argument) selects how Step 4's validation handles gate failures confidently assessed unrelated to this task's project: stop-and-ask (default — current behavior), expand-and-fix (repair the unrelated failure via the validation fixer), or ignore-and-merge (record waiver receipts and proceed). An invalid mode value → stop with a usage error. Thread the mode into the Step 4 validate invocation.
Error: Invalid format → "Please specify a task number, e.g. /groundwork:work-on 4 or /groundwork:work-on TASK-004"
If session context contains GROUNDWORK_BATCH_MODE=true, batch mode is active. In batch mode:
AskUserQuestion calls are skippedplan-taskCall Skill(skill="groundwork:plan-task") with the task ID from Step 1 in the conversation context.
Parse the output:
RESULT: PLANNED | plan_file_path=<path> | identifier=<id> | branch_prefix=<prefix> → Save plan_file_path, identifier, branch_prefix, then continue to Step 2.5 in this same turn.RESULT: FAILURE | ... → Report failure. In batch mode output RESULT: FAILURE | [TASK-NNN] <reason> and stop. In interactive mode, report the failure and stop.Do NOT stop after planning. Planning is only the first of three phases in
work-on. The "DO NOT proceed past this step" note insideplan-taskapplies toplan-taskitself, not to this orchestrator — when control returns here withRESULT: PLANNED, you are NOT done. Never end your turn on a bare plan summary; the very next action after a successful plan is the Step 2.5 question.
Batch mode (GROUNDWORK_BATCH_MODE=true): Skip to Step 3.
Interactive mode: This question is mandatory — if you reached here with a plan, you must ask it rather than stopping. Use AskUserQuestion:
"[TASK-NNN] [Title] — plan ready. Proceed to implementation?"
- Option 1: "Yes, begin implementation"
- Option 2: "Stop here — I'll review the plan first"
If "Stop here": Print the plan file path and resume instructions, then STOP:
Plan saved to: <plan_file_path>
To resume implementation later:
/groundwork:implement-task <task-number>
implement-taskCall Skill(skill="groundwork:implement-task") with task_id and plan_file_path in the conversation context.
Parse the output:
RESULT: IMPLEMENTED | worktree_path=<path> | branch=<branch> | base_branch=<bb> → Save values. Proceed.RESULT: FAILURE | ... → Report failure. In batch mode output RESULT: FAILURE | [TASK-NNN] <reason> and stop. In interactive mode, report and stop.Skip this step entirely if GROUNDWORK_BATCH_MODE=true — proceed directly to Step 4.
In interactive mode, the orchestrator's context now holds the plan summary and the executor result. Validation runs the reviewer agents and may iterate through a fix loop, which compounds context further. Offer the user a chance to stop here so they can clear context before validation begins.
Use AskUserQuestion to ask:
"Implementation complete for [TASK-NNN]. Validation runs the reviewer agents next and can compound context. Clear context before validation?"
- Option 1: "Continue to validation now"
- Option 2: "Stop here — I'll clear and resume manually"
If "Continue to validation now": Proceed to Step 4.
If "Stop here": Print the resume instructions below and STOP. Do NOT call validate. Do NOT proceed to Steps 4, 5, 6, or 7.
## Paused before validation
Implementation is committed in:
- **Worktree:** `<worktree_path>`
- **Branch:** `<branch>`
- **Base branch:** `<base_branch>`
To resume validation in a clean context:
1. Run `/clear` to clear Claude Code context
2. `cd <worktree_path>`
3. Run `/groundwork:validate`
When ready to merge (commit any uncommitted validation fixes inside the worktree first — the fixer never commits):
cd <project_root>
git checkout <base_branch>
git merge --no-ff <branch>
git worktree remove <worktree_path>
git branch -d <branch>
Then mark **TASK-NNN** as `Complete` in the tasks file.
This is a hard stop. The user explicitly chose to take over the rest of the workflow.
Call the validate skill directly. Do NOT wrap this in a subagent — this skill runs in the main conversation, which CAN spawn the validation subagents it needs.
cd into the worktree path from Step 3Skill(skill="groundwork:validate"). When the invocation carried --on-unrelated-failure <mode> other than the default, include the flag in that call's arguments: --on-unrelated-failure <mode> (combine with any other arguments present)After validate completes:
Validation PASSED-WITH-WAIVERS (...) (only possible with --on-unrelated-failure ignore-and-merge) → Proceed to Step 5. Relay the waived-gate lines from the result into this skill's Step 5 merge question and Step 7 report; never present a waived gate as passed. The same applies to incidental fixes made under expand-and-fix — mention them in the merge message.RESULT: FAILURE | [TASK-NNN] Validation incomplete: ....RESULT: FAILURE | [TASK-NNN] Validation failed: ... and stop.Follow the validate skill's bounded failure assessment. A passing rerun does not prove a failure unrelated. Retain that assessment, checks already performed and the pending decision in the existing task/validation record across delegation and resume. Publication remains subject to the source workflow's rules and explicit user decisions; never report a failed or waived gate as passed.
From the project root (NOT the worktree), handle merge:
Determine merge action:
| Condition | Behavior |
|---|---|
GROUNDWORK_BATCH_MODE=true | Auto-merge immediately |
GROUNDWORK_AUTO_MERGE env var is true | Auto-merge immediately |
| Otherwise | Prompt user for decision |
If prompting user:
Use AskUserQuestion to ask:
"Implementation and validation complete for [TASK-NNN]. Would you like me to merge this into [base-branch] now?"
- Option 1: "Yes, merge now"
- Option 2: "No, I'll merge manually later"
When validation returned PASSED-WITH-WAIVERS, prepend the waived-gate summary lines from Step 4 to this question so the user merges with full knowledge. When expand-and-fix repaired an unrelated failure, mention the incidental fix in the merge message.
Wait for user response before proceeding.
If merging: Follow ${CLAUDE_PLUGIN_ROOT}/references/task-merge-sequence.md with the worktree path, branch, and base branch from the execution context: commit the validation repairs on the task branch first (the fixer never commits), merge from the project root with --no-ff, then remove the worktree and delete the branch. On a conflict, abort, keep the worktree, and report as below.
If not merging or conflicts occurred:
Report worktree location and manual merge instructions:
## Implementation Complete in Worktree
**Location:** [worktree path from the execution context]
**Branch:** [branch from the execution context]
When ready to merge (commit any uncommitted validation fixes inside the worktree first — the fixer never commits):
```bash
cd <project_root>
git checkout <base_branch>
git merge --no-ff <branch>
git worktree remove <worktree_path>
git branch -d <branch>
To continue working:
cd <worktree-path>
## Step 6: Complete Task
After successful merge or user acknowledgment:
1. **Update status** — Change task file to `**Status:** Complete` and update the status table in `{{specs_dir}}/tasks/_index.md` or `{{specs_dir}}/tasks.md` (change the task's row to `Complete`)
## Step 7: Report
**Batch mode (GROUNDWORK_BATCH_MODE=true):** Output the structured result as your final line:
RESULT: SUCCESS | [TASK-NNN] [Task Title] - [one-line summary of what was done]
If the task failed at any step, output:
RESULT: FAILURE | [TASK-NNN] [reason for failure]
**Interactive mode:** Output exactly one line:
Done: [TASK-NNN] merged → . Validation passed in N iter(s).
If the merge did not happen, replace `merged → <base>` with `pending at <worktree_path>`. When validation returned `PASSED-WITH-WAIVERS`, replace `Validation passed in N iter(s)` with `Validation passed with W waived gate(s) in N iter(s)` and list each waived gate on its own line immediately after — never as passed.
---
## Reference
### Task Status Values
- `**Status:** Not Started`
- `**Status:** In Progress`
- `**Status:** Complete`
- `**Status:** Blocked`
### Dependency Handling
Task is blocked if `Blocked by:` lists any task not Complete.
### Final Checklist
Before marking complete, verify ALL:
- [ ] Working in the task worktree (path recorded from the worktree-identity helper)
- [ ] Plan agent was used (not your own plan)
- [ ] TDD was followed
- [ ] All acceptance criteria verified
- [ ] validate returned PASS, or PASSED-WITH-WAIVERS under `--on-unrelated-failure ignore-and-merge` with waiver receipts recorded (via direct Skill call)
- [ ] All validation fixes were applied by the validation-fixer subagent — zero `Edit`/`Write`/`NotebookEdit` calls and zero file-mutating `Bash` calls (`sed -i`, `awk -i`, `tee`, `>`, `>>`, etc.) by this orchestrator during the validation phase. If you fixed anything yourself instead of dispatching to validation-fixer, that is a violation of the validate hard rule and the task is NOT complete.
- [ ] Merge completed or user acknowledged worktree location
If any unchecked: task is NOT complete.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (etr/groundwork) — no native marketplace selected
npx claudepluginhub p/etr-groundwork44 skills in this plugin
/build-unplannedBuild a feature from a description with worktree isolation and TDD. Optional flag - --on-unrelated-failure stop-and-ask|expand-and-fix|ignore-and-merge - how validation treats gate failures unrelated to the active project (default stop-and-ask)./check-specs-alignmentVerify alignment between code and specs./create-tasksGenerate implementation tasks from architecture document./debugUse when investigating bugs, unexpected behavior, test failures, or any code that does not work as expected - enforces systematic root cause analysis before any fix/design-architectureUse when the user asks to design system architecture, make architectural decisions, or translate PRD into technical design/design-it-twiceUse before committing to a non-trivial module, service boundary, or public API - generate 2-3 divergent interface designs, compare them on depth/locality/seam, and recommend oneOther plugins' skills for the same job