Skip to main content

Claude/ChatGPT Prompt to Configure GitHub Branch Protection & CODEOWNERS

Lock down main with branch protection, required reviewers, linear history, and a CODEOWNERS map your whole team can trust.

Vul de plaatshouders in

Edit the values, then copy your finished prompt.

Jouw Prompt
prompt.txt

                                

What this prompt does

This prompt makes the model act as a senior platform engineer and return the exact CODEOWNERS file, branch-protection JSON, and gh CLI commands to apply them, not vague guidance. Four placeholders shape the output: [repo_name] (the repository), [team_size] (the number of engineers), [reviewers] (required approvals per PR), and [ownership] (the map of who owns which paths).

The structure works because repo governance should be reproducible, not click-ops. By asking for a branch-protection ruleset on main (required status checks, required approving reviews, dismiss stale approvals, require conversation resolution), linear history with force-push and deletion blocks, a complete CODEOWNERS file from [ownership] with glob precedence explained, gh commands to apply it all, and a short hotfix bypass policy, the prompt produces config you can commit and re-apply. Deciding the bypass before enabling signed commits prevents locking out your own emergency fix. Sizing [reviewers] against [team_size] keeps the review requirement achievable, and writing [ownership] as concrete paths means reviews route to the right team automatically instead of landing on whoever happens to be free.

When to use it

  • You are locking down main on [repo_name] and want it reproducible rather than configured by hand.
  • You want required reviews, status checks, and stale-approval dismissal set as a ruleset.
  • You need a CODEOWNERS file built from a specific [ownership] map with glob precedence explained.
  • You want linear history with force-push and deletion blocked.
  • You are weighing signed-commit enforcement and want the tradeoffs spelled out.
  • You need a bypass policy for hotfixes and clarity on who can use it.

Example output

Expect fenced blocks ready to commit: the complete CODEOWNERS file implementing [ownership] with glob precedence explained, the branch-protection ruleset JSON for main (required checks, [reviewers] approving reviews, dismiss stale approvals, require conversation resolution, linear history, force-push and deletion blocks, optional signed commits with tradeoffs), and the gh api/gh CLI commands to apply the protection reproducibly. A short bypass policy for hotfixes and who can use it closes it out.

Pro tips

  • Write [ownership] as concrete path-to-team mappings (e.g. backend owns /api, frontend owns /web) so CODEOWNERS routes reviews automatically.
  • Set [reviewers] to match [team_size]; requiring two approvals on a three-person team will stall every PR.
  • Decide your hotfix bypass before turning signed commits on, or you risk blocking your own emergency fix.
  • Apply the rules with the generated gh commands rather than the UI so the setup is reproducible and reviewable.
  • Have the model explain CODEOWNERS glob precedence — later matching patterns win, and getting that wrong sends reviews to the wrong team.
  • Turn on require-conversation-resolution and dismiss-stale-approvals together; the first stops unresolved threads merging, the second forces re-review after new pushes.
  • Document the hotfix bypass policy in the repo so the team knows who can use it and when, rather than discovering the rule during an incident.

Frequently Asked Questions

Does this apply the settings or just describe them?
It returns runnable `gh api` and `gh` CLI commands so you can apply the branch protection reproducibly from the terminal rather than clicking through the UI, plus the CODEOWNERS file and ruleset JSON you commit to the repo.
How does CODEOWNERS routing work here?
The file is built from your `[ownership]` map, and the prompt explains glob precedence so you understand which pattern wins when paths overlap. Later matching entries take priority, which determines who actually gets requested for review.
Can I require a specific number of reviewers?
Yes. Set `[reviewers]` to the approvals you want per PR and the ruleset enforces it. Match it to `[team_size]` so the requirement is achievable and does not stall every pull request.
Should I enforce signed commits?
It is offered as optional with the tradeoffs spelled out. The key caution is to define your hotfix bypass policy first, because enabling signed commits without one can block your own emergency fixes when you most need them.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Meer in Git & GitHub Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support