From d771c3200e0024a9a7d125a1b9b3fd3036c6e93f Mon Sep 17 00:00:00 2001 From: Vladimir Bragin Date: Sat, 28 Nov 2026 19:35:19 -0600 Subject: [PATCH 1/2] feat(skills): add fast-forward to level the default branch and land changes Captures the fetch -> --ff-only pull -> branch commit -> PR -> pinned merge -> fast-forward sequence used on synth-term (#32), with the guards it needed: stop when incoming commits touch dirty files, never push or force the default branch, leave untracked files alone, name the repo on every gh call, merge pinned to the full SHA, merge origin and regenerate on conflict, end at 0/0 and delete the branch with -d. Refs scf-sh3h2 Co-Authored-By: Claude Opus 5.5 --- .agent/SKILL_INVENTORY.md | 3 +- .agent/setup/library.json | 7 ++ .agents/skills/fast-forward/SKILL.md | 116 ++++++++++++++++++ .claude/skills/fast-forward/SKILL.md | 116 ++++++++++++++++++ .cursor/skills/fast-forward/SKILL.md | 116 ++++++++++++++++++ docs/agent-asset-inventory.md | 1 + .../fast-forward-lands-through-pinned-pr.json | 27 ++++ 7 files changed, 385 insertions(+), 1 deletion(-) create mode 100644 .agents/skills/fast-forward/SKILL.md create mode 100644 .claude/skills/fast-forward/SKILL.md create mode 100644 .cursor/skills/fast-forward/SKILL.md create mode 100644 evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json diff --git a/.agent/SKILL_INVENTORY.md b/.agent/SKILL_INVENTORY.md index 241a1ca..3cc3e75 100644 --- a/.agent/SKILL_INVENTORY.md +++ b/.agent/SKILL_INVENTORY.md @@ -1,6 +1,6 @@ # Skill inventory — ${PROJECT_NAME} -**Last reviewed:** 2026-11-28. Companion to [SKILL_CHANGE_AST10_REVIEW.md](SKILL_CHANGE_AST10_REVIEW.md) +**Last reviewed:** 2026-11-29. Companion to [SKILL_CHANGE_AST10_REVIEW.md](SKILL_CHANGE_AST10_REVIEW.md) and [SKILL_COMPILATION.md](SKILL_COMPILATION.md). Update this file (new row or **Last reviewed** date) in the same PR as any skill change. @@ -26,6 +26,7 @@ commands or edit code/config as part of its procedure. | cross-pc-ssh | Work in the same repository on a paired Windows PC over SSH: locate the peer checkout by root commit and normalized origin (any drive or root folder), re-verify it before each command, read-only status/ls/cat (secret-looking files refused)/allowlisted git, and a headless `claude -p` (Read/Grep/Glob only) or `codex exec -s read-only` (`--allow-edits` only with user approval). All remote strings travel as base64; paths stay inside the checkout; no key or sshd setup; remote-PowerShell quoting reference | L2 | 2026-11-27 | | repo-inventory | Compare checkouts of the same repos across PCs: snapshot a projects folder (remote key, default branch and origin SHA, HEAD, branches with ahead/behind/gone/unpushed, worktrees, dirty counts, stashes, in-progress ops) with read-only git, exchange it through the share (`private/host-profile/repos-.json`, atomic), over ssh or as a 16 KB digest, then compare hosts (exit 1 on drift) and print a SAFE / NEEDS HUMAN sync plan it never runs. Repos match by normalized remote plus an alias map for renames | L2 | 2026-11-27 | | commit-and-push | Stage, commit, and push with git safety rules; pairs with release-bump (**compiled harness**) | L2 | 2026-11-19 | +| fast-forward | Level the default branch with origin and land the intended tracked changes: fetch, `--ff-only` pull (stop on overlap with dirty files), commit staged-by-path changes on a short-lived branch, push, PR against the repo's own default branch, merge pinned to the full SHA (merge origin and regenerate on conflict, no force), fast-forward to 0/0, `branch -d`. Untracked files untouched. User-typed only | L2 | 2026-11-29 | | critical-commit-audit | Deep post-commit hunt for high-severity bugs | L2 | 2026-07-01 | | eval | Capture task quality signals to agent memory (**compiled harness**) | L2 | 2026-07-21 | | export-chat | Export the Cursor agent transcript to Markdown or the clipboard, like Claude Code `/export` | L2 | 2026-10-01 | diff --git a/.agent/setup/library.json b/.agent/setup/library.json index 13efbd2..93664ea 100644 --- a/.agent/setup/library.json +++ b/.agent/setup/library.json @@ -78,6 +78,13 @@ "global": true, "projects": [] }, + { + "id": "fast-forward", + "source": ".claude/skills/fast-forward", + "pack": "global", + "global": true, + "projects": [] + }, { "id": "commit-conventions", "source": ".claude/skills/commit-conventions", diff --git a/.agents/skills/fast-forward/SKILL.md b/.agents/skills/fast-forward/SKILL.md new file mode 100644 index 0000000..528db98 --- /dev/null +++ b/.agents/skills/fast-forward/SKILL.md @@ -0,0 +1,116 @@ +--- +name: fast-forward +description: "Bring the default branch of the current repository level with its remote and land the local work that belongs there: fetch, fast-forward the default branch, commit the intended tracked changes on a short-lived branch, push it, open a PR against the repository's own default branch, merge it pinned to the pushed commit, fast-forward the local default branch to the merge, and delete the branch. Leaves untracked and unrelated files alone. Runs only when the user types /fast-forward." +capability: "Sync a checkout's default branch with origin and land its intended tracked changes through a pinned PR merge, never by force or a direct push to the default branch." +side_effect_level: remote_write +approval_required: true +requires_tools: "git and gh, authenticated for the repository's own remote." +output_schema: "The default branch's position before and after (ahead/behind counts and short SHAs), what was committed (paths and the commit), the PR and its merge commit, the final ahead/behind of 0/0, and every file left untouched with the reason." +risk_class: medium +disable-model-invocation: true +--- + +# Fast-forward + +`/fast-forward` means: **make my default branch match the remote, and land the work that belongs on it.** +Typing it approves one commit of the intended tracked changes, one push of a new branch, one PR and its +merge. It is not standing approval, and it never force-pushes, rewrites history or pushes straight to the +default branch. + +How this differs from neighbours: +- `commit-and-push` commits and pushes a branch; it doesn't merge or fast-forward the default branch. +- `/merge-pr` and `/ship-pr` merge an existing PR on CI evidence. `/fast-forward` opens its own small PR + and merges it in the same run, so keep it for changes that need no review: tracker snapshots, + generated files, docs the user already approved. +- `sync-upstream-fork` brings an upstream repository **into** a fork. `/fast-forward` only talks to the + repository's own `origin`. + +## 1. Confirm the target + +- **The repository and its default branch.** Read `gh repo view --json nameWithOwner,defaultBranchRef` + for `origin`. In a fork, `gh` defaults to the parent repository, so name the repository on every + `gh` call (`--repo /`). If the project's notes name a read-only upstream, never write to it. +- **This checkout is on the default branch,** or can switch to it cleanly. If it's on another branch + with work in progress, stop and ask; that branch isn't yours to move. +- **Another session may share this checkout.** If one is active here (`ListAgents`, a held tracker ticket, + a running build), ask before switching branches. + +## 2. Fetch and fast-forward + +```bash +git fetch origin +git rev-list --left-right --count HEAD...origin/ # " " +``` + +- **Behind only (`0 N`):** `git pull --ff-only origin `. Dirty tracked files are fine when the + incoming commits don't touch them. Check with `git log HEAD..origin/ -- ` first. + If they do touch them, stop and report the overlap; don't stash, reset or merge over someone's edits. +- **Ahead (`N 0` or `N M`):** local commits exist on the default branch. Don't push them directly. Move + them to the step-3 branch (`git switch -c `, then reset the default branch to + `origin/` only after the branch holds them), or stop and ask if they aren't clearly the user's. +- **Never** `git pull` without `--ff-only`, and never `--rebase` or `--force` on the default branch. + +## 3. Commit the intended changes on a branch + +- **Decide what belongs.** List `git status --short`. Commit only tracked changes the user's request + covers, or that this run produced: a tracker snapshot, a regenerated file. Show the diff stat. +- **Untracked files stay untracked** unless the user names them. They are often local notes, exports, + device presets or machine config (`mcp_config.json`, `*.local.*`, `.env*`). List them in the report. +- **Secrets check:** no tokens, keys or machine-local paths in the staged diff (`git diff --cached`). +- Branch `chore/-` (or the project's pattern, such as `af/-`). Stage + paths explicitly (`git add `, never `git add -A`), and commit with a Conventional Commit message + and the attribution lines the session asks for. +- Nothing to commit? Skip steps 3–5 and report that the default branch only fast-forwarded. + +## 4. Push and open the PR + +```bash +git push -u origin +gh pr create --repo / --base --head --title "" --body-file +``` + +The body says what changed and why it needs no review. Reference the ticket (`Refs `) when the +project tracks work. + +## 5. Merge pinned to the pushed commit + +- Wait about five minutes after the push for checks to register. A required check that's pending or + failing, `mergeStateStatus` `BLOCKED`, or a conflict means stop. Hand it to `/ship-pr` or the user. +- Use the method the repository's recent PRs used, pinned to the **full 40-character SHA** (a short SHA + is rejected): + + ```bash + gh pr merge --repo / --merge --delete-branch --match-head-commit $(git rev-parse HEAD) + ``` +- **"The merge commit cannot be cleanly created":** the default branch moved. Fetch, merge + `origin/` into the branch, and resolve the conflicts. Regenerate generated files rather than + hand-merging them. Re-run the checks, push (no force), then merge again on the new head. + +## 6. Fast-forward the local default branch + +```bash +git switch +git pull --ff-only origin +git rev-list --left-right --count HEAD...origin/ # must print "0 0" +git branch -d # -d, not -D: it must be merged +``` + +`gh pr merge --delete-branch` removes the remote branch and often switches the local checkout. Check +`gh pr view --json state,mergeCommit` rather than trusting its exit code. + +## Report + +```markdown +**** is level with origin at (was ahead, behind). + +- Committed as on ; PR # merged as ; branch deleted. +- Left untouched: . +``` + +## Never + +- Push directly to the default branch, force-push, rebase or reset a branch with others' work. +- Stash, discard or commit files the user didn't ask for, including untracked ones. +- Merge past a pending or failing required check, a `BLOCKED` state or a requested change. +- Open the PR against an upstream or parent repository the project treats as read-only. +- Delete a branch with `-D`, or delete a branch that isn't merged. diff --git a/.claude/skills/fast-forward/SKILL.md b/.claude/skills/fast-forward/SKILL.md new file mode 100644 index 0000000..528db98 --- /dev/null +++ b/.claude/skills/fast-forward/SKILL.md @@ -0,0 +1,116 @@ +--- +name: fast-forward +description: "Bring the default branch of the current repository level with its remote and land the local work that belongs there: fetch, fast-forward the default branch, commit the intended tracked changes on a short-lived branch, push it, open a PR against the repository's own default branch, merge it pinned to the pushed commit, fast-forward the local default branch to the merge, and delete the branch. Leaves untracked and unrelated files alone. Runs only when the user types /fast-forward." +capability: "Sync a checkout's default branch with origin and land its intended tracked changes through a pinned PR merge, never by force or a direct push to the default branch." +side_effect_level: remote_write +approval_required: true +requires_tools: "git and gh, authenticated for the repository's own remote." +output_schema: "The default branch's position before and after (ahead/behind counts and short SHAs), what was committed (paths and the commit), the PR and its merge commit, the final ahead/behind of 0/0, and every file left untouched with the reason." +risk_class: medium +disable-model-invocation: true +--- + +# Fast-forward + +`/fast-forward` means: **make my default branch match the remote, and land the work that belongs on it.** +Typing it approves one commit of the intended tracked changes, one push of a new branch, one PR and its +merge. It is not standing approval, and it never force-pushes, rewrites history or pushes straight to the +default branch. + +How this differs from neighbours: +- `commit-and-push` commits and pushes a branch; it doesn't merge or fast-forward the default branch. +- `/merge-pr` and `/ship-pr` merge an existing PR on CI evidence. `/fast-forward` opens its own small PR + and merges it in the same run, so keep it for changes that need no review: tracker snapshots, + generated files, docs the user already approved. +- `sync-upstream-fork` brings an upstream repository **into** a fork. `/fast-forward` only talks to the + repository's own `origin`. + +## 1. Confirm the target + +- **The repository and its default branch.** Read `gh repo view --json nameWithOwner,defaultBranchRef` + for `origin`. In a fork, `gh` defaults to the parent repository, so name the repository on every + `gh` call (`--repo /`). If the project's notes name a read-only upstream, never write to it. +- **This checkout is on the default branch,** or can switch to it cleanly. If it's on another branch + with work in progress, stop and ask; that branch isn't yours to move. +- **Another session may share this checkout.** If one is active here (`ListAgents`, a held tracker ticket, + a running build), ask before switching branches. + +## 2. Fetch and fast-forward + +```bash +git fetch origin +git rev-list --left-right --count HEAD...origin/ # " " +``` + +- **Behind only (`0 N`):** `git pull --ff-only origin `. Dirty tracked files are fine when the + incoming commits don't touch them. Check with `git log HEAD..origin/ -- ` first. + If they do touch them, stop and report the overlap; don't stash, reset or merge over someone's edits. +- **Ahead (`N 0` or `N M`):** local commits exist on the default branch. Don't push them directly. Move + them to the step-3 branch (`git switch -c `, then reset the default branch to + `origin/` only after the branch holds them), or stop and ask if they aren't clearly the user's. +- **Never** `git pull` without `--ff-only`, and never `--rebase` or `--force` on the default branch. + +## 3. Commit the intended changes on a branch + +- **Decide what belongs.** List `git status --short`. Commit only tracked changes the user's request + covers, or that this run produced: a tracker snapshot, a regenerated file. Show the diff stat. +- **Untracked files stay untracked** unless the user names them. They are often local notes, exports, + device presets or machine config (`mcp_config.json`, `*.local.*`, `.env*`). List them in the report. +- **Secrets check:** no tokens, keys or machine-local paths in the staged diff (`git diff --cached`). +- Branch `chore/-` (or the project's pattern, such as `af/-`). Stage + paths explicitly (`git add `, never `git add -A`), and commit with a Conventional Commit message + and the attribution lines the session asks for. +- Nothing to commit? Skip steps 3–5 and report that the default branch only fast-forwarded. + +## 4. Push and open the PR + +```bash +git push -u origin +gh pr create --repo / --base --head --title "" --body-file +``` + +The body says what changed and why it needs no review. Reference the ticket (`Refs `) when the +project tracks work. + +## 5. Merge pinned to the pushed commit + +- Wait about five minutes after the push for checks to register. A required check that's pending or + failing, `mergeStateStatus` `BLOCKED`, or a conflict means stop. Hand it to `/ship-pr` or the user. +- Use the method the repository's recent PRs used, pinned to the **full 40-character SHA** (a short SHA + is rejected): + + ```bash + gh pr merge --repo / --merge --delete-branch --match-head-commit $(git rev-parse HEAD) + ``` +- **"The merge commit cannot be cleanly created":** the default branch moved. Fetch, merge + `origin/` into the branch, and resolve the conflicts. Regenerate generated files rather than + hand-merging them. Re-run the checks, push (no force), then merge again on the new head. + +## 6. Fast-forward the local default branch + +```bash +git switch +git pull --ff-only origin +git rev-list --left-right --count HEAD...origin/ # must print "0 0" +git branch -d # -d, not -D: it must be merged +``` + +`gh pr merge --delete-branch` removes the remote branch and often switches the local checkout. Check +`gh pr view --json state,mergeCommit` rather than trusting its exit code. + +## Report + +```markdown +**** is level with origin at (was ahead, behind). + +- Committed as on ; PR # merged as ; branch deleted. +- Left untouched: . +``` + +## Never + +- Push directly to the default branch, force-push, rebase or reset a branch with others' work. +- Stash, discard or commit files the user didn't ask for, including untracked ones. +- Merge past a pending or failing required check, a `BLOCKED` state or a requested change. +- Open the PR against an upstream or parent repository the project treats as read-only. +- Delete a branch with `-D`, or delete a branch that isn't merged. diff --git a/.cursor/skills/fast-forward/SKILL.md b/.cursor/skills/fast-forward/SKILL.md new file mode 100644 index 0000000..528db98 --- /dev/null +++ b/.cursor/skills/fast-forward/SKILL.md @@ -0,0 +1,116 @@ +--- +name: fast-forward +description: "Bring the default branch of the current repository level with its remote and land the local work that belongs there: fetch, fast-forward the default branch, commit the intended tracked changes on a short-lived branch, push it, open a PR against the repository's own default branch, merge it pinned to the pushed commit, fast-forward the local default branch to the merge, and delete the branch. Leaves untracked and unrelated files alone. Runs only when the user types /fast-forward." +capability: "Sync a checkout's default branch with origin and land its intended tracked changes through a pinned PR merge, never by force or a direct push to the default branch." +side_effect_level: remote_write +approval_required: true +requires_tools: "git and gh, authenticated for the repository's own remote." +output_schema: "The default branch's position before and after (ahead/behind counts and short SHAs), what was committed (paths and the commit), the PR and its merge commit, the final ahead/behind of 0/0, and every file left untouched with the reason." +risk_class: medium +disable-model-invocation: true +--- + +# Fast-forward + +`/fast-forward` means: **make my default branch match the remote, and land the work that belongs on it.** +Typing it approves one commit of the intended tracked changes, one push of a new branch, one PR and its +merge. It is not standing approval, and it never force-pushes, rewrites history or pushes straight to the +default branch. + +How this differs from neighbours: +- `commit-and-push` commits and pushes a branch; it doesn't merge or fast-forward the default branch. +- `/merge-pr` and `/ship-pr` merge an existing PR on CI evidence. `/fast-forward` opens its own small PR + and merges it in the same run, so keep it for changes that need no review: tracker snapshots, + generated files, docs the user already approved. +- `sync-upstream-fork` brings an upstream repository **into** a fork. `/fast-forward` only talks to the + repository's own `origin`. + +## 1. Confirm the target + +- **The repository and its default branch.** Read `gh repo view --json nameWithOwner,defaultBranchRef` + for `origin`. In a fork, `gh` defaults to the parent repository, so name the repository on every + `gh` call (`--repo /`). If the project's notes name a read-only upstream, never write to it. +- **This checkout is on the default branch,** or can switch to it cleanly. If it's on another branch + with work in progress, stop and ask; that branch isn't yours to move. +- **Another session may share this checkout.** If one is active here (`ListAgents`, a held tracker ticket, + a running build), ask before switching branches. + +## 2. Fetch and fast-forward + +```bash +git fetch origin +git rev-list --left-right --count HEAD...origin/ # " " +``` + +- **Behind only (`0 N`):** `git pull --ff-only origin `. Dirty tracked files are fine when the + incoming commits don't touch them. Check with `git log HEAD..origin/ -- ` first. + If they do touch them, stop and report the overlap; don't stash, reset or merge over someone's edits. +- **Ahead (`N 0` or `N M`):** local commits exist on the default branch. Don't push them directly. Move + them to the step-3 branch (`git switch -c `, then reset the default branch to + `origin/` only after the branch holds them), or stop and ask if they aren't clearly the user's. +- **Never** `git pull` without `--ff-only`, and never `--rebase` or `--force` on the default branch. + +## 3. Commit the intended changes on a branch + +- **Decide what belongs.** List `git status --short`. Commit only tracked changes the user's request + covers, or that this run produced: a tracker snapshot, a regenerated file. Show the diff stat. +- **Untracked files stay untracked** unless the user names them. They are often local notes, exports, + device presets or machine config (`mcp_config.json`, `*.local.*`, `.env*`). List them in the report. +- **Secrets check:** no tokens, keys or machine-local paths in the staged diff (`git diff --cached`). +- Branch `chore/-` (or the project's pattern, such as `af/-`). Stage + paths explicitly (`git add `, never `git add -A`), and commit with a Conventional Commit message + and the attribution lines the session asks for. +- Nothing to commit? Skip steps 3–5 and report that the default branch only fast-forwarded. + +## 4. Push and open the PR + +```bash +git push -u origin +gh pr create --repo / --base --head --title "" --body-file +``` + +The body says what changed and why it needs no review. Reference the ticket (`Refs `) when the +project tracks work. + +## 5. Merge pinned to the pushed commit + +- Wait about five minutes after the push for checks to register. A required check that's pending or + failing, `mergeStateStatus` `BLOCKED`, or a conflict means stop. Hand it to `/ship-pr` or the user. +- Use the method the repository's recent PRs used, pinned to the **full 40-character SHA** (a short SHA + is rejected): + + ```bash + gh pr merge --repo / --merge --delete-branch --match-head-commit $(git rev-parse HEAD) + ``` +- **"The merge commit cannot be cleanly created":** the default branch moved. Fetch, merge + `origin/` into the branch, and resolve the conflicts. Regenerate generated files rather than + hand-merging them. Re-run the checks, push (no force), then merge again on the new head. + +## 6. Fast-forward the local default branch + +```bash +git switch +git pull --ff-only origin +git rev-list --left-right --count HEAD...origin/ # must print "0 0" +git branch -d # -d, not -D: it must be merged +``` + +`gh pr merge --delete-branch` removes the remote branch and often switches the local checkout. Check +`gh pr view --json state,mergeCommit` rather than trusting its exit code. + +## Report + +```markdown +**** is level with origin at (was ahead, behind). + +- Committed as on ; PR # merged as ; branch deleted. +- Left untouched: . +``` + +## Never + +- Push directly to the default branch, force-push, rebase or reset a branch with others' work. +- Stash, discard or commit files the user didn't ask for, including untracked ones. +- Merge past a pending or failing required check, a `BLOCKED` state or a requested change. +- Open the PR against an upstream or parent repository the project treats as read-only. +- Delete a branch with `-D`, or delete a branch that isn't merged. diff --git a/docs/agent-asset-inventory.md b/docs/agent-asset-inventory.md index b59f9fd..ce608e4 100644 --- a/docs/agent-asset-inventory.md +++ b/docs/agent-asset-inventory.md @@ -81,6 +81,7 @@ This inventory lists the canonical Claude-authored assets mirrored to Cursor, Co | `electron-development` | `.claude/skills/electron-development/SKILL.md` | Use when changing an Electron main/preload/renderer contract, IPC handler, desktop database flow, or Electron test/build workflow. | | `eval` | `.claude/skills/eval/SKILL.md` | Use at the end of an implemented task, merged PR, or multi-iteration agent workflow to capture quality signals in project memory. Apply when the user mentions eval, feedback loop, task quality, regression learnings, or session scoring. | | `export-chat` | `.claude/skills/export-chat/SKILL.md` | Use when the user types /export or /export-chat, or asks to export, save, dump, copy, or share the current chat, conversation, or agent transcript as a file or to the clipboard. Renders Claude Code, Codex, Cursor, Google Antigravity and Grok transcripts (user/assistant text plus full tool-call inputs) to Markdown that /resume-task can read back. Also use to export an earlier chat by id. | +| `fast-forward` | `.claude/skills/fast-forward/SKILL.md` | Bring the default branch of the current repository level with its remote and land the local work that belongs there: fetch, fast-forward the default branch, commit the intended tracked changes on a short-lived branch, push it, open a PR against the repository's own default branch, merge it pinned to the pushed commit, fast-forward the local default branch to the merge, and delete the branch. Leaves untracked and unrelated files alone. Runs only when the user types /fast-forward. | | `feature-flag-lifecycle` | `.claude/skills/feature-flag-lifecycle/SKILL.md` | Use when adding, promoting, testing, or removing a feature flag or staged rollout. | | `fix-it` | `.claude/skills/fix-it/SKILL.md` | Fix the one problem your last report named (a gap, a mismatch, something left undone or still showing the old state), then prove it from the user's side. Use when the user types /fix-it, or replies \"fix it\", \"fix that\" or \"yes, fix it\" right after a report that named a problem. Diagnoses first, backs up before overwriting, makes the smallest reversible fix, verifies what the user actually sees, and reports how to undo it. Not for every open item (/go) or a plan (/step-by-step). | | `flow-complete` | `.claude/skills/flow-complete/SKILL.md` | Finish an agent-flow ticket — run the Definition of Done, commit and push the branch, open a PR that references the ticket, write the handoff note and submit for review. Use when implementation is done or the user says "wrap up", "complete", "submit", "open the PR". Only in projects with an `.agent-flow/` folder. | diff --git a/evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json b/evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json new file mode 100644 index 0000000..fb46698 --- /dev/null +++ b/evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json @@ -0,0 +1,27 @@ +{ + "id": "fast-forward-lands-through-pinned-pr", + "description": "Protect /fast-forward: user-typed only; --ff-only on the default branch; stop when incoming commits touch dirty files; commit only intended tracked paths on a branch; untracked files untouched; PR against the repo named explicitly; merge pinned to the full SHA; conflicts resolved by merging the default branch and regenerating, never force; ends at 0/0 and deletes the branch with -d.", + "target_asset": ".claude/skills/fast-forward/SKILL.md", + "linked_docs": [], + "must_contain": [ + "disable-model-invocation: true", + " Runs only when the user types /fast-forward.\"", + "it never force-pushes, rewrites history or pushes straight to the\ndefault branch.", + "git pull --ff-only origin ", + "don't stash, reset or merge over someone's edits.", + "**Untracked files stay untracked** unless the user names them.", + "never `git add -A`", + "--repo /", + "**full 40-character SHA**", + "Regenerate generated files rather than\n hand-merging them.", + "# must print \"0 0\"", + "git branch -d " + ], + "must_not_contain": [ + "side_effect_level: read_only", + "push --force", + "git add -A ", + "git reset --hard", + "or asks to fetch, pull" + ] +} From dd30ad8d07efc3747be8c193ebf86e2cfdc80751 Mon Sep 17 00:00:00 2001 From: Vladimir Bragin Date: Sat, 28 Nov 2026 19:53:25 -0600 Subject: [PATCH 2/2] fix(fast-forward): no -u, merge-pr gate, safe pointer move, push gate Review fixes: push without -u (it writes .git/config); require every run and check on the pushed SHA to be green and hand no-CI cases to /merge-pr; confirm headRefOid; move the default branch with git branch -f, never reset; make the secrets scan block the push and add the public-repo checks; describe upstream sync generically; note branch -d may already be done; CHANGELOG entry; fixture pins all. Refs scf-sh3h2 Co-Authored-By: Claude Opus 5.5 --- .agents/skills/fast-forward/SKILL.md | 32 +++++++++++++------ .claude/skills/fast-forward/SKILL.md | 32 +++++++++++++------ .cursor/skills/fast-forward/SKILL.md | 32 +++++++++++++------ CHANGELOG.md | 5 +++ .../fast-forward-lands-through-pinned-pr.json | 12 +++++-- 5 files changed, 81 insertions(+), 32 deletions(-) diff --git a/.agents/skills/fast-forward/SKILL.md b/.agents/skills/fast-forward/SKILL.md index 528db98..abb4948 100644 --- a/.agents/skills/fast-forward/SKILL.md +++ b/.agents/skills/fast-forward/SKILL.md @@ -22,8 +22,8 @@ How this differs from neighbours: - `/merge-pr` and `/ship-pr` merge an existing PR on CI evidence. `/fast-forward` opens its own small PR and merges it in the same run, so keep it for changes that need no review: tracker snapshots, generated files, docs the user already approved. -- `sync-upstream-fork` brings an upstream repository **into** a fork. `/fast-forward` only talks to the - repository's own `origin`. +- Syncing an upstream repository **into** a fork is a different job (some projects have their own + skill for it). `/fast-forward` only talks to the repository's own `origin`. ## 1. Confirm the target @@ -46,8 +46,10 @@ git rev-list --left-right --count HEAD...origin/ # " " incoming commits don't touch them. Check with `git log HEAD..origin/ -- ` first. If they do touch them, stop and report the overlap; don't stash, reset or merge over someone's edits. - **Ahead (`N 0` or `N M`):** local commits exist on the default branch. Don't push them directly. Move - them to the step-3 branch (`git switch -c `, then reset the default branch to - `origin/` only after the branch holds them), or stop and ask if they aren't clearly the user's. + them to the step-3 branch, or stop and ask if they aren't clearly the user's. `git switch -c ` + keeps the commits and the working tree, then `git branch -f origin/` moves only the + default branch's pointer back. Never use `git reset` for this: it can discard the dirty tracked files + this step allows. - **Never** `git pull` without `--ff-only`, and never `--rebase` or `--force` on the default branch. ## 3. Commit the intended changes on a branch @@ -56,7 +58,9 @@ git rev-list --left-right --count HEAD...origin/ # " " covers, or that this run produced: a tracker snapshot, a regenerated file. Show the diff stat. - **Untracked files stay untracked** unless the user names them. They are often local notes, exports, device presets or machine config (`mcp_config.json`, `*.local.*`, `.env*`). List them in the report. -- **Secrets check:** no tokens, keys or machine-local paths in the staged diff (`git diff --cached`). +- **Secrets gate before the push:** scan the staged diff (`git diff --cached`) for tokens, keys, + machine-local paths and personal identities. A hit blocks the push. For a PUBLIC repository + (`gh repo view --json visibility`), follow `commit-and-push`'s public-repo checks too. - Branch `chore/-` (or the project's pattern, such as `af/-`). Stage paths explicitly (`git add `, never `git add -A`), and commit with a Conventional Commit message and the attribution lines the session asks for. @@ -65,17 +69,24 @@ git rev-list --left-right --count HEAD...origin/ # " " ## 4. Push and open the PR ```bash -git push -u origin +git push origin gh pr create --repo / --base --head --title "" --body-file ``` -The body says what changed and why it needs no review. Reference the ticket (`Refs `) when the +Push without `-u`: an upstream setting writes branch tracking into `.git/config`. The body says what +changed and why it needs no review. Reference the ticket (`Refs `) when the project tracks work. ## 5. Merge pinned to the pushed commit -- Wait about five minutes after the push for checks to register. A required check that's pending or - failing, `mergeStateStatus` `BLOCKED`, or a conflict means stop. Hand it to `/ship-pr` or the user. +- **Same gate as `/merge-pr`.** Wait about five minutes after the push for checks to register. Then + **every** run and check on the pushed SHA (`gh run list --commit `, plus the commit's + check-runs and status) must have completed green. Anything pending, failing or skipped-only, a + `mergeStateStatus` of `BLOCKED`, or a conflict means stop: hand it to `/ship-pr` or the user. If the + repository has CI but no run registered, or no CI at all, hand the merge to `/merge-pr`, which proves + that case and runs the checks locally. Don't merge on a guess. +- Check that the PR's `headRefOid` equals `git rev-parse HEAD`, so the merge lands exactly the commit + you checked. - Use the method the repository's recent PRs used, pinned to the **full 40-character SHA** (a short SHA is rejected): @@ -95,7 +106,8 @@ git rev-list --left-right --count HEAD...origin/ # must print "0 0" git branch -d # -d, not -D: it must be merged ``` -`gh pr merge --delete-branch` removes the remote branch and often switches the local checkout. Check +`gh pr merge --delete-branch` removes the remote branch, often switches the local checkout, and may +already have deleted the local branch, so a failing `git branch -d` there is harmless. Check `gh pr view --json state,mergeCommit` rather than trusting its exit code. ## Report diff --git a/.claude/skills/fast-forward/SKILL.md b/.claude/skills/fast-forward/SKILL.md index 528db98..abb4948 100644 --- a/.claude/skills/fast-forward/SKILL.md +++ b/.claude/skills/fast-forward/SKILL.md @@ -22,8 +22,8 @@ How this differs from neighbours: - `/merge-pr` and `/ship-pr` merge an existing PR on CI evidence. `/fast-forward` opens its own small PR and merges it in the same run, so keep it for changes that need no review: tracker snapshots, generated files, docs the user already approved. -- `sync-upstream-fork` brings an upstream repository **into** a fork. `/fast-forward` only talks to the - repository's own `origin`. +- Syncing an upstream repository **into** a fork is a different job (some projects have their own + skill for it). `/fast-forward` only talks to the repository's own `origin`. ## 1. Confirm the target @@ -46,8 +46,10 @@ git rev-list --left-right --count HEAD...origin/ # " " incoming commits don't touch them. Check with `git log HEAD..origin/ -- ` first. If they do touch them, stop and report the overlap; don't stash, reset or merge over someone's edits. - **Ahead (`N 0` or `N M`):** local commits exist on the default branch. Don't push them directly. Move - them to the step-3 branch (`git switch -c `, then reset the default branch to - `origin/` only after the branch holds them), or stop and ask if they aren't clearly the user's. + them to the step-3 branch, or stop and ask if they aren't clearly the user's. `git switch -c ` + keeps the commits and the working tree, then `git branch -f origin/` moves only the + default branch's pointer back. Never use `git reset` for this: it can discard the dirty tracked files + this step allows. - **Never** `git pull` without `--ff-only`, and never `--rebase` or `--force` on the default branch. ## 3. Commit the intended changes on a branch @@ -56,7 +58,9 @@ git rev-list --left-right --count HEAD...origin/ # " " covers, or that this run produced: a tracker snapshot, a regenerated file. Show the diff stat. - **Untracked files stay untracked** unless the user names them. They are often local notes, exports, device presets or machine config (`mcp_config.json`, `*.local.*`, `.env*`). List them in the report. -- **Secrets check:** no tokens, keys or machine-local paths in the staged diff (`git diff --cached`). +- **Secrets gate before the push:** scan the staged diff (`git diff --cached`) for tokens, keys, + machine-local paths and personal identities. A hit blocks the push. For a PUBLIC repository + (`gh repo view --json visibility`), follow `commit-and-push`'s public-repo checks too. - Branch `chore/-` (or the project's pattern, such as `af/-`). Stage paths explicitly (`git add `, never `git add -A`), and commit with a Conventional Commit message and the attribution lines the session asks for. @@ -65,17 +69,24 @@ git rev-list --left-right --count HEAD...origin/ # " " ## 4. Push and open the PR ```bash -git push -u origin +git push origin gh pr create --repo / --base --head --title "" --body-file ``` -The body says what changed and why it needs no review. Reference the ticket (`Refs `) when the +Push without `-u`: an upstream setting writes branch tracking into `.git/config`. The body says what +changed and why it needs no review. Reference the ticket (`Refs `) when the project tracks work. ## 5. Merge pinned to the pushed commit -- Wait about five minutes after the push for checks to register. A required check that's pending or - failing, `mergeStateStatus` `BLOCKED`, or a conflict means stop. Hand it to `/ship-pr` or the user. +- **Same gate as `/merge-pr`.** Wait about five minutes after the push for checks to register. Then + **every** run and check on the pushed SHA (`gh run list --commit `, plus the commit's + check-runs and status) must have completed green. Anything pending, failing or skipped-only, a + `mergeStateStatus` of `BLOCKED`, or a conflict means stop: hand it to `/ship-pr` or the user. If the + repository has CI but no run registered, or no CI at all, hand the merge to `/merge-pr`, which proves + that case and runs the checks locally. Don't merge on a guess. +- Check that the PR's `headRefOid` equals `git rev-parse HEAD`, so the merge lands exactly the commit + you checked. - Use the method the repository's recent PRs used, pinned to the **full 40-character SHA** (a short SHA is rejected): @@ -95,7 +106,8 @@ git rev-list --left-right --count HEAD...origin/ # must print "0 0" git branch -d # -d, not -D: it must be merged ``` -`gh pr merge --delete-branch` removes the remote branch and often switches the local checkout. Check +`gh pr merge --delete-branch` removes the remote branch, often switches the local checkout, and may +already have deleted the local branch, so a failing `git branch -d` there is harmless. Check `gh pr view --json state,mergeCommit` rather than trusting its exit code. ## Report diff --git a/.cursor/skills/fast-forward/SKILL.md b/.cursor/skills/fast-forward/SKILL.md index 528db98..abb4948 100644 --- a/.cursor/skills/fast-forward/SKILL.md +++ b/.cursor/skills/fast-forward/SKILL.md @@ -22,8 +22,8 @@ How this differs from neighbours: - `/merge-pr` and `/ship-pr` merge an existing PR on CI evidence. `/fast-forward` opens its own small PR and merges it in the same run, so keep it for changes that need no review: tracker snapshots, generated files, docs the user already approved. -- `sync-upstream-fork` brings an upstream repository **into** a fork. `/fast-forward` only talks to the - repository's own `origin`. +- Syncing an upstream repository **into** a fork is a different job (some projects have their own + skill for it). `/fast-forward` only talks to the repository's own `origin`. ## 1. Confirm the target @@ -46,8 +46,10 @@ git rev-list --left-right --count HEAD...origin/ # " " incoming commits don't touch them. Check with `git log HEAD..origin/ -- ` first. If they do touch them, stop and report the overlap; don't stash, reset or merge over someone's edits. - **Ahead (`N 0` or `N M`):** local commits exist on the default branch. Don't push them directly. Move - them to the step-3 branch (`git switch -c `, then reset the default branch to - `origin/` only after the branch holds them), or stop and ask if they aren't clearly the user's. + them to the step-3 branch, or stop and ask if they aren't clearly the user's. `git switch -c ` + keeps the commits and the working tree, then `git branch -f origin/` moves only the + default branch's pointer back. Never use `git reset` for this: it can discard the dirty tracked files + this step allows. - **Never** `git pull` without `--ff-only`, and never `--rebase` or `--force` on the default branch. ## 3. Commit the intended changes on a branch @@ -56,7 +58,9 @@ git rev-list --left-right --count HEAD...origin/ # " " covers, or that this run produced: a tracker snapshot, a regenerated file. Show the diff stat. - **Untracked files stay untracked** unless the user names them. They are often local notes, exports, device presets or machine config (`mcp_config.json`, `*.local.*`, `.env*`). List them in the report. -- **Secrets check:** no tokens, keys or machine-local paths in the staged diff (`git diff --cached`). +- **Secrets gate before the push:** scan the staged diff (`git diff --cached`) for tokens, keys, + machine-local paths and personal identities. A hit blocks the push. For a PUBLIC repository + (`gh repo view --json visibility`), follow `commit-and-push`'s public-repo checks too. - Branch `chore/-` (or the project's pattern, such as `af/-`). Stage paths explicitly (`git add `, never `git add -A`), and commit with a Conventional Commit message and the attribution lines the session asks for. @@ -65,17 +69,24 @@ git rev-list --left-right --count HEAD...origin/ # " " ## 4. Push and open the PR ```bash -git push -u origin +git push origin gh pr create --repo / --base --head --title "" --body-file ``` -The body says what changed and why it needs no review. Reference the ticket (`Refs `) when the +Push without `-u`: an upstream setting writes branch tracking into `.git/config`. The body says what +changed and why it needs no review. Reference the ticket (`Refs `) when the project tracks work. ## 5. Merge pinned to the pushed commit -- Wait about five minutes after the push for checks to register. A required check that's pending or - failing, `mergeStateStatus` `BLOCKED`, or a conflict means stop. Hand it to `/ship-pr` or the user. +- **Same gate as `/merge-pr`.** Wait about five minutes after the push for checks to register. Then + **every** run and check on the pushed SHA (`gh run list --commit `, plus the commit's + check-runs and status) must have completed green. Anything pending, failing or skipped-only, a + `mergeStateStatus` of `BLOCKED`, or a conflict means stop: hand it to `/ship-pr` or the user. If the + repository has CI but no run registered, or no CI at all, hand the merge to `/merge-pr`, which proves + that case and runs the checks locally. Don't merge on a guess. +- Check that the PR's `headRefOid` equals `git rev-parse HEAD`, so the merge lands exactly the commit + you checked. - Use the method the repository's recent PRs used, pinned to the **full 40-character SHA** (a short SHA is rejected): @@ -95,7 +106,8 @@ git rev-list --left-right --count HEAD...origin/ # must print "0 0" git branch -d # -d, not -D: it must be merged ``` -`gh pr merge --delete-branch` removes the remote branch and often switches the local checkout. Check +`gh pr merge --delete-branch` removes the remote branch, often switches the local checkout, and may +already have deleted the local branch, so a failing `git branch -d` there is harmless. Check `gh pr view --json state,mergeCommit` rather than trusting its exit code. ## Report diff --git a/CHANGELOG.md b/CHANGELOG.md index 6851e38..f66513d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ All notable changes to this framework are documented here. The format follows ### Added +- `/fast-forward` skill (user-typed only): levels the default branch with `origin` and lands the intended + tracked changes through a small PR. It fetches, fast-forwards with `--ff-only`, commits explicitly staged + paths on a branch, pushes without `-u`, and merges pinned to the full SHA under the same all-green gate as + `/merge-pr`. It ends at 0 ahead, 0 behind and deletes the branch. It never pushes, forces or resets the + default branch, and leaves untracked files alone. - `repo-inventory` skill: snapshots every checkout under a projects folder with read-only git (remote key, default branch and origin SHA, HEAD, branches with ahead/behind/gone/unpushed, worktrees, dirty counts, stashes, merge or rebase in progress), exchanges snapshots through the cross-PC share, over diff --git a/evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json b/evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json index fb46698..e24d7b6 100644 --- a/evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json +++ b/evals/skill-scenarios/fast-forward-lands-through-pinned-pr.json @@ -15,13 +15,21 @@ "**full 40-character SHA**", "Regenerate generated files rather than\n hand-merging them.", "# must print \"0 0\"", - "git branch -d " + "git branch -d ", + "git push origin ", + "git branch -f origin/", + "**every** run and check on the pushed SHA", + "hand the merge to `/merge-pr`", + "`headRefOid` equals `git rev-parse HEAD`", + "A hit blocks the push." ], "must_not_contain": [ "side_effect_level: read_only", "push --force", "git add -A ", "git reset --hard", - "or asks to fetch, pull" + "or asks to fetch, pull", + "push -u", + "sync-upstream-fork" ] }