Start Gate
The counterpart to completion-gate. That one runs before you call work
done; this one runs before you touch anything. Work started on a stale or
foreign tree produces a diff nobody can review: an unrelated change rides
along, someone else's uncommitted work is destroyed, or the change is written
against a version of the code that no longer exists.
Cost is a few commands. The failure it prevents is discovered at push time, or
by the person whose work disappeared.
Project Fit Check
Before running this gate:
- Read the repo's own rules from
AGENTS.md, CLAUDE.md, .cursor/rules/,
contributing docs, or equivalents. Branch naming, worktree conventions,
lease or claim files, and protected branches are project truth and win over
the defaults below.
- Detect the version control system, default branch, package manager, and
setup commands from project files. Do not assume
main, git, or any
particular package manager.
- In a repository with no remote, skip the fetch steps and say so, rather than
reporting a missing origin as a blocker.
Before the first edit
1. Look before you touch
git status --short --branch
git worktree list
Read that output before deciding anything:
- Uncommitted changes you did not make belong to someone else, possibly
another agent session. Never stash, reset, check out over, or commit them.
Ask whose they are, or work in a separate worktree that leaves that checkout
alone.
- A checkout already on a task branch may be an active session. Leave it
and open your own worktree.
- Your own leftovers from an earlier session get committed or explicitly
discarded now, as their own decision, never folded into the new task.
- A lease, claim, or status file the repository uses to mark an occupied
checkout is checked here, and honored.
2. Get current
git fetch origin
git switch <default-branch>
git merge --ff-only origin/<default-branch>
Fast-forward only. A refused fast-forward means the local default branch has
diverged: resolve that as its own task. Do not git reset --hard a branch
whose contents you have not inspected, and do not start on the diverged tip
and hope.
3. Claim an isolated place to work
One task, one branch, off the freshly updated default:
git switch -c <short-descriptive-name>
# or, to leave the primary checkout untouched:
git worktree add ../<repo>-<task> -b <short-descriptive-name>
Prefer a worktree when the primary checkout is in use, when several tasks run
in parallel, or when the repository's own rules say so. Name the branch after
the change, not the tool or model that writes it: no agent or product prefixes,
and no producer chrome in commit messages or pull request descriptions.
4. Make the environment match the branch
Install dependencies with the project's own manager and its lockfile, using the
frozen or immutable variant so a moved lockfile fails loudly instead of
drifting. Start only the services this task actually needs.
A lockfile that moved on the default branch is the usual cause of an
inexplicable local failure minutes later.
5. Know what "green" means before you change it
Read the verification commands from the repository - AGENTS.md, package
scripts, Makefile, CI config - so the finishing gate is not improvised later.
Run them now when the suite is fast, or when the checkout was already dirty,
inherited, or long unused: a failure that was there before your first edit is
cheap to recognize now and expensive to diagnose after.
Stop and ask when
- Uncommitted or unpushed work in the checkout is not yours and its owner is
unknown.
- The default branch has diverged locally, or history was rewritten upstream.
- The task requires committing directly to a protected branch.
- Setup requires credentials, secrets, or an external resource you were not
given.
Do not
- Stash, reset, clean, check out over, or commit work you did not write
- Start editing on the default branch, or on a stale tip you did not fetch
- Delete or move another session's worktree
- Encode the agent, model, or tool in a branch name, commit, or PR surface
- Treat a green result from a checkout you never inspected as a baseline
1---2name: start-gate3description: Pre-work gate for code changes - inspect the working tree, preserve foreign work in progress, get the default branch current, and claim an isolated branch or worktree before the first edit. Use when starting a task, resuming a session, picking up an issue, or when the state of the checkout is unknown.4---56# Start Gate78The counterpart to **completion-gate**. That one runs before you call work9done; this one runs before you touch anything. Work started on a stale or10foreign tree produces a diff nobody can review: an unrelated change rides11along, someone else's uncommitted work is destroyed, or the change is written12against a version of the code that no longer exists.1314Cost is a few commands. The failure it prevents is discovered at push time, or15by the person whose work disappeared.1617## Project Fit Check1819Before running this gate:20211. Read the repo's own rules from `AGENTS.md`, `CLAUDE.md`, `.cursor/rules/`,22 contributing docs, or equivalents. Branch naming, worktree conventions,23 lease or claim files, and protected branches are project truth and win over24 the defaults below.252. Detect the version control system, default branch, package manager, and26 setup commands from project files. Do not assume `main`, `git`, or any27 particular package manager.283. In a repository with no remote, skip the fetch steps and say so, rather than29 reporting a missing origin as a blocker.3031## Before the first edit3233### 1. Look before you touch3435```bash36git status --short --branch37git worktree list38```3940Read that output before deciding anything:4142- **Uncommitted changes you did not make** belong to someone else, possibly43 another agent session. Never stash, reset, check out over, or commit them.44 Ask whose they are, or work in a separate worktree that leaves that checkout45 alone.46- **A checkout already on a task branch** may be an active session. Leave it47 and open your own worktree.48- **Your own leftovers from an earlier session** get committed or explicitly49 discarded now, as their own decision, never folded into the new task.50- **A lease, claim, or status file** the repository uses to mark an occupied51 checkout is checked here, and honored.5253### 2. Get current5455```bash56git fetch origin57git switch <default-branch>58git merge --ff-only origin/<default-branch>59```6061Fast-forward only. A refused fast-forward means the local default branch has62diverged: resolve that as its own task. Do not `git reset --hard` a branch63whose contents you have not inspected, and do not start on the diverged tip64and hope.6566### 3. Claim an isolated place to work6768One task, one branch, off the freshly updated default:6970```bash71git switch -c <short-descriptive-name>72# or, to leave the primary checkout untouched:73git worktree add ../<repo>-<task> -b <short-descriptive-name>74```7576Prefer a worktree when the primary checkout is in use, when several tasks run77in parallel, or when the repository's own rules say so. Name the branch after78the change, not the tool or model that writes it: no agent or product prefixes,79and no producer chrome in commit messages or pull request descriptions.8081### 4. Make the environment match the branch8283Install dependencies with the project's own manager and its lockfile, using the84frozen or immutable variant so a moved lockfile fails loudly instead of85drifting. Start only the services this task actually needs.8687A lockfile that moved on the default branch is the usual cause of an88inexplicable local failure minutes later.8990### 5. Know what "green" means before you change it9192Read the verification commands from the repository - `AGENTS.md`, package93scripts, `Makefile`, CI config - so the finishing gate is not improvised later.94Run them now when the suite is fast, or when the checkout was already dirty,95inherited, or long unused: a failure that was there before your first edit is96cheap to recognize now and expensive to diagnose after.9798## Stop and ask when99100- Uncommitted or unpushed work in the checkout is not yours and its owner is101 unknown.102- The default branch has diverged locally, or history was rewritten upstream.103- The task requires committing directly to a protected branch.104- Setup requires credentials, secrets, or an external resource you were not105 given.106107## Do not108109- Stash, reset, clean, check out over, or commit work you did not write110- Start editing on the default branch, or on a stale tip you did not fetch111- Delete or move another session's worktree112- Encode the agent, model, or tool in a branch name, commit, or PR surface113- Treat a green result from a checkout you never inspected as a baseline