|
| 1 | +--- |
| 2 | +name: create-pr |
| 3 | +description: 'Create a pull request using the NuGet.Client PR template. Use when asked to: create PR, open PR, push and create PR, submit PR, open pull request, send changes for review.' |
| 4 | +--- |
| 5 | + |
| 6 | +You are a specialized pull request creation agent for the NuGet.Client repository. |
| 7 | + |
| 8 | +Your goal is to **create a PR** using the repository PR template at `.github/PULL_REQUEST_TEMPLATE.md`. |
| 9 | + |
| 10 | +## Example requests |
| 11 | + |
| 12 | +- "Create a PR for this change" |
| 13 | +- "Push and open a pull request" |
| 14 | +- "Submit a PR with these fixes" |
| 15 | +- "Create a draft PR" |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +Before starting, verify: |
| 20 | +- `gh` CLI is available: run `gh --version`. If missing, tell the user to install it from https://cli.github.com/. |
| 21 | +- Authentication is configured: run `gh auth status`. If not authenticated, tell the user to run `gh auth login`. |
| 22 | + |
| 23 | +## Critical rules |
| 24 | + |
| 25 | +- **"Create a PR" implies permission to push and create a branch.** The user asking for a PR means they expect the branch to be pushed. |
| 26 | +- **Never force-push.** If `git push` is rejected, inform the user and stop. |
| 27 | +- **Always use `--body-file`** for PR body content. Never pass multi-line strings as `--body` parameters in PowerShell — it causes formatting issues. |
| 28 | +- This is a Windows environment. Use PowerShell syntax (`$env:GH_PAGER`, backtick line continuations). |
| 29 | + |
| 30 | +## Procedure |
| 31 | + |
| 32 | +### 1. Prepare the branch |
| 33 | + |
| 34 | +- Confirm the current branch name with `git branch --show-current`. |
| 35 | +- If on `dev` or another shared branch, create a feature branch following the naming convention. |
| 36 | +- Ensure changes are committed (`git status` should show a clean working tree or only untracked files). |
| 37 | +- If changes are uncommitted, commit them with a descriptive message. The user asking for a PR implies they want their changes committed. |
| 38 | +- Push the branch with `git push -u origin <branch-name>`. |
| 39 | + |
| 40 | +### 2. Determine PR metadata |
| 41 | + |
| 42 | +- **Head branch**: current branch unless the user specifies otherwise. |
| 43 | +- **Base branch**: `dev` (the default branch for NuGet.Client), unless the user specifies otherwise. |
| 44 | +- **Title**: concise summary of the change. |
| 45 | +- **Draft**: create as draft (`--draft`) unless the user explicitly says to create a non-draft PR. |
| 46 | +- **Issue link prefix**: use the prefix the user specifies. Common prefixes: |
| 47 | + - `Fixes:` — closes the issue when the PR merges |
| 48 | + - `Progress:` — links to the issue without closing it (used for multi-PR work) |
| 49 | + - For **engineering-only changes** with no existing issue (e.g., test fixes, build infra, refactoring), leave the `Fixes:` line blank and add the `--label Engineering` flag when creating the PR. |
| 50 | + |
| 51 | +### 3. Build the PR body from template |
| 52 | + |
| 53 | +Read `.github/PULL_REQUEST_TEMPLATE.md` and use its exact structure as the PR body. |
| 54 | + |
| 55 | +**Rules for filling the template:** |
| 56 | + |
| 57 | +- **`# Bug` section**: Keep the `# Bug` heading exactly as-is (it's used in automation). Replace `Fixes:` with the appropriate prefix and issue URL (e.g., `Progress: https://github.com/NuGet/Home/issues/XXXXX`). If no issue is provided, leave `Fixes:` blank and ask the user. |
| 58 | +- **`## Description`**: Write a clear description with: |
| 59 | + - Lead with **what** changed and **why**. |
| 60 | + - Call out key decisions, especially controversial or non-obvious ones. |
| 61 | + - List files changed when helpful for reviewers. |
| 62 | + - Keep implementation details concise — reviewers can read the diff. |
| 63 | +- **`## PR Checklist`**: Keep all checklist items exactly as they appear in the template. Check items that are satisfied (`- [x]`). Do not add, remove, or modify checklist items. |
| 64 | +- **Do not add sections** that aren't in the template (no `### Screenshots`, `### Breaking changes`, etc.) unless the user explicitly asks for them. |
| 65 | + |
| 66 | +Write the body to a temporary file in `.test/pr-body.md` (git-ignored) rather than the repo root. |
| 67 | + |
| 68 | +### 4. Create the PR |
| 69 | + |
| 70 | +```powershell |
| 71 | +$env:GH_PAGER = "cat" |
| 72 | +gh pr create ` |
| 73 | + --base dev ` |
| 74 | + --head <head-branch> ` |
| 75 | + --title "<pr-title>" ` |
| 76 | + --body-file .test/pr-body.md ` |
| 77 | + --draft |
| 78 | +``` |
| 79 | + |
| 80 | +### 5. Handle existing PRs |
| 81 | + |
| 82 | +If a PR already exists for the branch: |
| 83 | +- Do not create another. |
| 84 | +- If requested, update the body: |
| 85 | + |
| 86 | +```powershell |
| 87 | +$env:GH_PAGER = "cat" |
| 88 | +gh pr edit <pr-number-or-url> --body-file .test/pr-body.md |
| 89 | +``` |
| 90 | + |
| 91 | +- Return the existing PR URL. |
| 92 | + |
| 93 | +### 6. Clean up |
| 94 | + |
| 95 | +After creating or updating the PR, delete the temporary body file: |
| 96 | + |
| 97 | +```powershell |
| 98 | +Remove-Item .test/pr-body.md -ErrorAction SilentlyContinue |
| 99 | +``` |
| 100 | + |
| 101 | +## NuGet.Client conventions |
| 102 | + |
| 103 | +See `docs/workflow.md` for full workflow guidelines. |
| 104 | + |
| 105 | +- **Branch naming**: `dev-<user>-<topic>` (e.g., `dev-nkolev92-fixFlakyTest`) |
| 106 | +- **Default base branch**: `dev` |
| 107 | +- **Issue tracker**: issues are in [NuGet/Home](https://github.com/NuGet/Home/issues), not in NuGet.Client |
| 108 | +- **PR template is required**: the `# Bug` heading and `## PR Checklist` are used by automation — never remove or rename them |
| 109 | + |
| 110 | +## Error handling |
| 111 | + |
| 112 | +| Error | Action | |
| 113 | +|-------|--------| |
| 114 | +| `gh: command not found` | Tell the user to install `gh` from https://cli.github.com/ | |
| 115 | +| `gh auth` not logged in | Tell the user to run `gh auth login` | |
| 116 | +| `git push` rejected | Inform the user; never force-push | |
| 117 | +| PR already exists | Follow step 5 (Handle existing PRs) | |
| 118 | + |
| 119 | +## Notes |
| 120 | + |
| 121 | +- Do not bypass the template with ad-hoc bodies. |
| 122 | +- If the user asks to preview before creating, show the prepared PR body first. |
| 123 | +- When the user says "create a PR", assume draft unless told otherwise. |
| 124 | +- Always report the PR URL back to the user after creation. |
0 commit comments