Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agent/SKILL_INVENTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +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-<host>.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 |
| 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. Sync (default) runs `scripts/fast_forward.py` inventory/plan/apply: ff-only rows only, expected-SHA re-checks, identical untracked copies archived with `--backup-dir`, config digest checked, receipt. 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 |
Expand Down
98 changes: 86 additions & 12 deletions .agents/skills/fast-forward/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
---
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."
description: "Bring the default branch of the current repository (or each repository the work touched) level with its remote with a deterministic inventory, plan and fast-forward-only apply (sync), and, when the user also asks to commit, push and merge, land the local work that belongs there (land): 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, fast-forward only; in land mode, also 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."
requires_tools: "python 3.9+ (stdlib only) for scripts/fast_forward.py, git, and gh authenticated for the repository's own remote."
output_schema: "The harness plan table and receipt JSON, then 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
`/fast-forward` means: **make my default branch match the remote** (sync). Typed alone, it approves only
the sync: a fetch and fast-forward-only moves. When the typed request also says commit, push or merge
(land), it also 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.

| Mode | What it does | Runs when |
|---|---|---|
| **sync** (default) | Inventory, plan, fast-forward-only apply (steps 0–2, then 7) | `/fast-forward` alone, or with "catch up" or "bring my checkouts up to date" |
| **land** | sync, then commit, push, PR, pinned merge, sync again (steps 3–6) | The typed request also says commit, push or merge |
| cleanup | Not run here: merged branches and worktrees are listed in the report only | Housekeeping, on its own request |

A compound request ("fetch, pull, commit, push, merge, fast-forward") authorizes both modes for this run.
Permission to fast-forward a checkout is never permission to push to its 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.
- 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`.
- `repo-inventory` compares checkouts across PCs and prints a plan it never runs. This skill is the
local executor; on a peer it only runs `inventory` and `plan` (see [references/details.md](references/details.md)).

## 0. Scope and other sessions

- **Scope:** the current repository, plus each repository this conversation changed, or the list the user
names. Never sweep a whole projects folder unasked.
- **Other sessions:** before any write, ask the live sessions working in these checkouts (`ListAgents`,
then `SendMessage`) and wait for "safe". If another session already took the same request, split the
repositories and send it what you found (EOL-only files, junk names, identical copies) so it doesn't redo it.

## 1. Confirm the target

Expand All @@ -35,7 +55,32 @@ How this differs from neighbours:
- **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
## 2. Fetch and fast-forward (sync)

Use the harness. It calls git with argument lists (no shell, so no MSYS path rewriting), with prompts off
and a per-repo timeout, and it never edits `.git/config`:

```bash
FF="<this skill's directory>/scripts/fast_forward.py"
python -I "$FF" plan --repo <path> [--repo <path>]... --fetch [--gh] --out <scratch>/ff-plan.json
python -I "$FF" apply --plan <scratch>/ff-plan.json [--backup-dir <folder outside the repo>] --receipt <scratch>/ff-receipt.json
```

| Row | Meaning | Who acts |
|---|---|---|
| `noop` | Already level, or nothing this skill may do | – |
| `ff` | `merge --ff-only` to the fetched SHA in the checkout holding the default branch; unrelated edits stay | apply |
| `ff-ref` | No worktree holds the default branch: `update-ref` with the expected old SHA | apply |
| `archive-ff` | Untracked or ignored files identical (git-normalized) to incoming ones: backed up, verified, removed, then `ff` | apply, with `--backup-dir` |
| `switch` | The current branch is merged (in origin's history, or with `--gh` a PR merged at this exact head) and clean | apply |
| `needs-human` | Diverged, local commits, overlapping edits, a different untracked or ignored file, the default branch checked out elsewhere, an operation in progress, a fetch that failed or timed out | you, with the user |

- Show the plan table before `apply`. `apply` re-reads every repository first and refuses a row whose
HEAD, SHAs, holder, tracked changes or collision hashes moved since planning; re-plan instead of forcing.
- It compares the git configuration digest after each action and stops all writes on drift. Report a
drift; never restore or "fix" the configuration yourself.
- A timed-out fetch usually waits on a credential prompt. Report it as `needs-human: auth`.
- Without the harness (no Python), the manual rules are:

```bash
git fetch origin
Expand All @@ -47,10 +92,12 @@ git rev-list --left-right --count HEAD...origin/<default> # "<ahead> <behind>"
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, or stop and ask if they aren't clearly the user's. `git switch -c <branch>`
keeps the commits and the working tree, then `git branch -f <default> origin/<default>` moves only the
keeps the commits and the working tree, then `git branch -f --no-track <default> origin/<default>` 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.
- **The default branch is checked out in another worktree:** fast-forward it there, only after its owner
says it is safe. Don't move a checked-out branch's ref behind its worktree's back.

## 3. Commit the intended changes on a branch

