본문으로 건너뛰기
cccskills
무료GitHub에 공개

gwt-pr

Create or update GitHub Pull Requests with the gh CLI, including deciding whether to create a new PR or only push based on existing PR merge status. Use when the user asks to open/create/edit a PR, generate a PR body/template, or says 'open a PR/create a PR/gh pr'. Defaults: base=develop, head=current branch (same-branch only; never create/switch branches).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구GitHub
설치 방법 보기

포함된 파일(2)

  • SKILL.md15.3 KB
  • references/pr-body-template.md3.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

GH PR

Overview

Create or update GitHub Pull Requests with the gh CLI using a detailed body template and strict same-branch rules.

Decision rules (must follow)

  1. Do not create or switch branches. Always use the current branch as the PR head.
  2. Only develop may target main. If the base is main and the head branch is anything other than develop, refuse to create the PR and instruct the user to merge into develop first, then create a release PR from develop.
  3. Check local working tree state before push/PR operations.
    • git status --porcelain
    • If output is non-empty (tracked or untracked changes), pause and ask the user what to do.
    • Present 3 options: continue as-is, abort, or manual cleanup then rerun.
    • Do not run git stash, git commit, or git clean automatically unless explicitly requested.
  4. Check for an existing PR for the current head branch.
    • gh pr list --head <head> --state all --json number,state,mergedAt,updatedAt,url,title,mergeCommit
  5. If no PR exists → create a new PR.
  6. If any PR exists and is NOT merged (mergedAt is null) → push only and finish (do not create a new PR).
    • This applies to OPEN or CLOSED (unmerged) PRs.
    • Only update title/body/labels if the user explicitly requests changes.
  7. If all PRs for the head are merged → check for post-merge commits (see below).
  8. If multiple PRs exist for the head → use the most recently updated PR for reporting, but the create vs push decision is based on mergedAt.

Post-merge commit check (critical)

When all PRs for the head branch are merged, you must check whether there are new commits after the merge:

  1. Get the merge commit SHA of the most recent merged PR.
  2. Validate merge commit ancestry first: git merge-base --is-ancestor <merge_commit> HEAD
  3. If the merge commit is an ancestor of HEAD, count commits after the merge:
    • git rev-list --count <merge_commit>..HEAD
  4. If the merge commit is missing or not an ancestor of HEAD, fallback to the branch upstream first:
    • git rev-list --count origin/<head>..HEAD
  5. If the upstream comparison fails, fallback to the base branch comparison:
    • git rev-list --count origin/<base>..HEAD
  6. Decision:
    • If the selected count is greater than 0 → create a new PR
    • If the selected count is 0 → report "No new changes since merge" and finish
    • If both fallback comparisons fail → stop and report MANUAL CHECK

Why this matters

  • Scenario A: PR merged → user makes local changes → pushes → changes are NOT in the merged PR
    • Without this check, the changes would be lost or require manual intervention
  • Scenario B: PR merged → user says "create PR" without new changes → would create empty/duplicate PR
    • This check prevents unnecessary PR creation

PR title rules (must follow)

  1. Format: <type>(<scope>): <subject> — follow Conventional Commits.
  2. type: must be one of feat / fix / docs / chore / refactor / test / ci / perf.
  3. scope: optional. Use a short scope that clearly identifies the affected area (for example: gui, core, pty).
  4. subject: keep it within 70 characters. Use the imperative mood (for example: "add ..." / "fix ..."). Do not capitalize the first letter or end with a period.
  5. If the branch name has a prefix such as feat/ or fix/, the title type must match that prefix.

PR body rules (must follow)

Section classification

SectionRequiredNotes
SummaryYES1-3 bullet points. Include both the what and the why.
ChangesYESEnumerate changes by file or module.
TestingYESList the commands run or the exact manual test steps.
Closing IssuesYESCloses #N 形式。クローズ対象がなければ "None"。
Related Issues / LinksYES参照のみ(自動クローズしない)。
ChecklistYESReview every item and mark it checked or N/A.
ContextConditionalRequired when 3 or more files changed or the rationale is non-trivial.
Risk / ImpactConditionalRequired when the change is breaking, performance-sensitive, or needs rollback steps.
ScreenshotsConditionalRequired only for UI changes.
DeploymentOptionalInclude only when deployment steps exist.
NotesOptionalInclude only when reviewers need extra context.

