Git workflow
Apply these defaults unless the user explicitly overrides them in the same
turn. A git request authorizes only the repository and GitHub state required for
that operation.
- Resolve the base from the remote default; never hardcode
main.
- Make remote-default synchronization an automatic preflight for new work; do
not ask permission to perform a safe clean update.
- When new work starts from the local default branch, inspect status before
fetching or editing. If it is clean, fetch and fast-forward it to the fetched
remote-default tip automatically. Stop on local-only commits, divergence, or
a non-fast-forward update.
- If that local default worktree is dirty, stop before fetching, updating, or
editing and ask the user to choose: discard the state, or preserve it and
create a focused branch/worktree from the latest remote default. Do not make
either choice, stash, commit, or discard anything without the answer.
- Before the first edit in any other newly selected or reused branch or
worktree, require a clean worktree and fetch the remote default branch. Stop
and report dirty files; never stash, commit, or discard them automatically.
- Automatically create every new focused local branch and worktree at the exact
freshly fetched remote-default tip. Do not configure a focused branch to
track the remote default; set its upstream only when pushing that focused
branch.
- When entering an existing focused branch or worktree, merge the freshly
fetched remote default before editing.
- Merge the remote base to update a branch. Never rebase.
- Stop and report merge conflicts; do not bypass or rewrite them.
- Never amend commits. Add a new commit for every correction.
- Never force-push. Stop if a plain push is rejected by divergent history.
- Stage only relevant files and exclude secrets or unrelated local work.
- Use concise Conventional Commit subjects in imperative mood. Each commit title
must state its observable impact, not only the mechanism changed.
- Let hooks run unless the user explicitly asks otherwise.
- Squash-merge pull requests and delete the source branch afterward.
- Because the merge is a squash, the pull request title becomes the commit
subject on the base branch: the branch's own commit subjects do not survive.
Give the title a Conventional Commit subject that states the observable impact
of the change as a whole. Pick its type from the net effect rather than the
most frequent commit under it. Where a project generates its changelog or
version bump from commit history, a non-conforming title merges cleanly and is
then silently absent from it.
Native GitHub stacks
Use the official gh stack workflow when the user selects a stack, when work
has a real dependency chain, or when a confirmed large issue is deliberately
split into cumulative, independently reviewable layers. Do not stack unrelated
work. Each layer must have one clear claim, a bounded diff, its own validation,
and an explicit subset of the requirements.
Read references/github-stacks.md before creating,
syncing, pushing, submitting, reviewing, or merging a stack. That reference is
the only exception to the merge-only and never-force-push defaults above:
rebases and force-with-lease are permitted only when performed by verified
gh stack commands against a clean, confirmed native stack. Raw git rebase,
git push --force, and manual git push --force-with-lease remain forbidden.
After a squash merge, sync the local base and remove the merged local branch.
1---2name: git-workflow3description: Applies the user's git defaults: branch from the remote default, merge rather than rebase for ordinary branches, use native GitHub stacks when selected, never amend, and squash-merge pull requests. Use when branching, syncing, committing, pushing, or merging in the user's repos.4license: Unlicense OR MIT5---67# Git workflow89Apply these defaults unless the user explicitly overrides them in the same10turn. A git request authorizes only the repository and GitHub state required for11that operation.1213- Resolve the base from the remote default; never hardcode `main`.14- Make remote-default synchronization an automatic preflight for new work; do15 not ask permission to perform a safe clean update.16- When new work starts from the local default branch, inspect status before17 fetching or editing. If it is clean, fetch and fast-forward it to the fetched18 remote-default tip automatically. Stop on local-only commits, divergence, or19 a non-fast-forward update.20- If that local default worktree is dirty, stop before fetching, updating, or21 editing and ask the user to choose: discard the state, or preserve it and22 create a focused branch/worktree from the latest remote default. Do not make23 either choice, stash, commit, or discard anything without the answer.24- Before the first edit in any other newly selected or reused branch or25 worktree, require a clean worktree and fetch the remote default branch. Stop26 and report dirty files; never stash, commit, or discard them automatically.27- Automatically create every new focused local branch and worktree at the exact28 freshly fetched remote-default tip. Do not configure a focused branch to29 track the remote default; set its upstream only when pushing that focused30 branch.31- When entering an existing focused branch or worktree, merge the freshly32 fetched remote default before editing.33- Merge the remote base to update a branch. Never rebase.34- Stop and report merge conflicts; do not bypass or rewrite them.35- Never amend commits. Add a new commit for every correction.36- Never force-push. Stop if a plain push is rejected by divergent history.37- Stage only relevant files and exclude secrets or unrelated local work.38- Use concise Conventional Commit subjects in imperative mood. Each commit title39 must state its observable impact, not only the mechanism changed.40- Let hooks run unless the user explicitly asks otherwise.41- Squash-merge pull requests and delete the source branch afterward.42- Because the merge is a squash, the pull request **title** becomes the commit43 subject on the base branch: the branch's own commit subjects do not survive.44 Give the title a Conventional Commit subject that states the observable impact45 of the change as a whole. Pick its type from the net effect rather than the46 most frequent commit under it. Where a project generates its changelog or47 version bump from commit history, a non-conforming title merges cleanly and is48 then silently absent from it.4950## Native GitHub stacks5152Use the official `gh stack` workflow when the user selects a stack, when work53has a real dependency chain, or when a confirmed large issue is deliberately54split into cumulative, independently reviewable layers. Do not stack unrelated55work. Each layer must have one clear claim, a bounded diff, its own validation,56and an explicit subset of the requirements.5758Read [references/github-stacks.md](references/github-stacks.md) before creating,59syncing, pushing, submitting, reviewing, or merging a stack. That reference is60the only exception to the merge-only and never-force-push defaults above:61rebases and force-with-lease are permitted only when performed by verified62`gh stack` commands against a clean, confirmed native stack. Raw `git rebase`,63`git push --force`, and manual `git push --force-with-lease` remain forbidden.6465After a squash merge, sync the local base and remove the merged local branch.