Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: add default-branch guard to commit skills#386

Merged
tmchow merged 6 commits into
mainfrom
feat/git-commit-main-guard
Mar 26, 2026
Merged

fix: add default-branch guard to commit skills#386
tmchow merged 6 commits into
mainfrom
feat/git-commit-main-guard

Conversation

@tmchow
Copy link
Copy Markdown
Collaborator

@tmchow tmchow commented Mar 26, 2026

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 to main if the remote HEAD is unset. Also inlines sed in git-commit-push-pr's Step 6 symbolic-ref fallback to remove a prose "strip the prefix" instruction.


Compound Engineering v2.53.0
🤖 Generated with Claude Opus 4.6 (1M context, extended thinking) via Claude Code

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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread plugins/compound-engineering/skills/git-commit/SKILL.md Outdated
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)
@tmchow tmchow changed the title feat: add default-branch guard to git-commit skill fix: add default-branch guard to git-commit skill Mar 26, 2026
tmchow added 2 commits March 25, 2026 21:26
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
@tmchow tmchow changed the title fix: add default-branch guard to git-commit skill feat: add default-branch guard to commit skills Mar 26, 2026
@tmchow tmchow changed the title feat: add default-branch guard to commit skills fix: add default-branch guard to commit skills Mar 26, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread plugins/compound-engineering/skills/git-commit/SKILL.md Outdated
Comment thread plugins/compound-engineering/skills/git-commit-push-pr/SKILL.md Outdated
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)
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread plugins/compound-engineering/skills/git-commit-push-pr/SKILL.md Outdated
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)
@tmchow tmchow merged commit 31f07c0 into main Mar 26, 2026
2 checks passed
This was referenced Mar 26, 2026
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