# Protect Main Branch

> Block direct commits and pushes to main or master. Enforced at commit time by reading the current branch, and at push time by parsing the refs the agent is pushing.

- Skill: `open-coder-ai/protect-main-branch` (Agent Skill)
- Install (CLI): `npx skillmds@latest add open-coder-ai/protect-main-branch`
- Raw SKILL.md: https://api.skillmd.com/api/skills/open-coder-ai/protect-main-branch/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: open-coder-ai (https://skillmd.com/u/open-coder-ai)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/open-coder-ai/protect-main-branch

---


# Protect Main Branch

Block direct commits and pushes to main or master. Enforced at commit time by reading the current branch, and at push time by parsing the refs the agent is pushing.

```
on(commit|push): block(forbidden_ref) refs=main|master
Direct commits/pushes to a protected branch (main|master) are blocked. Create a feature branch and open a pull request.
```

This skill is advisory: the client reading it has no mechanism to enforce it. The same policy compiled by `chock` becomes a git hook that exits non-zero. See https://github.com/open-coder-ai/chock

