Git push to remote and create GitHub Pull Request. Use when the user wants to push changes and create a PR after completing code changes. Handles worktree environments, automatic upstream setup, and PR creation with Japanese title/body using HEREDOC format.
Pushes the current branch to remote and creates a GitHub Pull Request with structured Japanese descriptions.
This skill provides a workflow for:
gh pr create commandgit command availablegh CLI installed and authenticated (gh auth login)# Get current branch name
git branch --show-current
# Check for uncommitted changes
git status --porcelain
# Check if remote tracking exists
git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null
If upstream is not set (first push):
git push -u origin $(git branch --show-current)
If upstream already exists:
git push
Use HEREDOC format to preserve multi-line body formatting:
gh pr create --title "feat: [機能名]" --base main --body "$(cat <<'EOF'
## 概要
[変更の目的と背景]
## 変更内容
### 主な変更
- [変更点1]
- [変更点2]
### API変更
- [エンドポイント変更]
### UI/UX変更
- [画面変更]
## テスト
- [ ] 手動テスト実施
- [ ] エラーハンドリング確認
## 目視確認TODO
以下の項目は、AIでは確認できないため、必ず人間が画面で確認してください。
変更内容に応じて、できる限り具体的に記載すること。
- [ ] [具体的な確認項目1 - 画面パス、操作手順、期待される表示を記載]
- [ ] [具体的な確認項目2]
## レビュー観点
### 重点的に確認してほしい箇所
1. **[ファイル名]**: [理由]
## チェックリスト
- [ ] TypeScriptの型安全性を確保
- [ ] エラーハンドリングを実装
EOF
)"
# Get current branch
git branch --show-current
# Check if branch exists on remote
git ls-remote --heads origin $(git branch --show-current)
# Check tracking branch
git rev-parse --abbrev-ref --symbolic-full-name @{u}
# Push with upstream tracking (first push)
git push -u origin <branch-name>
# Normal push (after upstream is set)
git push
# Force push (use with caution)
git push --force-with-lease
# Create PR with HEREDOC body
gh pr create --title "<title>" --base main --body "$(cat <<'EOF'
<multi-line body>
EOF
)"
# Create PR interactively
gh pr create
# Create PR with specific reviewers
gh pr create --title "<title>" --body "<body>" --reviewer <username>
# Create draft PR
gh pr create --title "<title>" --body "<body>" --draft
# List PRs
gh pr list
# View PR URL after creation
gh pr view --web
Git worktrees share the same .git directory. Commands work the same way in worktrees:
# Check if in worktree
git rev-parse --git-common-dir
# Push from worktree (same as regular repo)
git push -u origin $(git branch --show-current)
Important: Each worktree has its own branch, so push operations are isolated per worktree.
# Check for uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Uncommitted changes exist. Please commit first."
exit 1
fi
# Prevent PR from main to main
current_branch=$(git branch --show-current)
if [ "$current_branch" = "main" ]; then
echo "Error: Cannot create PR from main branch. Create a feature branch first."
exit 1
fi
# Check gh auth status
gh auth status
# If not authenticated: gh auth login
# Check if PR already exists for branch
gh pr list --head $(git branch --show-current) --state open
Follow Conventional Commits format in Japanese:
| Type | Pattern | Example |
|---|---|---|
| Feature | feat: [機能名]の実装 | feat: 出席管理機能の実装 |
| Bug Fix | fix: [問題]の修正 | fix: ログインエラーの修正 |
| Refactor | refactor: [対象]のリファクタリング | refactor: API構造のリファクタリング |
| Docs | docs: [内容]のドキュメント更新 | docs: READMEの更新 |
| Performance | perf: [対象]のパフォーマンス改善 | perf: クエリの最適化 |
| Style | style: [対象]のスタイル修正 | style: UIデザインの調整 |
#!/bin/bash
# 1. Get current branch
BRANCH=$(git branch --show-current)
# 2. Check not on main
if [ "$BRANCH" = "main" ]; then
echo "Error: Cannot create PR from main branch"
exit 1
fi
# 3. Check for uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Uncommitted changes exist"
exit 1
fi
# 4. Push to remote (with -u if needed)
if ! git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null; then
echo "Setting upstream and pushing..."
git push -u origin "$BRANCH"
else
echo "Pushing to existing upstream..."
git push
fi
# 5. Create PR with HEREDOC
gh pr create --title "feat: 機能の実装" --base main --body "$(cat <<'EOF'
## 概要
[変更の目的と背景]
## 変更内容
### 主な変更
- [変更点1]
- [変更点2]
### API変更
- [エンドポイント変更]
### UI/UX変更
- [画面変更]
## テスト
- [ ] 手動テスト実施
- [ ] エラーハンドリング確認
## 目視確認TODO
以下の項目を必ず人間が画面で確認してください。
変更内容に応じて、できる限り具体的に記載すること。
- [ ] [具体的な確認項目1 - 画面パス、操作手順、期待される表示を記載]
- [ ] [具体的な確認項目2 - 画面パス、操作手順、期待される表示を記載]
## レビュー観点
### 重点的に確認してほしい箇所
1. **[ファイル名]**: [理由]
## チェックリスト
- [ ] TypeScriptの型安全性を確保
- [ ] エラーハンドリングを実装
EOF
)"
# 6. Show PR URL
echo "PR created successfully!"
gh pr view --web
This skill is designed to be used by the github-pr-creator agent:
git status firstfeat/attendance-management, fix/login-error"$BRANCH" to handle special characters--base main: Explicitly specify target branchPR本文の「目視確認TODO」セクションには、AIエージェントでは自動検証できず、人間が実際の画面を見て確認する必要がある項目を記載する。
重要: 変更したページ/コンポーネントに対して、具体的な確認パスと操作手順を書くこと。汎用的な「画面確認」ではなく、「/records/status ページで、検索バーに『山田』と入力し、フィルタ結果が正しく表示されることを確認」のように具体的に書く。
- [ ] `/children/list` ページで児童一覧が正しく表示され、50名以上でもページネーションが動作すること
- [ ] `/records/new` ページでメンション入力時にドロップダウンが正しい位置に表示されること
- [ ] モバイル(375px幅)で `/dashboard` のカードレイアウトが縦並びに切り替わること
- [ ] `/attendance` ページで出席ボタンをタップ後、トーストが画面下部に表示され3秒後に消えること
- [ ] 画面を確認する
- [ ] UIが正しいこと
- [ ] デザインに問題がないこと
# Check remote URL
git remote -v
# If HTTPS, may need credentials
gh auth setup-git
# Set upstream explicitly
git push -u origin $(git branch --show-current)
On Windows, use Git Bash or escape properly:
# PowerShell alternative
$body = @"
## 概要
変更内容...
"@
gh pr create --title "feat: 機能" --base main --body $body