no-commit-to-main

Prevents direct git commits to main or master branches and enforces branch-based PR workflows.

Updated Mar 10, 2026
One-click install
npx skills add https://github.com/jasoncrawford/brunel --skill no-commit-to-main-jasoncrawford
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: no-commit-to-main
Source: https://github.com/jasoncrawford/brunel/tree/main/.claude-plugin/skills/no-commit-to-main
Command: npx skills add https://github.com/jasoncrawford/brunel --skill no-commit-to-main-jasoncrawford

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Accidentally committing directly to the main branch bypasses code review, CI checks, and the pull request workflow, creating messy history and blocking parallel work. This Skill intercepts that mistake before it happens and provides a clean recovery path if it already did. ## Core Features & Use Cases - Commit Prevention: Triggers when you are about to run git commit while on the main or master branch, stopping the action before it lands. - Guided Branch Workflow: Provides the exact commands to create a feature branch, commit, push, and open a pull request with gh pr create. - Accidental Commit Recovery: Supplies a step-by-step recovery sequence using git checkout -b and git reset --hard origin/main to move an unpushed commit off main cleanly. - Use Case: An agent or developer finishes a fix and runs git commit without noticing they are on main; the Skill intervenes, redirects the work onto a short-lived branch, and opens a PR instead. ## Quick Start Before committing, ask the assistant to check the current git branch and move the work onto a new branch with a pull request if it is main.

Frequently Asked Questions about no-commit-to-main

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid committing directly to the main branch in git?▼

Check your current branch with git branch --show-current before committing. If it prints main, create a feature branch with git checkout -b short-description, then commit, push with git push -u origin, and open a pull request.

How do I fix an accidental commit on the main branch?▼

If the commit has not been pushed, create a branch from it with git checkout -b short-description, switch back to main, run git reset --hard origin/main, then push the new branch and open a PR with gh pr create.

Why is committing directly to main a problem?▼

Direct commits to main bypass code review, CI checks, and the PR workflow. They can block other agents working in parallel, add noise to main branch history, and are difficult to revert cleanly.

Does git reset --hard origin/main delete my commit?▼

No, as long as you first create a branch from the accidental commit with git checkout -b. The commit stays safe on that branch while main is reset to match origin, and you can then push the branch and open a PR.

When should I create a pull request instead of pushing to main?▼

Always, for any change including docs and one-liners. The workflow is to create a short-lived branch, commit there, push it to origin, and open a PR with gh pr create so changes go through review and CI.