@fro.bot/systematic 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/agents/document-review/adversarial-document-reviewer.md +87 -0
  2. package/agents/review/adversarial-reviewer.md +107 -0
  3. package/agents/review/cli-agent-readiness-reviewer.md +443 -0
  4. package/agents/review/cli-readiness-reviewer.md +69 -0
  5. package/agents/review/previous-comments-reviewer.md +64 -0
  6. package/agents/review/project-standards-reviewer.md +80 -0
  7. package/package.json +1 -1
  8. package/skills/ce-compound/assets/resolution-template.md +90 -0
  9. package/skills/ce-compound/references/schema.yaml +222 -0
  10. package/skills/ce-compound/references/yaml-schema.md +87 -0
  11. package/skills/ce-compound-refresh/assets/resolution-template.md +90 -0
  12. package/skills/ce-compound-refresh/references/schema.yaml +222 -0
  13. package/skills/ce-compound-refresh/references/yaml-schema.md +87 -0
  14. package/skills/{ce-review-beta → ce-review}/references/findings-schema.json +8 -7
  15. package/skills/ce-review/references/persona-catalog.md +67 -0
  16. package/skills/ce-review/references/resolve-base.sh +94 -0
  17. package/skills/{ce-review-beta → ce-review}/references/review-output-template.md +36 -3
  18. package/skills/ce-review/references/subagent-template.md +84 -0
  19. package/skills/claude-permissions-optimizer/scripts/extract-commands.mjs +2 -2
  20. package/skills/claude-permissions-optimizer/scripts/normalize.mjs +8 -8
  21. package/skills/document-review/references/findings-schema.json +109 -0
  22. package/skills/document-review/references/review-output-template.md +89 -0
  23. package/skills/document-review/references/subagent-template.md +57 -0
  24. package/skills/git-clean-gone-branches/SKILL.md +63 -0
  25. package/skills/git-clean-gone-branches/scripts/clean-gone +48 -0
  26. package/skills/git-commit/SKILL.md +103 -0
  27. package/skills/git-commit-push-pr/SKILL.md +419 -0
  28. package/skills/onboarding/SKILL.md +407 -0
  29. package/skills/onboarding/scripts/inventory.mjs +1043 -0
  30. package/skills/resolve-pr-feedback/SKILL.md +374 -0
  31. package/skills/resolve-pr-feedback/scripts/get-pr-comments +104 -0
  32. package/skills/resolve-pr-feedback/scripts/get-thread-for-comment +58 -0
  33. package/skills/resolve-pr-feedback/scripts/reply-to-pr-thread +33 -0
  34. package/skills/{resolve-pr-parallel → resolve-pr-feedback}/scripts/resolve-pr-thread +0 -0
  35. package/skills/todo-create/SKILL.md +109 -0
  36. package/skills/todo-resolve/SKILL.md +68 -0
  37. package/skills/todo-triage/SKILL.md +70 -0
  38. package/skills/ce-review-beta/SKILL.md +0 -506
  39. package/skills/ce-review-beta/references/persona-catalog.md +0 -50
  40. package/skills/ce-review-beta/references/subagent-template.md +0 -56
  41. package/skills/file-todos/SKILL.md +0 -231
  42. package/skills/resolve-pr-parallel/SKILL.md +0 -96
  43. package/skills/resolve-pr-parallel/scripts/get-pr-comments +0 -68
  44. package/skills/resolve-todo-parallel/SKILL.md +0 -68
  45. package/skills/triage/SKILL.md +0 -312
  46. package/skills/workflows-brainstorm/SKILL.md +0 -11
  47. package/skills/workflows-compound/SKILL.md +0 -10
  48. package/skills/workflows-plan/SKILL.md +0 -10
  49. package/skills/workflows-review/SKILL.md +0 -10
  50. package/skills/workflows-work/SKILL.md +0 -10
  51. /package/skills/{ce-review-beta → ce-review}/references/diff-scope.md +0 -0
  52. /package/skills/{file-todos → todo-create}/assets/todo-template.md +0 -0