Validation (agent must check before creating PR)

  1. Do not create a PR if any required section still contains TODO.
  2. If a conditional section does not apply, remove the entire section instead of leaving an empty TODO.
  3. Each Summary bullet must be a single sentence. Do not use vague wording such as "several changes" or "various fixes."
  4. Changes must be specific and include the changed file or module names.
  5. Testing must be reproducible. Do not use vague wording such as "tested."
  6. Add a reason comment to every unchecked checklist item (for example: - [ ] Docs updated — N/A: no user-facing change).
  7. Related Issues must be written as #123 or as a URL. If nothing applies, explicitly write "None".
  8. Closing Issues セクションは Closes #N または None のみ許可。- #N(キーワードなし)は不可。
  9. Related Issues / Links に #N があり、その Issue をリリースで閉じたい場合は、同じ番号を Closing Issues にも Closes #N で必ず記載する。Related Issues / Links のみでは auto-close されない。

Issue/PR Comment Formatting (must follow)

  • Final comment text must not contain escaped newline literals such as \n.
  • Use real line breaks in comment bodies. Do not rely on escaped sequences for formatting.
  • Before posting, verify the final body does not accidentally include escaped control sequences (\n, \t).
  • If a raw escape sequence must be shown for explanation, include it only inside a fenced code block and clarify it is intentional.

Issue Progress Comment Template (required for issue-based work)

When work is tracked in GitHub Issues, progress updates must use this template:

Progress
- ...

Done
- ...

Next
- ...
  • Post updates at least when starting work, after meaningful progress, and when blocked/unblocked.
  • In Next, explicitly state blockers or the immediate next action.

Workflow (recommended)

  1. Confirm repo + branches

    • Repo root: git rev-parse --show-toplevel
    • Current branch (head): git rev-parse --abbrev-ref HEAD
    • Base branch defaults to develop unless user specifies.
  2. Check local working tree state (preflight)

    • Run git status --porcelain.
    • If empty, continue.
    • If non-empty, show detected files and ask the user to choose:
      • Continue as-is
      • Abort
      • Manual cleanup first (git commit / git stash / git clean) and rerun
    • Proceed only when the user explicitly chooses continue.
  3. Fetch latest remote state

    • git fetch origin to ensure accurate comparison
  4. Check branch sync against base (critical)

    • Run git rev-list --left-right --count "HEAD...origin/$base".
    • Parse the result as ahead behind.
    • If behind == 0, continue.
    • If behind > 0, merge origin/$base into the current branch before PR creation.
    • The update strategy is always git merge origin/$base; do not use rebase for this workflow.
    • After merge, push the branch so the PR branch and worktree stay aligned with gwt's remote-first flow.
    • If merge conflicts occur, inspect the affected files carefully, resolve only when the resulting behavior is coherent, and continue.
    • If you cannot resolve the conflict with high confidence, stop and ask the user before proceeding.
  5. Check existing PR for head branch

    • Use decision rules above to pick action.
    • Treat mergedAt as the source of truth for "merged".
  6. If all PRs are merged, perform post-merge commit check

    • Get merge commit: gh pr list --head <head> --state merged --json mergeCommit -q '.[0].mergeCommit.oid'
    • If the merge commit is an ancestor of HEAD, count git rev-list --count <merge_commit>..HEAD
    • If the merge commit is missing or not an ancestor, count git rev-list --count origin/<head>..HEAD first
    • Only if the upstream comparison fails, count git rev-list --count origin/<base>..HEAD
    • If the selected count is 0 → finish with message "No new changes since merge"
    • If the selected count is >0 → proceed to create new PR
    • If neither comparison is usable → stop with MANUAL CHECK
  7. Ensure the head branch is pushed

    • If no upstream: git push -u origin <head>
    • Otherwise: git push
  8. Collect PR inputs (for new PR or explicit update)

    • Title, Summary, Context, Changes, Testing, Risk/Impact, Deployment, Screenshots, Related Links, Notes
    • Optional: labels, reviewers, assignees, draft
  9. Build PR body from template

    • Read the template from the gwt-pr skill path (not the current project path):
      • PR_BODY_TEMPLATE=".gemini/skills/gwt-pr/references/pr-body-template.md"
    • Read ${PR_BODY_TEMPLATE} and fill all required placeholders.
    • Derive missing sections from the diff, linked Issues/SPECs, and executed tests before asking the user.
    • If a conditional section does not apply, remove the entire section.
    • Remove any <!-- GUIDE: ... --> comments from the final output.
    • If any required section still contains TODO after inference, ask only for the irreducible missing information.
  10. Create or update the PR

    • Primary path:
      • Create: gh pr create -B <base> -H <head> --title "<title>" --body-file <file>
      • Update (only if user asked): gh pr edit <number> --title "<title>" --body-file <file>
    • If gh pr create or gh pr edit fails with a secondary rate limit or was submitted too quickly, do not stop.
    • Resolve the repo slug first: gh repo view --json nameWithOwner -q .nameWithOwner
    • REST fallback:
      • Create: gh api repos/<owner>/<repo>/pulls --method POST --input <json-file>
      • Update: gh api repos/<owner>/<repo>/pulls/<number> --method PATCH --input <json-file>
    • Keep the same title/body content across the primary path and REST fallback.
  11. Return PR URL

    • gh pr view <number> --json url -q .url
  12. Post-PR CI/merge check (automatic).

    • After PR creation or push, load .gemini/skills/gwt-pr-fix/SKILL.md and follow its workflow to inspect CI status, merge state, and review feedback.
    • If all CI checks are still pending, poll (30s interval) until complete.
    • If conflicts, review issues, or CI failures are detected, proceed with the gwt-pr-fix workflow to diagnose and fix.

