logo
Published on

CH5. pr-workflow: from issue to post-merge cleanup

Authors
  • avatar
    Name
    seren-wib
    Twitter
Contents

0. Introduction

Part 5 of the series. What a skill is and why these rules moved out of the instruction file is in CH0. Skills overview.

pr-workflow is the skill an AI coding agent opens right before it creates an issue, cuts a branch, makes a commit or PR, merges, or cleans up branches. Its rules were scattered across six global memory files. The commit message gives one reason for the move: rules needed for only one kind of task should not sit in global memory all the time, but live in a skill that opens only when that task comes up.

In restaurant terms, you pin the order ticket first, cook at your own station, get the plate inspected before it goes to the floor, send plates to the pass one at a time, and clear the station when service ends. The recipe book that writes this order down is the skill, one plate is one PR, and each cooking step inside it is one commit. The order ticket is the issue, the station is the branch, the inspection is CI, the pass is the release branch, and clearing the station is the branch update.

On 2026-11-13 I gathered the six memory rules into one skill. This post goes through the rules in it (order of work, one PR at a time, splitting commits, rule docs first, branch update, sorting bot reviews), where each came from, and how the skill changed afterwards.

1. Order of work

Order of work: GitHub issue, branch, PR, merge after CI, branch update. A trivial change skips the issue

Order of work: issue → branch → PR → merge → branch update. Only trivial changes skip the issue

  1. Create a GitHub issue in the main repo.
  2. Branch from upstream main: in my fork for someone else's repo, inside the repo for my own.
  3. Link the issue in the PR body. Fixes #N when this PR finishes the issue (merging closes it automatically), Part of #N when one issue is handled by several PRs.
  4. Right after the merge, run a branch update so local main matches the remote. If the work was in a worktree, update the main checkout too. Follow-ups (a docs mirror and so on) come after that.

One task per PR. Unrelated tasks never get folded into one PR.

This order was born on 2026-10-31 in the team repo of a hackathon (Woowangthon). The agent opened a one-line README link PR with no issue, and I said the issue comes first. Then we looked at the usual practice together. Issues track work that needs discussion or visibility; a one-line change is its own record in the PR. So one exception was added.

Trivial (PR without an issue)Not trivial (issue first)
A typo, a single linkAnything that needs a decision
A one-line doc fix nobody else needs to know ofAnything that spans more than one sitting
Anything someone else might pick up

The agent judges the size. It never asks me "is this big enough for an issue?"; it decides and says which path it took. The same day someone suggested folding that link fix into an unrelated diagram PR. One PR has one purpose, so it was not folded in.

2. One PR at a time

One PR at a time: a PR that triggers a deploy is merged and its deploy checked before the next PR opens. Docs-only PRs may be open together if they do not overlap, with the merge order written in the body

PRs that deploy go in single file; docs-only PRs touching different files may be open together

  • Merge the current PR after CI passes and check its deploy before opening the next one.
  • Queued tasks go in the order asked. If a new request arrives mid-task, the current one is finished first unless I say otherwise.
  • While CI runs, prepare the next work locally. Locally, run only the changed tests plus format, type and migration checks. The full suite is CI's job.

The reason is a single one. Each change should land and deploy on its own, so the history and the deploys stay easy to follow afterwards. Once the agent read "merge the current PR first" as "merge both together", so the rule now says it outright.

The exception came on 2026-11-02 at Woowangthon. Docs-only PRs with no deploy may be open at the same time when they touch different files or lines; the later PR's body states the merge order. The skill series this post belongs to is exactly that exception: one PR per post, each creating different files, all open together and merged in number order.

