/ceh-git-workflow:pull-requestfrom ceh-git-workflow
Load this skill when a branch is heading into main: open a PR, "merge it", "land this", or before you run `gh pr create` or `gh pr merge` yourself. Covers the PR body, pre-merge gate, merge, and cleanup. Not for shipping a version (use ceh-git-workflow:release).
Ships in ceh-git-workflow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Gets a branch into main through a merge commit: open the PR once the definition of done holds,
merge only on a green gate, then clean up and report whether the remote branch survived.
Pick the path from the request, then run only that path:
| Request | Path |
|---|---|
| "open a PR", "push this for review" | Open |
| "merge it", "land PR #N", "merge this branch" | Merge |
| "commit, PR and merge", "wrap up this branch" | Land the branch |
Check the definition of done for the change type and the author self-review.
Write the body to a temp file using the template, then:
git push -u origin <branch-name>
gh pr create --title "<type>(<scope>): <short summary>" --body-file body.md
rm body.md
if [ "$(gh api repos/{owner}/{repo} --jq .allow_auto_merge)" = "true" ]; then
gh pr merge --merge --auto # queues; lands when CI + approvals go green
fi
gh api repos/{owner}/{repo} --jq .delete_branch_on_merge # false: the branch survives
Record the PR in its build plan. The plan folder is .agents_workspace/product/plan/
(also the older plans/ beside it), unless the repo's CLAUDE.md names another plan folder. The plan is the one the user names,
or else the one in that folder whose record has a Built Phase entry with no PR entry after
it. Append - YYYY-MM-DD PR: #<n> <url> to the ## Record section at the end of that plan.
The plan then traces its change to the review that landed it. With no such plan, skip this
step. A plan with a <slug>.yaml beside its .md is a plan/v2 plan: append to the YAML's
record list instead, as date: YYYY-MM-DD, event: PR, and details: "#<n> <url>",
quoted because a bare # starts a YAML comment, and never edit its generated .md. Make no
source commit for the plan, wherever its folder is. When the .md did not change, because the hook that renders it
(ceh-build-plan) is not installed, say so in the reply.
Open as a draft while CI runs or the work is still settling, and mark it ready only once the self-review passes. A draft is safe to queue: auto-merge waits until the PR is marked ready. Request the reviewers the approval rules require.
Check the pre-merge gate. If the branch won't merge cleanly,
resolve conflicts first. Once CI is green, tick the body's
All CI checks pass box, also when auto-merge already landed the PR:
gh pr view <N> --json body -q '.body | split("- [ ] All CI") | join("- [x] All CI")' > body.md
gh pr edit <N> --body-file body.md && rm body.md
Merge, leaving the merge commit message to the repo's setting:
if [ "$(gh api repos/{owner}/{repo} --jq .allow_auto_merge)" = "true" ]; then
gh pr merge <N> --merge --auto
else
gh pr merge <N> --merge # gate must be green
fi
With no PR (solo repo, low-risk work), merge locally. Still --no-ff, never fast-forward, so
the branch still lands as one merge commit that reverts as a unit:
git checkout <branch-name> && git fetch origin && git rebase origin/main
git checkout main && git pull origin main
git merge --no-ff <branch-name>
git push origin main
In a worktree (git rev-parse --git-dir differs from git rev-parse --git-common-dir),
git checkout main fails because the main checkout holds main. Build the merge on a detached
HEAD instead:
git fetch origin && git rebase origin/main
git checkout --detach origin/main
git merge --no-ff <branch-name>
git push origin HEAD:main
Clean up once merged. In a worktree, skip this block: run only git fetch --prune, and tell
the user to pick remove at Claude Code's exit prompt. A branch that survives it, or a raw
git worktree add worktree, is cleaned up by this block run later from the main checkout.
Otherwise:
git checkout main && git pull origin main
git worktree list # a worktree on the branch blocks `branch -d`
git branch -d <branch-name> # lowercase: refuses an unmerged branch
git fetch --prune
git worktree prune # drops records of worktrees already deleted
Remove a worktree on the merged branch with git worktree remove <path> before branch -d.
Remove one this session created without asking. For any other, list it with its branch and
last commit and ask first: it may hold uncommitted work.
Changelog → README → commit → open → merge, on the branch you are already on. Each step gates the next.
main? Create a branch first with git checkout -b, which carries uncommitted work over.
Behind main? Rebase before opening, so the gate measures the right tree.## [Unreleased]: invoke the Skill tool with
skill="ceh-git-workflow:update-changelog" in Unreleased mode. A genuinely invisible change
(typo, test-only tweak) is the one exception; record the skip.gh run watch, never by polling by hand.The title is a Conventional Commits subject (imperative, lowercase, no trailing period, ≤ 72 chars). The repo's merge commit setting may use it as the merge commit subject.
## What
<One sentence: the change as an outcome for the reader, not a list of files.>
<The smallest before and after that shows it: command output, a screenshot, or a few diff lines.
Skip when there is nothing to show.>
## Why
<The problem or request that motivated it. Link the issue: Closes #NNN.>
## How
<Only the non-obvious decisions and the alternatives rejected. Skip if the diff explains itself.>
## Risk
<Two-way door (reverting the merge commit undoes it) or one-way (a migration, a published API,
rewritten or deleted data). Then the blast radius: what breaks, and for whom, if this is wrong.>
## Testing
<What you actually ran and added, so a reviewer can reproduce it. Never imply coverage you
didn't add.>
## Checklist
- [ ] All CI checks pass
- [ ] Tests added or updated for new behavior
- [ ] No new lint or type-check suppressions introduced
- [ ] No secrets or credentials in code
- [ ] Migrations (if any) are backward-compatible
- [ ] Decision record updated (if a durable decision was made)
- [ ] Attribution line included if AI tooling assisted
Attribution: end the PR body with the attribution.pr line the session's Git instructions supply,
verbatim. Never substitute a literal from this skill or from memory. If no line is supplied, or the
setting is false or empty, omit it and check the box.
Write the body to a temp file and pass --body-file, for gh pr create and gh pr edit alike.
Never inline it with a shell heredoc or a PowerShell here-string: the temp file avoids all quoting
and behaves the same in both shells.
| Change type | Bar |
|---|---|
| Bug fix | Root cause stated in the PR. A failing test reproduces the bug and now passes. Full suite green. Lint and type checks pass |
| Feature | Unit tests for new logic, integration tests for new API surface. Lint and type checks pass. No new suppressions |
| Refactor | No behavior change, proven by existing tests passing unchanged. No tests deleted to make it pass. PR names the structural problem |
Meet the repo's own coverage and type-check bars. Never lower strictness to pass them; fix the code.
git diff main...HEAD) before requesting review.TODO without a linked issue.main, scoped to one concern.| PR type | Recommended | Max |
|---|---|---|
| Bug fix | ≤ 200 LOC | 300 LOC |
| New feature | ≤ 400 LOC | 600 LOC |
| Refactor | ≤ 500 LOC | 800 LOC |
| DB migration | Migration file only; split app changes into a separate PR |
Over the guideline, split by layer (schema → service → API). Review quality falls with diff size: past these sizes a reviewer skims instead of verifying. A migration ships alone because the schema has to deploy and roll back independently of the app code.
main as written, and
the per-PR history is kept on purpose: each PR stays one revertable unit on main, and its
commits stay available to bisect. Keep each commit Conventional Commits format and clean the
branch as you go.--delete-branch. Claude Code's permission classifier reads it as destructive
and blocks the whole command, so the merge fails. Remote cleanup is left to the repo's
"Automatically delete head branches" setting.Do not merge until all hold: CI green, required approvals met, rebased on latest main, history
clean (fixup/WIP/debug commits squashed or dropped). With no PR, the gate is whatever signals
exist: rebased, clean history, local checks green.
A rebase or conflict fix after review can change what was reviewed without touching a check. When a review or local test run finishes, record the change's patch id, and compare it again right before merging:
git diff origin/main...HEAD | git patch-id --stable # first field is the id
The same id means the reviewed change is what lands, whatever the commit SHAs. A different id means the content moved: re-request review, or re-read the diff and rerun the local checks with no reviewer.
Read CI with gh run, anchored to the commit, never the branch:
gh run watch "$(gh run list -c "$(git rev-parse HEAD)" -L1 --json databaseId -q '.[0].databaseId')" --exit-status
gh run view <run-id> --log-failed # why it went red
Three traps make a red build look green or a green one look broken:
gh pr checks and --json statusCheckRollup return HTTP 403 with a fine-grained PAT lacking
checks=read. That is a permissions error, not a red gate. Use gh run instead.gh api .../commits/<sha>/status returns 200 but is the legacy Statuses API, which Actions
never writes to: pending, total_count: 0, forever. Never gate on it.gh run sees only this repo's Actions. Third-party checks (Codecov, Sonar, GitHub Apps) need
the rollup or a manual check.gh pr view <N> --json mergeStateStatus works without checks=read and is a valid gate, but
UNSTABLE cannot tell a pending optional check from a failing one. Use it to gate, gh run to
diagnose.
Rebase on main and resolve there, never inside the merge commit, where the resolution escapes
review and CI:
git fetch origin && git rebase origin/main
git add <file> && git rebase --continue # per resolved file
git push --force-with-lease # your own branch only
The gate applies to the rebased state: let CI re-run before merging.
A PR merge takes its message from the repo's GitHub setting for merge commits (Settings →
General → Pull Requests → Default commit message). Never pass --subject, --body, or
--body-file to gh pr merge, because they override that setting.
A local merge, with no PR and no setting, reads on its own in git log main:
Merge branch '<branch-name>': <the branch's Conventional Commits subject>
<one or two lines: what it delivers and why it is landing, plus anything a bisect would want>
Never claim the remote branch was deleted without checking
gh api repos/{owner}/{repo} --jq .delete_branch_on_merge:
true: the PR merged and GitHub deleted the remote branch.false: the PR merged and the remote branch still exists. Give the command that removes it:
git push origin --delete <branch-name>.Report the same when auto-merge is only queued: the branch outlives the queue either way.
ceh-git-workflow:release.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cheneeheng/ceh-claude-code-library --plugin ceh-git-workflow8 skills in this plugin
/address-review-commentsLoad this skill when acting on review feedback left on your change: verify each comment, fix what holds, push back with evidence on what does not, reply to every thread. Trigger on "address these review comments", "fix the review feedback", "the reviewer said"./commitLoad this skill when making a git commit or writing its message: Conventional Commits type and scope, subject line, body, and footers for breaking changes and issue references./releaseLoad this skill when shipping a version: bump, changelog, land it, tag, publish the GitHub release. Trigger on "cut a release", "bump the version", "tag a release", "hotfix", or a version field changing in a project manifest. Not for a branch with no version (use ceh-git-workflow:pull-request).