Command snippets (bash)

head=$(git rev-parse --abbrev-ref HEAD)
base=develop
PR_BODY_TEMPLATE=".gemini/skills/gwt-pr/references/pr-body-template.md"

if [ ! -f "$PR_BODY_TEMPLATE" ]; then
  echo "PR template not found: $PR_BODY_TEMPLATE" >&2
  exit 1
fi

# Preflight: local working tree state
status_lines=$(git status --porcelain)
if [ -n "$status_lines" ] && [ "${ALLOW_DIRTY_WORKTREE:-0}" != "1" ]; then
  echo "Detected local uncommitted/untracked changes:" >&2
  echo "$status_lines" >&2
  echo "Choose one before continuing: continue as-is, abort, or manual cleanup then rerun." >&2
  echo "Set ALLOW_DIRTY_WORKTREE=1 only after explicit user confirmation to continue." >&2
  exit 1
fi

# Fetch latest remote state
git fetch origin

# Check branch sync against base before PR creation
divergence=$(git rev-list --left-right --count "HEAD...origin/$base" 2>/dev/null) || {
  echo "Failed to compare HEAD with origin/$base" >&2
  exit 1
}
ahead_count=$(echo "$divergence" | awk '{print $1}')
behind_count=$(echo "$divergence" | awk '{print $2}')

if [ "${behind_count:-0}" -gt 0 ]; then
  echo "Merging origin/$base into $head before PR creation"
  git merge "origin/$base" || {
    echo "Base-branch merge produced conflicts. Inspect and resolve them before continuing." >&2
    exit 1
  }
  git push -u origin "$head"
fi

# Check existing PRs for the head branch
pr_json=$(gh pr list --head "$head" --state all --json number,state,mergedAt,mergeCommit)
pr_count=$(echo "$pr_json" | jq 'length')
unmerged_count=$(echo "$pr_json" | jq 'map(select(.mergedAt == null)) | length')

if [ "$pr_count" -eq 0 ]; then
  action=create
elif [ "$unmerged_count" -gt 0 ]; then
  action=push_only
