Skip to content

feat: add protected-branch check to git safety rules#1

Open
euxaristia wants to merge 3 commits intomasterfrom
chore/protected-branch-rule
Open

feat: add protected-branch check to git safety rules#1
euxaristia wants to merge 3 commits intomasterfrom
chore/protected-branch-rule

Conversation

@euxaristia
Copy link
Copy Markdown
Owner

Summary

  • Add a rule to check for protected branches before pushing, and open a PR instead when protected.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates CLAUDE.md to include a guideline for checking branch protection before pushing. Feedback suggests using a more reliable GitHub API endpoint and query to determine protection status, as the previously suggested endpoint returns a 404 error for unprotected branches.

Comment thread CLAUDE.md Outdated
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@euxaristia
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates CLAUDE.md to include a guideline for checking branch protection before pushing. A suggestion was made to use :owner and :repo placeholders in the gh api command to leverage the CLI's automatic context resolution.

Comment thread CLAUDE.md
- NEVER reset main/master or delete commits with destructive operations
- Always create backup branch before destructive operations
- Use conventional commits: `type(scope): description`
- Before pushing, check whether the target branch is protected (e.g. `gh api repos/{owner}/{repo}/branches/{branch} -q .protected`); if protected, create a feature branch and open a PR instead of pushing directly
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use :owner and :repo placeholders in the gh api example. The gh CLI automatically resolves these to the current repository's context, simplifying execution for the AI.

Suggested change
- Before pushing, check whether the target branch is protected (e.g. `gh api repos/{owner}/{repo}/branches/{branch} -q .protected`); if protected, create a feature branch and open a PR instead of pushing directly
- Before pushing, check whether the target branch is protected (e.g. `gh api repos/:owner/:repo/branches/{branch} -q .protected`); if protected, create a feature branch and open a PR instead of pushing directly
References
  1. The user prefers extremely concise and brief responses. Prioritize high signal-to-noise ratio and minimal conversational filler. (link)

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