/xp-agents:xp-free-closefrom xp-agents
Reviews and merges ad-hoc free branches into the integration branch, creating a PR and applying security/code reviews.
Ships in xp-agents. 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.
Read when SKILL.md points to them; scripts run unread.
Sequential discipline. Run Step 1 → 2 → 3 → 4 → 4b → 4.5 → 5–6 → 7 one per turn: make the call, observe, then decide the next. Never batch a step with one that depends on it, and never spawn the same subagent twice; independent read-only calls may batch.
The injected preload state names SMM_DIR, CURRENT_BRANCH, TARGET_BRANCH, GH_AVAILABLE, and WORKTREE_CLEAN. TARGET_BRANCH is the recorded plan branch when execution_plan.json sets one (and that branch exists locally), else the primary integration branch — a free branch forked off a plan branch merges back to the plan branch, never to main. Shared pipeline lives in ${CLAUDE_PLUGIN_ROOT}/scripts/close_common.py.
Commit trailer reminder — this is the ONLY leg that closes a Try. A commit on this free branch that lands a carried retro Try (one adopted via /xp-work-selection adopt) must include Resolves-Event: <try-id> in its body. Adoption only links its Try — taking work on must not close the item that verifies the work landed — and there is no cascade to fall back on: without the trailer the Try stays open forever, carried as adopted-but-never-landed.
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/close_common.py preflight \
--cwd . --current <CURRENT_BRANCH> --target <TARGET_BRANCH>
If the exit code is non-zero, stop — script emitted the reason on stderr (dirty worktree or <CURRENT_BRANCH> IS <TARGET_BRANCH>).
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/close_common.py push \
--cwd . --branch <CURRENT_BRANCH>
PR_OUTPUT=$(python3 ${CLAUDE_PLUGIN_ROOT}/scripts/close_common.py create-pr \
--cwd . --base <TARGET_BRANCH> --head <CURRENT_BRANCH> \
--title "<short title for the free work>" --body "<one-paragraph summary>")
PR_OUTPUT is a PR number or skipped: no gh on PATH.
Apply the shared ### Step 4: Security Review block above with <close-mode> → free and <close-skill-name> → xp-free-close.
Apply the shared ### Step 4b: Full code review (conditional) block above.
Compute the diff command:
DIFF_CMD=$(python3 ${CLAUDE_PLUGIN_ROOT}/scripts/close_common.py diff-command \
--target <TARGET_BRANCH> --source <CURRENT_BRANCH>)
Substitute the captured value as <DIFF_CMD> in the agent prompt below.
Agent(
subagent_type: "xp-agents:xp-close-reviewer",
prompt: "SMM_DIR=<SMM_DIR>\nSYSTEM_CONTEXT_RENDERED=<SYSTEM_CONTEXT_RENDERED>\n\n## Mode\nfree\n\n## Source Branch\n<CURRENT_BRANCH>\n\n## Target Branch\n<TARGET_BRANCH>\n\n## Diff Command\n<DIFF_CMD>\n\n## Close Cycle ID\n<CLOSE_CYCLE_ID>\n\n## Context\nClosing free branch <CURRENT_BRANCH> into <TARGET_BRANCH>. PR <PR_OUTPUT or 'not created (no gh)'>.\n\n## Instructions\nRun the Diff Command, analyze cumulative diff with free-mode focus (code quality, clarity, naming, obvious bugs, missing error handling at boundaries, test coverage gaps), plus Step 3b in every mode. Sprint/plan-level scope concerns do not apply. Return Keep / Concern / Block summary."
)
The shared reference (Steps 5, 5b, 6, 6b) is emitted by the preload — see scripts/_close_pipeline_shared.md. Apply in order after Step 4.5, then continue with Step 7 below.
Free-close override for Step 6 (auto-merge gate): if ALL of these hold, skip the shared Step 6's AskUserQuestion (Step 6b still runs):
Step 5c queued zero ask-user items. Verify via the canonical structured filter:
ASK_COUNT=$(python3 ${CLAUDE_PLUGIN_ROOT}/smm/smm_cli.py \
--smm-dir <SMM_DIR> count-classifications \
--route ask --cycle-id <CLOSE_CYCLE_ID> --since-ts <CLOSE_START_TS>)
<CLOSE_CYCLE_ID> and <CLOSE_START_TS> are emitted by the preload (captured at close-cycle start). --cycle-id excludes concern_classify events tagged with a DIFFERENT close-cycle, so concurrent close-cycles in other teammate worktrees don't leak in (SMM is shared across worktrees); an UNTAGGED event is still counted (fail closed, rather than dropping an ask-route the gate must see), so --since-ts is the bound that keeps pre-cycle events out. Test numerically: [ "$ASK_COUNT" -gt 0 ] → fall through to the shared Step 6 prompt.
No open high-severity concern recorded during Step 4.5, verified via the canonical structured filter:
HIGH_CONCERN_COUNT=$(git diff --no-renames --name-only -z <TARGET_BRANCH>...<CURRENT_BRANCH> \
| python3 ${CLAUDE_PLUGIN_ROOT}/smm/smm_cli.py \
--smm-dir <SMM_DIR> count-concerns --diff-paths - \
--severity high --cycle-id <CLOSE_CYCLE_ID> --since-ts <CLOSE_START_TS>)
--diff-paths - drops an untagged concern whose recorded files this close never touches, so a concurrent teammate's unrelated open defect cannot abort a clean close; an empty or unreadable diff counts everything (fail closed). Name both branches rather than HEAD so the range does not depend on your checkout.
Test [ "$HIGH_CONCERN_COUNT" -gt 0 ] → fall through to the shared Step 6 prompt.
The preload emitted a ### GATE_COMMANDS block AND every command in it, run AFTER all Step 5c fixes landed, exits 0. Run them in order and name which command failed on a non-zero exit — then fall through to the shared Step 6 prompt.
The preload already chose that set (surface-scoped where the branch diff maps onto declared surfaces, the full TEST_COMMAND otherwise) and reports which in GATE_SCOPE; do not re-derive it here — a gate decided in prose cannot be asserted. A selection covering every declared command collapses to the full command once, rather than running N. No block is emitted when there is nothing to run, so the gate can never run nothing and report green.
Step 5c classified zero design_decision findings — even if the classifier routed one to fix. Free-close merges into an integration branch (plan or primary), and architectural calls deserve a human checkpoint. Verify via:
DESIGN_DECISION_COUNT=$(python3 ${CLAUDE_PLUGIN_ROOT}/smm/smm_cli.py \
--smm-dir <SMM_DIR> count-classifications \
--category design_decision --cycle-id <CLOSE_CYCLE_ID> --since-ts <CLOSE_START_TS>)
Test numerically: [ "$DESIGN_DECISION_COUNT" -gt 0 ] → fall through to the shared Step 6 prompt.
No block: report the preload's GATE_DISABLED_REASON, never assume unset. not-set — no stack.test_command; declare one via system_context_cli.py edit-stack-field test_command. exit-status-masked — set but its exit status never reaches the shell (;, a pipe, &, ||, a $(...) capture), so it reports success when its runner failed; name the one it actually has and suggest &&. unresolved — the resolver itself did not answer (e.g. corrupt system_context.json); say so, do NOT claim the field is unset.
When all four conditions hold, print exactly:
"All reviewer findings addressed and tests green — proceeding to merge without confirmation."
then continue to Step 7. Otherwise apply the shared Step 6 AskUserQuestion as written.
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/close_common.py merge \
--cwd . --source <CURRENT_BRANCH> --target <TARGET_BRANCH> \
--smm-dir <SMM_DIR>
Any failing step aborts the chain — source intact for retry. Conflicts are never auto-resolved.
Surface the merge's trailer advisory. close_common.py merge prints a Resolves-Event: advisory to stdout when eligible commits fall below the trailer target (fail-open — it never blocks the merge). Tool output is invisible to the user, so relay any such advisory verbatim — the named commits are still in reach to add trailers.
Tell the user: free branch merged into <TARGET_BRANCH>, PR (if created) merged, local branch deleted. Free-close is complete.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub paulingalls/xp-agents --plugin xp-agents19 skills in this plugin
/xp-acceptVerify acceptance criteria for in-progress stories and mark each done or deferred. Use when a story is ready to accept./xp-assignPer-story execution-shape decision: continue in-agent, or spawn one teammate at the chosen tier. Runs once per story after its plan is reviewed./xp-end-sessionEnd-of-session cleanup: drafts a session summary, force-closes open questions, and triages maybe-addressed concerns and debts./xp-kickoffSession start orchestrator: sequences retrospective, sprint setup, work selection, housekeeping. Use every session.Other plugins' skills for the same job