Skip to content

fix: harden git workflow skills with better state handling#406

Merged
tmchow merged 9 commits intomainfrom
feat/fix-pr-detection-error
Mar 27, 2026
Merged

fix: harden git workflow skills with better state handling#406
tmchow merged 9 commits intomainfrom
feat/fix-pr-detection-error

Conversation

@tmchow
Copy link
Collaborator

@tmchow tmchow commented Mar 27, 2026

Summary

Three git workflow skills accumulated state-handling gaps: detached HEAD could fall through to invalid push/PR paths, a clean working tree was treated as "nothing to do" even when commits needed pushing or a PR needed creating, and the command prefix convention didn't actually bypass RTK (it operates as a Claude Code hook, not a shell alias).

Changes

  • Detached HEAD handling: Added explicit checks early in both git-commit (Step 1) and git-commit-push-pr (Step 1). Detached HEAD is caught before any commit/push logic runs, with an offer to create a feature branch.
  • No-changes shortcut (git-commit-push-pr): When the working tree is clean, the skill now checks for unpushed commits and missing PRs before stopping. A clean working tree doesn't mean there's nothing to do.
  • PR detection error interpretation (git-commit-push-pr): gh pr view exits 1 when no PR exists, which could surface as misleading error output. Added explicit guidance: "Do not treat every non-zero exit as a fatal error here." The command is unchanged; the interpretation guidance is new.
  • Remove command prefix: Dropped command git / command gh from all three skills and the clean-gone script. RTK is a Claude Code hook that rewrites commands before the shell sees them, so command never bypassed it.
  • Description-only update mode (git-commit-push-pr): The skill can now update an existing PR description without committing. Triggered by phrases like "update the PR description". Confirms intent, summarizes changes, and asks before applying. Supports an optional focus (e.g., "update the PR description and add the benchmarking results").
  • PR description writing principle: When commit messages tell a contradictory story (e.g., "switch to X" then later "switch back"), the description should describe the end state from the final diff, not narrate intermediate steps.

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

Trevin Chow added 8 commits March 26, 2026 23:21
… branches

gh pr view exits 1 when no PR exists, surfacing a misleading error.
gh pr list always exits 0 and its default --state open filter handles
closed/merged PRs automatically. Also adds explicit detached HEAD handling.
…ions

The command prefix was intended to bypass RTK proxies, but RTK operates
as a Claude Code hook (not a shell alias), so command never bypassed it.
Aligns these three skills with the rest of the plugin which uses bare
git/gh.
Allows triggering the skill with "update the PR description" or similar
phrases to refresh an existing PR description without committing or
pushing. Supports an optional focus instruction (e.g., "add benchmarking
results"). Confirms intent, summarizes changes, and asks before applying.
Update git-commit-push-pr to ask before creating a branch when detached HEAD blocks push/PR flow.\nAdd matching detached HEAD guidance to git-commit and refresh the README skill description.
…h-pr

Move detached HEAD detection into Step 1 so it runs before both the
no-changes shortcut and the PR check. The no-changes path now checks
for unpushed commits and missing PRs before stopping, so the skill
can push and create a PR even when there's nothing new to commit.
Rewrite git-commit and git-commit-push-pr around explicit branch and upstream re-checks. Clarify detached HEAD, clean working tree, default branch, and existing PR flows to avoid stale state and invalid branch/PR transitions.
Refine gh pr view handling in git-commit-push-pr so the no-PR case is treated as expected state. Add a compounded learning doc covering the detached HEAD, upstream, default-branch, untracked-file, and PR-detection pitfalls discovered while hardening the git workflow skills.
Clarify the PR description writing guidance so contradictory commit messages are treated as intermediate history and the full branch diff remains the source of truth for what shipped.
Copy link

@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: 239f3bcc4f

ℹ️ 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".

gh pr view can return CLOSED/MERGED PRs on reused branches.
Without the state gate, the skill skips PR creation or edits
the wrong PR. Restores the check in both the full workflow
(Step 3) and the description-update flow (DU-2).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tmchow tmchow merged commit f83305e into main Mar 27, 2026
2 checks passed
@github-actions github-actions bot mentioned this pull request Mar 27, 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