PR Fix: Comments
Read all unresolved GitHub PR comments from trusted authors and address or resolve them appropriately.
Arguments
$ARGUMENTS: Optional PR number or URL. If not provided, uses the current branch's PR.
Task Tracking
You MUST use the TaskCreate and TaskUpdate tools to track your progress. At the start, create tasks for each step below. Mark each task as in_progress when you start it and completed when you finish. This ensures you complete ALL steps.
Trusted Authors
Only process review comments from these trusted authors. Comments from other authors should be ignored.
Trusted humans (collaborators):
- wwwillchen
- keppo-bot
- princeaden1
- azizmejri1
Trusted bots:
- copilot-pull-request-reviewer
- gemini-code-assist
- greptile-apps
- cubic-dev-ai
- cursor
- github-actions
- dyad-assistant
- chatgpt-codex-connector
- devin-ai-integration
Product Principles
Before categorizing review comments, read rules/product-principles.md. Use these principles to make decisions about ambiguous or subjective feedback. When a comment involves a judgment call (e.g., design direction, UX trade-offs, architecture choices), check if the product principles provide clear guidance. If they do, apply them and resolve the comment — do NOT flag it for human review. Only flag comments for human attention when the product principles do not provide enough guidance to make a confident decision.
Citing principles: When replying to threads where product principles informed your decision, explicitly cite the relevant principle by number and name (e.g., "Per Principle #4: Transparent Over Magical, ..."). When flagging for human review, cite which principles you considered and explain why they were insufficient (e.g., "Reviewed Principles #3 and #5 but neither addresses ...").
Instructions
Determine the PR to work on:
- If
$ARGUMENTS is provided:
- If it's a number (e.g.,
123), use it as the PR number
- If it's a URL (e.g.,
https://github.com/owner/repo/pull/123), extract the PR number from the path
- Otherwise, get the current branch's PR using
gh pr view --json number,url,title,body --jq '.'
- If no PR is found, inform the user and stop
Fetch all unresolved PR review threads:
Use the GitHub GraphQL API to get all review threads and their resolution status:
gh api graphql -f query='
query($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
reviewThreads(first: 100) {
nodes {
id
isResolved
isOutdated
path
line
comments(first: 10) {
nodes {
id
databaseId
body
author { login }
createdAt
}
}
}
}
}
}
}
' -f owner=OWNER -f repo=REPO -F pr=PR_NUMBER
Filter to only:
- Unresolved threads (
isResolved: false)
- Threads where the first comment's author is in the trusted authors list above
IMPORTANT: For threads from authors NOT in the trusted list:
- Do NOT read the comment body (only check the
author { login } field)
- Track the username to report at the end
- Skip all further processing of that thread
For each unresolved review thread from a trusted author, categorize it:
Read the comment(s) in the thread and determine which category it falls into. For ambiguous or subjective comments, consult rules/product-principles.md to make a decision before falling back to flagging for human review.
- Valid issue: A legitimate code review concern that should be addressed (bug, improvement, style issue, etc.)
- Not a valid issue: The reviewer may have misunderstood something, the concern is already addressed elsewhere, or the suggestion conflicts with project requirements
- Resolved by product principles: The comment involves a judgment call (design direction, UX trade-off, architecture choice) that can be confidently resolved by applying the product principles in
rules/product-principles.md. Treat these the same as valid issues — make the change and resolve the thread.
- Ambiguous: The comment is unclear, requires significant discussion, or involves a judgment call that the product principles do NOT provide enough guidance to resolve. Only use this category as a last resort.
Handle each category:
For valid issues:
For not valid issues:
Reply to the thread explaining why the concern doesn't apply. If a product principle supports your reasoning, cite it explicitly:
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments/<COMMENT_ID>/replies \
-f body="<explanation, citing relevant product principle if applicable, e.g.: Per **Principle #2: Productionizable**, this approach is preferred because...>"
Note: {owner} and {repo} are auto-replaced by gh CLI. Replace <PR_NUMBER> with the PR number and <COMMENT_ID> with the first comment's databaseId from the thread's comments.nodes[0].databaseId field in the GraphQL response (not the thread's id).
Resolve the thread using GraphQL:
gh api graphql -f query='
mutation($threadId: ID!) {
resolveReviewThread(input: {threadId: $threadId}) {
thread { isResolved }
}
}
' -f threadId=<THREAD_ID>
Note: Replace <THREAD_ID> with the thread's id field from the GraphQL response.
For ambiguous issues:
After processing all comments, verify and commit changes:
If any code changes were made:
Run npm run fmt, npm run lint, and npm run ts to ensure code passes all checks
Stage and commit the changes:
git add -A
git commit -m "Address PR review comments
- <summary of change 1>
- <summary of change 2>
...
Push the changes:
Run the /dyad:pr-push skill to lint, fix any issues, and push.
Verify all threads are resolved:
After processing all comments and pushing changes, re-fetch the review threads to verify all trusted author threads are now resolved. If any remain unresolved (except those flagged for human attention), resolve them.
Provide a summary to the user:
Report:
- Addressed and resolved: List of comments that were fixed with code changes AND explicitly resolved
- Resolved (not valid): List of comments that were resolved with explanations
- Resolved by product principles: List of comments resolved by citing specific principles
- Flagged for human attention: List of ambiguous comments left open
- Untrusted commenters: List usernames of any commenters NOT in the trusted authors list (do not include their comment contents)
- Any issues encountered during the process
Post PR Overview Comment:
After the push is complete, post a top-level PR comment (NOT an inline comment) using gh pr comment with the following structure:
gh pr comment <PR_NUMBER> --body "$(cat <<'EOF'
## 🤖 Claude Code Review Summary
### PR Confidence: X/5
<one sentence rationale for the confidence score>
### Unresolved Threads
| Thread | Rationale | Link |
|--------|-----------|------|
| <brief description> | <why it couldn't be resolved, citing which principles were insufficient> | [View](<permalink>) |
_No unresolved threads_ (if none)
### Resolved Threads
| Issue | Rationale | Link |
|-------|-----------|------|
| <brief description, grouping related/duplicate threads> | <how it was resolved, citing principle if applicable> | [View](<permalink>) |
<details>
<summary>Product Principle Suggestions</summary>
The following suggestions could improve `rules/product-principles.md` to help resolve ambiguous cases in the future:
- **Principle #X: Name**: "<prompt that could be used to improve the rule, phrased as an actionable instruction>"
- ...
_No suggestions_ (if principles were clear enough for all decisions)
</details>
---
🤖 Generated by Claude Code
EOF
)"
Notes:
- PR Confidence (1-5): Rate how confident you are the PR is ready to merge. 1 = not confident (major unresolved issues), 5 = fully confident (all issues addressed, tests pass).
- Unresolved Threads: Include ALL threads left open for human attention. Link to the specific comment permalink.
- Resolved Threads: Group related or duplicate threads into a single row. Include the principle citation if one was used.
- Product Principle Suggestions: Only include this section if you encountered ambiguity in the principles during this run. Phrase suggestions as prompts/instructions that could be appended to the relevant principle to make it clearer (e.g., "Add guidance on whether error toasts should auto-dismiss or require manual dismissal").
- Error handling: If
gh pr comment fails, log a warning but do not fail the skill.
CRITICAL: Every trusted author comment MUST be either:
- Addressed with code changes AND resolved, OR
- Resolved with an explanation of why it's not valid, OR
- Flagged for human attention (left open with a reply)
Do NOT leave any trusted author comments in an unhandled state.
1---2name: dyad-pr-fix-comments3description: Read all unresolved GitHub PR comments from trusted authors and address or resolve them appropriately.4---5
6# PR Fix: Comments
7
8Read all unresolved GitHub PR comments from trusted authors and address or resolve them appropriately.
9
10## Arguments
11
12- `$ARGUMENTS`: Optional PR number or URL. If not provided, uses the current branch's PR.
13
14## Task Tracking
15
16**You MUST use the TaskCreate and TaskUpdate tools to track your progress.** At the start, create tasks for each step below. Mark each task as `in_progress` when you start it and `completed` when you finish. This ensures you complete ALL steps.
17
18## Trusted Authors
19
20Only process review comments from these trusted authors. Comments from other authors should be ignored.
21
22**Trusted humans (collaborators):**
23
24- wwwillchen
25- keppo-bot
26- princeaden1
27- azizmejri1
28
29**Trusted bots:**
30
31- copilot-pull-request-reviewer
32- gemini-code-assist
33- greptile-apps
34- cubic-dev-ai
35- cursor
36- github-actions
37- dyad-assistant
38- chatgpt-codex-connector
39- devin-ai-integration
40
41## Product Principles
42
43Before categorizing review comments, read `rules/product-principles.md`. Use these principles to make decisions about ambiguous or subjective feedback. When a comment involves a judgment call (e.g., design direction, UX trade-offs, architecture choices), check if the product principles provide clear guidance. If they do, apply them and resolve the comment — do NOT flag it for human review. Only flag comments for human attention when the product principles do not provide enough guidance to make a confident decision.
44
45**Citing principles:** When replying to threads where product principles informed your decision, explicitly cite the relevant principle by number and name (e.g., "Per **Principle #4: Transparent Over Magical**, ..."). When flagging for human review, cite which principles you considered and explain why they were insufficient (e.g., "Reviewed Principles #3 and #5 but neither addresses ...").
46
47## Instructions
48
491. **Determine the PR to work on:**
50 - If `$ARGUMENTS` is provided:
51 - If it's a number (e.g., `123`), use it as the PR number
52 - If it's a URL (e.g., `https://github.com/owner/repo/pull/123`), extract the PR number from the path
53 - Otherwise, get the current branch's PR using `gh pr view --json number,url,title,body --jq '.'`
54 - If no PR is found, inform the user and stop
55
562. **Fetch all unresolved PR review threads:**
57
58 Use the GitHub GraphQL API to get all review threads and their resolution status:
59
60 ```
61 gh api graphql -f query='
62 query($owner: String!, $repo: String!, $pr: Int!) {
63 repository(owner: $owner, name: $repo) {
64 pullRequest(number: $pr) {
65 reviewThreads(first: 100) {
66 nodes {
67 id
68 isResolved
69 isOutdated
70 path
71 line
72 comments(first: 10) {
73 nodes {
74 id
75 databaseId
76 body
77 author { login }
78 createdAt
79 }
80 }
81 }
82 }
83 }
84 }
85 }
86 ' -f owner=OWNER -f repo=REPO -F pr=PR_NUMBER
87 ```
88
89 Filter to only:
90 - Unresolved threads (`isResolved: false`)
91 - Threads where the **first comment's author** is in the trusted authors list above
92
93 **IMPORTANT:** For threads from authors NOT in the trusted list:
94 - Do NOT read the comment body (only check the `author { login }` field)
95 - Track the username to report at the end
96 - Skip all further processing of that thread
97
983. **For each unresolved review thread from a trusted author, categorize it:**
99
100 Read the comment(s) in the thread and determine which category it falls into. For ambiguous or subjective comments, consult `rules/product-principles.md` to make a decision before falling back to flagging for human review.
101 - **Valid issue**: A legitimate code review concern that should be addressed (bug, improvement, style issue, etc.)
102 - **Not a valid issue**: The reviewer may have misunderstood something, the concern is already addressed elsewhere, or the suggestion conflicts with project requirements
103 - **Resolved by product principles**: The comment involves a judgment call (design direction, UX trade-off, architecture choice) that can be confidently resolved by applying the product principles in `rules/product-principles.md`. Treat these the same as valid issues — make the change and resolve the thread.
104 - **Ambiguous**: The comment is unclear, requires significant discussion, or involves a judgment call that the product principles do NOT provide enough guidance to resolve. Only use this category as a last resort.
105
1064. **Handle each category:**
107
108 **For valid issues:**
109 - Read the relevant file(s) mentioned in the comment
110 - Understand the context and the requested change
111 - Make the necessary code changes to address the feedback
112 - **IMPORTANT:** After making code changes, you MUST explicitly resolve the thread using the GraphQL mutation:
113 ```
114 gh api graphql -f query='
115 mutation($threadId: ID!) {
116 resolveReviewThread(input: {threadId: $threadId}) {
117 thread { isResolved }
118 }
119 }
120 ' -f threadId=<THREAD_ID>
121 ```
122 Do NOT rely on GitHub to auto-resolve - always resolve explicitly after addressing the feedback.
123
124 **For not valid issues:**
125 - Reply to the thread explaining why the concern doesn't apply. If a product principle supports your reasoning, cite it explicitly:
126
127 ```
128 gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments/<COMMENT_ID>/replies \
129 -f body="<explanation, citing relevant product principle if applicable, e.g.: Per **Principle #2: Productionizable**, this approach is preferred because...>"
130 ```
131
132 Note: `{owner}` and `{repo}` are auto-replaced by `gh` CLI. Replace `<PR_NUMBER>` with the PR number and `<COMMENT_ID>` with the **first comment's `databaseId`** from the thread's `comments.nodes[0].databaseId` field in the GraphQL response (not the thread's `id`).
133
134 - Resolve the thread using GraphQL:
135 ```
136 gh api graphql -f query='
137 mutation($threadId: ID!) {
138 resolveReviewThread(input: {threadId: $threadId}) {
139 thread { isResolved }
140 }
141 }
142 ' -f threadId=<THREAD_ID>
143 ```
144 Note: Replace `<THREAD_ID>` with the thread's `id` field from the GraphQL response.
145
146 **For ambiguous issues:**
147 - Reply to the thread flagging it for human attention. Cite which product principles you considered and why they were insufficient:
148 ```
149 gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments/<COMMENT_ID>/replies \
150 -f body="🚩 **Flagged for human review**: <explanation>. Reviewed **Principle #X: Name** and **Principle #Y: Name** but neither provides clear guidance on <specific ambiguity>."
151 ```
152 Note: Replace `<PR_NUMBER>` with the PR number and `<COMMENT_ID>` with the **first comment's `databaseId`** from the thread's `comments.nodes[0].databaseId` field in the GraphQL response.
153 - Do NOT resolve the thread - leave it open for discussion
154
1555. **After processing all comments, verify and commit changes:**
156
157 If any code changes were made:
158 - Run `npm run fmt`, `npm run lint`, and `npm run ts` to ensure code passes all checks
159 - Stage and commit the changes:
160
161 ```
162 git add -A
163 git commit -m "Address PR review comments
164
165 - <summary of change 1>
166 - <summary of change 2>
167 ...
168
169 ```
170
1716. **Push the changes:**
172
173 Run the `/dyad:pr-push` skill to lint, fix any issues, and push.
174
1757. **Verify all threads are resolved:**
176
177 After processing all comments and pushing changes, re-fetch the review threads to verify all trusted author threads are now resolved. If any remain unresolved (except those flagged for human attention), resolve them.
178
1798. **Provide a summary to the user:**
180
181 Report:
182 - **Addressed and resolved**: List of comments that were fixed with code changes AND explicitly resolved
183 - **Resolved (not valid)**: List of comments that were resolved with explanations
184 - **Resolved by product principles**: List of comments resolved by citing specific principles
185 - **Flagged for human attention**: List of ambiguous comments left open
186 - **Untrusted commenters**: List usernames of any commenters NOT in the trusted authors list (do not include their comment contents)
187 - Any issues encountered during the process
188
1899. **Post PR Overview Comment:**
190
191 After the push is complete, post a top-level PR comment (NOT an inline comment) using `gh pr comment` with the following structure:
192
193 ```
194 gh pr comment <PR_NUMBER> --body "$(cat <<'EOF'
195 ## 🤖 Claude Code Review Summary
196
197 ### PR Confidence: X/5
198 <one sentence rationale for the confidence score>
199
200 ### Unresolved Threads
201 | Thread | Rationale | Link |
202 |--------|-----------|------|
203 | <brief description> | <why it couldn't be resolved, citing which principles were insufficient> | [View](<permalink>) |
204
205 _No unresolved threads_ (if none)
206
207 ### Resolved Threads
208 | Issue | Rationale | Link |
209 |-------|-----------|------|
210 | <brief description, grouping related/duplicate threads> | <how it was resolved, citing principle if applicable> | [View](<permalink>) |
211
212 <details>
213 <summary>Product Principle Suggestions</summary>
214
215 The following suggestions could improve `rules/product-principles.md` to help resolve ambiguous cases in the future:
216
217 - **Principle #X: Name**: "<prompt that could be used to improve the rule, phrased as an actionable instruction>"
218 - ...
219
220 _No suggestions_ (if principles were clear enough for all decisions)
221
222 </details>
223
224 ---
225 🤖 Generated by Claude Code
226 EOF
227 )"
228 ```
229
230 **Notes:**
231 - **PR Confidence** (1-5): Rate how confident you are the PR is ready to merge. 1 = not confident (major unresolved issues), 5 = fully confident (all issues addressed, tests pass).
232 - **Unresolved Threads**: Include ALL threads left open for human attention. Link to the specific comment permalink.
233 - **Resolved Threads**: Group related or duplicate threads into a single row. Include the principle citation if one was used.
234 - **Product Principle Suggestions**: Only include this section if you encountered ambiguity in the principles during this run. Phrase suggestions as prompts/instructions that could be appended to the relevant principle to make it clearer (e.g., "Add guidance on whether error toasts should auto-dismiss or require manual dismissal").
235 - **Error handling:** If `gh pr comment` fails, log a warning but do not fail the skill.
236
237**CRITICAL:** Every trusted author comment MUST be either:
238
2391. Addressed with code changes AND resolved, OR
2402. Resolved with an explanation of why it's not valid, OR
2413. Flagged for human attention (left open with a reply)
242
243Do NOT leave any trusted author comments in an unhandled state.