|
| 1 | +# Pull Request Description Guidelines |
| 2 | + |
| 3 | +Good PR descriptions help reviewers understand the context and impact of your changes. They enable faster reviews, better decision-making, and serve as valuable historical documentation. |
| 4 | + |
| 5 | +When creating a PR, follow the [GitHub PR template](../.github/PULL_REQUEST_TEMPLATE.md) and use these guidelines to fill it out effectively. |
| 6 | + |
| 7 | +## Who's Reading Your PR? |
| 8 | + |
| 9 | +Write for senior engineers familiar with the SDK. Assume your reader: |
| 10 | + |
| 11 | +- Understands the SDK's architecture and patterns |
| 12 | +- Has context about the broader system |
| 13 | +- Can read code diffs to understand implementation details |
| 14 | +- Values concise, focused communication |
| 15 | + |
| 16 | +## What to Include |
| 17 | + |
| 18 | +Every PR description should have: |
| 19 | + |
| 20 | +1. **Motivation** — Why is this change needed? |
| 21 | +2. **Public API Changes** — What changes to the public API (with code snippets)? |
| 22 | +3. **Use Cases** (optional) — When would developers use this feature? Only include for non-obvious functionality; skip for trivial changes or obvious fixes. |
| 23 | +4. **Breaking Changes** (if applicable) — What breaks and how to migrate? |
| 24 | + |
| 25 | +## Writing Principles |
| 26 | + |
| 27 | +**Focus on WHY, not HOW:** |
| 28 | + |
| 29 | +- ✅ "The OpenAI SDK supports dynamic API keys, but we don't expose this capability" |
| 30 | +- ❌ "Added ApiKeySetter type import from openai/client" |
| 31 | + |
| 32 | +**Document public API changes with example code snippets:** |
| 33 | + |
| 34 | +- ✅ Show before/after code snippets for API changes |
| 35 | +- ❌ List every file or line changed |
| 36 | + |
| 37 | +**Be concise:** |
| 38 | + |
| 39 | +- ✅ Use prose over bullet lists when possible |
| 40 | +- ❌ Create exhaustive implementation checklists |
| 41 | + |
| 42 | +**Emphasize user impact:** |
| 43 | + |
| 44 | +- ✅ "Enables secret manager integration for credential rotation" |
| 45 | +- ❌ "Updated error message to mention 'string or function'" |
| 46 | + |
| 47 | +## What to Skip |
| 48 | + |
| 49 | +Leave these out of your PR description: |
| 50 | + |
| 51 | +- **Implementation details** — Code comments and commit messages cover this |
| 52 | +- **Test coverage notes** — CI will catch issues; assume tests are comprehensive |
| 53 | +- **Line-by-line change lists** — The diff provides this |
| 54 | +- **Build/lint/coverage status** — CI handles verification |
| 55 | +- **Commit hashes** — GitHub links commits automatically |
| 56 | + |
| 57 | +## Anti-patterns |
| 58 | + |
| 59 | +❌ **Over-detailed checklists:** |
| 60 | + |
| 61 | +```markdown |
| 62 | +### Type Definition Updates |
| 63 | + |
| 64 | +- Added ApiKeySetter type import from 'openai/client' |
| 65 | +- Updated OpenAIModelOptions interface apiKey type |
| 66 | +``` |
| 67 | + |
| 68 | +❌ **Implementation notes reviewers don't need:** |
| 69 | + |
| 70 | +```markdown |
| 71 | +## Implementation Notes |
| 72 | + |
| 73 | +- No breaking changes - all existing string-based usage continues to work |
| 74 | +- OpenAI SDK handles validation of function return values |
| 75 | +``` |
| 76 | + |
| 77 | +❌ **Test coverage bullets:** |
| 78 | + |
| 79 | +```markdown |
| 80 | +### Test Coverage |
| 81 | + |
| 82 | +- Added test: accepts function-based API key |
| 83 | +- Added test: accepts async function-based API key |
| 84 | +``` |
| 85 | + |
| 86 | +## Good Examples |
| 87 | + |
| 88 | +✅ **Motivation section:** |
| 89 | + |
| 90 | +```markdown |
| 91 | +## Motivation |
| 92 | + |
| 93 | +The OpenAI SDK supports dynamic API key resolution through async functions, |
| 94 | +enabling use cases like credential rotation and secret manager integration. |
| 95 | +However, our SDK currently only accepts static strings for the apiKey parameter, |
| 96 | +preventing users from leveraging these capabilities. |
| 97 | +``` |
| 98 | + |
| 99 | +✅ **Public API Changes section:** |
| 100 | + |
| 101 | +````markdown |
| 102 | +## Public API Changes |
| 103 | + |
| 104 | +The `OpenAIModelOptions.apiKey` parameter now accepts either a string or an |
| 105 | +async function: |
| 106 | + |
| 107 | +```typescript |
| 108 | +// Before: only string supported |
| 109 | +const model = new OpenAIModel({ |
| 110 | + modelId: 'gpt-4o', |
| 111 | + apiKey: 'sk-...', |
| 112 | +}) |
| 113 | + |
| 114 | +// After: function also supported |
| 115 | +const model = new OpenAIModel({ |
| 116 | + modelId: 'gpt-4o', |
| 117 | + apiKey: async () => await secretManager.getApiKey(), |
| 118 | +}) |
| 119 | +``` |
| 120 | + |
| 121 | +The change is backward compatible—all existing string-based usage continues |
| 122 | +to work without modification. |
| 123 | + |
| 124 | +```` |
| 125 | + |
| 126 | +✅ **Use Cases section:** |
| 127 | +```markdown |
| 128 | +## Use Cases |
| 129 | + |
| 130 | +- **API key rotation**: Rotate keys without application restart |
| 131 | +- **Secret manager integration**: Fetch credentials from AWS Secrets Manager, Vault, etc. |
| 132 | +- **Multi-tenant systems**: Dynamically select API keys based on context |
| 133 | +```` |
| 134 | + |
| 135 | +## Template |
| 136 | + |
| 137 | +````markdown |
| 138 | +## Motivation |
| 139 | + |
| 140 | +[Explain WHY this change is needed. What problem does it solve? What limitation |
| 141 | +does it address? What user need does it fulfill?] |
| 142 | + |
| 143 | +Resolves: #[issue-number] |
| 144 | + |
| 145 | +## Public API Changes |
| 146 | + |
| 147 | +[Document changes to public APIs with before/after code snippets. If no public |
| 148 | +API changes, state "No public API changes."] |
| 149 | + |
| 150 | +```typescript |
| 151 | +// Before |
| 152 | +[existing API usage] |
| 153 | + |
| 154 | +// After |
| 155 | +[new API usage] |
| 156 | +``` |
| 157 | + |
| 158 | +[Explain behavior, parameters, return values, and backward compatibility.] |
| 159 | + |
| 160 | +## Use Cases (optional) |
| 161 | + |
| 162 | +[Only include for non-obvious functionality. Provide 1-3 concrete use cases |
| 163 | +showing when developers would use this feature. Skip for trivial changes obvious fixes..] |
| 164 | + |
| 165 | +## Breaking Changes (if applicable) |
| 166 | + |
| 167 | +[If this is a breaking change, explain what breaks and provide migration guidance.] |
| 168 | + |
| 169 | +### Migration |
| 170 | + |
| 171 | +```typescript |
| 172 | +// Before |
| 173 | +[old code] |
| 174 | + |
| 175 | +// After |
| 176 | +[new code] |
| 177 | +``` |
| 178 | + |
| 179 | +```` |
| 180 | +
|
| 181 | +## Why These Guidelines? |
| 182 | +
|
| 183 | +**Focus on WHY over HOW** because code diffs show implementation details, commit messages document granular changes, and PR descriptions provide the broader context reviewers need. |
| 184 | +
|
| 185 | +**Skip test/lint/coverage details** because CI pipelines verify these automatically. Including them adds noise without value. |
| 186 | +
|
| 187 | +**Write for senior engineers** to enable concise, technical communication without redundant explanations. |
| 188 | +
|
| 189 | +## References |
| 190 | +
|
| 191 | +- [Conventional Commits](https://www.conventionalcommits.org/) |
| 192 | +- [Google's Code Review Guidelines](https://google.github.io/eng-practices/review/) |
| 193 | +
|
| 194 | +## Checklist Items |
| 195 | +
|
| 196 | + - [ ] Does the PR description target a Senior Engineer familiar with the project? |
| 197 | + - [ ] Does the PR description give an overview of the feature being implemented, including any notes on key implemention decisions |
| 198 | + - [ ] Does the PR include a "Resolves #<ISSUE NUMBER>" in the body and is not bolded? |
| 199 | + - [ ] Does the PR contain the motivation or use-cases behind the change? |
| 200 | + - [ ] Does the PR omit irrelevent details not needed for historical reference? |
0 commit comments