# Graysurf Agent Kit Close Feature Pr

> Close Feature PR

- Skill: `tomevault-io/graysurf-agent-kit-close-feature-pr` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/graysurf-agent-kit-close-feature-pr`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/graysurf-agent-kit-close-feature-pr/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/graysurf-agent-kit-close-feature-pr

---


# Close Feature PR

## Contract

Prereqs:

- Run inside the target git repo.
- `git` and `gh` available on `PATH`, and `gh auth status` succeeds.
- Working tree clean (`git status --porcelain=v1` is empty).

Inputs:

- PR number (or current-branch PR).
- Optional: whether to skip checks (`--skip-checks`).

Outputs:

- PR merged (default merge commit) and remote branch deleted.
- Local checkout switched back to base branch and updated; local feature branch deleted (best-effort).

Exit codes:

- `0`: success
- non-zero: checks failing, PR not mergeable, auth issues, or git/gh command failures

Failure modes:

- PR is draft and automatic `gh pr ready` fails.
- Required checks failing or branch not mergeable.
- Missing `gh` auth or insufficient permissions.

## Setup

- Ensure `gh auth status` succeeds.

## When to use

- The user asks to merge/close a PR and clean up the feature branch.

## Workflow

1. Identify the PR number
   - Prefer current branch PR: `gh pr view --json number -q .number`
2. Preflight
   - Ensure working tree is clean: `git status --porcelain=v1` should be empty
   - Ensure checks pass: `gh pr checks <pr>`
   - Ensure PR is not draft: `gh pr view <pr> --json isDraft -q .isDraft` should be `false`; if `true`, run `gh pr ready <pr>`
     automatically, then continue to merge.
   - if `true`, run `gh pr ready <pr>` automatically, then continue to merge.
3. Review PR hygiene (aligned with `create-feature-pr`)
   - Title reflects feature outcome; capitalize the first word.
   - PR body includes: `Summary`, `Changes`, `Testing`, `Risk / Notes`.
   - If PR body includes `Open Questions` and/or `Next Steps` and they are not already `- None`, update them to the latest status (resolve
     questions or confirm with the user, check off completed steps, link follow-ups).
   - `Testing` records results (`pass/failed/skipped`) and reasons if not run.
   - If edits are needed: use `gh pr edit <pr> --title ...` / `gh pr edit <pr> --body-file ...`.
4. Merge and delete branch
   - Default merge method: merge commit
   - `gh pr merge <pr> --merge --delete-branch`
5. Local cleanup
   - Resolve refs:
     - `baseRefName="$(gh pr view <pr> --json baseRefName -q .baseRefName)"`
     - `headRefName="$(gh pr view <pr> --json headRefName -q .headRefName)"`
   - `git switch "$baseRefName" && git pull --ff-only`
   - Delete local feature branch if it still exists: `git branch -d "$headRefName"`

## Optional helper script

- Use `$AGENT_HOME/skills/workflows/pr/feature/close-feature-pr/scripts/close_feature_pr.sh` in this skill folder to run a deterministic
  merge + cleanup.
- If `$AGENT_HOME/skills/workflows/pr/feature/close-feature-pr/scripts/close_feature_pr.sh` fails, 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.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/graysurf) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