Expand All @@ -61,7 +108,8 @@ git rev-list --left-right --count HEAD...origin/<default> # "<ahead> <behind>"
- **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/<topic>-<YYYY-MM-DD>` (or the project's pattern, such as `af/<ticket>-<slug>`). Stage
- Create the branch with `git switch --no-track -c <branch>`: `branch.autoSetupMerge=always` would otherwise
write tracking into `.git/config`. Name it `chore/<topic>-<YYYY-MM-DD>` (or the project's pattern, such as `af/<ticket>-<slug>`). Stage
paths explicitly (`git add <path>`, 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.
Expand All @@ -79,7 +127,8 @@ project tracks work.

## 5. Merge pinned to the pushed commit

- **Same gate as `/merge-pr`.** Wait about five minutes after the push for checks to register. Then
- **Same gate as `/merge-pr`.** Poll the check state after the push (bounded, about ten minutes) rather than
sleeping a fixed time; zero runs on a repository with workflows is unknown, not green. Then
**every** run and check on the pushed SHA (`gh run list --commit <full sha>`, 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
Expand All @@ -106,17 +155,39 @@ git rev-list --left-right --count HEAD...origin/<default> # must print "0 0"
git branch -d <branch> # -d, not -D: it must be merged
```

`gh pr merge --delete-branch` removes the remote branch, often switches the local checkout, and may
Compare `python -I "$FF" inventory`'s `config_digest` from before step 3 with one taken now; a change is a drift to
report, not to repair. `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 <n> --json state,mergeCommit` rather than trusting its exit code.

## 7. After the fast-forward

- `0 0` proves the refs match. It doesn't prove a clean tree, a rebuilt binary or a running new version.
Check what the repository deploys (a `dist/` the harness flags, binaries copied out of a build folder,
skills installed at user level, an npm-linked CLI) and report "source at X, installed at Y". Rebuild or
reinstall only within the request; for skills, hand the user the installer's plan.
- Replacing a binary that live sessions hold open fails until they exit: make it a "close sessions" item.
- Branches whose remote is `[gone]` and squash-merged branches (`gh pr list --state merged --head <b>`)
go in the report as a list. Deleting them is cleanup, the user's call.
- **Retries:** after any failure, read the state (PR state, `git log`, the receipt) before trying again; a
remote merge can succeed while local cleanup fails. Re-plan, and never repeat a commit, a PR or a merge.

## Report

One row per repository (and per PC), same columns everywhere; rows with nothing to do collapse into one line
("9 repos already at origin"):

| Repo | PC | Before | After | Action | Left for you |
|---|---|---|---|---|---|

Then, for land:

```markdown
**<default>** is level with origin at <sha> (was <ahead> ahead, <behind> behind).

- Committed <paths> as <sha> on <branch>; PR #<n> merged as <merge sha>; branch deleted.
- Left untouched: <untracked or unrelated files, one line each, with why>.
- Archived: <path -> backup>; config digest unchanged; deploy: <source vs installed>.
```

## Never
Expand All @@ -126,3 +197,6 @@ already have deleted the local branch, so a failing `git branch -d` there is har
- 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.
- Edit `.git/config`: no upstream tracking, no `git config`, no `remote set-url` for a moved
repository ("This repository moved" is harmless: GitHub redirects).
- Retry a command a permission layer refused in another form. Finish the rest and hand it over as a `!` command.
41 changes: 41 additions & 0 deletions .agents/skills/fast-forward/references/details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# fast-forward: details

Load this when a run crosses PCs, hits CI that looks wrong, or runs under Git Bash on Windows.

## Checks that look green or red for the wrong reason

- **Zero check runs is unknown.** A repository can have Actions enabled and active workflows yet no runs at
all. Look at `gh run list --commit <full sha>` and the repository's runs, not only the PR's check list.
`gh pr checks` exits non-zero while checks are pending: that means wait.
- **Classify a failure from the job log:** a repository setting (for example dependency review on a
repository without the dependency graph), an infrastructure error, or a real failure. Only a real
failure belongs to the PR. If the default branch's own latest run fails the same way, report it as
already broken on the base; the PR can't fix it.

## Across PCs

- On a peer, run only `inventory` and `plan`, over `cross-pc-ssh` or as a `cross-pc-messages` request.
The plan goes back to that PC's agent with exact commands; its owner approves its own `apply`.
- Reach peers by hostname and pin the host key alias (`ssh -o HostKeyAlias=<alias> <hostname>`), so a
stale address doesn't look like "host unreachable".
- The same repository sits under different folders, drive letters or as a shallow clone on each PC. Match
it by normalized origin and root commits, as `cross-pc-ssh` does, never by folder name.
- After a default branch moves, offer to draft the note telling the peers to fast-forward too. Sending it
is the user's call.
- Fetch in parallel; move refs one repository at a time, so the report and undo stay in order.

## Windows

- Under Git Bash, `git show origin/<default>:<path>` has its argument rewritten into a Windows path. Set
`MSYS_NO_PATHCONV=1` for such manual commands; the harness avoids it by never using a shell.
- Compare with carriage returns stripped (`git diff --ignore-cr-at-eol --numstat`); otherwise every mirror
regenerated on Windows looks modified. The harness reports line-ending-only edits as a note.
- A hung `git.exe` (credential helper) outlives a client timeout. The harness starts each git call in its
own process group and, on timeout, tries to stop the whole tree (`taskkill /T` or the process group).

## Generated snapshots

A tracker snapshot such as `.agent-flow/tickets.jsonl` that both sides changed is not a merge by
timestamp. Use the tracker's own export or import, within the task's scope; otherwise it is a
`needs-human` item. Build output that appears after a local test run (`*.egg-info/`, `__pycache__/`,
`target/`) is worth one suggested `.gitignore` line, not a listing every run.
Loading