|
| 1 | +--- |
| 2 | +name: writing-prs-and-commits |
| 3 | +description: Writes and revises Sourcegraph pull request titles, descriptions, and single-PR commit messages. Use when creating or updating a pull request, or when preparing a commit that should stand on its own as the eventual PR. |
| 4 | +--- |
| 5 | + |
| 6 | +# Writing PRs and commits |
| 7 | + |
| 8 | +Use this skill when the user asks to create a PR, update an existing PR title or body, or write a commit message for a change that maps cleanly to one PR. |
| 9 | + |
| 10 | +## Resolve the target |
| 11 | + |
| 12 | +- If the user names a PR number or URL, use that. |
| 13 | +- Otherwise, inspect the current branch and use `gh pr view --json number,title,body,baseRefName,headRefName,url` to find the associated PR. |
| 14 | +- If no PR exists and the user wants one created, use `gh pr create`, then immediately verify or adjust the title and body. |
| 15 | +- If the user wants text only, provide the draft without mutating GitHub. |
| 16 | +- When a PR is part of a stack, describe only the net change between the PR head and its base branch. Do not describe the full stack relative to `main`. |
| 17 | + |
| 18 | +## Core writing rules |
| 19 | + |
| 20 | +- Lead with _why_. The first paragraph or sentence should explain the problem, motivation, or user impact. |
| 21 | +- Follow with _what_ changed. Once the reader understands why the change exists, describe the solution and any important constraints or tradeoffs. |
| 22 | +- Write the net change only. Do not document abandoned experiments, reverted approaches, or temporary dead ends. |
| 23 | +- Prefer natural prose over rigid `Summary` / `Problem` / `Solution` headings unless the user explicitly asks for that format. |
| 24 | +- Keep references repo-relative. Do not mention absolute local filesystem paths. |
| 25 | +- Preserve valuable existing PR content such as screenshots, images, rollout notes, and manually written context unless the user asks to remove it. |
| 26 | +- Use Markdown cleanly: inline code in backticks, fenced blocks when needed, and GitHub permalinks when citing specific code. |
| 27 | + |
| 28 | +## PR titles |
| 29 | + |
| 30 | +- Keep titles short, specific, and verb-first. |
| 31 | +- Prefer Sourcegraph's changelog-friendly shape when it fits the change: `type/domain: title`. |
| 32 | +- Use conventional prefixes like `feat`, `fix`, `remove`, and `chore` when they match the change. |
| 33 | +- Make the title describe the improvement or behavior change, not just the bug report. |
| 34 | +- If the PR is user-visible and likely to feed the changelog, choose a domain that reflects the product or feature area rather than an implementation detail. |
| 35 | + |
| 36 | +## PR descriptions |
| 37 | + |
| 38 | +- Write the opening prose in this order: |
| 39 | + 1. Why this change is needed. |
| 40 | + 2. What changed. |
| 41 | + 3. Any important tradeoffs, rollout notes, or follow-up context. |
| 42 | +- When relevant, reference linked Linear issues or related Slack threads. |
| 43 | +- If docs or handbook follow-up is needed, mention it in the prose before the verification section. |
| 44 | +- Include `## Test Plan` near the end when there is meaningful validation to report. |
| 45 | +- The test plan should mention intentional verification such as focused tests, manual flows, or reproduction steps. Do not pad it with routine formatting or CI work the repository already expects. |
| 46 | +- Include `## Changelog` only for end-user-visible changes worth communicating outside the PR. Keep it as the last section. Omit it for refactors, tooling, internal cleanup, or other changes with no user-facing impact. |
| 47 | + |
| 48 | +## Commit messages for single-PR changes |
| 49 | + |
| 50 | +Treat a single commit that is intended to become one PR as a PR. GitHub by default will use the title and body from the commit. |
| 51 | + |
| 52 | +## Workflow |
| 53 | + |
| 54 | +1. Inspect the diff, linked context, and any existing PR title, body, or commit message. |
| 55 | +2. Decide whether you are creating a new PR, editing an existing PR, or writing a stand-alone commit message. |
| 56 | +3. Draft the title and body so the motivation is clear before the implementation details. |
| 57 | +4. Check that the text matches the net change, preserves important existing content, and follows Sourcegraph conventions for `Test Plan` and `Changelog`. |
| 58 | +5. Apply the final text with `gh pr create`, `gh pr edit`, or `git commit` as requested. |
0 commit comments