@@ -0,0 +1,374 @@
1
+ ---
2
+ name: resolve-pr-feedback
3
+ description: Resolve PR review feedback by evaluating validity and fixing issues in parallel. Use when addressing PR review comments, resolving review threads, or fixing code review feedback.
4
+ argument-hint: "[PR number, comment URL, or blank for current branch's PR]"
5
+ disable-model-invocation: true
6
+ allowed-tools: Bash(gh *), Bash(git *), Read
7
+ ---
8
+
9
+ # Resolve PR Review Feedback
10
+
11
+ Evaluate and fix PR review feedback, then reply and resolve threads. Spawns parallel agents for each thread.
12
+
13
+ > **Agent time is cheap. Tech debt is expensive.**
14
+ > Fix everything valid -- including nitpicks and low-priority items. If we're already in the code, fix it rather than punt it.
15
+
16
+ ## Mode Detection
17
+
18
+ | Argument | Mode |
19
+ |----------|------|
20
+ | No argument | **Full** -- all unresolved threads on the current branch's PR |
21
+ | PR number (e.g., `123`) | **Full** -- all unresolved threads on that PR |
22
+ | Comment/thread URL | **Targeted** -- only that specific thread |
23
+
24
+ **Targeted mode**: When a URL is provided, ONLY address that feedback. Do not fetch or process other threads.
25
+
26
+ ---
27
+
28
+ ## Full Mode
29
+
30
+ ### 1. Fetch Unresolved Threads
31
+
32
+ If no PR number was provided, detect from the current branch:
33
+ ```bash
34
+ gh pr view --json number -q .number
35
+ ```
36
+
37
+ Then fetch all feedback using the GraphQL script at [scripts/get-pr-comments](scripts/get-pr-comments):
38
+
39
+ ```bash
40
+ bash scripts/get-pr-comments PR_NUMBER
41
+ ```
42
+
43
+ Returns a JSON object with three keys:
44
+
45
+ | Key | Contents | Has file/line? | Resolvable? |
46
+ |-----|----------|---------------|-------------|
47
+ | `review_threads` | Unresolved, non-outdated inline code review threads | Yes | Yes (GraphQL) |
48
+ | `pr_comments` | Top-level PR conversation comments (excludes PR author) | No | No |
49
+ | `review_bodies` | Review submission bodies with non-empty text (excludes PR author) | No | No |
50
+
51
+ If the script fails, fall back to:
52
+ ```bash
53
+ gh pr view PR_NUMBER --json reviews,comments
54
+ gh api repos/{owner}/{repo}/pulls/PR_NUMBER/comments
55
+ ```
56
+
57
+ ### 2. Triage: Separate New from Pending
58
+
59
+ Before processing, classify each piece of feedback as **new** or **already handled**.
60
+
61
+ **Review threads**: Read the thread's comments. If there's a substantive reply that acknowledges the concern but defers action (e.g., "need to align on this", "going to think through this", or a reply that presents options without resolving), it's a **pending decision** -- don't re-process. If there's only the original reviewer comment(s) with no substantive response, it's **new**.
62
+
63
+ **PR comments and review bodies**: These have no resolve mechanism, so they reappear on every run. Apply two filters in order:
64
+
65
+ 1. **Actionability**: Skip items that contain no actionable feedback or questions to answer. Examples: review wrapper text ("Here are some automated review suggestions..."), approvals ("this looks great!"), status badges ("Validated"), CI summaries with no follow-up asks. If there's nothing to fix, answer, or decide, it's not actionable -- drop it from the count entirely.
66
+ 2. **Already replied**: For actionable items, check the PR conversation for an existing reply that quotes and addresses the feedback. If a reply already exists, skip. If not, it's new.
67
+
68
+ The distinction is about content, not who posted what. A deferral from a teammate, a previous skill run, or a manual reply all count. Similarly, actionability is about content -- bot feedback that requests a specific code change is actionable; a bot's boilerplate header wrapping those requests is not.
69
+
70
+ If there are no new items across all feedback types, skip steps 3-8 and go straight to step 9.
71
+
72
+ ### 3. Cluster Analysis (Gated)
73
+
74
+ Before planning and dispatching fixes, check whether feedback patterns suggest a systemic issue that warrants broader investigation rather than individual fixes.
75
+
76
+ **Gate check**: Cluster analysis only runs when at least one signal fires. If neither fires, skip directly to step 4.
77
+
78
+ | Gate signal | Check |
79
+ |---|---|
80
+ | **Volume** | 3+ new items from triage |
81
+ | **Cross-invocation** | `cross_invocation.signal == true` in the script output (resolved threads exist alongside new ones — evidence of multi-round review) |
82
+
83
+ If the gate does not fire, proceed to step 4. The common case (first review round with 1-2 comments) skips this step entirely with zero overhead.
84
+
85
+ **If the gate fires**, analyze feedback for thematic clusters. When the cross-invocation signal fired, include resolved threads from `cross_invocation.resolved_threads` alongside new threads in the analysis — these are previously-resolved threads from earlier review rounds that provide pattern context. Mark them as `previously_resolved` so dispatch (step 5) knows not to individually re-resolve them.
86
+
87
+ 1. **Assign concern categories** from this fixed list: `error-handling`, `validation`, `type-safety`, `naming`, `performance`, `testing`, `security`, `documentation`, `style`, `architecture`, `other`. Each item (new and previously-resolved) gets exactly one category based on what the feedback is about.
88
+
89
+ 2. **Group by category + spatial proximity**. Two items form a potential cluster when they share a concern category AND are spatially proximate (same file, or files in the same directory subtree). Clusters can span new and previously-resolved threads.
90
+
91
+ | Thematic match | Spatial proximity | Action |
92
+ |---|---|---|
93
+ | Same category | Same file | Cluster |
94
+ | Same category | Same directory subtree | Cluster |
95
+ | Same category | Unrelated locations | No cluster |
96
+ | Different categories | Any | No cluster (same-file grouping still applies for conflict avoidance) |
97
+
98
+ 3. **Synthesize a cluster brief** for each cluster of 2+ items. Pass briefs to agents using a `<cluster-brief>` XML block:
99
+
100
+ ```xml
101
+ <cluster-brief>
102
+ <theme>[concern category]</theme>
103
+ <area>[common directory path]</area>
104
+ <files>[comma-separated file paths]</files>
105
+ <threads>[comma-separated new thread/comment IDs]</threads>
106
+ <hypothesis>[one sentence: what the individual comments collectively suggest about a deeper issue]</hypothesis>
107
+ <prior-resolutions>
108
+ <thread id="PRRT_..." path="..." category="..."/>
109
+ </prior-resolutions>
110
+ </cluster-brief>
111
+ ```
112
+
113
+ The `<prior-resolutions>` element lists previously-resolved threads that clustered with the new threads — their IDs, file paths, and assigned concern categories. This gives the resolver agent the full cross-round picture. When no previously-resolved threads are in the cluster, omit the element.
114
+
115
+ 4. **Items not in any cluster** remain as individual items and are dispatched normally in step 5. Previously-resolved threads that don't cluster with any new thread are dropped — they provided context but no pattern was found.
116
+
117
+ 5. **If no clusters are found** after analysis (the gate fired but items don't form thematic+spatial groups), proceed with all items as individual. The gate was a false positive -- the only cost was the analysis itself.
118
+
119
+ ### 4. Plan
120
+
121
+ Create a task list of all **new** unresolved items grouped by type (e.g., `todowrite` in OpenCode, `update_plan` in Codex):
122
+ - Code changes requested
123
+ - Questions to answer
124
+ - Style/convention fixes
125
+ - Test additions needed
126
+
127
+ If step 3 produced clusters, include them in the task list as cluster items alongside individual items.
128
+
129
+ ### 5. Implement (PARALLEL)
130
+
131
+ Process all three feedback types. Review threads are the primary type; PR comments and review bodies are secondary but should not be ignored.
132
+
133
+ #### Dispatch boundary for previously-resolved threads
134
+
135
+ Previously-resolved threads (from `cross_invocation.resolved_threads`) participate in clustering and appear in cluster briefs as `<prior-resolutions>` context. They are NEVER individually dispatched — they were already resolved in prior rounds. Only new threads get individual or cluster dispatch.
136
+
137
+ #### Individual dispatch (default)
138
+
139
+ **For review threads** (`review_threads`): Spawn a `systematic:workflow:pr-comment-resolver` agent for each new thread that is NOT already assigned to a cluster from step 3. Clustered threads are handled by cluster dispatch below -- do not dispatch them individually.
140
+
141
+ Each agent receives:
142
+ - The thread ID
143
+ - The file path and line number
144
+ - The full comment text (all comments in the thread)
145
+ - The PR number (for context)
146
+ - The feedback type (`review_thread`)
147
+
148
+ **For PR comments and review bodies** (`pr_comments`, `review_bodies`): These lack file/line context. Spawn a `systematic:workflow:pr-comment-resolver` agent for each actionable non-clustered item. The agent receives the comment ID, body text, PR number, and feedback type (`pr_comment` or `review_body`). The agent must identify the relevant files from the comment text and the PR diff.
149
+
150
+ #### Cluster dispatch
151
+
152
+ For each cluster identified in step 3, dispatch ONE `systematic:workflow:pr-comment-resolver` agent that receives:
153
+ - The `<cluster-brief>` XML block
154
+ - All thread details for threads in the cluster (IDs, file paths, line numbers, comment text)
155
+ - The PR number
156
+ - The feedback types
157
+
158
+ The cluster agent reads the broader area before making targeted fixes. It returns one summary per thread it handled (same structure as individual agents), plus a `cluster_assessment` field describing what broader investigation revealed and whether a holistic or individual approach was taken.
159
+
160
+ #### Agent return format
161
+
162
+ Each agent returns a short summary:
163
+ - **verdict**: `fixed`, `fixed-differently`, `replied`, `not-addressing`, or `needs-human`
164
+ - **feedback_id**: the thread ID or comment ID it handled
165
+ - **feedback_type**: `review_thread`, `pr_comment`, or `review_body`
166
+ - **reply_text**: the markdown reply to post (quoting the relevant part of the original feedback)
167
+ - **files_changed**: list of files modified (empty if replied/not-addressing)
168
+ - **reason**: brief explanation of what was done or why it was skipped
169
+
170
+ Cluster agents additionally return:
171
+ - **cluster_assessment**: what the broader investigation found, whether a holistic or individual approach was taken
172
+
173
+ Verdict meanings:
174
+ - `fixed` -- code change made as requested
175
+ - `fixed-differently` -- code change made, but with a better approach than suggested
176
+ - `replied` -- no code change needed; answered a question, acknowledged feedback, or explained a design decision
177
+ - `not-addressing` -- feedback is factually wrong about the code; skip with evidence
178
+ - `needs-human` -- cannot determine the right action; needs user decision
179
+
180
+ #### Batching and conflict avoidance
181
+
182
+ **Batching**: Clusters count as 1 dispatch unit regardless of how many threads they contain. If there are 1-4 dispatch units total (clusters + individual items), dispatch all in parallel. For 5+ dispatch units, batch in groups of 4.
183
+
184
+ **Conflict avoidance**: No two dispatch units that touch the same file should run in parallel. Before dispatching, check for file overlaps across all dispatch units (clusters and individual items). If a cluster's file list overlaps with an individual item's file, or with another cluster's files, serialize those units -- dispatch one, wait for it to complete, then dispatch the next. Non-overlapping units can still run in parallel. Within a single dispatch unit handling multiple threads on the same file, the agent addresses them sequentially.
185
+
186
+ **Sequential fallback**: Platforms that do not support parallel dispatch should run agents sequentially. Dispatch cluster units first (they are higher-leverage), then individual items.
187
+
188
+ Fixes can occasionally expand beyond their referenced file (e.g., renaming a method updates callers elsewhere). This is rare but can cause parallel agents to collide. The verification step (step 8) catches this -- if re-fetching shows unresolved threads or if the commit reveals inconsistent changes, re-run the affected agents sequentially.
189
+
190
+ ### 6. Commit and Push
191
+
192
+ After all agents complete, check whether any files were actually changed. If all verdicts are `replied`, `not-addressing`, or `needs-human` (no code changes), skip this step entirely and proceed to step 7.
193
+
194
+ If there are file changes:
195
+
196
+ 1. Stage only files reported by sub-agents and commit with a message referencing the PR:
197
+
198
+ ```bash
199
+ git add [files from agent summaries]
200
+ git commit -m "Address PR review feedback (#PR_NUMBER)
201
+
202
+ - [list changes from agent summaries]"
203
+ ```
204
+
205
+ 2. Push to remote:
206
+ ```bash
207
+ git push
208
+ ```
209
+
210
+ ### 7. Reply and Resolve
211
+
212
+ After the push succeeds, post replies and resolve where applicable. The mechanism depends on the feedback type.
213
+
214
+ #### Reply format
215
+
216
+ All replies should quote the relevant part of the original feedback for continuity. Quote the specific sentence or passage being addressed, not the entire comment if it's long.
217
+
218
+ For fixed items:
219
+ ```markdown
220
+ > [quoted relevant part of original feedback]
221
+
222
+ Addressed: [brief description of the fix]
223
+ ```
224
+
225
+ For items not addressed:
226
+ ```markdown
227
+ > [quoted relevant part of original feedback]
228
+
229
+ Not addressing: [reason with evidence, e.g., "null check already exists at line 85"]
230
+ ```
231
+
232
+ For `needs-human` verdicts, post the reply but do NOT resolve the thread. Leave it open for human input.
233
+
234
+ #### Review threads
235
+
236
+ 1. **Reply** using [scripts/reply-to-pr-thread](scripts/reply-to-pr-thread):
237
+ ```bash
238
+ echo "REPLY_TEXT" | bash scripts/reply-to-pr-thread THREAD_ID
239
+ ```
240
+
241
+ 2. **Resolve** using [scripts/resolve-pr-thread](scripts/resolve-pr-thread):
242
+ ```bash
243
+ bash scripts/resolve-pr-thread THREAD_ID
244
+ ```
245
+
246
+ #### PR comments and review bodies
247
+
248
+ These cannot be resolved via GitHub's API. Reply with a top-level PR comment referencing the original:
249
+
250
+ ```bash
251
+ gh pr comment PR_NUMBER --body "REPLY_TEXT"
252
+ ```
253
+
254
+ Include enough quoted context in the reply so the reader can follow which comment is being addressed without scrolling.
255
+
256
+ ### 8. Verify
257
+
258
+ Re-fetch feedback to confirm resolution:
259
+
260
+ ```bash
261
+ bash scripts/get-pr-comments PR_NUMBER
262
+ ```
263
+
264
+ The `review_threads` array should be empty (except `needs-human` items).
265
+
266
+ **If new threads remain**, check the iteration count for this run:
267
+
268
+ - **First or second fix-verify cycle**: Repeat from step 2 for the remaining threads. The re-fetch in step 1 will pick up threads resolved in earlier cycles as resolved threads in `cross_invocation`, so the cross-invocation gate (step 3) will fire naturally if patterns emerge across cycles.
269
+
270
+ - **After the second fix-verify cycle** (3rd pass would begin): Stop looping. Surface remaining issues to the user with context about the recurring pattern: "Multiple rounds of feedback on [area/theme] suggest a deeper issue. Here's what we've fixed so far and what keeps appearing." Use the same `needs-human` escalation pattern -- leave threads open and present the pattern for the user to decide.
271
+
272
+ PR comments and review bodies have no resolve mechanism, so they will still appear in the output. Verify they were replied to by checking the PR conversation.
273
+
274
+ ### 9. Summary
275
+
276
+ Present a concise summary of all work done. Group by verdict, one line per item describing *what was done* not just *where*. This is the primary output the user sees.
277
+
278
+ Format:
279
+
280
+ ```
281
+ Resolved N of M new items on PR #NUMBER:
282
+
283
+ Fixed (count): [brief description of each fix]
284
+ Fixed differently (count): [what was changed and why the approach differed]
285
+ Replied (count): [what questions were answered]
286
+ Not addressing (count): [what was skipped and why]
287
+ ```
288
+
289
+ If any clusters were investigated, append a cluster investigation section:
290
+
291
+ ```
292
+ Cluster investigations (count):
293
+
294
+ 1. [theme] in [area]: [cluster_assessment from the agent --
295
+ what was found, whether a holistic or individual approach was taken]
296
+ ```
297
+
298
+ If any agent returned `needs-human`, append a decisions section. These are rare but high-signal. Each `needs-human` agent returns a `decision_context` field with a structured analysis: what the reviewer said, what the agent investigated, why it needs a decision, concrete options with tradeoffs, and the agent's lean if it has one.
299
+
300
+ Present the `decision_context` directly -- it's already structured for the user to read and decide quickly:
301
+
302
+ ```
303
+ Needs your input (count):
304
+
305
+ 1. [decision_context from the agent -- includes quoted feedback,
306
+ investigation findings, why it needs a decision, options with
307
+ tradeoffs, and the agent's recommendation if any]
308
+ ```
309
+
310
+ The `needs-human` threads already have a natural-sounding acknowledgment reply posted and remain open on the PR.
311
+
312
+ If there are **pending decisions from a previous run** (threads detected in step 2 as already responded to but still unresolved), surface them after the new work:
313
+
314
+ ```
315
+ Still pending from a previous run (count):
316
+
317
+ 1. [Thread path:line] -- [brief description of what's pending]
318
+ Previous reply: [link to the existing reply]
319
+ [Re-present the decision options if the original context is available,
320
+ or summarize what was asked]
321
+ ```
322
+
323
+ If a blocking question tool is available, use it to ask about all pending decisions (both new `needs-human` and previous-run pending) together. If there are only pending decisions and no new work was done, the summary is just the pending items.
324
+
325
+ If a blocking question tool is available (`question` in OpenCode, `request_user_input` in Codex, `ask_user` in Gemini), use it to present the decisions and wait for the user's response. After they decide, process the remaining items: fix the code, compose the reply, post it, and resolve the thread.
326
+
327
+ If no question tool is available, present the decisions in the summary output and wait for the user to respond in conversation. If they don't respond, the items remain open on the PR for later handling.
328
+
329
+ ---
330
+
331
+ ## Targeted Mode
332
+
333
+ When a specific comment or thread URL is provided:
334
+
335
+ ### 1. Extract Thread Context
336
+
337
+ Parse the URL to extract OWNER, REPO, PR number, and comment REST ID:
338
+ ```
339
+ https://github.com/OWNER/REPO/pull/NUMBER#discussion_rCOMMENT_ID
340
+ ```
341
+
342
+ **Step 1** -- Get comment details and GraphQL node ID via REST (cheap, single comment):
343
+ ```bash
344
+ gh api repos/OWNER/REPO/pulls/comments/COMMENT_ID \
345
+ --jq '{node_id, path, line, body}'
346
+ ```
347
+
348
+ **Step 2** -- Map comment to its thread ID. Use [scripts/get-thread-for-comment](scripts/get-thread-for-comment):
349
+ ```bash
350
+ bash scripts/get-thread-for-comment PR_NUMBER COMMENT_NODE_ID [OWNER/REPO]
351
+ ```
352
+
353
+ This fetches thread IDs and their first comment IDs (minimal fields, no bodies) and returns the matching thread with full comment details.
354
+
355
+ ### 2. Fix, Reply, Resolve
356
+
357
+ Spawn a single `systematic:workflow:pr-comment-resolver` agent for the thread. Then follow the same commit -> push -> reply -> resolve flow as Full Mode steps 6-7.
358
+
359
+ ---
360
+
361
+ ## Scripts
362
+
363
+ - [scripts/get-pr-comments](scripts/get-pr-comments) -- GraphQL query for unresolved review threads
364
+ - [scripts/get-thread-for-comment](scripts/get-thread-for-comment) -- Map a comment node ID to its parent thread (for targeted mode)
365
+ - [scripts/reply-to-pr-thread](scripts/reply-to-pr-thread) -- GraphQL mutation to reply within a review thread
366
+ - [scripts/resolve-pr-thread](scripts/resolve-pr-thread) -- GraphQL mutation to resolve a thread by ID
367
+
368
+ ## Success Criteria
369
+
370
+ - All unresolved review threads evaluated
371
+ - Valid fixes committed and pushed
372
+ - Each thread replied to with quoted context
373
+ - Threads resolved via GraphQL (except `needs-human`)
374
+ - Empty result from get-pr-comments on verify (minus intentionally-open threads)
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ if [ $# -lt 1 ]; then
6
+ echo "Usage: get-pr-comments PR_NUMBER [OWNER/REPO]"
7
+ echo "Example: get-pr-comments 123"
8
+ echo "Example: get-pr-comments 123 EveryInc/cora"
9
+ exit 1
10
+ fi
11
+
12
+ PR_NUMBER=$1
13
+
14
+ if [ -n "$2" ]; then
15
+ OWNER=$(echo "$2" | cut -d/ -f1)
16
+ REPO=$(echo "$2" | cut -d/ -f2)
17
+ else
18
+ OWNER=$(gh repo view --json owner -q .owner.login 2>/dev/null)
19
+ REPO=$(gh repo view --json name -q .name 2>/dev/null)
20
+ fi
21
+
22
+ if [ -z "$OWNER" ] || [ -z "$REPO" ]; then
23
+ echo "Error: Could not detect repository. Pass OWNER/REPO as second argument."
24
+ exit 1
25
+ fi
26
+
27
+ # Fetch review threads, regular PR comments, and review bodies in one query.
28
+ # Output is a JSON object with four keys:
29
+ # review_threads - unresolved, non-outdated inline code review threads
30
+ # pr_comments - top-level PR conversation comments (excludes PR author)
31
+ # review_bodies - review submissions with non-empty body text (excludes PR author)
32
+ # cross_invocation - cross-invocation awareness envelope:
33
+ # signal: true when both resolved and unresolved threads exist (multi-round review)
34
+ # resolved_threads: last N resolved threads by recency, for cluster analysis input
35
+ gh api graphql -f owner="$OWNER" -f repo="$REPO" -F pr="$PR_NUMBER" -f query='
36
+ query FetchPRFeedback($owner: String!, $repo: String!, $pr: Int!) {
37
+ repository(owner: $owner, name: $repo) {
38
+ pullRequest(number: $pr) {
39
+ author { login }
40
+ reviewThreads(first: 50) {
41
+ edges {
42
+ node {
43
+ id
44
+ isResolved
45
+ isOutdated
46
+ path
47
+ line
48
+ comments(first: 10) {
49
+ nodes {
50
+ id
51
+ author { login }
52
+ body
53
+ createdAt
54
+ url
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ comments(first: 100) {
61
+ nodes {
62
+ id
63
+ author { login }
64
+ body
65
+ createdAt
66
+ url
67
+ }
68
+ }
69
+ reviews(first: 50) {
70
+ nodes {
71
+ id
72
+ author { login }
73
+ body
74
+ state
75
+ createdAt
76
+ url
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }' | jq '.data.repository.pullRequest as $pr |
82
+ # Unresolved threads (existing behavior, unchanged)
83
+ [$pr.reviewThreads.edges[]
84
+ | select(.node.isResolved == false and .node.isOutdated == false)] as $unresolved |
85
+ # Resolved threads for cross-invocation awareness (last 10 by most recent comment)
86
+ [$pr.reviewThreads.edges[]
87
+ | select(.node.isResolved == true)
88
+ | { thread_id: .node.id, path: .node.path, line: .node.line,
89
+ first_comment_body: .node.comments.nodes[0].body,
90
+ last_comment_at: ([.node.comments.nodes[].createdAt] | sort | last) }]
91
+ | sort_by(.last_comment_at) | .[-10:] | reverse as $resolved |
92
+ {
93
+ review_threads: $unresolved,
94
+ pr_comments: [$pr.comments.nodes[]
95
+ | select(.author.login != $pr.author.login)
96
+ | select(.body | test("^\\s*$") | not)],
97
+ review_bodies: [$pr.reviews.nodes[]
98
+ | select(.body != null and .body != "")
99
+ | select(.author.login != $pr.author.login)],
100
+ cross_invocation: {
101
+ signal: (($resolved | length) > 0 and ($unresolved | length) > 0),
102
+ resolved_threads: $resolved
103
+ }
104
+ }'
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Maps a PR review comment node ID to its parent thread.
4
+ # Fetches thread IDs and first comment IDs to find the match,
5
+ # then returns the matching thread with full comment details.
6
+
7
+ set -e
8
+
9
+ if [ $# -lt 2 ]; then
10
+ echo "Usage: get-thread-for-comment PR_NUMBER COMMENT_NODE_ID [OWNER/REPO]"
11
+ echo "Example: get-thread-for-comment 378 PRRC_kwDOP_gZVc6ySv89"
12
+ exit 1
13
+ fi
14
+
15
+ PR_NUMBER=$1
16
+ COMMENT_NODE_ID=$2
17
+
18
+ if [ -n "$3" ]; then
19
+ OWNER=$(echo "$3" | cut -d/ -f1)
20
+ REPO=$(echo "$3" | cut -d/ -f2)
21
+ else
22
+ OWNER=$(gh repo view --json owner -q .owner.login 2>/dev/null)
23
+ REPO=$(gh repo view --json name -q .name 2>/dev/null)
24
+ fi
25
+
26
+ if [ -z "$OWNER" ] || [ -z "$REPO" ]; then
27
+ echo "Error: Could not detect repository. Pass OWNER/REPO as third argument."
28
+ exit 1
29
+ fi
30
+
31
+ gh api graphql -f owner="$OWNER" -f repo="$REPO" -F pr="$PR_NUMBER" -f query='
32
+ query($owner: String!, $repo: String!, $pr: Int!) {
33
+ repository(owner: $owner, name: $repo) {
34
+ pullRequest(number: $pr) {
35
+ reviewThreads(first: 100) {
36
+ nodes {
37
+ id
38
+ isResolved
39
+ path
40
+ line
41
+ comments(first: 100) {
42
+ nodes {
43
+ id
44
+ author { login }
45
+ body
46
+ createdAt
47
+ url
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }' | jq -e --arg cid "$COMMENT_NODE_ID" '
55
+ [.data.repository.pullRequest.reviewThreads.nodes[]
56
+ | select(.comments.nodes | map(.id) | index($cid))]
57
+ | if length == 0 then error("No thread found for comment \($cid)") else .[0] end
58
+ '
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Replies to a PR review thread. Body is read from stdin to avoid
4
+ # shell escaping issues with markdown (quotes, newlines, etc.).
5
+
6
+ set -e
7
+
8
+ if [ $# -lt 1 ]; then
9
+ echo "Usage: echo 'reply body' | reply-to-pr-thread THREAD_ID"
10
+ echo "Example: echo 'Addressed: added null check' | reply-to-pr-thread PRRT_kwDOABC123"
11
+ exit 1
12
+ fi
13
+
14
+ THREAD_ID=$1
15
+ BODY=$(cat)
16
+
17
+ if [ -z "$BODY" ]; then
18
+ echo "Error: No body provided on stdin."
19
+ exit 1
20
+ fi
21
+
22
+ gh api graphql -f threadId="$THREAD_ID" -f body="$BODY" -f query='
23
+ mutation ReplyToReviewThread($threadId: ID!, $body: String!) {
24
+ addPullRequestReviewThreadReply(input: {
25
+ pullRequestReviewThreadId: $threadId
26
+ body: $body
27
+ }) {
28
+ comment {
29
+ id
30
+ url
31
+ }
32
+ }
33
+ }'
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: todo-create
3
+ description: Use when creating durable work items, managing todo lifecycle, or tracking findings across sessions in the file-based todo system
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # File-Based Todo Tracking
8
+
9
+ ## Overview
10
+
11
+ The `.context/systematic/todos/` directory is a file-based tracking system for code review feedback, technical debt, feature requests, and work items. Each todo is a markdown file with YAML frontmatter.
12
+
13
+ > **Legacy support:** Always check both `.context/systematic/todos/` (canonical) and `todos/` (legacy) when reading. Write new todos only to the canonical path. This directory has a multi-session lifecycle -- do not clean it up as scratch.
14
+
15
+ ## Directory Paths
16
+
17
+ | Purpose | Path |
18
+ |---------|------|
19
+ | **Canonical (write here)** | `.context/systematic/todos/` |
20
+ | **Legacy (read-only)** | `todos/` |
21
+
22
+ ## File Naming Convention
23
+
24
+ ```
25
+ {issue_id}-{status}-{priority}-{description}.md
26
+ ```
27
+
28
+ - **issue_id**: Sequential number (001, 002, ...) -- never reused
29
+ - **status**: `pending` | `ready` | `complete`
30
+ - **priority**: `p1` (critical) | `p2` (important) | `p3` (nice-to-have)
31
+ - **description**: kebab-case, brief
32
+
33
+ **Example:** `002-ready-p1-fix-n-plus-1.md`
34
+
35
+ ## File Structure
36
+
37
+ Each todo has YAML frontmatter and structured sections. Use the todo template included below when creating new todos.
38
+
39
+ ```yaml
40
+ ---
41
+ status: ready
42
+ priority: p1
43
+ issue_id: "002"
44
+ tags: [rails, performance]
45
+ dependencies: ["001"] # Issue IDs this is blocked by
46
+ ---
47
+ ```
48
+
49
+ **Required sections:** Problem Statement, Findings, Proposed Solutions, Recommended Action (filled during triage), Acceptance Criteria, Work Log.
50
+
51
+ **Optional sections:** Technical Details, Resources, Notes.
52
+
53
+ ## Workflows
54
+
55
+ > **Tool preference:** Use native file-search/glob and content-search tools instead of shell commands for finding and reading todo files. Shell only for operations with no native equivalent (`mv`, `mkdir -p`).
56
+
57
+ ### Creating a New Todo
58
+
59
+ 1. `mkdir -p .context/systematic/todos/`
60
+ 2. Search both paths for `[0-9]*-*.md`, find the highest numeric prefix, increment, zero-pad to 3 digits.
61
+ 3. Use the todo template included below, write to canonical path as `{NEXT_ID}-pending-{priority}-{description}.md`.
62
+ 4. Fill Problem Statement, Findings, Proposed Solutions, Acceptance Criteria, and initial Work Log entry.
63
+ 5. Set status: `pending` (needs triage) or `ready` (pre-approved).
64
+
65
+ **Create a todo when** the work needs more than ~15 minutes, has dependencies, requires planning, or needs prioritization. **Act immediately instead** when the fix is trivial, obvious, and self-contained.
66
+
67
+ ### Triaging Pending Items
68
+
69
+ 1. Glob `*-pending-*.md` in both paths.
70
+ 2. Review each todo's Problem Statement, Findings, and Proposed Solutions.
71
+ 3. Approve: rename `pending` -> `ready` in filename and frontmatter, fill Recommended Action.
72
+ 4. Defer: leave as `pending`.
73
+
74
+ Load the `todo-triage` skill for an interactive approval workflow.
75
+
76
+ ### Managing Dependencies
77
+
78
+ ```yaml
79
+ dependencies: ["002", "005"] # Blocked by these issues
80
+ dependencies: [] # No blockers
81
+ ```
82
+
83
+ To check blockers: search for `{dep_id}-complete-*.md` in both paths. Missing matches = incomplete blockers.
84
+
85
+ ### Completing a Todo
86
+
87
+ 1. Verify all acceptance criteria.
88
+ 2. Update Work Log with final session.
89
+ 3. Rename `ready` -> `complete` in filename and frontmatter.
90
+ 4. Check for unblocked work: search for files containing `dependencies:.*"{issue_id}"`.
91
+
92
+ ## Integration with Workflows
93
+
94
+ | Trigger | Flow |
95
+ |---------|------|
96
+ | Code review | `/ce:review` -> Findings -> `/todo-triage` -> Todos |
97
+ | Autonomous review | `/ce:review mode:autofix` -> Residual todos -> `/todo-resolve` |
98
+ | Code TODOs | `/todo-resolve` -> Fixes + Complex todos |
99
+ | Planning | Brainstorm -> Create todo -> Work -> Complete |
100
+
101
+ ## Key Distinction
102
+
103
+ This skill manages **durable, cross-session work items** persisted as markdown files. For temporary in-session step tracking, use platform task tools (`todowrite`/`TaskUpdate` in OpenCode, `update_plan` in Codex) instead.
104
+
105
+ ---
106
+
107
+ ## Todo Template
108
+
109
+ @./assets/todo-template.md