close-progress-pr
Finalize and archive a progress file for a GitHub PR: locate the related docs/progress file (prefer PR body Progress link), set Status to DONE, move it to docs/progress/archived/, update docs/progress/README.md, merge the PR with gh, patch the PR body Progress link to point to the base branch so it survives branch deletion, and (when present) patch the planning PR body to include an Implementation PR link. Use when a feature PR is ready to be closed and its progress tracking should be marked DONE.
When & Why to Use This Skill
This Claude skill automates the end-to-end lifecycle of closing a GitHub Pull Request while maintaining rigorous documentation standards. It solves the problem of fragmented project tracking by automatically archiving progress files, updating README indexes, and patching PR links to ensure they remain functional after branch deletion, effectively bridging the gap between code merging and project status reporting.
Use Cases
- Finalizing feature development by automatically moving progress logs from active to archived status and updating the project's central README.
- Ensuring documentation link integrity by repointing PR body links to the base branch (e.g., main) so that references don't break when the head branch is deleted post-merge.
- Maintaining traceability between planning and execution by automatically linking implementation PRs back to their original planning documents or PRs.
- Streamlining repository maintenance by combining git merge operations with automated documentation cleanup in a single, error-proof workflow.
| name | close-progress-pr |
|---|---|
| description | "Finalize and archive a progress file for a GitHub PR: locate the related docs/progress file (prefer PR body Progress link), set Status to DONE, move it to docs/progress/archived/, update docs/progress/README.md, merge the PR with gh, patch the PR body Progress link to point to the base branch so it survives branch deletion, and (when present) patch the planning PR body to include an Implementation PR link. Use when a feature PR is ready to be closed and its progress tracking should be marked DONE." |
Close Progress PR
Contract
Prereqs:
- Run inside the target git repo with a clean working tree.
gitandghavailable onPATH, andgh auth statussucceeds.- Target PR has a
## Progresslink in its body (preferred) or the progress file contains the PR URL.
Inputs:
- PR number (or current-branch PR).
- Progress file under
docs/progress/referenced by the PR.
Outputs:
- Progress file finalized (
Status: DONE), moved todocs/progress/archived/, and indexed indocs/progress/README.md. - PR merged (default merge commit) and branch deleted.
- PR body
## Progresslink patched to point to base branch (survives branch deletion).
Exit codes:
0: success- non-zero: missing progress link/file, validation failures, or git/gh command failures
Failure modes:
- Unchecked checklist items missing
Reason:(fail-fast). - Progress file cannot be located or moved (path mismatch, conflicts).
- PR merge blocked (draft/checks failing/permissions).
Setup
- Ensure
gh auth statussucceeds. - Load local helper commands (optional):
source $AGENT_KIT_HOME/scripts/kit-tools.sh
Key rule: Progress links must survive branch deletion
After merge, GitHub often deletes the head branch. Any PR body link like:
https://github.com/<owner>/<repo>/blob/<head-branch>/docs/progress/...
will break.
Patch the PR body ## Progress link to point to the base branch (usually main) after merge:
https://github.com/<owner>/<repo>/blob/<base-branch>/docs/progress/archived/<file>.md
Key rule: Planning PRs should link to the implementation PR
If the progress file includes a Links -> Planning PR entry, ensure that planning PR body includes an ## Implementation section linking to the implementation PR (this PR).
Workflow
- Identify the PR number
- Prefer current branch PR:
gh pr view --json number -q .number
- Prefer current branch PR:
- Preflight
- Ensure working tree is clean:
git status --porcelain=v1should be empty - Ensure checks pass (optional but recommended):
gh pr checks <pr> - If PR body includes
Open Questionsand/orNext Stepsand they are not already- None, update them to the latest status before merge (resolve questions or confirm with the user, check off completed steps, link follow-ups).
- Ensure working tree is clean:
- Locate the progress file
- Prefer parsing the PR body
## Progresslink and extractingdocs/progress/... - If missing, fallback: search by PR URL inside
docs/progress/:pr_url="$(gh pr view <pr> --json url -q .url)"rg -n --fixed-string "$pr_url" docs/progress -S
- Prefer parsing the PR body
- Finalize progress
- Update the progress file:
- Fail-fast if any unchecked checklist item under
## Steps (Checklist)lacks aReason:(excluding Step 4 “Release / wrap-up”) - For intentionally deferred / not-do items (Steps 0–3), prefer marking the item text with Markdown strikethrough (
~~like this~~) while keeping the checkbox unchecked, and include an explicitReason: - Set Status to
DONE - Update the
Updateddate to today - Set
Links -> PRto the PR URL - Ensure
Links -> DocsandLinks -> Glossaryare Markdown links (not backticks) that resolve to existing files - If there are no related docs for this PR, set
Links -> DocstoNone(do not guess a random file)
- Fail-fast if any unchecked checklist item under
- Move it to
docs/progress/archived/<file>.mdif not already archived - Update
docs/progress/README.md(move row to Archived; keep Archived sorted newest-first byDate; set PR link to[#<number>](<url>); best-effort if table format differs)
- Update the progress file:
- Commit and push these changes to the PR branch
- Merge and delete branch
- Default merge method: merge commit
gh pr merge <pr> --merge --delete-branch
- Post-merge: patch PR body links to base branch
- Get base branch:
gh pr view <pr> --json baseRefName -q .baseRefName - Update
## Progressto:https://github.com/<owner>/<repo>/blob/<baseRefName>/docs/progress/archived/<file>.md
- Get base branch:
- Post-merge: patch planning PR (when present)
- Extract planning PR from the progress file
Links -> Planning PR - Ensure the planning PR body contains:
## Implementation- [PR #<feature_pr_number>: <feature_pr_title>](<feature_pr_url>)
- Extract planning PR from the progress file
Optional helper script
- Use
scripts/close_progress_pr.shin this skill folder to run a deterministic version of steps 3–8. - If
scripts/close_progress_pr.shfails, attempt to fix the underlying cause (prefer fixing the script when it's a script bug, otherwise fix the documented prerequisites/workflow), re-run it, and explicitly report whether the fix succeeded.