AGENT SKILL

finishing-work

Sync back to a clean, current main after a PR merges — confirm the merge landed, switch to main, fast-forward pull, prune remote-tracking branches, and verify a clean repo state. Use when finishing work, asked to "I just merged, clean this up", "sync back to main after merge", "finish this branch", or "get back to a clean main". Never deletes branches or worktrees itself — hands off to `/git-cleanup` for that.

License 许可
Apache-2.0
最近更新
2026-11-15
Stars
★ 0
Forks
0

01 前言 Front Matter

name
finishing-work
description
Sync back to a clean, current main after a PR merges — confirm the merge landed, switch to main, fast-forward pull, prune remote-tracking branches, and verify a clean repo state. Use when finishing work, asked to "I just merged, clean this up", "sync back to main after merge", "finish this branch", or "get back to a clean main". Never deletes branches or worktrees itself — hands off to `/git-cleanup` for that.
allowed-tools
Bash(gh pr view:*), Bash(gh repo view:*), Bash(git checkout:*), Bash(git pull:*), Bash(git fetch:*), Bash(git status:*), Bash(git worktree list:*), Bash(git branch --show-current:*), Bash(git symbolic-ref refs/remotes/origin/HEAD:*)
argument-hint
(optional) PR number or URL — defaults to the current branch's PR if omitted

03 SKILL.md 正文

Finishing Work

Get local main back to a clean, current state right after a PR merges — without assuming the merge actually happened, and without doing the branch/worktree deletion itself (that stays a deliberate, user-invoked step via /git-cleanup).

When to Use

Right after a PR merges: confirming the merge, returning to a synced main, and verifying nothing was left dirty. Triggers: "I just merged, clean this up", "sync back to main after merge", "finish this branch", "get back to a clean main".

When NOT to Use

  • Actually deleting the merged branch or its worktree — that's /git-cleanup's job. This skill only syncs local state and tells you to run it.
  • The PR hasn't merged yet — step 1 below checks this and stops if it hasn't; don't skip straight to syncing main on the assumption it landed.

Instructions

  1. Confirm the PR actually merged: capture the current branch with git branch --show-current (used only to detect the mismatch below — step 4's own worktree check uses headRefName, not this value). Run gh pr view $ARGUMENTS --json state,mergedAt,headRefName,url. If state isn't MERGED (still open, or closed without merging), tell the user exactly which state it's in and stop — don't sync main on an assumption. If $ARGUMENTS was given, check whether the returned headRefName differs from the branch just captured, or the returned url's <owner>/<repo> segment differs from gh repo view --json nameWithOwner --jq .nameWithOwner (the current repository) — on either mismatch, stop and ask via AskUserQuestion whether to proceed anyway rather than silently continuing on an unrelated PR's merge state.
  2. Return to main: resolve the actual default branch rather than assuming main — git symbolic-ref refs/remotes/origin/HEAD (falling back to main if that fails, e.g. no origin remote configured), then git checkout <resolved-branch>, then git pull --ff-only. If the checkout or pull fails, tell the user why and stop rather than force anything — three distinct reasons, not just one: a diverged local branch; the resolved branch already checked out in another worktree (git refuses with "already used by worktree"); or this session is itself sandboxed to a worktree checkout rather than the primary checkout — a worktree-sandboxed session cannot cd out to the primary repo root, so even a successful-looking checkout here would switch the worktree's own branch, not the primary checkout's, leaving the actual goal (a synced primary main) unmet. Tell the user plainly which of the three applies, and — for the sandboxed case specifically — that they need to run finishing-work (and subsequently /git-cleanup) from a session started in the primary checkout instead. allowed-tools grants Bash(git checkout:*) broadly for this step since the resolved branch name is dynamic and can't be statically pinned — this skill never runs the file-restore form (git checkout -- <path>), only branch checkout.
  3. Prune: git fetch --prune to drop stale remote-tracking refs for branches deleted on the remote.
  4. Verify clean state: git status --porcelain on the current worktree must come back empty. Also run git worktree list and compare against the PR's headRefName from step 1 (not the git branch --show-current value, which only served step 1's own mismatch check) — if another worktree is still checked out on that specific branch, flag it (especially if it has uncommitted changes) without touching it.
  5. Hand off: tell the user local main is synced and current, and that /git-cleanup is the next step to review and delete the merged branch (and worktree, if any). Never invoke git-cleanup automatically — it has disable-model-invocation: true by design and only runs on direct user invocation. If this session is sandboxed to a worktree checkout, remind them here too: /git-cleanup needs to run from a session started in the primary checkout, not from inside the worktree — the same constraint step 2 above stops on, not a separate one.

Testing & Validation

Verify this skill activates on:

  • "I just merged PR #42, clean this up"
  • "sync back to main after merge" / "finish this branch"

Verify it does NOT activate on:

  • "delete my old branches" → /git-cleanup
  • "start a new branch for X" → starting-work

Quality gates:

  • [ ] Step 1 always checks actual PR state via gh pr view — never assumes merged from context alone
  • [ ] A not-yet-merged PR always stops the flow before touching main
  • [ ] Step 1 always binds the merge confirmation to a specific branch and repository (headRefName, nameWithOwner) — never assumes $ARGUMENTS refers to the current branch/repo without checking, and always stops to ask on a mismatch rather than continuing silently
  • [ ] Step 5 always tells the user to run /git-cleanup themselves — never invokes it via Skill()
  • [ ] A session sandboxed to a worktree checkout is told plainly, at both step 2 and step 5, that it cannot complete the sync/hand-off from there — never left to discover the cd failure on its own
  • [ ] A diverged local default branch at step 2 always stops rather than force-syncing

04 同仓库更多 Skills

AndreHahm
AndreHahm/andres-cc-marketplace

demo

Fixture skill used by scripts.marketplace_ci sync tests.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

export-demo

Fixture skill used by scripts.marketplace_ci export tests.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

work-to-development

Validate an accepted Linear Issue's readiness for implementation (criteria, dependencies, duplicate/existing artifacts) and request governed branch/worktree creation through git-kit:starting-work — recording work-started Git/GitHub evidence and a deliberate Linear Started transition only after Git identity is read back and verified. Use when asked to start work on a Linear issue, begin development for an accepted issue, or prepare an accepted issue for implementation. Never creates a branch directly — always delegates to git-kit.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

work-linking

Create and maintain stable cross-system links and authority labels between Notion and Linear records, and detect/repair drift between them. Use when asked to link a Notion record to a Linear record, check for drift between Notion and Linear, or repair a broken/stale link. Repairs only the bounded non-authoritative copy or link — never chooses by newest timestamp, and never creates a reverse-write loop against either system's own authority.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

status-and-learning

Produce a dated, explicitly non-live Linear-to-Notion progress summary, or capture an outcome/learning after work completes. Use when asked to summarize progress to Notion, report portfolio status, or capture what was learned from a completed piece of work — not to disposition open follow-up items (see open-item-management for that). Never runs automatically or continuously — every summary is a deliberate, approved snapshot, not a live sync.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

repository-gates

Discover, delegate, record, and invalidate this repository's actual Git/GitHub lifecycle gates (pre-commit, pre-push, PR required checks, Codex delta review, review requirements, merge rights) and the repository-policy provider profile that maps governed operations to git-kit. Use when asked what gates apply to this repository, to discover repository policy before starting Wave 2 work, or to check whether prior gate evidence is still valid after new commits. Discovery and delegation only — never executes a gate's own internal logic, and never invents a gate the repository doesn't actually define (in particular, never assumes a "Review Changes" gate exists).

★ 0