else
  # All PRs are merged - check for post-merge commits
  merge_commit=$(echo "$pr_json" | jq -r 'sort_by(.mergedAt) | last | .mergeCommit.oid')
  new_commits=""

  if [ -n "$merge_commit" ] && [ "$merge_commit" != "null" ] && \
     git merge-base --is-ancestor "$merge_commit" HEAD 2>/dev/null; then
    new_commits=$(git rev-list --count "$merge_commit"..HEAD 2>/dev/null || echo "")
  fi

  if [ -n "$new_commits" ]; then
    if [ "$new_commits" -gt 0 ]; then
      echo "Found $new_commits commit(s) after merge - creating new PR"
      action=create
    else
      echo "No new commits since merge - nothing to do"
      action=none
    fi
  else
    upstream_commits=$(git rev-list --count "origin/$head"..HEAD 2>/dev/null || echo "")

    if [ -n "$upstream_commits" ]; then
      if [ "$upstream_commits" -gt 0 ]; then
        echo "Found $upstream_commits commit(s) ahead of origin/$head - creating new PR"
        action=create
      else
        echo "No new commits ahead of origin/$head - nothing to do"
        action=none
      fi
    else
      fallback_commits=$(git rev-list --count "origin/$base"..HEAD 2>/dev/null || echo "")

      if [ -n "$fallback_commits" ]; then
        if [ "$fallback_commits" -gt 0 ]; then
          echo "Upstream comparison unavailable; found $fallback_commits commit(s) ahead of origin/$base - creating new PR"
          action=create
        else
          echo "Upstream comparison unavailable and no commits ahead of origin/$base - nothing to do"
          action=none
        fi
      else
        echo "Manual check required: could not determine whether new commits exist after the last merge" >&2
        action=manual_check
      fi
    fi
  fi
fi

# Execute action
case "$action" in
  create)
    cp "$PR_BODY_TEMPLATE" /tmp/pr-body.md

    git push -u origin "$head"
    gh pr create -B "$base" -H "$head" --title "..." --body-file /tmp/pr-body.md || {
      repo_slug=$(gh repo view --json nameWithOwner -q .nameWithOwner)
      jq -n --arg title "..." --arg head "$head" --arg base "$base" --rawfile body /tmp/pr-body.md \
        '{title:$title, head:$head, base:$base, body:$body}' >/tmp/pr-create.json
      gh api "repos/$repo_slug/pulls" --method POST --input /tmp/pr-create.json
    }
    ;;
  push_only)
    echo "Existing unmerged PR found - pushing changes only"
    git push
    gh pr list --head "$head" --state open --json url -q '.[0].url'
    ;;
  none)
    echo "No action needed - no new changes since last merge"
    ;;
  manual_check)
    echo "Manual check required - post-merge commit status could not be determined" >&2
    exit 1
    ;;
esac

References

  • .gemini/skills/gwt-pr/references/pr-body-template.md: PR body template

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

drawio

무료

Create and edit draw.io diagrams in XML format. Use when the user wants to create flowcharts, architecture diagrams, sequence diagrams, or any visual diagrams. Handles XML structure, styling, fonts (Noto Sans JP), arrows, connectors, and PNG export.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akiojin/llmlb102026년 10월 18일 업데이트

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akiojin/llmlb102026년 10월 18일 업데이트

Inspect GitHub PR for CI failures, merge conflicts, update-branch requirements, reviewer comments, change requests, and unresolved review threads. Create fix plans and implement after user approval. Reply to ALL reviewer comments with action taken or reason for not addressing, then resolve threads. Notify reviewers after fixes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akiojin/llmlb102026년 10월 18일 업데이트

Check GitHub PR status with the gh CLI, including unmerged PR detection and post-merge new-commit detection for the current branch.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akiojin/llmlb102026년 10월 18일 업데이트

Semantic search over project source files using vector embeddings. Use to find files related to a feature, bug, or concept.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akiojin/llmlb102026년 10월 18일 업데이트

PTY based communication tools for Project Mode orchestration (Lead/Coordinator/Developer).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

akiojin/llmlb102026년 10월 18일 업데이트

akiojin의 스킬 모두 보기

이 스킬의 문제 신고