Add a hook primitive to plugins/git that a consumer deploys with apm install (Claude target: merged into .claude/settings.json, script under .claude/hooks/<pkg>/). On a PreToolUse Bash call, it refuses a git push whose target is main, covering:
--force / --force-with-lease variants of the above.
It allows pushes to any other branch and tags.
Why
Consumer repositories protect main on the server, so the push fails anyway; the hook makes an agent learn that before the round-trip, and keeps it from retrying with variations.
Notes
Executable primitive: consumers allow it with apm approve and commit the executables entry in their apm.yml; say so in the plugin README.
Generic only: no repository-specific guards in this plugin.
Test the refspec cases above, allowed and refused.
## What
Add a hook primitive to `plugins/git` that a consumer deploys with `apm install` (Claude target: merged into `.claude/settings.json`, script under `.claude/hooks/<pkg>/`). On a `PreToolUse` Bash call, it refuses a `git push` whose target is `main`, covering:
- `git push` while on `main` with no refspec,
- `git push <remote> main`, `HEAD:main`, `<branch>:main`, `refs/heads/main`,
- `--force` / `--force-with-lease` variants of the above.
It allows pushes to any other branch and tags.
## Why
Consumer repositories protect `main` on the server, so the push fails anyway; the hook makes an agent learn that before the round-trip, and keeps it from retrying with variations.
## Notes
- Executable primitive: consumers allow it with `apm approve` and commit the `executables` entry in their `apm.yml`; say so in the plugin README.
- Generic only: no repository-specific guards in this plugin.
- Test the refspec cases above, allowed and refused.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
Add a hook primitive to
plugins/gitthat a consumer deploys withapm install(Claude target: merged into.claude/settings.json, script under.claude/hooks/<pkg>/). On aPreToolUseBash call, it refuses agit pushwhose target ismain, covering:git pushwhile onmainwith no refspec,git push <remote> main,HEAD:main,<branch>:main,refs/heads/main,--force/--force-with-leasevariants of the above.It allows pushes to any other branch and tags.
Why
Consumer repositories protect
mainon the server, so the push fails anyway; the hook makes an agent learn that before the round-trip, and keeps it from retrying with variations.Notes
apm approveand commit theexecutablesentry in theirapm.yml; say so in the plugin README.