Git Flow repos follow their own CONTRIBUTING.md. Usually main is the release (PR and CI required, merge commit, a merge deploys, tag vX.Y.Z) and develop is the default branch. feature/* goes into develop without waiting for CI. How Stairno switched to this is in the Git Flow section of Stairno part 3.

There is one repo-specific line too. For Stairno, production writes and merges that deploy are done by me. PRs on this blog the agent may merge.

3. Splitting commits

Splitting commits: refactor, a failing test, then feat commits pile up on one branch and become one PR

Inside one branch, refactor → test → feat slices pile up into one PR

  • One branch and PR = one feature a user can use. Its API, screen, tests and spec updates go in together. That is about 300 to 800 changed lines; past 1000, look for a place to split.
  • An adapter or small fix that only serves that feature is a commit on the same branch. No small PR whose only job is to unblock the next one.
  • Inside the branch, each slice is a failing test commit followed by a feat commit (TDD). Moves that keep behaviour the same are their own refactor commit before the pair. Each commit must be revertable on its own.
  • Stage explicit paths. Never git add -A. No record states the reason for this line.

The rule came after 14 small PRs, split finely by concern, did little but add CI and deploy waits. 300 to 800 lines is the size that lets a whole feature be reviewed and reverted at once without a CI and deploy wait for every piece.

4. Rule docs first

Rule docs before a restructure: PR 1 changes CLAUDE.md and the rule docs and is merged, then PR 2 moves the files

The rule-docs PR merges first; file moves come in the next PR

When a convention changes (naming, folder layout, paths), CLAUDE.md, the docs it imports and other instruction files are changed first, in a PR of their own. Only after that PR passes CI and merges does the move branch start.

This blog still shows it. On 2026-10-10, #44 changed one file only, docs/agent/publish_pipeline.md (13 lines added, 9 removed): post file names get a category prefix, and images are grouped in one folder per post. Later that day #45 moved 119 files by that rule.

There is a counter-example too. On 2026-11-28, #163, which added parent categories, carried the structure-doc commit and the post-move commit in the same PR. There is no record of why it was not split this time.

5. Branch update

Branch update: fetch --prune, ff main, push fork main, delete merged, drop stashes, plus the rule for spotting squash merges

The five steps of a branch update. Squash merges don't show up in git branch --merged, so the PR state decides

When I say "브랜치 갱신" (branch update), the agent does all of the following in one go, without asking about deletions.

  1. git fetch --prune on every remote.
  2. Fast-forward local main to upstream/main. Uncommitted edits are stashed, not discarded, and then checked against upstream.
  3. Push the fork's main to match.
  4. Delete merged branches both locally and on the remote (the fork, or origin in my own repos) with git push origin --delete <b>. Afterwards only main and branches still in progress remain.
  5. Drop stashes whose content is already in main.

It then reports deleted and kept branches in one short list, with a reason for each kept one.

Step 4 has two traps.

  • Squash merge. A squash merge puts a single new commit on main; the branch's own commits never land there. So git branch --merged can't find the merged branch, and the test is different: a branch counts as merged when its PR is MERGED and the PR's headRefOid (the last PR commit GitHub remembers) equals the branch tip, or the tip is already in upstream/main. If the tip is past the PR head, check whether those later commits already landed through another PR before deleting.
  • Worktree. git refuses git branch -D on a branch checked out in a worktree. So git worktree remove comes first, and git worktree prune at the end.

This section grew twice. On 2026-11-12 only local branches were deleted and the fork's remote branches were left behind; I said an update obviously includes the fork and asking before each deletion was unnecessary. So it became "the fork too, without asking". On 2026-11-19 one of my private repos had 24 local and 22 remote branches, 22 of them already merged. The rule only mentioned forks, so origin in my own repos was never cleaned. That day step 4 gained "or origin in my own repos", and step 4 of section 1, "branch update right after the merge", came in the same day. How the session carries on after a merge is in CH6. session-flow.

6. Sorting bot reviews

Bot reviews: bot comments sorted into right, half right and wrong, which are fixed, asked about and left out. Human reviews always get an answer

Bot comments go three ways; human reviews all get an answer

The AI review bot is something like CodeRabbit. Bot comments are advice, not a gate that blocks the merge.

  • First sort them into right / half right / wrong and show me.
  • Fix the right ones. Ask about the half-right ones. Leave the wrong ones out.
  • Reply to the bot only when I ask.
  • Human (teammate) reviews always get an answer, regardless of this sorting.

The rule comes from Woowangthon. Section 5 of the team repo's AGENTS.md said bot review is advice, not a gate, and the reason given was that following every comment bends the docs to the bot's taste and only adds commits. How the bot read proposal docs as implementation specs in the first week, kept asking for designs and got paused, is in Woowangthon part 1. On 2026-11-06 I also saw the bot review again on its own after a fix commit was pushed. That is the record that "one bot review per PR" was a wrong assumption.

7. How the skill changed

SKILL.md size per commit: it started at 5284 B, dropped to 4211 B when the SDLC section moved to project-docs, and is 4509 B now

SKILL.md size per commit. The biggest drop was 2026-11-16, when the SDLC section moved to project-docs

Before 2026-11-13 these rules lived in six global memory files (issue-first-workflow, one-pr-at-a-time, split-commits-by-feature, rule-docs-before-restructure, branch-update-cleanup, bot-review-triage). As of 2026-11-28, SKILL.md is 48 lines, 4509 B and 8 sections (##) (sources: git log, git show and wc in ~/dotfiles).

DateCommitChange
2026-11-13fa0ceb8Six memory rules into one skill (55 lines)
2026-11-132bc5f8f"Repo-specific" section added (Stairno and blog merge rights)
2026-11-16e1c18a0The 11-line Project SDLC section becomes a one-line pointer to project-docs
2026-11-193cff282Branch update right after a merge; a merge no longer closes the session
2026-11-19a82bb3aStep 4 of the branch update gains origin in my own repos

The SDLC section moved out when the new project-docs skill was made to hold the rules for the stage documents (SPMP, SRS, SDD, STP, SIP, SMP). That skill's story is in Project Docs 0.

8. Reflection

I gathered the rules scattered across global memory into one skill on 2026-11-13.