pr
GitHub PR workflow - create, status, merge with intelligent conflict handling
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
GitHub PR workflow - create, status, merge with intelligent conflict handling
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
Read and write the second brain — a git-backed Obsidian vault at ~/SourceRoot/brain (PARA structure + a top-level wiki/ knowledge tree). Use whenever the user mentions "brain", "second brain", "knowledge base", "note", "remember", "look up", "find note", "capture", "wiki", or "okf". Also use for any request to save, retrieve, or organize personal knowledge that belongs in the brain rather than in a repo-specific doc.
Write, draft, and polish prose through a human-owned 7-step pipeline. Use whenever the user says "distill", "write article", "draft", "summarize into", "create content", "synthesize", or "publish". Also use for any task where the output is a piece of long-form writing — the pipeline keeps prose quality out of coding sessions.
RETIRED — manage the (now decommissioned) per-machine mlx-audio TTS/STT stack; TTS/STT moved to the cloud audio-gateway (VPS)
Operate the Mac mini remote dev host — connecting from the MacBook over mosh or herdr --remote, running and reattaching many Claude Code agents, herdr workspaces/panes and its socket API, claude --bg durable daemons, the Uptime Kuma readiness heartbeat, and the failure modes specific to a headless always-on Mac. Use when the user mentions herdr, mosh, the mini, "remote dev", "dev host", detaching or reattaching agents, "did my agent survive", sessions dying on lid-close, or asks how to reach a dev server running on the mini.
Manage the personal image stack — public CDN uploads/transform URLs and the private image-share layer. Use whenever an image needs a URL (public or private) for an article, blog post, vault note, README, OpenGraph tag, or a one-off share; or when the user says "upload this image", "share this image", "private image", "publish image", "host this screenshot", "get me a CDN link", "resize this", mentions "image-share", or asks where an image lives.
Bidirectionally sync ALL git repos across two machines — this MacBook and the always-on Mac mini — over SSH, using GitHub/GitLab as the transport. Commits and pushes uncommitted work on both sides, then rebases/fast-forwards each so they converge, with per-repo subagents resolving rebases and merge conflicts. This is a MULTI-repo, TWO-machine operation — distinct from /commit, /ship, or /git-cleanup, which act on a single repo. Use whenever the user wants to sync their machines/repos, "catch up" the laptop to the Mac mini or push laptop work back, is about to travel or just got back, has uncommitted work scattered across many repos, or wants to reconcile branches that diverged between the two machines. Trigger even on a bare "sync", "sync my machines", or "get my repos up to date".
| name | pr |
| description | GitHub PR workflow - create, status, merge with intelligent conflict handling |
Manage GitHub Pull Requests with intelligent branch management, conflict resolution, CodeRabbit integration, and full review iteration loop.
Platform: GitHub (SourceRoot projects)
action - Action to perform: create (default), status, merge, updateticket - Optional ticket number (JK-XX). Auto-detected if not provided.--draft - Create as draft PR| Action | Description |
|---|---|
create | Create new PR (default action) |
update | Update existing PR description |
status | Fetch PR status, CI, CodeRabbit findings, and offer to fix issues |
merge | Merge PR via rebase (trunk-based) |
When iterating on an existing PR after review feedback:
/commit --amend (amends last commit + force push)/pr status (re-check CI + CodeRabbit, offer to fix remaining issues)/pr update if implementation approach changed substantivelyWhen to update PR description:
When NOT to update:
/pr createdefault_branch=$(git remote show origin | grep "HEAD branch" | cut -d: -f2 | xargs)
current_branch=$(git branch --show-current)
Check: On default branch or detached HEAD?
$default_branch. Create a feature branch first: git checkout -b feat/description"Check: Branch name relevance
Fetch branch context:
git log --oneline origin/$default_branch..HEAD
git diff origin/$default_branch..HEAD --stat
Analyze whether the branch name reflects the actual changes:
feat/, fix/, refactor/, docs/, chore/, test/, build/, ci/, perf/feat/user-settings but all commits are about auth)If mismatch detected:
Branch name 'feat/user-settings' may not match your changes.
Commits suggest this is auth-related work.
Suggested rename: feat/auth-login
Commands:
git branch -m feat/user-settings feat/auth-login
git push origin --delete feat/user-settings (if already pushed)
git push -u origin feat/auth-login
Rename now? [y/N]
If user confirms: execute the rename. Continue with the new branch name.
# Check for uncommitted/unstaged changes
git status --short
# Count commits ahead of default
commit_count=$(git rev-list --count origin/$default_branch..HEAD 2>/dev/null || echo 0)
If uncommitted changes exist:
Uncommitted changes detected. Running /commit first...
Invoke /commit skill:
Skill({ skill: "commit" })
Wait for commit to complete, then continue.
If commit_count >= 3:
Branch is $commit_count commits ahead of $default_branch.
Consider '/git-cleanup' to group commits into logical units before creating the PR.
Run '/git-cleanup' now? [y/N/skip]
y → Skill({ skill: "git-cleanup" }), wait for completion, then continueN or skip → continue without cleanupALWAYS run /check skill:
Skill({ skill: "check" })
CRITICAL: Abort if validation fails. Show errors and suggest fixes. Do not proceed with PR creation on failing code.
Priority order:
/pr create JK-123.openspec/changes/*/proposal.md for ticket referencefeat/JK-123-* patternRefs: JK-XX in commit messagesgit fetch origingit rebase origin/$default_branchgit add <file> && git rebase --continuegit push (or git push -u origin $current_branch if first push)gh pr list --head $(git branch --show-current) --json number,url,title
CRITICAL: NO AI ATTRIBUTION
PR Title: Derived from the most significant commit message on the branch, or synthesized from the commit sequence. Follows conventional commits format. Max 70 chars.
Generate PR body by analyzing git log origin/$default_branch..HEAD + git diff origin/$default_branch..HEAD:
gh pr create \
--title "<type>(<scope>): <subject>" \
--body "$(cat <<'EOF'
## Summary
[1-2 sentences explaining WHY this is being done — the problem solved or value added.
Write for a teammate who hasn't followed this implementation.
NOT: "Updated auth module"
YES: "Token refresh was silently failing on long sessions — this implements automatic
rotation to prevent 401s in long-lived user flows."]
## What Changed
- [Impact-focused bullet: WHAT changed + WHY it matters — not file-focused]
- [Another change + its impact on users or the system]
## Technical Notes
[DELETE this section entirely if no meaningful architecture decisions, tradeoffs, or
reviewer attention points. Do not include if there's nothing genuinely useful to say.
Delete the section header too.]
- [Architecture choice + rationale]
- [Non-obvious implementation decision]
- [Breaking change implications]
## Testing
- [x] Code quality validation passed (format + lint + types)
- [ ] [Specific manual test scenario derived from what actually changed]
EOF
)"
[--draft] # if --draft flag passed
Generation rules:
Show:
/pr status to check CI and reviews"Whenever a PR exists, ALWAYS fetch and parse ALL CodeRabbit feedback. CodeRabbit posts as user coderabbitai[bot].
MANDATORY: Run all three API calls below — every time, without exception. Never skip or abbreviate. Use --paginate to retrieve all pages.
# Get repo info for API calls
owner=$(gh repo view --json owner -q .owner.login)
repo=$(gh repo view --json name -q .name)
# 1. Issue comments (CodeRabbit summary/overview posts) — ALL pages
gh api --paginate "repos/$owner/$repo/issues/$pr_number/comments" \
--jq '[.[] | select(.user.login == "coderabbitai[bot]")]'
# 2. Inline review comments (line-by-line code feedback) — ALL pages
gh api --paginate "repos/$owner/$repo/pulls/$pr_number/comments" \
--jq '[.[] | select(.user.login == "coderabbitai[bot]")]'
# 3. PR reviews (approval status and review body from CodeRabbit) — ALL pages
gh api --paginate "repos/$owner/$repo/pulls/$pr_number/reviews" \
--jq '[.[] | select(.user.login == "coderabbitai[bot]") | {state, body, submitted_at}]'
From issue comments (summary post):
[BLOCKER], or "must fix"From inline review comments:
in_reply_to_id setpath)diff_hunk context (trimmed to 5 lines), and full comment bodyFrom reviews:
state == "CHANGES_REQUESTED" → flag as blocking mergestate == "APPROVED" → note approvalbody if non-empty (not truncated)### CodeRabbit
**Review:** Approved | Changes Requested | Pending
**Summary:**
[Full text of the CodeRabbit summary issue comment, untruncated]
**Inline Comments (N total):**
#### `src/auth/token.ts`
- **Line 42** [Blocking] — Potential null dereference when `refreshToken` is undefined.
> diff_hunk context (trimmed)
Full comment body here.
- **Line 55** [Suggestion] — Variable name `t` is unclear, prefer `token`.
> diff_hunk context (trimmed)
Full comment body here.
#### `src/api/routes.ts`
- **Line 18** [Blocking] — Missing input validation on `userId` parameter.
Full comment body here.
If no CodeRabbit comments found on any of the three endpoints: **CodeRabbit:** No review yet
/pr status# Get PR number and repo info
pr_number=$(gh pr view --json number -q .number)
owner=$(gh repo view --json owner -q .owner.login)
repo=$(gh repo view --json name -q .name)
# Check for local uncommitted changes or unpushed commits
git status --short
unpushed=$(git rev-list --count origin/$(git branch --show-current)..HEAD 2>/dev/null || echo 0)
# Get PR details
gh pr view $pr_number --json state,mergeable,mergeStateStatus,reviewDecision,body
# Get all CI checks
gh pr checks $pr_number
# MANDATORY: Load ALL CodeRabbit comments — run all three calls (see section above)
# Load ALL user (non-bot) PR comments — always, same as CodeRabbit
gh api --paginate "repos/$owner/$repo/issues/$pr_number/comments" \
--jq '[.[] | select(.user.type != "Bot")] | map({user: .user.login, id, created_at, body})'
gh api --paginate "repos/$owner/$repo/pulls/$pr_number/comments" \
--jq '[.[] | select(.user.type != "Bot")] | map({user: .user.login, id, path, line, diff_hunk, body})'
# Include top-level human PR reviews (state + review body)
gh api --paginate "repos/$owner/$repo/pulls/$pr_number/reviews" \
--jq '[.[] | select(.user.type != "Bot")] | map({user: .user.login, id, state, submitted_at, body})'
If uncommitted changes exist:
You have uncommitted changes.
Run `/check` + `/commit` before checking PR status? [y/N]
If unpushed commits exist:
You have $unpushed unpushed commit(s).
Run `/check` and push first? [y/N]
Format:
## PR #123: feat(auth): add token refresh
**Status:** Draft | Ready for Review | Approved | Changes Requested
**Mergeable:** Yes | No (reason)
### CI Checks (X/Y passed)
- [pass/fail] Check name
- If failed: Error details
### CodeRabbit
[Parsed output per "CodeRabbit Comment Parsing" section]
### PR Discussion Comments (by user)
[Top-level issue comments (no file path). Include: user, created_at, body. Present every comment.]
### Inline File Comments (by user)
[All non-bot inline comments grouped by `path`. Include: user, file path, line, body. Present every comment — do not skip.]
### Actions Available
- Fix blocking issues (see below)
- Mark ready: `/pr update --ready` (if draft)
- Merge: `/pr merge` (if all checks pass)
After presenting the full status, process CodeRabbit feedback interactively:
If CHANGES_REQUESTED review state:
⚠️ CodeRabbit requested changes — address all blocking issues before merging.
Blocking items — ask for each one in sequence:
CodeRabbit found 2 blocking issues:
1. [Blocking] src/auth/token.ts:42 — Potential null dereference when refreshToken is undefined
2. [Blocking] src/api/routes.ts:18 — Missing input validation on userId parameter
Implement fix for item 1? [y/N]
y → implement the fix in the main thread, run /check, fold into last commit with /commit --amend, then ask for next blocking itemN → skip that item, ask for next/pr merge once CI passes."Suggestions (non-blocking) — show as numbered list, ask once:
CodeRabbit has 3 suggestions (non-blocking):
1. [Suggestion] src/auth/token.ts:55 — Variable name 't' is unclear, prefer 'token'
2. [Suggestion] src/api/auth.ts:23 — Consider extracting validation to a helper function
3. [Suggestion] src/api/routes.ts:44 — Add JSDoc comment for this public method
Implement any of these? (enter numbers like "1 3", or "none")
/check, /commit --amendnone → proceedCheck if new commits have been added to the branch since PR creation (compare PR body creation date vs latest commit):
gh pr view --json commits,body
If new commits pushed since last description update:
New commits detected since PR description was last written.
Update PR description to reflect current state? [y/N]
y → regenerate description using the improved template (WHY-focused summary, impact bullets), show diff, ask to confirm before applying/pr updateUpdate PR title, description, or status.
ALWAYS run /check first:
Skill({ skill: "check" })
If /check fails → abort, show errors. Do not update PR on failing code.
If passes → regenerate PR description using the improved template, show diff of old vs new, ask for confirmation before applying:
# Update description
gh pr edit --body "updated description"
# Mark as ready (remove draft)
gh pr ready
# Add comment
gh pr comment --body "Additional context..."
/pr mergeCRITICAL: Must run merge from main worktree, not feature worktree.
main_wt=$(git worktree list --porcelain | grep -m1 "^worktree" | cut -d' ' -f2)
current_dir=$(pwd)
if [[ "$current_dir" != "$main_wt" ]]; then
feature_branch=$(git branch --show-current)
echo "Detected feature worktree. Switching to main worktree..."
cd "$main_wt"
fi
No confirmation needed — solo dev workflow with admin privileges.
gh pr merge --rebase --delete-branch --admin
Why --admin? PR-required repos carry the protect-default-branch ruleset (require PR; 0 approvals). --admin lets the owner merge via your admin bypass even if a rule (e.g. the PR requirement or a pending check) would otherwise block — solo-dev streamlining, no second reviewer exists.
if [[ -n "$feature_branch" ]]; then
echo "Removing feature worktree and branch..."
git worktree remove "$feature_branch" --force
git branch -D "$feature_branch"
fi
# Update main worktree ONLY if clean
if git diff-index --quiet HEAD --; then
git pull --rebase
else
echo "Main worktree has uncommitted changes — skipping pull."
echo "Run 'git pull --rebase' manually when ready."
fi
# If basalt-ui package was changed
"basalt-ui package was updated. Run `/release` to publish?"
# If significant feature merged
"Feature merged. Consider `/release` if ready for users."
| Conflict Type | Resolution Strategy |
|---|---|
| Whitespace/formatting only | Take the formatted version |
| Import additions (non-overlapping) | Keep both imports |
| Package.json version field | Take newer version |
| Lock files | Regenerate after rebase |
| Additive changes in different sections | Keep both additions |
| Conflict Type | How to Present |
|---|---|
| Logic in same function | Show both versions with surrounding context |
| Database migrations | NEVER auto-resolve, show both with timestamps |
| API contracts/schemas | Highlight breaking change implications |
| Security-related code | Emphasize security implications |
| Test assertions changed | Show expected vs actual changes |
| Action | Auto | Ask |
|---|---|---|
| Branch validation (on default branch) | Error out | |
| Branch name mismatch detection | Ask to rename | |
| Run /commit for uncommitted changes | Invoke, wait | |
| git-cleanup suggestion (≥3 commits) | Ask y/N/skip | |
| Run /check validation | Auto (abort on fail) | |
| Rebase (no conflicts) | Auto | |
| Auto-resolve safe conflicts | Auto (report) | |
| Complex conflict resolution | Ask | |
| Create branch (ticket found) | Auto | |
| Create branch (no ticket) | Ask | |
| Create PR | Preview first | |
| Update PR description (new commits) | Ask | |
| Mark PR ready | Auto | |
| Implement CodeRabbit blocking fix | Ask per item | |
| Implement CodeRabbit suggestions | Ask (numbered list) | |
| Merge PR (checks pass) | Auto (--admin) | |
| Merge PR (checks fail) | Report & ask |
| Error | Action |
|---|---|
| On default branch | Abort: "Create a feature branch first" |
| Detached HEAD | Abort: "Not on a branch. Check out a branch first." |
| /check fails | Abort, show errors, suggest fixes |
| Not on git repo | Error: "Not in a git repository" |
| No GitHub remote | Error: "No GitHub remote found" |
| gh not authenticated | Prompt: "Run gh auth login" |
| Rebase conflicts (complex) | Present both versions, ask user |
| PR creation fails | Check branch pushed, show error |
| Merge blocked | Show blocking reason, suggest action |
# Create PR for current branch
/pr create
# Create PR with explicit ticket
/pr create JK-123
# Create draft PR
/pr create --draft
# Check PR status with all feedback + CodeRabbit loop
/pr status
# Merge approved PR
/pr merge
.openspec/changes/*/proposal.md for context (if directory exists)/commit skill: Invoked automatically if uncommitted changes found on create/git-cleanup skill: Offered when branch has ≥3 commits on create/check skill: Validates before PR create and update--admin bypass