name: pr description: Create a pull request with cleanup, fmt, and test gates disable-model-invocation: true
Open a pull request for the current branch. This is the only sanctioned path
to PR creation — a pr-skill-gate hook blocks any direct gh pr create that
doesn't carry this skill's bypass marker.
Optional arguments: $ARGUMENTS
Instructions
Each phase has a gate. Do not proceed until it passes.
Phase 1: Sync state
Run in parallel:
git status— warn if uncommitted changes (but proceed; the cleanup phase may add commits anyway).BASE=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||' || echo main)— detect default branch.git branch --show-current— current branch.git rev-parse --abbrev-ref @{upstream} 2>/dev/null— does it track a remote?git log --oneline $(git merge-base HEAD "$BASE")..HEAD— commits on this branch.git diff --name-only "$BASE"...HEAD— files changed vs base. Save this list — it's the input to Phase 3.
Gate: You have the changed-file list and the base branch.
Phase 2: Clean up scratch artifacts
Delete transient files left over from implementation, testing, and discovery — screenshots, Playwright MCP output, and tmp scratch — before the cleaner pass inspects the diff. Untracked only. Never touch tracked or staged files.
Identify untracked artifacts. Use
git ls-files --others --exclude-standardfor unignored untracked files, andgit ls-files --others --ignored --exclude-standardfor ignored untracked files. Filter for these patterns:*.pngat the repo root only — these are typically Playwright/visual-audit screenshots. PNGs inside subdirectories (build outputsout/,dist/,build/, asset dirspublic/,static/, source dirssrc/, etc.) are legitimate and must NOT be deleted..playwright-mcp/(directory)*.tmp(anywhere)tmp/(directory, when at repo root or inside a subproject root)
Show the user the list of files about to be deleted (one line each). If the list is empty, skip the rest of this phase.
Delete them. For files:
rm -f <path>. For directories:rm -rf <path>. Run from the repo root.Verify with
git status --porcelain— none of the deletions should appear, because every removed path was untracked. If any tracked file shows as deleted, stop and surface it to the user (something matched a tracked path; the patterns above are wrong for this repo).
Gate: No matching untracked artifacts remain in the worktree, and git status shows no unexpected tracked-file deletions.
Phase 3: Refactor-cleaner pass on the branch diff
- Spawn the
refactor-cleaneragent (run_in_background: false) with the changed-file list from Phase 1 as scope. Pass file paths explicitly — don't let it roam the whole repo. - If the cleaner edited files:
- Run
make test. If it fails, fix the regression before continuing. - Commit:
git add -u && git commit -m "chore: ai-fmt".
- Run
- If the cleaner made no changes, skip the commit.
Then prune implementation-only tests. The cleaner above never touches tests — this step does.
- From the Phase 1 changed-file list, take only the test files this branch ADDED or MODIFIED — identify tests by their role, not a fixed extension list. Never consider pre-existing tests.
- Remove cases that exist only to scaffold the implementation and add no regression value: trivial assertions (constructor returns non-nil, plain getters/setters, framework behavior), placeholder /
assert truestubs, and cases fully subsumed or duplicated by another retained test. NEVER remove a test that is the sole coverage of a behavior, branch, edge case, error path, or regression — if unsure the coverage is unique, keep it. - Report each removed test, one line with its rationale (trivial / subsumed-by-X / duplicate).
- Run
make test— must stay green. Commit the removals on their own:git add -A && git commit -m "test: remove implementation-only tests". - If nothing qualifies, skip silently.
Gate: Cleaner changes (if any) are committed and green; implementation-only tests are pruned in their own commit (or none qualified); no sole-coverage test was removed; make test passes.
Phase 4: make fmt
Check if the target exists first: make -n fmt >/dev/null 2>&1.
If the target exists: run
make fmt. Then checkgit status --porcelain. If anything changed, runmake test, then commit withgit add -u && git commit -m "chore: fmt". If nothing changed, skip the commit.If no Makefile exists, or no
fmttarget: surface this hint to the user, then proceed:No
make fmttarget found in this repo. Recommend adding one — even a thin wrapper around the language-native formatter (gofmt -w .,ruff format,prettier --write,cargo fmt, etc.) is enough to make this gate work and keeps formatting deterministic across contributors. Want me to add it now? (Y/n)If the user says yes, add the target before opening the PR (a separate
chore: add make fmt targetcommit). If no, proceed without formatting.
Gate: Either make fmt ran clean, or the user has been notified the target is missing.
Phase 5: make test
Check if the target exists first: make -n test >/dev/null 2>&1 (also accept test-fast per the test-gate hook's preference order).
If the target exists: run it — must pass. If it fails, stop. Do not push a broken branch. Fix the failure (likely a separate
fix:commit) and re-run.If no Makefile exists, or no
test/test-fasttarget: surface this hint to the user, then proceed:No
make testtarget found in this repo. Recommend adding one (e.g.test: ; <runner>) so the PR gate can verify changes pass before opening the PR. Want me to add it now? (Y/n)If yes, add it (separate
chore: add make test targetcommit) and run it. If no, proceed but note in the PR body that tests were not gated.
Gate: Either tests are green, or the user has been notified the target is missing and accepted that trade-off.
Phase 6: Draft, push, and create
Compose the PR using all commits on the branch (not just the latest):
- Title: ≤70 chars, conventional format
<type>: <description>. Pick the type that matches the primary change. - Summary: 1–3 bullets — what changed and why. The "why" matters more than the "what".
- Test plan: bulleted checklist of how to verify.
If no upstream:
git push -u origin $(git branch --show-current). If upstream exists but is behind:git push.Create the PR. The
AGENT_DASHBOARD_PR_SKILL=1prefix is mandatory — without it thepr-skill-gatehook blocks the call:AGENT_DASHBOARD_PR_SKILL=1 gh pr create --title "<title>" --body "$(cat <<'EOF' ## Summary <bullets> ## Test plan <checklist> EOF )"Return the PR URL.
Gate: PR is open. URL displayed.
Red Flags — STOP
- "I'll just call
gh pr createdirectly" → the hook will block you. Use the prefix. - "Skip the cleaner, the diff looks clean" → don't. The cleaner is the whole point of this skill.
- "Tests fail but my changes are unrelated" → fix or revert. Never push red.
- "I'll bundle the fmt diff into the feature commit" → keep
chore: fmtandchore: ai-fmtas their own commits; squash happens at merge.