Git Workflow — Release-Branch Model
Enforce the release-branch Git model and help execute the correct git operations for your current context: start new work, open a PR, cut a release, or view the workflow reference.
Hard Rules (always enforced, no exceptions)
- Never commit or push directly to
main. If the current branch is main, stop and create a new branch before making any changes.
- Never force-push to
main.
- All changes must reach
main via a PR from a release branch.
Instructions
When invoked, ask the user what they want to do (if not already specified):
"What would you like to do?
(a) View the Git workflow reference
(b) Start new work — scaffold a feature or fix branch
(c) Open a PR for the current branch
(d) Cut a release — merge release branch to main and tag
(e) Resolve a merge conflict on the current branch
(f) Manage stashes — list, view, apply, or drop stashes"
Then execute the appropriate action below.
Action (a) — View Workflow Reference
Print the full Git Workflow Reference section below.
Action (b) — Start New Work
Use Bash to identify the current release branch:
git branch -r | grep release | sort -V | tail -1
No-release-branch fallback: If the command above returns no output (no release/* branch exists), fall back to branching from main and target main for the PR. Inform the user:
"No release branch found. Branching from main and the PR will target main directly. This is normal for simple repos and early-stage projects that do not yet use the release-branch model."
In this case, replace origin/<release-branch> in step 4 with origin/main, and use --base main in the gh pr create call in Action (c).
Ask the user:
- Is this a new feature or a bug fix? (determines
feature/ vs fix/ prefix)
- What is the task ID or short description? (e.g.
task-042, login-crash)
Construct the branch name: feature/task-XXX-short-description or fix/task-XXX-short-description.
Use Bash to fetch the latest remote state, then create and check out the branch from the release branch:
git fetch origin
git checkout -b <branch-name> origin/<release-branch>
Without the fetch, a stale remote-tracking ref would create the branch off an old tip.
Confirm the branch was created and remind the user:
- Never commit directly to
main or the release branch.
- Open a PR from this branch into the release branch when work is complete.
Action (c) — Open a PR
Use Bash to check the current branch and recent commits:
git branch --show-current
git log --oneline -10
Use Glob to check if handoffs/reviews/ exists. If it does, use Read on any open review artifacts to check for unresolved findings with severity: critical | severe | moderate. If any exist, block the PR and inform the user these must be resolved first.
Use Bash to identify the target release branch:
git branch -r | grep release | sort -V | tail -1
Use Read to check handoffs/plans/ for context to include in the PR description.
Produce a PR description with: summary of changes, related task IDs, testing notes. Then use Bash:
gh pr create --title "<title>" --body "<description>" --base <release-branch>
If gh is not available, print the PR body for the user to paste manually.
Action (d) — Cut a Release
Use Bash to confirm the current release branch is clean and all PRs are merged:
git status
git log --oneline origin/main..HEAD
Ask the user for the version tag (e.g. 1.0.0).
Open a release PR from the release branch into main — all changes reach main via PR, including releases:
gh pr create --base main --head release/<version> --title "Release v<version>" --body "<release summary>"
If gh is not available, print the PR body and ask the user to open the PR manually.
After the PR is approved and merged, tag the release on main. Confirm before pushing the tag:
git checkout main
git pull origin main
git tag v<version>
git push origin v<version>
Remind the user to invoke /abd-docs (or the Documentation agent) to create the changelog for this release in docs/CHANGELOG.md or docs/changelogs/<version>.md.
Action (e) — Resolve a Merge Conflict
Use Bash to identify all conflicted files:
git status
List each file that shows both modified, deleted by us, deleted by them, or any other conflict marker.
Use Bash to fetch the latest remote state and show how far behind the current branch is:
git fetch origin
git log --oneline HEAD..origin/$(git branch --show-current)
Report how many commits the remote is ahead. If the remote branch no longer exists, note that and continue with local conflict resolution.
Ask the user whether to rebase or merge to incorporate upstream changes, and explain the tradeoffs:
- Rebase (
git rebase origin/<branch>): rewrites your local commits on top of the upstream tip, producing a linear history. Best for feature branches that are not shared with others. Avoid rebasing branches that other people have checked out.
- Merge (
git merge origin/<branch>): creates a merge commit that preserves the full history of both sides. Safer for shared or long-lived branches where rewriting history would disrupt collaborators.
Wait for the user's choice before proceeding.
For each conflicted file identified in step 1:
a. Use Read to display the file and locate the conflict markers (<<<<<<<, =======, >>>>>>>).
b. Explain to the user what each side of the conflict contains:
- HEAD (your changes): the lines between
<<<<<<< HEAD and =======.
- Incoming (their changes): the lines between
======= and >>>>>>> <ref>.
c. Ask the user which resolution to apply (keep yours, keep theirs, or combine), or propose a resolution if the intent is clear from context.
d. Use Edit to apply the agreed resolution, removing all conflict markers so the file is valid.
After all conflicted files are resolved, use Bash to stage only the resolved files by name (never git add ., which would sweep untracked files like build output or .env into the commit) and complete the rebase or merge:
Use Bash to confirm the branch is clean and ready to push:
git status
git log --oneline -5
Verify there are no remaining conflict markers and the working tree is clean. Remind the user:
- If rebase was used, a force-push is required:
git push --force-with-lease origin <branch>. Only do this if the branch is not shared.
- If merge was used, a regular push is safe:
git push origin <branch>.
Action (f) — Manage Stashes
Use Bash to list all stashes:
git stash list
If the list is empty, inform the user and stop.
Show the stash list to the user and ask what they want to do:
"(i) Inspect a stash — show its diff
(ii) Apply a stash — apply without dropping
(iii) Pop a stash — apply and drop
(iv) Drop a stash — delete without applying
(v) Drop all stashes — clear the entire stash list (confirm first)"
Execute the chosen sub-action:
Sub-action (i) — Inspect a stash
Ask the user which stash number (N) to inspect. Then:
git stash show -p stash@{N}
Display the diff and provide a plain-language summary of what changes are stashed (files changed, nature of changes).
Sub-action (ii) — Apply a stash
Ask the user which stash number (N) to apply. Then:
git stash apply stash@{N}
After applying, check for conflicts:
git status
If any conflicts are present (files show both modified or similar), inform the user and run Action (e) to resolve them.
Sub-action (iii) — Pop a stash
Ask the user which stash number (N) to pop. Then:
git stash pop stash@{N}
After popping, check for conflicts the same way as sub-action (ii). If conflicts are found, run Action (e) to resolve them.
Sub-action (iv) — Drop a stash
Ask the user which stash number (N) to drop. Show the stash message and confirm:
"This will permanently delete stash@{N}: <message>. Confirm? (y/n)"
If confirmed:
git stash drop stash@{N}
Sub-action (v) — Drop all stashes
Count the total number of stashes and confirm with the user:
"This will permanently delete ALL X stashes. This cannot be undone. Confirm? (y/n)"
If confirmed:
git stash clear
After any sub-action completes, run git stash list again and show the user the updated stash state.
Git Workflow Reference
Branch Model
| Branch |
Purpose |
Rules |
main |
Production-ready history |
Never commit directly. Only merge from release branches. |
release/<version> |
Integration branch per release |
Never commit directly. All feature/fix PRs target this. |
feature/task-XXX-description |
New work |
One per task. Created from the release branch. |
fix/task-XXX-description |
Bug fixes |
One per issue. Created from the release branch. |
Flow
feature/* or fix/*
↓ (PR)
release/<version>
↓ (PR when release is ready)
main → tag v<version>
Who Does What
| Action |
Responsible |
| Create feature/fix branch |
Planning or Dev agent |
| Open PR |
Dev agent (the one that did the work) |
| Code review |
Tech Review + Security agents |
| Approve PR |
Tech Review + Security; Planning after triage |
| Merge to release |
Planning or designated agent |
| Cut release (release → main + tag) |
Planning or DevOps |
| Create changelog |
Documentation agent |
Naming Conventions
- Feature branches:
feature/task-NNN-short-description
- Fix branches:
fix/issue-NNN-short-description
- Version tags:
vMAJOR.MINOR.PATCH (e.g. v1.0.0)
- Changelog:
docs/CHANGELOG.md or docs/changelogs/<version>.md
Merge Style
Document the chosen merge style in docs/assumptions.md at project start. Default: merge commit (--no-ff) to preserve branch history.
Changelogs
The Documentation agent creates or updates changelogs in docs/ for each release. Format: version, date, sections for Added / Changed / Fixed / Security, links to PRs or handoff artifacts.
Output Format
After completing any action, confirm:
- What git operations were run (list commands with output).
- The current state of relevant branches.
- What the next step is.
1---2name: git-workflow3description: Enforces the release-branch Git model: scaffold feature branches, open PRs with review checks, cut releases with tags, and view workflow reference.4---56# Git Workflow — Release-Branch Model78Enforce the release-branch Git model and help execute the correct git operations for your current context: start new work, open a PR, cut a release, or view the workflow reference.910## Hard Rules (always enforced, no exceptions)1112- **Never commit or push directly to `main`.** If the current branch is `main`, stop and create a new branch before making any changes.13- **Never force-push to `main`.**14- All changes must reach `main` via a PR from a release branch.1516## Instructions1718When invoked, ask the user what they want to do (if not already specified):1920> "What would you like to do?21> (a) View the Git workflow reference22> (b) Start new work — scaffold a feature or fix branch23> (c) Open a PR for the current branch24> (d) Cut a release — merge release branch to main and tag25> (e) Resolve a merge conflict on the current branch26> (f) Manage stashes — list, view, apply, or drop stashes"2728Then execute the appropriate action below.2930---3132### Action (a) — View Workflow Reference3334Print the full Git Workflow Reference section below.3536---3738### Action (b) — Start New Work39401. Use Bash to identify the current release branch:41 ```bash42 git branch -r | grep release | sort -V | tail -143 ```4445 **No-release-branch fallback:** If the command above returns no output (no `release/*` branch exists), fall back to branching from `main` and target `main` for the PR. Inform the user:46 > "No release branch found. Branching from `main` and the PR will target `main` directly. This is normal for simple repos and early-stage projects that do not yet use the release-branch model."47 In this case, replace `origin/<release-branch>` in step 4 with `origin/main`, and use `--base main` in the `gh pr create` call in Action (c).48492. Ask the user:50 - Is this a new **feature** or a **bug fix**? (determines `feature/` vs `fix/` prefix)51 - What is the task ID or short description? (e.g. `task-042`, `login-crash`)52533. Construct the branch name: `feature/task-XXX-short-description` or `fix/task-XXX-short-description`.54554. Use Bash to fetch the latest remote state, then create and check out the branch from the release branch:56 ```bash57 git fetch origin58 git checkout -b <branch-name> origin/<release-branch>59 ```60 Without the fetch, a stale remote-tracking ref would create the branch off an old tip.61625. Confirm the branch was created and remind the user:63 - Never commit directly to `main` or the release branch.64 - Open a PR from this branch into the release branch when work is complete.6566---6768### Action (c) — Open a PR69701. Use Bash to check the current branch and recent commits:71 ```bash72 git branch --show-current73 git log --oneline -1074 ```75762. Use Glob to check if `handoffs/reviews/` exists. If it does, use Read on any open review artifacts to check for unresolved findings with `severity: critical | severe | moderate`. If any exist, **block the PR** and inform the user these must be resolved first.77783. Use Bash to identify the target release branch:79 ```bash80 git branch -r | grep release | sort -V | tail -181 ```82834. Use Read to check `handoffs/plans/` for context to include in the PR description.84855. Produce a PR description with: summary of changes, related task IDs, testing notes. Then use Bash:86 ```bash87 gh pr create --title "<title>" --body "<description>" --base <release-branch>88 ```89 If `gh` is not available, print the PR body for the user to paste manually.9091---9293### Action (d) — Cut a Release94951. Use Bash to confirm the current release branch is clean and all PRs are merged:96 ```bash97 git status98 git log --oneline origin/main..HEAD99 ```1001012. Ask the user for the version tag (e.g. `1.0.0`).1021033. Open a release PR from the release branch into `main` — all changes reach `main` via PR, including releases:104 ```bash105 gh pr create --base main --head release/<version> --title "Release v<version>" --body "<release summary>"106 ```107 If `gh` is not available, print the PR body and ask the user to open the PR manually.1081094. After the PR is approved and merged, tag the release on `main`. Confirm before pushing the tag:110 ```bash111 git checkout main112 git pull origin main113 git tag v<version>114 git push origin v<version>115 ```1161175. Remind the user to invoke `/abd-docs` (or the Documentation agent) to create the changelog for this release in `docs/CHANGELOG.md` or `docs/changelogs/<version>.md`.118119---120121### Action (e) — Resolve a Merge Conflict1221231. Use Bash to identify all conflicted files:124 ```bash125 git status126 ```127 List each file that shows `both modified`, `deleted by us`, `deleted by them`, or any other conflict marker.1281292. Use Bash to fetch the latest remote state and show how far behind the current branch is:130 ```bash131 git fetch origin132 git log --oneline HEAD..origin/$(git branch --show-current)133 ```134 Report how many commits the remote is ahead. If the remote branch no longer exists, note that and continue with local conflict resolution.1351363. Ask the user whether to **rebase** or **merge** to incorporate upstream changes, and explain the tradeoffs:137 > - **Rebase** (`git rebase origin/<branch>`): rewrites your local commits on top of the upstream tip, producing a linear history. Best for feature branches that are not shared with others. Avoid rebasing branches that other people have checked out.138 > - **Merge** (`git merge origin/<branch>`): creates a merge commit that preserves the full history of both sides. Safer for shared or long-lived branches where rewriting history would disrupt collaborators.139140 Wait for the user's choice before proceeding.1411424. For each conflicted file identified in step 1:143 a. Use Read to display the file and locate the conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`).144 b. Explain to the user what each side of the conflict contains:145 - **HEAD (your changes):** the lines between `<<<<<<< HEAD` and `=======`.146 - **Incoming (their changes):** the lines between `=======` and `>>>>>>> <ref>`.147 c. Ask the user which resolution to apply (keep yours, keep theirs, or combine), or propose a resolution if the intent is clear from context.148 d. Use Edit to apply the agreed resolution, removing all conflict markers so the file is valid.1491505. After all conflicted files are resolved, use Bash to stage **only the resolved files by name** (never `git add .`, which would sweep untracked files like build output or `.env` into the commit) and complete the rebase or merge:151 - If **rebase** was chosen:152 ```bash153 git add <resolved-file-1> <resolved-file-2> ...154 git rebase --continue155 ```156 If additional conflict rounds occur, repeat steps 4–5 for each round until the rebase completes.157 - If **merge** was chosen:158 ```bash159 git add <resolved-file-1> <resolved-file-2> ...160 git merge --continue161 ```1621636. Use Bash to confirm the branch is clean and ready to push:164 ```bash165 git status166 git log --oneline -5167 ```168 Verify there are no remaining conflict markers and the working tree is clean. Remind the user:169 - If rebase was used, a force-push is required: `git push --force-with-lease origin <branch>`. Only do this if the branch is not shared.170 - If merge was used, a regular push is safe: `git push origin <branch>`.171172---173174### Action (f) — Manage Stashes1751761. Use Bash to list all stashes:177 ```bash178 git stash list179 ```180 If the list is empty, inform the user and stop.1811822. Show the stash list to the user and ask what they want to do:183 > "(i) Inspect a stash — show its diff184 > (ii) Apply a stash — apply without dropping185 > (iii) Pop a stash — apply and drop186 > (iv) Drop a stash — delete without applying187 > (v) Drop all stashes — clear the entire stash list (confirm first)"1881893. Execute the chosen sub-action:190191 **Sub-action (i) — Inspect a stash**192193 Ask the user which stash number (N) to inspect. Then:194 ```bash195 git stash show -p stash@{N}196 ```197 Display the diff and provide a plain-language summary of what changes are stashed (files changed, nature of changes).198199 **Sub-action (ii) — Apply a stash**200201 Ask the user which stash number (N) to apply. Then:202 ```bash203 git stash apply stash@{N}204 ```205 After applying, check for conflicts:206 ```bash207 git status208 ```209 If any conflicts are present (files show `both modified` or similar), inform the user and run Action (e) to resolve them.210211 **Sub-action (iii) — Pop a stash**212213 Ask the user which stash number (N) to pop. Then:214 ```bash215 git stash pop stash@{N}216 ```217 After popping, check for conflicts the same way as sub-action (ii). If conflicts are found, run Action (e) to resolve them.218219 **Sub-action (iv) — Drop a stash**220221 Ask the user which stash number (N) to drop. Show the stash message and confirm:222 > "This will permanently delete stash@{N}: `<message>`. Confirm? (y/n)"223224 If confirmed:225 ```bash226 git stash drop stash@{N}227 ```228229 **Sub-action (v) — Drop all stashes**230231 Count the total number of stashes and confirm with the user:232 > "This will permanently delete ALL X stashes. This cannot be undone. Confirm? (y/n)"233234 If confirmed:235 ```bash236 git stash clear237 ```2382394. After any sub-action completes, run `git stash list` again and show the user the updated stash state.240241---242243## Git Workflow Reference244245### Branch Model246247| Branch | Purpose | Rules |248|--------|---------|-------|249| `main` | Production-ready history | Never commit directly. Only merge from release branches. |250| `release/<version>` | Integration branch per release | Never commit directly. All feature/fix PRs target this. |251| `feature/task-XXX-description` | New work | One per task. Created from the release branch. |252| `fix/task-XXX-description` | Bug fixes | One per issue. Created from the release branch. |253254### Flow255256```257feature/* or fix/*258 ↓ (PR)259release/<version>260 ↓ (PR when release is ready)261 main → tag v<version>262```263264### Who Does What265266| Action | Responsible |267|--------|------------|268| Create feature/fix branch | Planning or Dev agent |269| Open PR | Dev agent (the one that did the work) |270| Code review | Tech Review + Security agents |271| Approve PR | Tech Review + Security; Planning after triage |272| Merge to release | Planning or designated agent |273| Cut release (release → main + tag) | Planning or DevOps |274| Create changelog | Documentation agent |275276### Naming Conventions277278- Feature branches: `feature/task-NNN-short-description`279- Fix branches: `fix/issue-NNN-short-description`280- Version tags: `vMAJOR.MINOR.PATCH` (e.g. `v1.0.0`)281- Changelog: `docs/CHANGELOG.md` or `docs/changelogs/<version>.md`282283### Merge Style284285Document the chosen merge style in `docs/assumptions.md` at project start. Default: merge commit (`--no-ff`) to preserve branch history.286287### Changelogs288289The Documentation agent creates or updates changelogs in `docs/` for each release. Format: version, date, sections for Added / Changed / Fixed / Security, links to PRs or handoff artifacts.290291## Output Format292293After completing any action, confirm:294- What git operations were run (list commands with output).295- The current state of relevant branches.296- What the next step is.