SuperAPI AI Directory

create-pr

Design & creation

View repository

Updated 10-15 21:40

About this skill

create-pr

Analyze the changes, perform a security check, and then create a GitHub PR.

Prerequisites

  • gh The CLI is installed and authenticated
  • The current branch is forked from the base branch

Flow

Step 1: Analyze the changes

git log main..HEAD --oneline
git diff main...HEAD --stat

The base branch follows the repository's conventions (main / develop etc.).

Step 2: Security check (required)

Perform a security check using the Agent tool.

Check items:

  • Missing authentication/authorization implementation
  • Hardcoding of API keys/secrets
  • Possibility of XSS
  • Lack of input validation
  • OWASP Top 10

If any issues are found, warn the user and advise them to retry PR creation after addressing them.

Step 2.5: Check the milestone of the Issue to be closed

Identify the Issue(s) (same-repo only) that this PR is intended to close, and check their milestone assignment status.

  1. Identify candidates: from the Issue number being worked on (conversation context) and the commit messages on the branch Closes #N / Fixes #N / Resolves #N references
  2. Confirm whether to close: for each candidate, confirm "whether this PR completes that Issue" (Issues that are only partially implemented or merely related should not be closed. In the PR body in Step 4, write only the close targets as Closes #N and for the rest use Refs #N etc. as related references only)
  3. Milestone check: for the Issues confirmed as close targets, check the assignment status as follows. Guard for repositories that do not use milestones: If the repository has no milestones at all (including closed), consider it a repository that does not use milestones, and skip only this procedure 3 without checking or warning, then proceed to Step 3 (do not add noise to PR creation for repositories that do not use milestones. Do not skip the close-ability check in procedures 1-2, as it is a safety check unrelated to milestones)
# 非運用ガード: MILESTONE_COUNT が 0 なら手順 3 をスキップして Step 3 へ進む
MILESTONE_COUNT=$(gh api "repos/{owner}/{repo}/milestones?state=all" --jq 'length')

if ! [[ "${MILESTONE_COUNT}" =~ ^[0-9]+$ ]]; then
  # gh api の失敗等で件数が数値化できない場合は fail-open せず中止して原因を確認する
  echo "milestone 件数の取得に失敗した。原因を確認してから手順 3 をやり直す" >&2
  exit 1   # fail-closed: 診断だけ出して PR 作成へ進まない
elif [ "${MILESTONE_COUNT}" -eq 0 ]; then
  echo "milestone 非運用リポジトリのためスキップして Step 3 へ進む"
else
  # close 対象 Issue の milestone 割当状況を確認する
  gh issue view <N> --json milestone --jq '.milestone.title // empty'
fi
  • A milestone is already assigned → proceed to the next Step
  • If unassigned:
    • If there is only one open milestone, ask the user whether it is okay to assign that milestone, and if consent is obtained, assign it with gh issue edit <N> --milestone <title> to attach with
    • If there are multiple or 0, ask the user. If it cannot be decided which milestone to use, you may proceed to Step 3 with no milestone, but state that clearly in the PR body as a warning (assuming that in repositories with a CI gate that requires milestones, that will function as the last line of defense, and this Step does not block PR creation itself)

If there is no Issue to close with this PR, skip this Step.

Step 3: Generate the PR title

Conventional Commits format: type(scope): subject

Example:

feat(auth): ソーシャルログイン機能を追加
fix(api): レスポンスのエラーハンドリングを修正

Step 4: Generate the PR body

## Summary

- 変更内容の箇条書き

## Test plan

- [ ] 動作確認手順1
- [ ] 動作確認手順2
- [ ] エッジケース確認

## Design

- Figma: (あれば記載)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Step 5: Create the PR

gh pr create \
  --base main \
  --title "type(scope): subject" \
  --body "$(cat <<'EOF'
...
EOF
)"

Return the PR URL to the user.

Verification

After creating the PR, confirm the following before declaring completion (if .claude/rules/verification.md exists in the target repository, follow its 5-stage gate. If it does not exist, follow these key points: run the commands anew, check the entire output and exit code, and only then declare completion). Declaring completion with speculative wording such as "the PR should have been created" is prohibited.

# PR が作成されたことと CI ステータスを確認する
gh pr view <pr-number>
gh pr checks <pr-number>

Common failures

Problem Workaround
Continuing PR creation even after detecting a security issue If a problem is discovered in Step 2, immediately stop the process, warn the user, and request a fix
Completing without returning the PR URL gh pr create Obtain the PR URL from the output of and present it to the user
Using a title that does not conform to the Conventional Commits format type(scope): subjectstrictly follow the (within 72 characters) format
Creating a PR while the Closes target Issue is still unassigned to a milestone → it fails for the first time in CI Always check in Step 2.5. Even if the milestone cannot be fully decided, leave a warning in the PR body

Notes

  • The base branch follows the repository's conventions
  • If a security issue is unresolved, abort PR creation
  • Do not omit the milestone check in Step 2.5 (if there is no Closes target, all of Step 2.5 may be skipped; in repositories that do not use milestones, only procedure 3 may be skipped)
  • When creating a Draft PR, --draft add the flag (confirm with the user)

Execution in a sandbox environment

This skill requires GitHub operations over the network (git push / gh pr create). The relevant commands are executed with the sandbox disabled on a per-command basis. It cannot be executed in an environment where network blocking cannot be lifted.