Skip to content

docs: stop the workflow from forking local main - #661

Merged
huichen merged 1 commit into
mainfrom
claude/doc-dev-workflow
Sep 16, 2026
Merged

huichen merged 1 commit into
mainfrom
claude/doc-dev-workflow

Conversation

@huichen

@huichen huichen commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

The local main branch kept ending up unable to fast-forward to origin/main, and CLAUDE.md was the cause. This fixes the process; it is docs-only.

Root cause: the workflow doc told agents to do it

L26: Development happens in an isolated worktree … never in the local main branch
L29: To let the user test locally, merge the worktree branch into the local main branch (main)   ← contradicts L26

L29 was well-intentioned — let the user test on main — but the mechanism is broken by design:

worktree branch commit ──fast-forward──▶ local main        SHA: A
same change            ──squash──────▶   origin/main       SHA: B ≠ A
─────────────────────────────────────────────────────────────────────
git merge --ff-only origin/main  →  permanently refused
only way out: manual git reset --hard origin/main

Evidence: it is a loop, not an incident

git reflog main:

resets to origin/main                 8
ff-merges of claude/* branches       12   ← the fork generator
direct commits on main                1

Three of those appeared in a single session today, each one requiring the user to stop and adjudicate. Today's specific refusal was not a duplicate at all: it was a parallel session's unpushed work (8d96b076 on claude/mobile-perf-energy, with uncommitted changes in that live worktree), while the doc told agents to conclude "the user has local commits".

Changes

  1. Remove the permission, replace it with a prohibition — never commit to main, never merge a worktree branch into it; to let the user test, point them at the worktree; to land a change, let the PR squash-merge and fast-forward from origin/main. The reason (SHA mismatch) and the observed cost are stated inline so the rule does not read as arbitrary.
  2. Make the "fast-forward refused" step diagnostic instead of assumptive — how to tell a stale squash duplicate (identical tree to the squashed commit, which is already an ancestor of origin/main) from live work, and to ask before any reset. Live work is reported (commit, branch, unpushed), never rebased or reset.
  3. Fix the documented worktree path — .claude/worktrees/ (empty directory) → .worktrees/. Nothing caught this because .gitignore ignores both, so the wrong path silently worked.
  4. Record that sessions share this repo concurrently — stay inside your own worktree and branch, never prune or remove someone else's, and report a commit on main you did not make instead of cleaning it up.

Verification

make check-docs (both modes) passes — 164 docs OK; CLAUDE.md is a root-level doc the gate deliberately excludes from bilingual pairing.

CLAUDE.md told agents to fast-forward worktree branches into local `main` so the
user could test. PRs are squash-merged, so the branch commit that lands on
`origin/main` has a *different* SHA than the one now sitting on local `main` —
and that single commit blocks `git merge --ff-only origin/main` permanently,
leaving a manual `git reset --hard origin/main` as the only way out. The reflog
shows the loop it produced: 12 such fast-forwards against 8 manual resets, with
three of them in one session today, each needing the user to stop and decide.

The permission is removed: never commit to `main`, never merge a worktree branch
into it, and point the user at the worktree to test. The "ff refused" step now
says how to tell a stale squash duplicate (identical tree, squashed commit
already an ancestor) from live work before anyone reaches for a reset, instead
of assuming the latter — today that assumption was wrong, and the commit was a
parallel session's unpushed work.

Also corrects the documented worktree path (`.claude/worktrees/` is empty; the
real root is `.worktrees/`), which nothing caught because both are gitignored,
and records that other sessions work in this repo concurrently: stay in your own
worktree, and report a commit on `main` you did not make rather than cleaning it
up.
@huichen
huichen enabled auto-merge (squash) September 16, 2026 09:12
@huichen
huichen merged commit aba2eb8 into main Sep 16, 2026
12 checks passed
@huichen
huichen deleted the claude/doc-dev-workflow branch September 16, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant