On this page

From 5.8.0, the plugin reads every shell command Claude is about to run in your repository and refuses the ones that would move a shared branch by hand or break the release rules the skills follow. A refused command does not run, and Claude is told why and what to do instead; an allowed command prints nothing. It is a speed bump for honest mistakes, not a security boundary: your required checks and branch rules on GitHub remain the boundary.

The guard works in any repository with a .claude/ds-config.json and needs no setting to start. Each command is judged by the settings of the repository it actually runs in, including one it reaches with cd or git -C; a repository with no settings file is left alone.

What it refuses#

  • A push straight to the base or production branch, or a push that could reach every branch at once.
  • A force-push or deletion of a protected branch: the base, production and release source branches, the release train, release branches and any protectedBranches entry. A release branch that is already released, or an abandoned cut, may still be deleted.
  • A merge by hand while on the base or production branch.
  • Merging a pull request into production that is neither a release nor a hotfix, or a release merged by a session that does not hold the release clearance.
  • Merging an epic or plan onto the release train without the settled review proof the release will ask for, or without pinning the merge to the reviewed commit.
  • Merging a migration or deploy change onto the train from an ordinary branch, or a migration whose content nobody approved.
  • Marking a pull request into the release train, base or production branch ready while a check on it has already failed.
  • Writing branch rulesets or branch protection.

The base and production rules always apply, on the usual defaults (develop and master) when those branches are not named. Every other rule applies only once the repository sets what it needs: with no release train configured there is no train rule, with no release clearance no clearance rule, and so on.

At session start it also prints a short banner: the branch the session is on, what kind of branch it is and where it lands, any open release into production, and how far the release train is ahead of the base branch.

Keys#

Key Value Default What it does
mergeGuard object or null on null switches the guard off for this repository.
mergeGuard.enabled boolean true false switches the guard off for this repository: no check and no banner. Use it for a repository that runs a guard of its own.
mergeGuard.trainAdvisoryChecks list of check names none Checks that are only advice on a pull request into the release train: a failure of one never stops it being marked ready there. Into the base or production branch they still count.
mergeGuard.ignoredRepositories list of owner/repo names none Repositories whose pull-request merges and ready flips the guard does not judge, because they have branches and rules of their own.
mergeGuard.command shell command or null none Your own extra rules. It runs from the repository root with check or banner appended and the hook's input on stdin. In check it runs only after the plugin's rules have allowed the command, for at most 10 seconds, and can add a refusal but never remove one. In banner each line it prints joins the session-start banner.

Your own command runs only for the repository the session started in. Another repository a command reaches is judged by the plugin's rules alone, and none of its own commands run.

Switches on a machine#

  • DEVSTRIDE_MERGE_GUARD=0 in the environment turns the guard off on that machine. Never use it to get past a refusal: ask the person who owns the release instead.
  • DEVSTRIDE_MERGE_GUARD_BANNER=0 turns off only the session-start banner.

When it cannot tell#

The guard has one 25-second limit. Any error or timeout lets the command run and writes one line to the guard's log. Three cases refuse instead, because a wrong allow there cannot be undone: a pull-request merge when GitHub cannot say where it merges within 8 seconds, an epic or plan merge onto the train when its review proof cannot be checked, and the deletion of a protected release branch it cannot prove released or abandoned.

Codex#

The plugin's hooks run in Claude Code only. A repository that wants the guard under Codex wires it in its own Codex hook settings, pointing at a copy of the guard from an installed plugin.

The full contract is skills/setup/references/merge-guard.md in the plugin repository.

Powered by DevStride