$npx -y skills add NeoLabHQ/context-engineering-kit --skill create-prCreate pull requests using GitHub CLI with proper templates and formatting
| 1 | # How to Create a Pull Request Using GitHub CLI |
| 2 | |
| 3 | This guide explains how to create pull requests using GitHub CLI in our project. |
| 4 | |
| 5 | **Important**: All PR titles and descriptions should be written in English. |
| 6 | |
| 7 | ## Prerequisites |
| 8 | |
| 9 | Check if `gh` is installed, if not follow this instruction to install it: |
| 10 | |
| 11 | 1. Install GitHub CLI if you haven't already: |
| 12 | |
| 13 | ```bash |
| 14 | # macOS |
| 15 | brew install gh |
| 16 | |
| 17 | # Windows |
| 18 | winget install --id GitHub.cli |
| 19 | |
| 20 | # Linux |
| 21 | # Follow instructions at https://github.com/cli/cli/blob/trunk/docs/install_linux.md |
| 22 | ``` |
| 23 | |
| 24 | 2. Authenticate with GitHub: |
| 25 | ```bash |
| 26 | gh auth login |
| 27 | ``` |
| 28 | |
| 29 | ## Pre-flight Checks |
| 30 | |
| 31 | Before creating a PR, check for uncommitted changes: |
| 32 | |
| 33 | 1. Run `git status` to check for uncommitted changes (staged, unstaged, or untracked files) |
| 34 | 2. If uncommitted changes exist, use the Skill tool to run the `commit` skill first: |
| 35 | ``` |
| 36 | Skill: commit |
| 37 | ``` |
| 38 | 3. This ensures all your work is committed before creating the PR |
| 39 | |
| 40 | ## Creating a New Pull Request |
| 41 | |
| 42 | 1. First, prepare your PR description following the template in @.github/pull_request_template.md |
| 43 | |
| 44 | 2. Use the `gh pr create --draft` command to create a new pull request: |
| 45 | |
| 46 | ```bash |
| 47 | # Basic command structure |
| 48 | gh pr create --draft --title "✨(scope): Your descriptive title" --body "Your PR description" --base main |
| 49 | ``` |
| 50 | |
| 51 | For more complex PR descriptions with proper formatting, use the `--body-file` option with the exact PR template structure: |
| 52 | |
| 53 | ```bash |
| 54 | # Create PR with proper template structure |
| 55 | gh pr create --draft --title "✨(scope): Your descriptive title" --body-file .github/pull_request_template.md --base main |
| 56 | ``` |
| 57 | |
| 58 | ## Best Practices |
| 59 | |
| 60 | 1. **Language**: Always use English for PR titles and descriptions |
| 61 | |
| 62 | 2. **PR Title Format**: Use conventional commit format with emojis |
| 63 | |
| 64 | - Always include an appropriate emoji at the beginning of the title |
| 65 | - Use the actual emoji character (not the code representation like `:sparkles:`) |
| 66 | - Examples: |
| 67 | - `✨(supabase): Add staging remote configuration` |
| 68 | - `🐛(auth): Fix login redirect issue` |
| 69 | - `📝(readme): Update installation instructions` |
| 70 | |
| 71 | 3. **Description Template**: Always use our PR template structure from @.github/pull_request_template.md: |
| 72 | |
| 73 | 4. **Template Accuracy**: Ensure your PR description precisely follows the template structure: |
| 74 | |
| 75 | - Don't modify or rename the PR-Agent sections (`pr_agent:summary` and `pr_agent:walkthrough`) |
| 76 | - Keep all section headers exactly as they appear in the template |
| 77 | - Don't add custom sections that aren't in the template |
| 78 | |
| 79 | 5. **Draft PRs**: Start as draft when the work is in progress |
| 80 | - Use `--draft` flag in the command |
| 81 | - Convert to ready for review when complete using `gh pr ready` |
| 82 | |
| 83 | ### Common Mistakes to Avoid |
| 84 | |
| 85 | 1. **Using Non-English Text**: All PR content must be in English |
| 86 | 2. **Incorrect Section Headers**: Always use the exact section headers from the template |
| 87 | 3. **Adding Custom Sections**: Stick to the sections defined in the template |
| 88 | 4. **Using Outdated Templates**: Always refer to the current @.github/pull_request_template.md file |
| 89 | |
| 90 | ### Missing Sections |
| 91 | |
| 92 | Always include all template sections, even if some are marked as "N/A" or "None" |
| 93 | |
| 94 | ## Additional GitHub CLI PR Commands |
| 95 | |
| 96 | Here are some additional useful GitHub CLI commands for managing PRs: |
| 97 | |
| 98 | ```bash |
| 99 | # List your open pull requests |
| 100 | gh pr list --author "@me" |
| 101 | |
| 102 | # Check PR status |
| 103 | gh pr status |
| 104 | |
| 105 | # View a specific PR |
| 106 | gh pr view <PR-NUMBER> |
| 107 | |
| 108 | # Check out a PR branch locally |
| 109 | gh pr checkout <PR-NUMBER> |
| 110 | |
| 111 | # Convert a draft PR to ready for review |
| 112 | gh pr ready <PR-NUMBER> |
| 113 | |
| 114 | # Add reviewers to a PR |
| 115 | gh pr edit <PR-NUMBER> --add-reviewer username1,username2 |
| 116 | |
| 117 | # Merge a PR |
| 118 | gh pr merge <PR-NUMBER> --squash |
| 119 | ``` |
| 120 | |
| 121 | ## Using Templates for PR Creation |
| 122 | |
| 123 | To simplify PR creation with consistent descriptions, you can create a template file: |
| 124 | |
| 125 | 1. Create a file named `pr-template.md` with your PR template |
| 126 | 2. Use it when creating PRs: |
| 127 | |
| 128 | ```bash |
| 129 | gh pr create --draft --title "feat(scope): Your title" --body-file pr-template.md --base main |
| 130 | ``` |
| 131 | |
| 132 | ## Related Documentation |
| 133 | |
| 134 | - [PR Template](.github/pull_request_template.md) |
| 135 | - [Conventional Commits](https://www.conventionalcommits.org/) |
| 136 | - [GitHub CLI documentation](https://cli.github.com/manual/) |