Branch Guard

Enforce "never write on main/master/trunk". Backing PreToolUse hook blocks Write/Edit/MultiEdit/NotebookEdit when HEAD is on a protected branch, aborting with exit 2. This skill documents the rule and provides the "branch off and continue" recipe Claude should reach for whenever the guard fires or whenever a task begins on a protected branch. Auto-trigger when the guard blocks a write, when the user asks "am I on main?" / "create a new branch", or at the start of any task that will write to a git repo.

BK202503 Updated

File contents

BK202503/open-claude-all/tree/main/skills/branch-guard commit b725be3da6

Frequently asked questions

npx skillmds@latest add bk202503/branch-guard