agentleFS
ritmillioritmillio/skills/skills/engineering/pr-fold/SKILL.md

pr-fold

Skill0 starsChanged 14 days agoMITView on GitHub

Fold several open PR branches into an integration or release branch: dry run for conflicts and migration prefix collisions, merge in a detached worktree, resolve with both sides' intent, gate what the fold touched, put cross-PR breakage in one seams commit, push the integration branch. Never a protected branch, never a GitHub merge. Use when the user says \"fold #N into ...\", \"put these PRs on the release branch\", or \"one release PR with all open PRs\".

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    When a founder ships through one release PR, someone has to fold the feature PRs into it.

    line 8
  2. Very specific:

    Never merge a PR on GitHub (no gh pr merge, no merge button, no API call), not even into the integration branch.

    line 19
  3. Very specific:

    Never fold in a shared checkout.

    line 22
  4. Distinctive:

    Check HEAD in the same command as every commit.

    line 24
  5. Distinctive:

    Never rename a PR's head branch.

    line 25
  6. Distinctive:

    Read the repo's migration rules before you renumber.

    line 47
  7. Distinctive:

    Keep a list of every hunk you resolved by hand: the file, what each side wanted, what you kept.

    line 54
  8. Very specific:

    Gates, scoped to what the fold touched: Use the Gates section of the config.

    line 63
  9. Very specific:

    Fold reds or inherited reds?: Run the same failing tests on origin/<target> in a second detached worktree (never git stash).

    line 66
  10. Distinctive:

    Remove the fold worktree when you are done (git worktree remove).

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/pr-fold: many PRs, one integration branch, still green

When a founder ships through one release PR, someone has to fold the feature PRs into it. Every rule below exists because a fold once went wrong: a protected branch got the merges, a wholesale "ours" dropped someone's keys, two migrations took the same number.

Hard stops

  • The target is never a protected branch: the repo's default branch, main, master, staging, development, production, plus whatever .agents/founderstack.md lists under branches:. fold.sh refuses them, and so do you.
  • Never merge a PR on GitHub (no gh pr merge, no merge button, no API call), not even into the integration branch. A fold is a local git merge and a push.
  • Never fold in a shared checkout. Work in a detached worktree of origin/<target>.
  • Check HEAD in the same command as every commit.
  • Never rename a PR's head branch; GitHub closes the PR.

Steps

$SKILL_DIR is this skill's folder; resolve it at runtime (where this SKILL.md lives).

  1. Resolve the target and the PRs. The target is the integration branch the user names, or the head of the release PR they name (gh pr view <n> --json headRefName). If a PR's author or relay is still committing, fold it at a pinned sha and say "re-fold from <sha>" later.
  2. Dry run. It predicts conflicts against the running tip, lists the touched areas and flags migration prefix collisions. It changes nothing.
    bash "$SKILL_DIR/scripts/fold.sh" --into release/1.4 [--migrations db/migrations] 601 586
    Exit 0 clean, 1 conflict, 2 migration prefix collision, 3 both, 4 refused or failed (read the message). Pass --migrations <dir> when the repo has numbered SQL migrations; without it, prefixes are not checked.
  3. Migration prefixes first. Two PRs adding the same NNNN_ prefix, or a PR adding a prefix the target already has, get renumbered during the fold. A migration renamed after it ran anywhere counts as a different migration. Read the repo's migration rules before you renumber.
  4. Apply in the detached worktree. It stops at the first conflict:
    bash "$SKILL_DIR/scripts/fold.sh" --into release/1.4 --apply 601 586
    Merge message: merge: #N <head-branch> into <target>.
  5. Resolve with both sides' intent, never "ours" or "theirs" wholesale. Keep a list of every hunk you resolved by hand: the file, what each side wanted, what you kept. Known shapes:
    • two implementations of the same idea: keep the later or more complete one and port what the other has uniquely;
    • two blocks added at the same spot: keep both, in a deliberate order;
    • a whole catalog or locale file in conflict: diff against the default branch afterwards, because taking one side drops the other's keys. Then git -C "$WT" commit --no-edit and rerun --apply with the PRs that are left.
  6. Gates, scoped to what the fold touched. Use the Gates section of the config; the dry run's areas tell you which ones apply. For a release fold, run the full suite once.
  7. Fold reds or inherited reds? Run the same failing tests on origin/<target> in a second detached worktree (never git stash). Only reds that pass on the base belong to the fold. Name inherited reds with the base sha, and do not fix them inside the fold.
  8. Seams. Breakage between PRs (one PR's new guard test fails on another PR's new route; a moved module the other PR still imports) goes into ONE separate commit: fix(merge): seams after folding #A, #B into <target>, with each seam listed in the body. Never hide seam fixes in a merge commit.
  9. Push and record. The script prints the push command. It checks first that nobody pushed meanwhile. If the ancestry check fails, merge origin/<target> in, gate again, and retry. Update the integration PR's body with the folded list (PR, head sha, conflicts resolved, seams). A source PR based on the target is marked merged by GitHub on its own. A source PR based on the default branch stays open unless the user asked for one release PR; then close it with a comment that links the integration PR.
  10. Remove the fold worktree when you are done (git worktree remove).

Reply

fold -> <target> @ <new head sha>   (base <old sha>)
PR     head sha   result         notes
#601   592eef6    merged         docs only
#593   1a2b3c4    conflicts 3    card: #594 kept, #593 planner ported
seams  <sha> fix(merge): ...     2 seams: ...
gates  typecheck 0 | tests: 2 reds inherited (base <sha>) | migrations ok
pushed <remote> HEAD:<target> | PR #602 body updated | #601 closed
Not checked: <what you did not run>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.