Skip to content

Add local hooks protecting main branch#14

Merged
xhwSkhizein merged 1 commit intomainfrom
codex/main-branch-local-protection
Apr 14, 2026
Merged

Add local hooks protecting main branch#14
xhwSkhizein merged 1 commit intomainfrom
codex/main-branch-local-protection

Conversation

@xhwSkhizein
Copy link
Copy Markdown
Owner

@xhwSkhizein xhwSkhizein commented Apr 14, 2026

Summary

  • add repo-local pre-commit and pre-push hooks that block direct work on main
  • document hook activation and troubleshooting in AGENTS.md
  • record the local protection design note under docs/superpowers/specs

Validation

  • ./scripts/check.sh
  • verified .githooks/pre-commit rejects commits on main
  • verified .githooks/pre-push rejects pushes to refs/heads/main

Summary by CodeRabbit

  • New Features

    • Added local Git hooks that block direct commits and pushes to the main branch, guiding developers to use feature branches and pull requests instead.
  • Documentation

    • Updated contributor guidelines with setup and troubleshooting instructions for branch protection hooks.
    • Added design specification detailing the repository-local branch protection workflow.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 019eab24-60b1-4012-8fa0-cd803b7555fd

📥 Commits

Reviewing files that changed from the base of the PR and between 6311d77 and 3954dfe.

📒 Files selected for processing (4)
  • .githooks/pre-commit
  • .githooks/pre-push
  • AGENTS.md
  • docs/superpowers/specs/2026-04-14-main-branch-local-protection-design.md

📝 Walkthrough

Walkthrough

This PR adds repository-local Git hooks under .githooks/ to prevent direct commits and pushes to the main branch. It includes pre-commit and pre-push hook scripts along with design documentation and contributor guidance on activation via git config core.hooksPath .githooks.

Changes

Cohort / File(s) Summary
Git Hooks
.githooks/pre-commit, .githooks/pre-push
Two new POSIX shell hook scripts that enforce branch protection locally. The pre-commit hook blocks commits when the current branch is main; the pre-push hook rejects direct pushes targeting refs/heads/main. Both fail with exit code 1 and print instructional messages when violations are detected.
Documentation
AGENTS.md, docs/superpowers/specs/2026-04-14-main-branch-local-protection-design.md
Updated contributor guidance to document the new hook location, activation method (git config core.hooksPath .githooks), and troubleshooting steps. Added design specification defining the local branch protection workflow, hook behaviors, advisory nature (bypassable via --no-verify), and validation steps.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops to guard the main,
With hooks that catch each stray refrain,
No direct pushes, no commits astray,
Just pull requests the proper way! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description lacks the required PR template structure including Type of Change checkboxes and Checklist items, though it provides a custom summary and validation details. Use the repository's PR template structure with Type of Change section and Checklist items to ensure consistency and completeness.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add local hooks protecting main branch' accurately and concisely summarizes the main change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/main-branch-local-protection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

xhwSkhizein

This comment was marked as low quality.

@xhwSkhizein xhwSkhizein merged commit 267a4ba into main Apr 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant