Skip to content
Merged
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
99 changes: 99 additions & 0 deletions docs/fast-forward/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
type: Design Note
title: fast-forward skill ideas
description: Ideas for a skill that brings local checkouts to their default branch tip safely, on one PC or several, after PRs merge.
resource: fast-forward/README.md
tags: [docs, skills, git, ideas]
timestamp: 2026-11-28T00:00:00Z
okf_version: 0.1
---

# fast-forward skill: ideas

Status: ideas only, nothing built. The goal is a skill that brings local checkouts up to their default branch
tip safely, on one PC or several, after PRs merge. It would answer "fetch, pull, merge, fast-forward to main"
without the trial and error that request takes by hand today.

## What goes wrong today

Each of these came up in real sessions:

- **`git pull` fails with "no tracking information"** when `main` has no upstream. Setting one writes
`.git/config`, which some workspaces forbid. `git fetch origin` then `git merge --ff-only origin/<default>`
does the same job without touching config.
- **A generated file blocks the fast-forward.** A tracker snapshot such as `.agent-flow/tickets.jsonl`
is modified locally, and the incoming commit changes the same file. Whether to keep the local copy or the
incoming one is a per-record decision: compare by record id, then version and `updated_at`.
- **Untracked files block switching to `main`.** Typical case: an older copy of a file that `main` now
tracks. If the content matches, or the file is only an older copy of what `main` has, it's safe. Otherwise
it's someone's work.
- **The current branch was squash-merged.** `git branch --merged` doesn't see that. The PR state (merged),
or a tree or patch-id comparison against `main`, does.
- **Noise looks like work.** Line-ending-only changes (empty under `git diff --ignore-cr-at-eol`), and junk
files with mangled names left by a broken shell redirect, make a clean checkout look dirty.
- **Another worktree already has `main` checked out**, so `git checkout main` fails, and so does `git fetch
origin main:main` (git refuses to fetch into a branch checked out anywhere). Find that worktree with
`git worktree list --porcelain`, run `git fetch origin`, then `git -C <that worktree> merge --ff-only
origin/main`. `git fetch origin main:main` is only for a `main` that no worktree has checked out; it
refuses a move that isn't a fast-forward.
- **Fast-forwarding doesn't deploy.** A CLI linked from the checkout (an npm global junction, a plugin read
from the folder) can keep running an old untracked `dist/` build. The skill should notice the build step
and offer it, not claim the update is live.
- **Renamed repos.** "This repository moved" on push or fetch is harmless, because GitHub redirects. Rewriting
the remote URL edits `.git/config`, so report it and leave it.
- **Permission layers block discards.** Auto-mode classifiers refuse `git checkout -- <file>` and `git branch
-D` even after a dialog answer. Prefer non-destructive forms (merge `--ff-only`, a rescue branch) and hand
the rest to the user as paste-ready `!` commands.
- **Shared checkouts.** Another agent session may be working in the same folder. Ask the live sessions first.

## Shape

Same pattern as the other harness skills: a stdlib Python script with `scan`, `plan` and `apply`.

- **scan** (read-only, `--fetch`): for each repo under a root, or the current repo only, record:
- default branch and its origin SHA, current branch, ahead and behind;
- upstream set or not;
- the merged-PR state of the current branch (via `gh` when available);
- tracked changes classified into real edits, EOL-only and known generated snapshots;
- untracked files classified into older copies of tracked files, junk names and unknown;
- worktrees holding the default branch;
- in-progress operations;
- a linked-build hint: a `build` script plus an untracked `dist/` older than `HEAD`.
- **plan**: one row per repo with an action and a reason:
- `ff`: `merge --ff-only origin/<default>` in the worktree that has the default branch checked out, or
`fetch origin main:main` when no worktree has it;
- `switch-and-ff`: the current branch is merged and the tree is clean apart from noise;
- `rescue-then-ff`: real edits move to a `rescue/<date>-<branch>` branch, never discarded;
- `needs-human`: diverged, conflicted, unpushed commits, or an unknown untracked file;
- `rebuild`: the follow-up when a linked build is stale.
- **apply**: executes only the `ff`, `switch-and-ff` and `rescue-then-ff` rows. It re-checks each repo's
state first and writes a manifest (old and new SHAs, rescue branches) with undo commands. It never
force-pushes, resets `--hard`, deletes branches or edits `.git/config`.

## Decisions it should batch into one question

- Snapshot conflicts: keep incoming or keep local, per record, with a "rescue local first" default.
- Branches already merged by squash: delete the local branch (the user runs the `!` command) or keep it.
- Whether to run a stale build.

## Across PCs

- Reuse `repo-inventory`: its `plan` already lists SAFE fast-forwards and NEEDS HUMAN rows per host. This
skill can be the one that executes the SAFE rows locally.
- On a peer, run it through `cross-pc-ssh` (read-only `scan` and `plan`), or send a `cross-pc-messages`
request. Each peer's owner approves its own `apply`.

## Neighbours

| Skill | Relationship |
|---|---|
| `merge-pr`, `ship-pr` | They merge; `fast-forward` brings checkouts up to date after a merge. Its natural follow-up step. |
| `projects-housekeeping` | Removes stale worktrees and branches; reuse its rescue and manifest code. |
| `repo-inventory` | Read-only snapshot and plan across PCs; `fast-forward` is the local executor. |
| `commit-and-push` | For real edits found in a checkout, when the user wants them shipped instead of rescued. |

## Open questions

- Which generated files count as snapshots? A per-repo config list, or detection by path (`.agent-flow/*.jsonl`)?
- Should `switch-and-ff` also remove a merged worktree, or leave that to `projects-housekeeping`?
- Should it run the project's tests after a fast-forward, or only report the new SHA?