Skip to content

fix(guardex): auto-stash dirty primary on branch-switch#417

Merged
NagyVikt merged 1 commit intomainfrom
agent/claude/harden-primary-branch-guard-2026-04-24-14-10
Apr 24, 2026
Merged

fix(guardex): auto-stash dirty primary on branch-switch#417
NagyVikt merged 1 commit intomainfrom
agent/claude/harden-primary-branch-guard-2026-04-24-14-10

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Automated by gx branch finish (PR flow).

Previously the post-checkout guard only reverted a primary-tree switch
back to the protected branch when the working tree was clean. A dirty
tree caused the guard to print "auto-revert skipped" and silently leave
the primary checkout on the agent branch - the exact symptom that flips
local main to an agent/* worktree branch.

- templates/githooks/post-checkout: stash dirty worktree as
  `guardex-auto-revert <ts> <prev>-><new>` (include untracked) before
  reverting; primary always ends up back on the protected branch in an
  agent session. Fallback message only fires when stash itself fails.
- AGENTS.md + templates/AGENTS.multiagent-safety.md: promote the
  primary-tree lock to an explicit blocking rule enumerating every
  disallowed command (git checkout/switch/checkout -b/switch -c/worktree
  add onto an existing agent branch) and add a dirty-tree rule that
  points at the new auto-stash safety net without making it a workflow.
@NagyVikt NagyVikt merged commit 56f2675 into main Apr 24, 2026
@NagyVikt NagyVikt deleted the agent/claude/harden-primary-branch-guard-2026-04-24-14-10 branch April 24, 2026 12:13
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