/ai-cli-harness-better-practices:wrap-upfrom ai-cli-harness-better-practices
End-of-session handler: checks if the plan is complete. If complete: quick retrospective, forward follow-up prompt, and (in a repo) refresh + clean gone branches. If incomplete: skip cleanup, emit resume prompts. Cleanup needs a repo; rest doesn't.
Ships in ai-cli-harness-better-practices. 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.
State warning: TaskList contents, plan checklist state, and any branch or remote-tracking state all change between invocations. Re-gather them from Step 0; never trust prior outputs from this conversation.
/wrap-up has two paths. Step 0 decides which one runs.
| Step 0 outcome | Path |
|---|---|
| Plan complete OR no plan | Path A — retrospective + follow-up prompt; plus repo refresh and branch cleanup when in a repository |
| Plan incomplete | Path B — emit resume blocks; skip Path A cleanup entirely |
The purge-pr focused mode (bottom of this file) bypasses Step 0 entirely.
Everything this skill reads before it decides is token-heavy and reasoning-light:
the plan checklist and TaskList, the origin/main..origin/develop promotion log, the
open-PR listing, and the remaining plan/TaskList items Path B groups. Hand that
raw material to the router via the local-subagents skill (ai-delegation)
at the cheapest capable tier — capability small, or a subagent carrying an explicit
lower model: when the input is longer than one call holds. The premium lead
makes the Path A/Path B verdict over the returned table, never the raw dump.
Cap the input: at most 30 promotion-log lines and 30 PRs. Truncate, do not paginate. Exact small-model prompt text: references/path-b-and-purge-pr.md.
Fallback (verbatim from local-subagents): none of the router's failure
paths authorize a silent fallback. "Absorbing the work back into your own
context without saying so is the exact cost delegation was meant to avoid, and
it hides the failure from whoever pays for it." If the router is unreachable, do
the step yourself and say so in the Wrap-Up Summary. Never silently skip it.
The completion verdict itself is never delegated — that is the judgment this skill exists to make.
Read the plan checklist and the TaskList, and list unfinished work and issues. Check each done claim with
/agentops:research (does the claim hold) before you count it. This is the Step 0 report.
Determine the completion outcome from the Step 0 report:
Path A (complete): Every TaskList task is complete (or empty), AND every plan-file checklist item is checked or complete (or no plan file exists).
Additional Git Flow Requirement — repository only. Establish that first:
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || echo "not a repository"
Outside a repository, skip this requirement entirely; completion is decided by the TaskList and plan checklist alone.
Inside one, determine whether this is a git-flow repo (default branch
develop). Run this as one block — the resolution and its use must share a
shell (see
ARCHITECTURE.md) — and
take exactly one of three branches; this gate must never fail open:
default_branch=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null)
default_branch=${default_branch#origin/}
[ -n "$default_branch" ] || default_branch=$(
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' 2>/dev/null)
if [ -z "$default_branch" ]; then
echo "BLOCKED: default branch unresolved; cannot confirm promotion state"
elif [ "$default_branch" = develop ]; then
git fetch origin --force develop main &&
git log --oneline origin/main..origin/develop
else
echo "trunk repo — promotion requirement does not apply"
fi
refs/remotes/origin/HEAD is unset in fetch-based and CI checkouts, so the
first branch is reachable in practice; treat it as unknown, not clean. The
plan is incomplete until promotion state is positively confirmed.
When the log shows commits, they MUST be promoted to main via
/promote-release. Until then the plan is incomplete and the session must
not follow Path A.
Path B (incomplete): Any TaskList task or plan checklist item remains incomplete.
Steps A1 and A3 are repository cleanup and only run when the cwd is a repository. Gate them:
git rev-parse --is-inside-work-tree >/dev/null 2>&1
When that fails, skip A1 and A3, note "no repository at this cwd; cleanup skipped" in the summary, and run A2, A2.5, and A4 as normal. Steps A2, A2.5, and A4 are the part of a wrap-up that always applies — tracking a follow-up needs a tracker, not a repository.
In a repository, run Steps A1 and A2 in parallel (they are independent). A2.5 runs after A2, and A3 after both A2.5 and A1 finish. Provide a summary of actions taken.
Invoke /refresh-repo to sync, then /prune-branches to delete anything
left with nothing useful:
Invoke /agentops:postmortem for a brief session retrospective: what went as
planned, what did not, and proven causes kept apart from coincidence. Outside a
repository it has no git history; record that in the summary as
"retrospective: session log only, no git history".
Requires: the agentops plugin. If it is not installed, skip this step and note it was skipped.
When the session hit a real failure rather than merely finishing, deepen the
retrospective with /why (Five Whys — drill from the symptom to the systemic
cause) and frame the improvement with /kaizen (small, incremental, error-proofed
by design). Both are optional passes over the same material, not replacements for
the retrospective.
Invoke the track-followups skill with the triaged buckets from the Step 0 report.
It deduplicates, creates each item in the issue tracker or the incident system
of record, and returns the created identifiers.
This runs before A3 so the handoff can cite real item URLs instead of restating work that is now tracked. Follow-ups that are only listed are follow-ups that get lost.
No follow-up work in the Step 0 report → skip this step and say so.
If the Step 0 report surfaced follow-up work, invoke /goal (this plugin) for its
next-session objective. Print the statement and measured character count with
the working directory, plan path, remaining work, and relevant context from
the Step 0 report. Include full URLs for identifiers returned by A2.5.
Keep the two tracked-follow-up kinds distinct in the handoff — a tracker task is work to be done, an incident ticket is operational/incident work — never relabel one as the other. Items already tracked in A2.5 appear in the handoff as a one-line reference to their identifier, not as restated work.
For a portable handoff document, direct the user to invoke /agentops:doc.
Never invoke it from this skill; this skill prints its own prompts.
If no follow-up items are found in the Step 0 report, state that explicitly — do not fabricate work.
Wrap-Up Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Plan: <path or "none">
Plan status: complete
Refresh: done or skipped
Retrospective: done or skipped
Branch cleanup: done or skipped
Follow-ups filed: <n> tracked (<identifiers>) or "none" or "listed only — <reason>"
Follow-up prompt: done or skipped
Git Flow promote: done or N/A
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Skip Path A entirely. Skipping is intentional: /prune-branches deletes stale
worktrees, which would delete the in-flight worktree the user needs to resume
in.
Goal: emit one copy-pasteable, self-contained resume block per coherent
group of remaining work, in dependency order, each carrying a real
/goal statement — never "continue what you were doing".
Done when: every plan-checklist item still unchecked and every TaskList
task not completed appears in exactly one block; each block states its
working directory, plan-file path, remaining items with line numbers, and
any referenced PR/issue as a full URL; and the Path B summary table is
printed. Full grouping rules, the block/summary formats, and the worked
example: references/path-b-and-purge-pr.md.
Invoke as /wrap-up purge-pr <PR_NUMBER> to close one PR and atomically
purge all local state for its branch. Bypasses Step 0 and both paths
above. Use when you know a PR should be closed (obsolete duplicate,
workaround anti-pattern, abandoned work) and you want the local trace gone
in one operation. Sequence and command shapes:
references/path-b-and-purge-pr.md.
/goal (this plugin) — supplies the capped objective for Path A Step A3
and the Path B resume blocks./agentops:postmortem — the Path A Step A2 retrospective./agentops:doc — the portable handoff document, and docs that must absorb
the session's technical changes./agentops:research — checks done claims in Step 0.--sweep and --prune-stale modespurge-pr modepurge-pr is the right actionWhat SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/goalEmit a /goal line for the work in flight, under 4000 chars. Derives focus from the session, then runs goal-prompt, or /agentops:craft-goal for multi-experiment campaigns./replanSuperseded by /agentops:plan. Use that skill instead./session-statusSuperseded by /agentops:doc. Use that skill instead.Other plugins' skills for the same job
/track-followupsRecord triaged follow-up work where it'll be seen: create the item in Vikunja or Zammad (incidents), deduplicating first and reporting the id. Use when session work outlives it or items were triaged elsewhere. Never opens a GitHub issue.npx claudepluginhub jacobpevans-ai/claude-code-plugins --plugin ai-cli-harness-better-practices