|
| 1 | +# Pull Request Description Style Guide |
| 2 | + |
| 3 | +This guide documents the PR description style used in the Coder repository, based on analysis of recent merged PRs. |
| 4 | + |
| 5 | +## PR Title Format |
| 6 | + |
| 7 | +Follow [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) format: |
| 8 | + |
| 9 | +```text |
| 10 | +type(scope): brief description |
| 11 | +``` |
| 12 | + |
| 13 | +**Common types:** |
| 14 | + |
| 15 | +- `feat`: New features |
| 16 | +- `fix`: Bug fixes |
| 17 | +- `refactor`: Code refactoring without behavior change |
| 18 | +- `perf`: Performance improvements |
| 19 | +- `docs`: Documentation changes |
| 20 | +- `chore`: Dependency updates, tooling changes |
| 21 | + |
| 22 | +**Examples:** |
| 23 | + |
| 24 | +- `feat: add tracing to aibridge` |
| 25 | +- `fix: move contexts to appropriate locations` |
| 26 | +- `perf(coderd/database): add index on workspace_app_statuses.app_id` |
| 27 | +- `docs: fix swagger tags for license endpoints` |
| 28 | +- `refactor(site): remove redundant client-side sorting of app statuses` |
| 29 | + |
| 30 | +## PR Description Structure |
| 31 | + |
| 32 | +### Default Pattern: Keep It Concise |
| 33 | + |
| 34 | +Most PRs use a simple 1-2 paragraph format: |
| 35 | + |
| 36 | +```markdown |
| 37 | +[Brief statement of what changed] |
| 38 | + |
| 39 | +[One sentence explaining technical details or context if needed] |
| 40 | +``` |
| 41 | + |
| 42 | +**Example (bugfix):** |
| 43 | + |
| 44 | +```markdown |
| 45 | +Previously, when a devcontainer config file was modified, the dirty |
| 46 | +status was updated internally but not broadcast to websocket listeners. |
| 47 | + |
| 48 | +Add `broadcastUpdatesLocked()` call in `markDevcontainerDirty` to notify |
| 49 | +websocket listeners immediately when a config file changes. |
| 50 | +``` |
| 51 | + |
| 52 | +**Example (dependency update):** |
| 53 | + |
| 54 | +```markdown |
| 55 | +Changes from https://github.com/upstream/repo/pull/XXX/ |
| 56 | +``` |
| 57 | + |
| 58 | +**Example (docs correction):** |
| 59 | + |
| 60 | +```markdown |
| 61 | +Removes incorrect references to database replicas from the scaling documentation. |
| 62 | +Coder only supports a single database connection URL. |
| 63 | +``` |
| 64 | + |
| 65 | +### For Complex Changes: Use "Summary", "Problem", "Fix" |
| 66 | + |
| 67 | +Only use structured sections when the change requires significant explanation: |
| 68 | + |
| 69 | +```markdown |
| 70 | +## Summary |
| 71 | +Brief overview of the change |
| 72 | + |
| 73 | +## Problem |
| 74 | +Detailed explanation of the issue being addressed |
| 75 | + |
| 76 | +## Fix |
| 77 | +How the solution works |
| 78 | +``` |
| 79 | + |
| 80 | +**Example (API documentation fix):** |
| 81 | + |
| 82 | +```markdown |
| 83 | +## Summary |
| 84 | +Change `@Tags` from `Organizations` to `Enterprise` for POST /licenses... |
| 85 | + |
| 86 | +## Problem |
| 87 | +The license API endpoints were inconsistently tagged... |
| 88 | + |
| 89 | +## Fix |
| 90 | +Simply updated the `@Tags` annotation from `Organizations` to `Enterprise`... |
| 91 | +``` |
| 92 | + |
| 93 | +### For Large Refactors: Lead with Context |
| 94 | + |
| 95 | +When rewriting significant documentation or code, start with the problems being fixed: |
| 96 | + |
| 97 | +```markdown |
| 98 | +This PR rewrites [component] for [reason]. |
| 99 | + |
| 100 | +The previous [component] had [specific issues]: [details]. |
| 101 | + |
| 102 | +[What changed]: [specific improvements made]. |
| 103 | + |
| 104 | +[Additional changes]: [context]. |
| 105 | + |
| 106 | +Refs #[issue-number] |
| 107 | +``` |
| 108 | + |
| 109 | +**Example (major documentation rewrite):** |
| 110 | + |
| 111 | +- Started with "This PR rewrites the dev containers documentation for GA readiness" |
| 112 | +- Listed specific inaccuracies being fixed |
| 113 | +- Explained organizational changes |
| 114 | +- Referenced related issue |
| 115 | + |
| 116 | +## What to Include |
| 117 | + |
| 118 | +### Always Include |
| 119 | + |
| 120 | +1. **Link Related Work** |
| 121 | + - `Closes https://github.com/coder/internal/issues/XXX` |
| 122 | + - `Depends on #XXX` |
| 123 | + - `Fixes: https://github.com/coder/aibridge/issues/XX` |
| 124 | + - `Refs #XXX` (for general reference) |
| 125 | + |
| 126 | +2. **Performance Context** (when relevant) |
| 127 | + |
| 128 | + ```markdown |
| 129 | + Each query took ~30ms on average with 80 requests/second to the cluster, |
| 130 | + resulting in ~5.2 query-seconds every second. |
| 131 | + ``` |
| 132 | + |
| 133 | +3. **Migration Warnings** (when relevant) |
| 134 | + |
| 135 | + ```markdown |
| 136 | + **NOTE**: This migration creates an index on `workspace_app_statuses`. |
| 137 | + For deployments with heavy task usage, this may take a moment to complete. |
| 138 | + ``` |
| 139 | + |
| 140 | +4. **Visual Evidence** (for UI changes) |
| 141 | + |
| 142 | + ```markdown |
| 143 | + <img width="1281" height="425" alt="image" src="..." /> |
| 144 | + ``` |
| 145 | + |
| 146 | +### Never Include |
| 147 | + |
| 148 | +- ❌ **Test plans** - Testing is handled through code review and CI |
| 149 | +- ❌ **"Benefits" sections** - Benefits should be clear from the description |
| 150 | +- ❌ **Implementation details** - Keep it high-level |
| 151 | +- ❌ **Marketing language** - Stay technical and factual |
| 152 | +- ❌ **Bullet lists of features** (unless it's a large refactor that needs enumeration) |
| 153 | + |
| 154 | +## Special Patterns |
| 155 | + |
| 156 | +### Simple Chore PRs |
| 157 | + |
| 158 | +For straightforward updates (dependency bumps, minor fixes): |
| 159 | + |
| 160 | +```markdown |
| 161 | +Changes from [link to upstream PR/issue] |
| 162 | +``` |
| 163 | + |
| 164 | +Or: |
| 165 | + |
| 166 | +```markdown |
| 167 | +Reference: |
| 168 | +[link explaining why this change is needed] |
| 169 | +``` |
| 170 | + |
| 171 | +### Bug Fixes |
| 172 | + |
| 173 | +Start with the problem, then explain the fix: |
| 174 | + |
| 175 | +```markdown |
| 176 | +[What was broken and why it matters] |
| 177 | + |
| 178 | +[What you changed to fix it] |
| 179 | +``` |
| 180 | + |
| 181 | +### Dependency Updates |
| 182 | + |
| 183 | +Dependabot PRs are auto-generated - don't try to match their verbose style for manual updates. Instead use: |
| 184 | + |
| 185 | +```markdown |
| 186 | +Changes from https://github.com/upstream/repo/pull/XXX/ |
| 187 | +``` |
| 188 | + |
| 189 | +## Attribution Footer |
| 190 | + |
| 191 | +For AI-generated PRs, end with: |
| 192 | + |
| 193 | +```markdown |
| 194 | +🤖 Generated with [Claude Code](https://claude.com/claude-code) |
| 195 | + |
| 196 | +Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
| 197 | +``` |
| 198 | + |
| 199 | +## Creating PRs as Draft |
| 200 | + |
| 201 | +**IMPORTANT**: Unless explicitly told otherwise, always create PRs as drafts using the `--draft` flag: |
| 202 | + |
| 203 | +```bash |
| 204 | +gh pr create --draft --title "..." --body "..." |
| 205 | +``` |
| 206 | + |
| 207 | +After creating the PR, encourage the user to review it before marking as ready: |
| 208 | + |
| 209 | +``` |
| 210 | +I've created draft PR #XXXX. Please review the changes and mark it as ready for review when you're satisfied. |
| 211 | +``` |
| 212 | + |
| 213 | +This allows the user to: |
| 214 | +- Review the code changes before requesting reviews from maintainers |
| 215 | +- Make additional adjustments if needed |
| 216 | +- Ensure CI passes before notifying reviewers |
| 217 | +- Control when the PR enters the review queue |
| 218 | + |
| 219 | +Only create non-draft PRs when the user explicitly requests it or when following up on an existing draft. |
| 220 | + |
| 221 | +## Key Principles |
| 222 | + |
| 223 | +1. **Always create draft PRs** - Unless explicitly told otherwise |
| 224 | +2. **Be concise** - Default to 1-2 paragraphs unless complexity demands more |
| 225 | +3. **Be technical** - Explain what and why, not detailed how |
| 226 | +4. **Link everything** - Issues, PRs, upstream changes, Notion docs |
| 227 | +5. **Show impact** - Metrics for performance, screenshots for UI, warnings for migrations |
| 228 | +6. **No test plans** - Code review and CI handle testing |
| 229 | +7. **No benefits sections** - Benefits should be obvious from the technical description |
| 230 | + |
| 231 | +## Examples by Category |
| 232 | + |
| 233 | +### Performance Improvements |
| 234 | + |
| 235 | +Includes query timing metrics and explains the index solution |
| 236 | + |
| 237 | +### Bug Fixes |
| 238 | + |
| 239 | +Describes broken behavior then the fix in two sentences |
| 240 | + |
| 241 | +### Documentation |
| 242 | + |
| 243 | +- **Major rewrite**: Long form explaining inaccuracies and improvements |
| 244 | +- **Simple correction**: One sentence for simple correction |
| 245 | + |
| 246 | +### Features |
| 247 | + |
| 248 | +Simple statement of what was added and dependencies |
| 249 | + |
| 250 | +### Refactoring |
| 251 | + |
| 252 | +Explains why client-side sorting is now redundant |
| 253 | + |
| 254 | +### Configuration |
| 255 | + |
| 256 | +Adds guidelines with issue reference |
0 commit comments