/groundwork:finalize-task [task-id] [--project name] [--on-unrelated-failure stop-and-ask|expand-and-fix|ignore-and-merge]from groundwork
Commits, merges, and cleans up a validated task worktree. Supports optional flags for project name and handling unrelated failures (ignore-and-merge for PASSED-WITH-WAIVERS).
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.
Finalize one validated task. Use judgment for commit and merge messages. Preserve the worktree and branch whenever state is ambiguous.
Accept a task ID, optional --project <name>, and optional --on-unrelated-failure <mode> (stop-and-ask, expand-and-fix, or ignore-and-merge; default stop-and-ask when absent). ignore-and-merge is the only mode that changes finalization behavior here: it authorizes merging a tree whose terminal validation result was Validation PASSED-WITH-WAIVERS (see item 4 below). An invalid mode value → stop with a usage error.
When invoked by the external runner, treat its exact project_root, worktree_path, branch, base_branch, base_head, and validated_head values as authoritative. Missing or inconsistent runner inputs are a failure.
When invoked manually from the task worktree:
--project directly from the repository's .groundwork.yml; do not depend on or change persisted project selection.validated_head. If validation did not just pass for this exact tree and working state, stop and ask the user to run validate first. A Validation PASSED-WITH-WAIVERS outcome counts as a pass only when this invocation carried --on-unrelated-failure ignore-and-merge and the terminal validation session's coordinator-owned record contains at least one waiver receipt (failed gate, evidence, causal assessment, path attribution outside the project root, authorizing flag — see ${CLAUDE_PLUGIN_ROOT}/references/validation-session-protocol.md); otherwise it is not a pass: stop and ask. Exception — resume entry: when a resume gate (node ${CLAUDE_PLUGIN_ROOT}/lib/task-resume.js check <task-id>) classified this task as resume_at: finalize, its terminal validated session already covers this exact tree; proceed (see ${CLAUDE_PLUGIN_ROOT}/references/task-resume-protocol.md).Before changing anything:
validated_head.Never reset, stash, rebase, force-delete, or silently switch either worktree to another branch.
Within the selected project's task files:
Complete.Inspect the actual remaining diff. Include validation fixes and task bookkeeping belonging to this task.
action: "commit" and propose <task-id>: Mark task complete plus an explanatory body. Use action: "none" only when no bookkeeping change remains.<task-id>: Mark task complete.In runner mode, never ask a question. Return RESULT: FAILURE for missing information or unsafe state.
Check whether the current base head is an ancestor of the task branch.
If it is not:
--no-ff --no-commit.git add or create the merge commit. Leave the prepared merge for the runner and propose an expressive task-prefixed commit subject and body. Return RESULT: BASE_INTEGRATED, bind it to the exact integrated base head, and report conflicts_resolved: true only when the merge command reported conflicts. The runner owns the opt-in revalidation policy and invokes finalization again after sealing the integration.If resolution needs product, architecture, or ownership judgment, safely abort the integration when possible and return RESULT: NEEDS_INPUT.
Decide the integration path before anything else (manual mode only). Take the pull-request path in 5a — instead of merging — only when the user asked for it in this invocation, or the repository's stated policy (its CLAUDE.md/AGENTS.md, or a standing instruction from the user) names pull requests as the integration path. Every other invocation merges directly, below.
In runner mode:
PASSED-WITH-WAIVERS validation, the merge body must name each waived gate as waived (never as passed). When validation repaired an unrelated failure under expand-and-fix, mention the incidental fix.RESULT: READY_TO_MERGE receipt with the exact runner token, task identity, bookkeeping commit proposal when needed, and expressive outward merge subject/body. Do not merge outward, remove the worktree, or delete the branch; the runner verifies and commits the prepared tree before performing those operations.When invoked manually, merge with --no-ff, then continue to cleanup below. If an unexpected conflict occurs, abort it when safe and return RESULT: NEEDS_INPUT. Do not resolve it on the base branch because the resolution would not have been validated.
A merge rejected by branch protection is not, by itself, permission to open a pull request — pushing a branch and opening a PR publish work outward. Interactive: stop and ask. Unattended (GROUNDWORK_BATCH_MODE=true): return RESULT: NEEDS_INPUT | reason=direct merge rejected; pull-request integration is not authorized and leave the worktree and branch untouched.
Taken only as decided at the top of step 5 (never in runner mode, where the runner owns publication). Push the task branch, open (or update) the PR against the base branch instead of merging, and write its body in this shape:
## Summary
<the smallest visual that makes the change clear — pseudocode for logic,
a call tree for control flow, a component/file tree for structure,
or a diff matched to the topic; one short paragraph at most>
## Evidence
- **Before:** <screenshot / output / failing test run>
**After:** <screenshot / output / passing test run>
<Test runs are the default; screenshots when the change is visual>
## Merge Danger
**Door:** <one-way or two-way — can this be walked back cheaply?>
**Blast radius:** <one phrase — what breaks if this is wrong>
State the confirmed root-cause or decision in the body when one exists (from the debug journal or a decision record), so the reviewer starts from the answer. Use the project's domain vocabulary from {{specs_dir}}/glossary.md when it exists. The merge/PR message rules above (waived gates named as waived, incidental fixes mentioned) still apply to the body.
This path ends with the PR open, not with a merge: skip step 6, keep the worktree and the branch until the PR merges, and report RESULT: NEEDS_INPUT | reason=pull request <URL> awaiting review and merge; worktree and branch preserved.
After a successful manual merge:
If the merge succeeded but cleanup fails, return RESULT: CLEANUP_REQUIRED; do not undo the merge.
Make the final line exactly one of:
RESULT: FINALIZED | task_id=<id> | task_head=<sha> | merge_commit=<sha> | base_branch=<branch>
RESULT: NEEDS_INPUT | reason=<one-line reason>
RESULT: CLEANUP_REQUIRED | merge_commit=<sha> | worktree_path=<path> | branch=<branch> | reason=<one-line reason>
RESULT: FAILURE | reason=<one-line reason> | worktree_path=<path> | branch=<branch>
In runner mode, report only one of these compact JSON receipts or a failure result:
RESULT: READY_TO_MERGE | {"v":1,"token":"<exact-runner-token>","task_id":"TASK-NNN","phase":"finalize","action":"commit","commit":{"subject":"TASK-NNN: Mark task complete","body":"<bookkeeping summary>"},"merge":{"subject":"Merge TASK-NNN: <actual outcome>","body":"<publication summary>"}}
RESULT: BASE_INTEGRATED | {"v":1,"token":"<exact-runner-token>","task_id":"TASK-NNN","phase":"finalize","action":"commit","base_head":"<full-integrated-base-sha>","conflicts_resolved":true,"commit":{"subject":"TASK-NNN: Integrate updated base branch","body":"<resolution summary>"}}
RESULT: REVALIDATE | {"v":1,"token":"<exact-runner-token>","task_id":"TASK-NNN","phase":"finalize","action":"commit","base_head":"<full-integrated-base-sha>","reason":"<why revalidation is required>","commit":{"subject":"TASK-NNN: Integrate updated base branch","body":"<resolution summary>"}}
For READY_TO_MERGE, use action: "none" and omit commit when the task worktree is clean. BASE_INTEGRATED always uses action: "commit"; REVALIDATE remains accepted only for compatibility with older skill exports. Report FINALIZED only after a manual merge is present, both remaining worktrees are clean, and cleanup succeeded.
What SKILL.md sets; muted values are Claude Code's defaults
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