Create PR Description
Overview
Generate a comprehensive, reviewer-friendly pull request description by analyzing staged git changes, commit history, and project conventions. The output is a ready-to-paste PR body that explains the "why" behind every change.
Workflow
Read project context — Check for .chalk/docs/engineering/ files, especially PR conventions, coding style, and architecture docs. If a conventions file exists, follow its PR template. If not, use the default structure below.
Gather git context — Run these commands to understand the change:
git diff --cached --stat for an overview of changed files
git diff --cached for the full staged diff
git log --oneline -10 for recent commit context
git branch --show-current for the branch name
- If
$ARGUMENTS contains an issue number, read the issue details if accessible
Analyze the diff — Before writing anything, categorize the changes:
- Identify the primary intent (feature, bugfix, refactor, chore, docs)
- Group file changes by concern (e.g., "API changes", "UI updates", "test additions", "config changes")
- Note any files that are deleted, renamed, or have significant permission changes
- Flag potential risks: new dependencies, migration files, API contract changes, security-sensitive files
Determine change type and scope — This shapes the description tone:
- Feature: Emphasize user-facing behavior and motivation
- Bugfix: Describe the bug, root cause, and fix approach
- Refactor: Explain what stays the same (behavior) and what changes (structure)
- Chore/Config: Keep it brief, focus on why now
Write the PR description — Use the structure defined in the Output section. Every section must add value; omit sections that genuinely do not apply rather than filling them with "N/A".
Output the description — Print the full PR description in a markdown code block so the user can copy it. If the user has a PR already open, suggest the gh pr edit command to update it.
Output
## Summary
<!-- 1-2 sentences. What does this PR do and why? -->
## Motivation
<!-- Why is this change needed? Link to the problem, user feedback, or product requirement. -->
<!-- If fixing a bug: what was the broken behavior? What triggers it? -->
## Changes
<!-- Group changes by concern. Use sub-headers for large PRs. -->
### <Concern 1, e.g., "API Layer">
- Change description with enough context to understand without reading the diff
### <Concern 2, e.g., "Database">
- Change description
## Testing
<!-- What was tested? How can a reviewer verify? -->
- [ ] Unit tests added/updated
- [ ] Manual testing performed (describe steps)
- [ ] Edge cases considered: <list them>
## Screenshots
<!-- For UI changes only. Remove this section if no UI changes. -->
<!-- Before/after screenshots or screen recordings -->
## Reviewer Notes
<!-- Where should the reviewer start reading? -->
<!-- What's the trickiest part of this change? -->
<!-- Any concerns or tradeoffs you want a second opinion on? -->
## Related Issues
<!-- Use closing keywords: Fixes #123, Closes #456, Resolves #789 -->
<!-- Or just references: Related to #123, Part of #456 -->
---
### Checklist
- [ ] Tests pass locally (`npm test` / `pytest` / equivalent)
- [ ] No new console errors or warnings
- [ ] Accessibility checked (if UI changes)
- [ ] Documentation updated (if behavior changes)
- [ ] Migration tested (if schema changes)
- [ ] Feature flag configured (if gradual rollout)
Adapting to Change Type
Feature PRs
- Motivation section is mandatory and should reference the user problem
- Testing section must include manual verification steps
- Screenshots section is required for any UI changes
Bugfix PRs
- Summary must state the bug clearly: "Users experienced X when doing Y"
- Motivation must include root cause analysis
- Testing must describe how to reproduce the original bug and verify the fix
- Add "Regression risk" note in Reviewer Notes
Refactor PRs
- Summary must explicitly state "No behavior change"
- Changes section should show before/after patterns
- Testing should explain how behavior preservation was verified
Dependency Updates
- List all updated packages with version ranges
- Note any breaking changes from changelogs
- Flag transitive dependency changes
Writing Quality Rules
- Summary: Lead with the user-visible or system-visible impact. Not "Updated the handler" but "Fix timeout errors when uploading files larger than 50MB."
- Changes: Each bullet should answer "what changed and why" not just "what file changed." Bad: "Modified
auth.ts". Good: "Added token refresh retry logic to handle intermittent auth failures."
- Testing: Specific and reproducible. Bad: "Tested locally." Good: "Created a 100MB file upload, verified no timeout after 60s. Tested with expired token, confirmed retry succeeds."
- Reviewer Notes: Be honest about complexity. If something is hacky, say so and explain why. Reviewers trust authors who flag their own concerns.
Anti-patterns
- Empty PR descriptions — Every PR must explain "why." Even a one-line fix has a reason.
- Diff-as-description — Do not just restate what the diff shows. The reviewer can read the diff. Explain intent, tradeoffs, and context that is not in the code.
- All "what" no "why" — "Added error handling to processPayment" is useless. "Added error handling to processPayment because silent failures were causing orphaned transactions" is useful.
- No test evidence — If you say "tested locally," describe what you tested. Unnamed testing is the same as no testing.
- Missing issue links — If this PR addresses an issue, link it with closing keywords. Do not make reviewers search for the connection.
- Wall of text — Use structure. A 500-word paragraph is harder to review than 10 bullets grouped by concern.
- Burying breaking changes — API contract changes, migration requirements, and config changes must be called out prominently, not hidden in a bullet list.
- Omitting rollback context — For risky changes, explain how to revert if something goes wrong.
1---2name: create-pr-description3description: Generate a structured PR description from staged git changes when the user asks to create, write, or draft a pull request description4---5
6# Create PR Description
7
8## Overview
9
10Generate a comprehensive, reviewer-friendly pull request description by analyzing staged git changes, commit history, and project conventions. The output is a ready-to-paste PR body that explains the "why" behind every change.
11
12## Workflow
13
141. **Read project context** — Check for `.chalk/docs/engineering/` files, especially PR conventions, coding style, and architecture docs. If a conventions file exists, follow its PR template. If not, use the default structure below.
15
162. **Gather git context** — Run these commands to understand the change:
17 - `git diff --cached --stat` for an overview of changed files
18 - `git diff --cached` for the full staged diff
19 - `git log --oneline -10` for recent commit context
20 - `git branch --show-current` for the branch name
21 - If `$ARGUMENTS` contains an issue number, read the issue details if accessible
22
233. **Analyze the diff** — Before writing anything, categorize the changes:
24 - Identify the primary intent (feature, bugfix, refactor, chore, docs)
25 - Group file changes by concern (e.g., "API changes", "UI updates", "test additions", "config changes")
26 - Note any files that are deleted, renamed, or have significant permission changes
27 - Flag potential risks: new dependencies, migration files, API contract changes, security-sensitive files
28
294. **Determine change type and scope** — This shapes the description tone:
30 - **Feature**: Emphasize user-facing behavior and motivation
31 - **Bugfix**: Describe the bug, root cause, and fix approach
32 - **Refactor**: Explain what stays the same (behavior) and what changes (structure)
33 - **Chore/Config**: Keep it brief, focus on why now
34
355. **Write the PR description** — Use the structure defined in the Output section. Every section must add value; omit sections that genuinely do not apply rather than filling them with "N/A".
36
376. **Output the description** — Print the full PR description in a markdown code block so the user can copy it. If the user has a PR already open, suggest the `gh pr edit` command to update it.
38
39## Output
40
41```markdown
42## Summary
43
44<!-- 1-2 sentences. What does this PR do and why? -->
45
46## Motivation
47
48<!-- Why is this change needed? Link to the problem, user feedback, or product requirement. -->
49<!-- If fixing a bug: what was the broken behavior? What triggers it? -->
50
51## Changes
52
53<!-- Group changes by concern. Use sub-headers for large PRs. -->
54
55### <Concern 1, e.g., "API Layer">
56- Change description with enough context to understand without reading the diff
57
58### <Concern 2, e.g., "Database">
59- Change description
60
61## Testing
62
63<!-- What was tested? How can a reviewer verify? -->
64- [ ] Unit tests added/updated
65- [ ] Manual testing performed (describe steps)
66- [ ] Edge cases considered: <list them>
67
68## Screenshots
69
70<!-- For UI changes only. Remove this section if no UI changes. -->
71<!-- Before/after screenshots or screen recordings -->
72
73## Reviewer Notes
74
75<!-- Where should the reviewer start reading? -->
76<!-- What's the trickiest part of this change? -->
77<!-- Any concerns or tradeoffs you want a second opinion on? -->
78
79## Related Issues
80
81<!-- Use closing keywords: Fixes #123, Closes #456, Resolves #789 -->
82<!-- Or just references: Related to #123, Part of #456 -->
83
84---
85
86### Checklist
87
88- [ ] Tests pass locally (`npm test` / `pytest` / equivalent)
89- [ ] No new console errors or warnings
90- [ ] Accessibility checked (if UI changes)
91- [ ] Documentation updated (if behavior changes)
92- [ ] Migration tested (if schema changes)
93- [ ] Feature flag configured (if gradual rollout)
94```
95
96## Adapting to Change Type
97
98### Feature PRs
99- Motivation section is mandatory and should reference the user problem
100- Testing section must include manual verification steps
101- Screenshots section is required for any UI changes
102
103### Bugfix PRs
104- Summary must state the bug clearly: "Users experienced X when doing Y"
105- Motivation must include root cause analysis
106- Testing must describe how to reproduce the original bug and verify the fix
107- Add "Regression risk" note in Reviewer Notes
108
109### Refactor PRs
110- Summary must explicitly state "No behavior change"
111- Changes section should show before/after patterns
112- Testing should explain how behavior preservation was verified
113
114### Dependency Updates
115- List all updated packages with version ranges
116- Note any breaking changes from changelogs
117- Flag transitive dependency changes
118
119## Writing Quality Rules
120
121- **Summary**: Lead with the user-visible or system-visible impact. Not "Updated the handler" but "Fix timeout errors when uploading files larger than 50MB."
122- **Changes**: Each bullet should answer "what changed and why" not just "what file changed." Bad: "Modified `auth.ts`". Good: "Added token refresh retry logic to handle intermittent auth failures."
123- **Testing**: Specific and reproducible. Bad: "Tested locally." Good: "Created a 100MB file upload, verified no timeout after 60s. Tested with expired token, confirmed retry succeeds."
124- **Reviewer Notes**: Be honest about complexity. If something is hacky, say so and explain why. Reviewers trust authors who flag their own concerns.
125
126## Anti-patterns
127
128- **Empty PR descriptions** — Every PR must explain "why." Even a one-line fix has a reason.
129- **Diff-as-description** — Do not just restate what the diff shows. The reviewer can read the diff. Explain intent, tradeoffs, and context that is not in the code.
130- **All "what" no "why"** — "Added error handling to processPayment" is useless. "Added error handling to processPayment because silent failures were causing orphaned transactions" is useful.
131- **No test evidence** — If you say "tested locally," describe what you tested. Unnamed testing is the same as no testing.
132- **Missing issue links** — If this PR addresses an issue, link it with closing keywords. Do not make reviewers search for the connection.
133- **Wall of text** — Use structure. A 500-word paragraph is harder to review than 10 bullets grouped by concern.
134- **Burying breaking changes** — API contract changes, migration requirements, and config changes must be called out prominently, not hidden in a bullet list.
135- **Omitting rollback context** — For risky changes, explain how to revert if something goes wrong.