ワンクリックで
refresh-repo
Check PR merge readiness, sync local repo, cleanup stale worktrees; optional cross-repo sweep and stale-branch prune modes
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Check PR merge readiness, sync local repo, cleanup stale worktrees; optional cross-repo sweep and stale-branch prune modes
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when creating PRs, linking issues, managing PR comments, or creating GitHub issues
Use when creating or editing GitHub Actions workflows that call reusable workflows (uses: OWNER/repo/.github/workflows/...) — org owner references must be the literal current org, and shared-CI homes are under dryvist.
Emit a paste-ready two-part handoff for a fresh session: a `## Goal statement` hard-capped under 4000 characters (measured with wc -c, never estimated) that pastes straight into Claude Code's /goal Stop hook, plus an unbounded `## Full prompt` carrying cwd, ordered reading list, hard rules, pitfalls, and deliverables. Use when forking work to a new session, spinning up an orchestrator, or when wrap-up needs a next-session prompt with a real goal and not just a task list.
Analyzes current session state and repository status without any cleanup. Full mode (default): resolves the active plan file, reads plan checklist + TaskList, gathers unfinished work/issues from conversation history, checks git status, and emits a /handoff-built next-session prompt. Mid-session mode (`/session-status mid`): a fast plain-language 'done vs remaining' snapshot for mid-flight orientation, skipping the history scan, triage, and handoff.
End-of-session handler that first checks whether the current session's plan is actually complete. If complete: refresh repo, run quick retrospective, clean gone branches, and emit a forward-looking follow-up prompt. If incomplete: skip cleanup and emit one or more `cd`-into-worktree blocks paired with ready-to-paste resume prompts so the unfinished work can be picked up cold in a new session.
Automatically finalize pull requests for merge by resolving CodeQL violations, review threads, merge conflicts, and CI failures. Handles single PR (current branch or by number), all open PRs in the repo, or all open PRs across the org. Includes bot-authored PRs in all modes.
| name | refresh-repo |
| description | Check PR merge readiness, sync local repo, cleanup stale worktrees; optional cross-repo sweep and stale-branch prune modes |
Check open PR merge-readiness status, sync the local repository, and cleanup stale worktrees.
State warning: Branch state, remote tracking, and PR status change between invocations. Re-run all git/gh commands from Step 1.
CRITICAL: Always check for open PRs, regardless of current branch.
# Check for PR from current branch
gh pr view --json state,number,title 2>/dev/null
# ALWAYS also check for any open PRs by the user
gh pr list --author @me --state open --json number,title,headRefName
For each open PR, check and report.
Run the canonical PR-readiness gate from /gh-cli-patterns.
Replace <OWNER>, <REPO>, <PR_NUMBER> per the placeholder legend in that skill.
Merge-ready criteria — all of the following must hold:
| Field | Required | Status |
|---|---|---|
state | OPEN | Not ready |
mergeable | MERGEABLE | Not ready |
mergeStateStatus | CLEAN or HAS_HOOKS | Not ready (BEHIND, BLOCKED, DIRTY, UNSTABLE, UNKNOWN, DRAFT) |
isDraft | false | Not ready |
reviewDecision | APPROVED or null | Not ready |
statusCheckRollup.state | SUCCESS | Not ready |
All reviewThreads.isResolved | true | Not ready — unresolved threads |
reviewThreads.pageInfo.hasNextPage | false | Not ready — >100 threads, paginate |
git fetch origin --no-tags --prune --forceorigin/HEAD, falling back to main or master.[gone] feature branch. Detect and fix:
git worktree list --porcelain,
matching on the branch refs/heads/<default> entry — do not rely on
basename matching of paths, since a feature branch named
feature/<default> would also produce a path basename of <default>.git -C <path> rev-parse --abbrev-ref HEAD does not equal
<default> (this is safer than symbolic-ref --short HEAD, which errors on
detached HEAD during a rebase or commit-checkout):
git -C <path> status --porcelain is non-empty), stash them first with
git -C <path> stash push -u -m "refresh-repo: auto-stash before <default> restore"
and surface the stash reference in the summary so the user can recover.git -C <path> checkout <default>.--force, never discard uncommitted work, never reset.git -C <path> so the merge always targets the default worktree regardless
of the current shell directory:
git -C <path> merge --ff-only origin/<default>.
If the default worktree is dirty or divergent, report it and skip instead of resetting.git branch -d.
Never delete main/master/develop/current branches, worktree-checked-out branches, or branches
with open PRs.git -C <path> to operate on the default worktree directly, the current shell's
working directory and branch were never changed — each worktree owns its checkout.Do not use git fetch --tags, git fetch --prune-tags, or git pull --tags during the
normal refresh. Tags are audited separately in Step 4 so local-only non-release tags and
tag rewrites are not deleted by a broad fetch refspec.
Treat origin as authoritative for release tags only.
Use native Git commands to compare local tags to remote tags:
git for-each-ref '--format=%(refname:short)' refs/tags
git show-ref --tags
git ls-remote --tags --refs origin
For local-only tags:
v[0-9]*, delete it with
git tag -d <tag>.For tags that exist both locally and on origin but point at different objects, report the mismatch and do not force-update it automatically. Never delete or rewrite remote tags.
Only remove a worktree if it is confirmed stale.
Stale definition: No open PR, no uncommitted changes, and either:
mergedAt) whose headRefOid matches the local branch HEAD
(gh pr list --state merged --head <branch> --json number,headRefOid,mergedAt)[gone] in git branch -vv) and it has no commits
ahead of the default branch (git log origin/<default>..HEAD --oneline is empty)Branches with open PRs, local-only branches without PRs, and worktrees with uncommitted changes are NEVER stale.
For each worktree from git worktree list:
git worktree remove <path> — NEVER use --forcegit branch -d <branch>.
If this fails only because a squash-merged branch is not reachable from local default,
use git branch -D <branch> only when the merged PR headRefOid matched the local
branch HEAD before removing the worktree.Finish with git worktree prune.
Report: PRs assessed as merge-ready (if any), tags deleted or reported, branches cleaned up, worktrees removed, default-branch worktree restorations (with any stash references created), current branch, and sync status.
Optional modes that change /refresh-repo from single-repo to workspace-wide.
Both modes reuse the stale-worktree definition from Step 5 and the deletion
rules from Step 5.7 — they only add new pre-filters, never weaken existing
safety.
--sweep [<repo-glob>]Multi-repo cleanup of abandoned local branches. For every default-branch
worktree in your workspace (caller can pass a custom glob if their layout
differs), resolve that repo's own default branch first (per Step 3 above —
main on trunk repos, develop on git-flow repos), then for every local
branch where git log origin/<default>..HEAD is non-empty:
origin/<default>. If every touched file is content-equivalent
to (or older than) origin/<default>, delete the branch and its worktree.
Already-on-the-default-branch contributions do not deserve a PR.grep -r <name> . returns
zero matches for, surface for human review. Do not open a draft.Origin: the 2026-05-22 sweep opened 8 dead PRs against ansible-splunk
(6 already-on-main duplicates, 2 workaround anti-patterns). Both filters
above would have caught all 8 before any CI ran.
--prune-stale <days> (default 60)Delete local branches with no open PR and no push activity within <days>.
Expands Step 5's stale definition with a time threshold; still respects every
safety rule (never delete branches with open PRs, uncommitted changes, or
the current checkout).
Per branch: if gh pr list --head <branch> is empty AND
git log -1 --format=%cr <branch> is older than <days>, run
git worktree remove <path> (per Step 5 — never --force) then
git branch -d <branch>.
Use --prune-stale 30 for an aggressive sweep, --prune-stale 90 for
conservative.
DO NOT skip the PR check just because you're on main. The user may have multiple open PRs from different branches.
Always run gh pr list --author @me --state open to find work that needs merging.
Do not use --prune-tags as a shortcut for tag cleanup. Git treats tag pruning as an
explicit refspec prune and can delete local-only tags that are not release artifacts.