Not loaded · from dev
Pins the agent to one git branch and blocks checkout/switch to any other branch via pre-tool hooks. Use /branch-lock to set, change, or clear the lock.
Claude Code won't load this skill
It ships in dev at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
Pin the agent to one branch in the primary checkout and block it from switching away.
Never hand-edit branch-lock.yaml — route every lock change through red-skills-resource run plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh so the lock-store stays single-writer.
The user invokes /branch-lock <branch> or /branch-lock clear (or just asks
to lock/unlock). Map it to one CLI action and run the bundled CLI:
/branch-lock <branch> → red-skills-resource run plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh set <branch>/branch-lock (no arg) → red-skills-resource run plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh set (lock to the current branch)/branch-lock clear → red-skills-resource run plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh clearred-skills-resource run plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh statusThe CLI does the atomic relock-then-switch: it rewrites the lock target first, so the switch to that branch is itself "return to the lock target" and the hook never blocks the very change the user asked for.
If the hooks are not yet wired in this repo, install them before relying on the lock:
The dev plugin ships Codex wiring in
plugins/dev/.codex-plugin/plugin.json ("hooks": "./hooks/codex.hooks.json").
That manifest calls red-skills-resource run plugins/dev/hooks/branch-lock-codex.sh, which reads Codex
PreToolUse payloads and reuses the same lock-store, scope-resolver, and
git-command-classifier modules as the Claude hook.
Codex must load the updated dev plugin, and plugin hooks must be enabled.
Current Codex builds list plugin_hooks as stable/enabled; older builds may
need [features].plugin_hooks = true in ~/.codex/config.toml. Once that is
true, no per-repo .codex/ copy is needed: set the lock with
red-skills-resource run plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh set or the /branch-lock skill command and the Codex
hook enforces it for shell-command tool calls. If Codex has plugin hooks
disabled, the lock file may exist but Codex will not enforce it.
The dev plugin ships Claude wiring in
plugins/dev/.claude-plugin/plugin.json ("hooks": "./hooks/claude.hooks.json").
That manifest registers branch-lock-hook.sh under PreToolUse/matcher Bash
at the plugin level, so no per-repo .claude/settings.json copy is needed for
the primary-branch guard. The hook reads .red/config.yaml at runtime; once
plugins.dev.enabled: true it enforces the untouchable-primary rule and, when a
branch-lock file is present, the work-loss family too.
Manual per-repo installation is only needed for older/pluginless Claude setups:
copy scripts/branch-lock-hook.sh,
scripts/branch-lock-session-start.sh,
and scripts/lib/ together into .claude/hooks/branch-lock/, make the scripts
executable, and register branch-lock-hook.sh under PreToolUse/matcher Bash.
The optional SessionStart hook only injects an instruction asking whether to
lock; it never writes the lock itself.
red-skills-resource run plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh.status to the user after set/clear.branch-lock.yaml — route via CLI so the lock-store stays single-writer.The lock is a local fact — .red/state/branch-lock.yaml whose content is the
branch name — under the gitignored state tier, so every checkout and machine
locks independently and nothing is committed. Legacy readers may still recognize
the old .red/tmp/branch-lock.yaml path during migration, but the canonical home
is the durable state tier. Absence of the file means unlocked: the branch-lock
layer is strictly opt-in.
Layered under it, the dev plugin ships an unconditional primary-checkout
branch guard (ADR 0083 §2, untouchable primary). Once the dev plugin is enabled
(plugins.dev.enabled: true), the pre-tool hook blocks the agent from changing
the primary checkout's branch — always, with no lock file and no config toggle.
The answer to "may an agent switch the primary checkout's branch" is not
configurable: it is always no. The historical dev.lock.primary-branch key
stays readable for backward compatibility but can no longer enable or disable
switching; the guard fires regardless of its value, and /red-doctor may note it as
redundant.
dev: { lock: { primary-branch: true } } # retained for backward compatibility only — no longer toggles the guard
The same unconditional guard also blocks the work-destroying commands the
standing maintainer rules forbid in the primary checkout, because parallel human
WIP lives there and these have destroyed in-progress work before (issue #1024).
The refusal points to the sanctioned alternative — do branch work in an isolated
worktree under .red/tmp/worktrees/manual/<slug>, and if the local trunk
diverged from origin, leave it alone and base on the fresh remote ref (ADR 0083).
Inside isolated worktrees these commands remain allowed — the guard is about the
primary checkout only, and /afk and /go worktrees under their registered
.red/tmp/ lanes are always exempt.
Enforcement is agent-only, via runner pre-tool hooks — Claude Code
PreToolUse(Bash) and Codex plugin PreToolUse — that intercept the agent's own
tool calls, not the human's terminal (ADR 0006, unaffected). See
ADR 0006.
The hook logic is self-contained: it depends on neither the
git-guardrails-claude-code skill nor anything else, and the two stack
harmlessly if both are installed.
branch-lock/
├── SKILL.md
├── ../../../hooks/
│ ├── codex.hooks.json ← Codex plugin hook manifest
│ └── branch-lock-codex.sh ← Codex PreToolUse hook
└── scripts/
├── branch-lock.sh ← /branch-lock CLI (set | clear | status)
├── branch-lock-hook.sh ← Claude PreToolUse(Bash) hook
├── branch-lock-session-start.sh ← SessionStart hook (offers to lock at start)
├── lib/
│ ├── dev-config.sh ← read dev.lock.primary-branch from .red/config.yaml
│ ├── lock-store.sh ← read/write/clear branch-lock.yaml
│ ├── scope-resolver.sh ← primary enforces, registered .red/tmp worktrees exempt
│ └── git-command-classifier.sh ← branch-switch + work-loss family = block
└── tests/
├── lock-store.test.sh
├── scope-resolver.test.sh
├── git-command-classifier.test.sh
├── dev-config.test.sh
├── session-start.test.sh
├── claude-plugin-hook.test.sh
├── codex-hook.test.sh
└── branch-lock-cli.test.sh ← /branch-lock set: atomic relock-then-switch
In the primary checkout, once plugins.dev.enabled: true, the hook blocks (the
first three are the unconditional untouchable-primary rule; the rest are the
work-loss family, blocked only while a branch-lock file is present):
git checkout <any> / git switch <any> — switching to any branch, including
the lock target (untouchable primary — the agent can never move the primary)git checkout -b <new> / git switch -c <new> — leaving via a new branchgit switch - — switching to the previous branchgit stash / git stash push / git stash save — shelving away the working treegit clean -f (any force flag: -fd, -xfd, --force) — deleting untracked filesgit reset --hard — discarding the working treegit checkout . / git checkout -- . / git restore . — whole-tree restoreIt allows (exit 0, silent):
git checkout -- <path> / git restore <path> — targeted file-level restoregit stash list / git stash show — read-only stashgit clean -n / --dry-run — non-destructive cleangit reset --soft / mixed reset, git restore --staged <path> — no working-tree lossgit worktree add .red/tmp/worktrees/manual/<slug> — manual worktrees stay in the registered lanegit commit, git status / read-only git, and any other commandThe dev command proxy has a stricter host-wide invariant when
plugins.dev.enabled: true: any agent-created git worktree add destination
must resolve under a registered lane in the repo's .red/tmp/. Branch-lock
allows the command class; the dev proxy decides whether the destination path is
inside the repo-owned runtime area.
Pure-module unit tests, run directly with bash:
for t in scripts/tests/*.test.sh; do bash "$t"; done
Each prints summary: N passed, 0 failed and exits non-zero on any failure.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub reddb-io/red-skills --plugin dev59 skills in this plugin
/adr-editorProposal-driven reverse grill for the active `.red/adr/` collection. Ranks active ADR clusters, recommends where to start, confronts one cluster with current implementation evidence, and applies maintainer-approved dispositions through the full ADR verb set. Use to review, curate, reorganise, fix, or extend ADRs and to pay down accumulated decision debt./afkAutonomous loop that drains the `ready-for-agent` queue on the issue tracker. Registers the project with the `redskilled` daemon at a runner and a target width, arms the drain, and observes; the daemon admits each Worker, which claims an issue, works it in its own workspace, validates, lands, and closes. Use when the user wants to run AFK execution, drain a Spec, hammer specific issues, or otherwise let agents grind through the backlog./Other plugins' skills for the same job