fix: add default-branch guard to commit skills#386
Conversation
The git-commit skill collected the current branch name but never checked whether it was main/master. Add a guard that warns the user and offers to create a feature branch before committing, matching the protection already present in git-commit-push-pr.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 561b289cea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add `git rev-parse --abbrev-ref origin/HEAD` to Step 1 so the guard works for repos whose default branch is not main or master (e.g. develop, trunk). Falls back to main if the remote HEAD is unset. Addresses PR review feedback (#386)
Use `| sed 's@^origin/@@'` directly in the command instead of instructing the agent to strip the prefix in a separate step.
- Add rev-parse command to Step 1 so the branch guard in Step 4 can check the actual default branch, not just hard-coded main - Update Step 4 to reference the resolved default branch - Inline sed pipe in Step 6 symbolic-ref fallback instead of prose instruction to strip the origin/ prefix
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 699c60beb2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Piping into sed returns exit 0 even when the upstream git command fails, so the "fall back to main" path never triggers. The agent reads stdout/stderr directly and can strip the origin/ prefix and detect failures itself. Addresses PR review feedback (#386)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28c3f78ae7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
When origin/HEAD is unavailable (no remote, ref unset), fall back to gh repo view to query the GitHub default branch before hard-coding main. Covers repos using develop/trunk as their default. Addresses PR review feedback (#386)
Both git-commit and git-commit-push-pr skills had a gap: they referenced "the repo's default branch" in their branch-protection guards but never resolved the actual default branch name. Repos using
develop,trunk, or other non-standard defaults would silently bypass the guard.Adds
git rev-parse --abbrev-ref origin/HEAD | sed 's@^origin/@@'to Step 1 of both skills so the guard checks the real default branch, falling back tomainif the remote HEAD is unset. Also inlinessedin git-commit-push-pr's Step 6symbolic-reffallback to remove a prose "strip the prefix" instruction.🤖 Generated with Claude Opus 4.6 (1M context, extended thinking) via Claude Code