crysk 0.0.0 → 0.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 (229) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +609 -3
  3. package/bin/pr-hero.js +166 -0
  4. package/config/models/anthropic.json +5 -0
  5. package/dist/SKILL-7e3725zn.md +496 -0
  6. package/dist/SKILL-7q35wcaz.md +66 -0
  7. package/dist/SKILL-9at22381.md +74 -0
  8. package/dist/SKILL-ex2hxxh3.md +134 -0
  9. package/dist/adjudicator-dtg2axnh.md +86 -0
  10. package/dist/admission-config.example-a9vqmmad.json +9 -0
  11. package/dist/ci-admission-camfbx2b.md +122 -0
  12. package/dist/cli.js +42292 -0
  13. package/dist/consolidate-ac0mnfyj.md +24 -0
  14. package/dist/deep-review-lifecycle-m698ybjp.md +362 -0
  15. package/dist/deep-review-logic-a6b1gczf.md +156 -0
  16. package/dist/deep-review-parity-0ec904db.md +120 -0
  17. package/dist/deep-review-reliability-qyakbjb9.md +125 -0
  18. package/dist/deep-review-resilience-3tz8y26e.md +118 -0
  19. package/dist/index.js +20190 -0
  20. package/dist/opencode-ci-7b0be64p.md +141 -0
  21. package/dist/review-refuter-j4e9gezy.md +71 -0
  22. package/dist/scout-yvp153q7.md +140 -0
  23. package/dist/summarizer-zca44nxa.md +18 -0
  24. package/dist/workflow-w1g9szna.yml +151 -0
  25. package/package.json +81 -4
  26. package/prompts/consolidate.md +24 -0
  27. package/prompts/default/PROVENANCE.md +18 -0
  28. package/prompts/default/deep-review-lifecycle.md +362 -0
  29. package/prompts/default/deep-review-logic.md +156 -0
  30. package/prompts/default/deep-review-parity.md +120 -0
  31. package/prompts/default/deep-review-reliability.md +125 -0
  32. package/prompts/default/deep-review-resilience.md +118 -0
  33. package/prompts/default/review-refuter.md +71 -0
  34. package/prompts/scout.md +140 -0
  35. package/prompts/summarizer.md +18 -0
  36. package/skills/crysk/SKILL.md +74 -0
  37. package/skills/crysk-ci-setup/SKILL.md +134 -0
  38. package/skills/crysk-ci-setup/assets/admission-config.example.json +9 -0
  39. package/skills/crysk-ci-setup/assets/workflow.yml +151 -0
  40. package/skills/crysk-ci-setup/references/ci-admission.md +122 -0
  41. package/skills/crysk-ci-setup/references/opencode-ci.md +141 -0
  42. package/skills/crysk-loop/SKILL.md +496 -0
  43. package/skills/crysk-loop/adjudicator.md +86 -0
  44. package/skills/crysk-pr/SKILL.md +66 -0
  45. package/src/agent-env.ts +1084 -0
  46. package/src/asset-manifest.ts +83 -0
  47. package/src/assets.d.ts +6 -0
  48. package/src/assets.ts +183 -0
  49. package/src/brand-paths.ts +155 -0
  50. package/src/brand.ts +255 -0
  51. package/src/ci/admission-ledger.ts +350 -0
  52. package/src/ci/classify-error.ts +73 -0
  53. package/src/ci/cli-record.ts +271 -0
  54. package/src/ci/force-comment.ts +39 -0
  55. package/src/ci/gates.ts +923 -0
  56. package/src/ci/outcome.ts +2181 -0
  57. package/src/ci/override.ts +187 -0
  58. package/src/ci/publish.ts +1639 -0
  59. package/src/ci/reporter.ts +626 -0
  60. package/src/ci/review-admission.ts +901 -0
  61. package/src/ci/review-levels.ts +310 -0
  62. package/src/ci/review-policy.ts +18 -0
  63. package/src/ci/review-risk.ts +184 -0
  64. package/src/ci/setup.ts +844 -0
  65. package/src/ci/trigger.ts +1353 -0
  66. package/src/cli.ts +348 -0
  67. package/src/commands/activity.ts +67 -0
  68. package/src/commands/ci-setup-questions.ts +397 -0
  69. package/src/commands/ci-setup.ts +381 -0
  70. package/src/commands/config.ts +99 -0
  71. package/src/commands/doctor.ts +108 -0
  72. package/src/commands/init.ts +139 -0
  73. package/src/commands/mcp.ts +10 -0
  74. package/src/commands/menu.ts +129 -0
  75. package/src/commands/post.ts +302 -0
  76. package/src/commands/skills.ts +83 -0
  77. package/src/commands/status.ts +173 -0
  78. package/src/commands/triage.ts +342 -0
  79. package/src/commands/uninstall.ts +37 -0
  80. package/src/commands/upgrade.ts +214 -0
  81. package/src/commands/usage.ts +98 -0
  82. package/src/compare/compare.ts +28 -0
  83. package/src/compare/floor-test.ts +471 -0
  84. package/src/compare/martian-adapter.ts +80 -0
  85. package/src/config/config.ts +267 -0
  86. package/src/corpus/corpus.ts +1094 -0
  87. package/src/corpus/preflight.ts +1789 -0
  88. package/src/diversity/accounting.ts +90 -0
  89. package/src/diversity/adjudication.ts +145 -0
  90. package/src/diversity/admission.ts +60 -0
  91. package/src/diversity/benchmark.ts +195 -0
  92. package/src/diversity/clustering.ts +285 -0
  93. package/src/diversity/errors.ts +7 -0
  94. package/src/diversity/identity.ts +285 -0
  95. package/src/diversity/index.ts +11 -0
  96. package/src/diversity/pipeline-integration.ts +448 -0
  97. package/src/diversity/projection.ts +57 -0
  98. package/src/diversity/self-contained.ts +68 -0
  99. package/src/diversity/target-validation.ts +179 -0
  100. package/src/doctor-migration.ts +209 -0
  101. package/src/doctor.ts +723 -0
  102. package/src/errors.ts +83 -0
  103. package/src/execution/admission.ts +75 -0
  104. package/src/execution/atomic-write.ts +35 -0
  105. package/src/execution/attempt-evidence.ts +415 -0
  106. package/src/execution/bucket-id.ts +136 -0
  107. package/src/execution/concurrency-limiter.ts +175 -0
  108. package/src/execution/contracts.ts +443 -0
  109. package/src/execution/failure-classification.ts +42 -0
  110. package/src/execution/failure-policy.ts +240 -0
  111. package/src/execution/harness.ts +2548 -0
  112. package/src/execution/settlement.ts +348 -0
  113. package/src/execution/spawned-process.ts +66 -0
  114. package/src/execution/spend-limiter.ts +424 -0
  115. package/src/execution/step-artifacts.ts +55 -0
  116. package/src/execution/usage-normalized.ts +469 -0
  117. package/src/git/git.ts +396 -0
  118. package/src/git/identity.ts +64 -0
  119. package/src/git/refs.ts +140 -0
  120. package/src/home-preflight.ts +443 -0
  121. package/src/home.ts +243 -0
  122. package/src/ignore-file.ts +336 -0
  123. package/src/ignore-read.ts +118 -0
  124. package/src/index.ts +34 -0
  125. package/src/legacy-launchd.ts +29 -0
  126. package/src/mcp/mcp.ts +150 -0
  127. package/src/mcp/preflight.ts +407 -0
  128. package/src/menu-context.ts +192 -0
  129. package/src/model/catalog.ts +251 -0
  130. package/src/model/exec-snapshots.ts +390 -0
  131. package/src/model/free-discovery.ts +302 -0
  132. package/src/model/provider-capabilities.ts +814 -0
  133. package/src/model/routing.ts +600 -0
  134. package/src/pr/admission.ts +847 -0
  135. package/src/pr/ci-admission-gate.ts +665 -0
  136. package/src/pr/ci-publish.ts +76 -0
  137. package/src/pr/discovery.ts +432 -0
  138. package/src/pr/inline.ts +507 -0
  139. package/src/pr/plan.ts +366 -0
  140. package/src/pr/posting.ts +115 -0
  141. package/src/pr/pr-status.ts +787 -0
  142. package/src/pr/pr.ts +3642 -0
  143. package/src/pr/preflight.ts +1031 -0
  144. package/src/pr/publish-outcome.ts +361 -0
  145. package/src/pr/range.ts +119 -0
  146. package/src/pr/reverts-preflight.ts +606 -0
  147. package/src/pr/reverts.ts +377 -0
  148. package/src/pr/review-pr.ts +927 -0
  149. package/src/pr/status.ts +154 -0
  150. package/src/pr/target.ts +388 -0
  151. package/src/pr/teardown.ts +437 -0
  152. package/src/pr/worktree-setup.ts +60 -0
  153. package/src/production-runtime.ts +1877 -0
  154. package/src/progress.ts +487 -0
  155. package/src/rereview/adjudicate.ts +89 -0
  156. package/src/rereview/classify.ts +362 -0
  157. package/src/rereview/identity.ts +211 -0
  158. package/src/rereview/plan.ts +308 -0
  159. package/src/rereview/prepare.ts +1025 -0
  160. package/src/rereview/state.ts +767 -0
  161. package/src/rereview/verify.ts +241 -0
  162. package/src/review/boundary.ts +105 -0
  163. package/src/review/consolidate.ts +246 -0
  164. package/src/review/dedupe.ts +368 -0
  165. package/src/review/drafts.ts +448 -0
  166. package/src/review/findings-conformance.ts +120 -0
  167. package/src/review/findings.ts +714 -0
  168. package/src/review/pipeline.ts +3977 -0
  169. package/src/review/preflight.ts +3575 -0
  170. package/src/review/prompt-set.ts +177 -0
  171. package/src/review/proof-refs.ts +187 -0
  172. package/src/review/report.ts +1821 -0
  173. package/src/review/review.ts +490 -0
  174. package/src/review/root-cause.ts +120 -0
  175. package/src/review/route-preflight.ts +289 -0
  176. package/src/review/run.ts +601 -0
  177. package/src/review/scout.ts +323 -0
  178. package/src/review/size-gate.ts +595 -0
  179. package/src/review/spec.ts +235 -0
  180. package/src/review/step-runner.ts +233 -0
  181. package/src/runner-authority.ts +596 -0
  182. package/src/security/binding-policy.ts +115 -0
  183. package/src/security/credential-broker.ts +773 -0
  184. package/src/security/evidence-redaction.ts +62 -0
  185. package/src/security/execution-authority.ts +27 -0
  186. package/src/security/redact.ts +71 -0
  187. package/src/security/workspace-read-broker.ts +466 -0
  188. package/src/server/client.ts +190 -0
  189. package/src/server/preflight.ts +217 -0
  190. package/src/server/server.ts +327 -0
  191. package/src/signal-handler.ts +50 -0
  192. package/src/store/activity.ts +413 -0
  193. package/src/store/backfill-preflight.ts +49 -0
  194. package/src/store/backfill.ts +141 -0
  195. package/src/store/gc-preflight.ts +206 -0
  196. package/src/store/gc.ts +424 -0
  197. package/src/store/metrics-preflight.ts +229 -0
  198. package/src/store/metrics.ts +236 -0
  199. package/src/store/preflight.ts +748 -0
  200. package/src/store/store.ts +693 -0
  201. package/src/system-tools.ts +355 -0
  202. package/src/transport-registry.ts +1124 -0
  203. package/src/transports/claude-code-cli.ts +1348 -0
  204. package/src/transports/opencode-admission.ts +515 -0
  205. package/src/transports/opencode-client.ts +3328 -0
  206. package/src/transports/opencode-evidence.ts +557 -0
  207. package/src/transports/opencode-mcp.ts +248 -0
  208. package/src/transports/opencode-sdk.ts +2294 -0
  209. package/src/transports/opencode-server.ts +535 -0
  210. package/src/triage/adjudication.ts +113 -0
  211. package/src/triage/reply.ts +125 -0
  212. package/src/triage/triage.ts +255 -0
  213. package/src/ui/activity.ts +173 -0
  214. package/src/ui/config-edit.ts +816 -0
  215. package/src/ui/config.ts +462 -0
  216. package/src/ui/menu.ts +1325 -0
  217. package/src/ui/plan.ts +1039 -0
  218. package/src/ui/primitives.ts +300 -0
  219. package/src/ui/progress.ts +298 -0
  220. package/src/ui/result.ts +552 -0
  221. package/src/ui/review-menu.ts +312 -0
  222. package/src/ui/select.ts +528 -0
  223. package/src/ui/tree.ts +178 -0
  224. package/src/uninstaller.ts +479 -0
  225. package/src/updater.ts +836 -0
  226. package/src/usage.ts +77 -0
  227. package/src/watch/preflight.ts +1389 -0
  228. package/src/watch/watch.ts +1235 -0
  229. package/src/wizard.ts +877 -0
@@ -0,0 +1,496 @@
1
+ ---
2
+ name: crysk-loop
3
+ description: "Run the autonomous Crysk PR review loop end-to-end (review -> judge -> fix/reply -> wait -> recheck until done): triage Crysk findings posted as PR comments in their own thread with applied, dismissed, deferred, or misclassified plus reasoning, push verified fixes, and subscribe to re-reviews with `crysk status --pr <n> --wait --json` without stopping to ask the user. Trigger: Crysk (formerly pr-hero) finding comments on a PR you authored, crysk-loop, pr-hero-loop, closing the PR review loop, responding to automated code review, `<!-- crysk-finding` or legacy `<!-- pr-hero-finding` markers in a PR."
4
+ license: Apache-2.0
5
+ metadata:
6
+ author: juanmaagd
7
+ version: "1.8"
8
+ ---
9
+
10
+ ## When to Use
11
+
12
+ Load this skill after Crysk has posted findings on a PR you (the coding agent) authored, and
13
+ you need to answer each one so the review loop closes without a human in it by default.
14
+
15
+ Use it when you see comments whose FIRST line matches:
16
+
17
+ ```
18
+ <!-- crysk-finding path=<url-encoded-path> line=<n> head=<40-hex-sha> c=<12-hex> -->
19
+ ```
20
+
21
+ Comments posted before the rename to Crysk start with `<!-- pr-hero-` instead of
22
+ `<!-- crysk-` (`<!-- pr-hero-finding`, `<!-- pr-hero-report`, `<!-- pr-hero-triage`, ...).
23
+ Treat them exactly the same; the CLI reads both.
24
+
25
+ Do not use it for ordinary human review comments, or for Crysk's own summary comment
26
+ (`<!-- crysk-report head=<sha> -->`). That comment is a status roll-up plus, since W2
27
+ (issues #16/#17), a `### Comments Outside Diff` bucket for findings GitHub would not
28
+ anchor. Those bucket findings have **no** `<!-- crysk-finding` marker and **no**
29
+ review thread. Do not reply on the summary. Do not invent a `gh` comment for them.
30
+ This skill only answers findings that already have their own `<!-- crysk-finding`
31
+ comment — almost always an inline review comment on Files changed.
32
+
33
+ ## Running the CLI (no install needed)
34
+
35
+ Every command below runs through `npx`, so nothing has to be installed on the machine first:
36
+
37
+ ```bash
38
+ npx -y crysk <command> ...
39
+ ```
40
+
41
+ `npx` needs only Node. Crysk's package brings its own Bun runtime, and when that is
42
+ unavailable it uses a `bun` already on PATH. `-y` skips npx's install prompt, which an agent
43
+ cannot answer. If `crysk` is already on PATH (a global install), `crysk <command>` is the
44
+ same command. Do not install Crysk just to triage a PR. To put these skills into another coding
45
+ agent on the machine, run `npx -y crysk skills install` (non-interactive; `--force` overwrites local edits).
46
+
47
+ You also need `gh`, authenticated as a user with write access to the repository: the driver posts
48
+ through it, and you comment `/crysk recheck` and `/crysk review` through it.
49
+
50
+ ## The strategic why
51
+
52
+ The bottleneck of coding with AI is the review. If an agent writes the code and only a human can
53
+ answer a review, the human is the queue. This skill exists so the default actor answering a
54
+ finding is an agent — **the human is the objector, never the gate**: free to weigh in with a
55
+ reaction or a reply whenever they have context or an opinion, never required for the loop to
56
+ close. That only works if the agent actually judges. Closing the loop means answering with a
57
+ tag, not applying the review as a todo list.
58
+
59
+ ## You own the judgment
60
+
61
+ Every Crysk comment is a **claim to verify**, not an order. An advisory report never blocks anything. A CI
62
+ report in gate mode can turn the `crysk` status red on blocking findings. Your reply is argument and evidence,
63
+ and it never clears that status on its own. A blocking finding stops counting in exactly two ways:
64
+
65
+ - **A fix**, pushed to the head and verified gone by the next review.
66
+ - **A dismissal the CI adjudicator upholds.** You reply `dismissed`, comment `/crysk recheck`, an
67
+ adjudicator running in CI rules on your argument, and only its `upheld` (posted by
68
+ `github-actions[bot]` on that head) lets the next review stop counting the finding. See
69
+ "Closing a dismissal" below.
70
+
71
+ `deferred` and `misclassified` never leave the gate count, whatever any adjudicator says: they are
72
+ for findings that are real (or real at another severity), so the gate stays red until a fix or a
73
+ human `/crysk override`. You — the
74
+ coding agent running this skill — have the authority and the duty to accept it **or reject
75
+ it**. The four tags are peers. None is the default.
76
+
77
+ - Read the cited code yourself before you pick a tag. The repository is the evidence; the
78
+ review is not.
79
+ - Applying every finding is a failure of this skill, not compliance with it.
80
+ - Do not pick `applied` because it skips the adjudicator and closes the thread faster. Pick
81
+ `applied` only after you independently confirmed the defect and fixed it in this PR.
82
+ - "It is marked CRITICAL" / "the review said so" is not a reason to change code. Severity is
83
+ the hunter's claim, not a command.
84
+ - If you cannot confirm the defect from the code, `dismissed` (with cited disproof) or
85
+ `deferred` (with a real scope argument) is the honest move. Rubber-stamping a fix you did
86
+ not verify is the failure this section exists to prevent.
87
+
88
+ ## Review judgment: when to stop vs. when to request another pass
89
+
90
+ You also own the judgment of whether the PR needs **zero more reviews** (stop and merge) or **one more forced review** (when workflow rules suppressed an automatic run on a risky change). Always compare `report.head` against `head` in `crysk status --pr <n> --json` and inspect `git diff <report.head>..<head>`:
91
+
92
+ ### A. Stopping diminishing returns (when to stop reviewing and merge)
93
+
94
+ Later review passes hunt only the push delta. Once the real defects from pass 1 are fixed, hunters scanning a small fix-up commit can surface increasingly contrived, speculative, or nitpicky claims. **Fixing a contrived finding just to turn the gate green is worse than a wasted edit:** it creates a new push, triggers another review pass on an even smaller delta, and feeds an endless spiral of defensive code and absurd findings.
95
+
96
+ 1. **Never patch code to appease a contrived or over-severitied finding.**
97
+ - If the claimed bug requires an impossible precondition, contradicts an intentional invariant, or is already guarded: tag it `dismissed` with cited code and use `/crysk recheck` so the CI adjudicator clears it **without** a code change or a new push.
98
+ - If the observation is technically true but trivial, stylistic, pre-existing, or inflated to blocking: tag it `misclassified` or `deferred`. Never rewrite working code just to avoid asking for `/crysk override`.
99
+ 2. **Do not auto-force past `ci_max_attempts` on routine fix-ups.** The repository's `ci_max_attempts` (default `2`) exists specifically to stop diminishing-returns re-reviews. When step 0 returns `next_action: "review"` with reason *"The automatic review budget for this PR is used up"*, inspect `git diff <report.head>..<head>`: if the commits since `report.head` only applied straightforward fixes for already-triaged findings, **stop the loop**. Do not post `/crysk review`. Tell the user the PR has completed its review passes, the fixes are in place, and it is ready for `/crysk override` and merge.
100
+ 3. **Stop and recommend merge when only diminishing-returns items remain.** On `override-or-fix` (or pass 2+ when every real bug is fixed and the only remaining red-gate items are `deferred`, `misclassified`, or a contrived finding whose dismissal the adjudicator did not uphold), **do not cave in and edit the code**. Exit the loop, list the remaining finding(s) with a one-line explanation of why they are contrived/out-of-scope, and tell the user the PR is ready to `/crysk override` and merge.
101
+ 4. **Stop automatic reviews BEFORE the push that should not be reviewed.** When you decide no further review pass is needed but you still have fixes to push, post `gh pr comment <n> --body "/crysk stop"` **first**, then `git push`. CI admission reads the stop on that push and skips the review, carrying the last verdict (a red gate stays red: it still needs `/crysk override`). The stop stays in force for every later push until someone comments `/crysk review` or `/crysk recheck`. It counts only from a user with write access, starts no workflow run, and costs $0. Never push first and try to stop the review afterwards: nothing cancels a review that already started.
102
+
103
+ ### B. Requesting or suggesting another review when workflow rules skipped it
104
+
105
+ The opposite happens when a repository's workflow policy (`once_per_pr`, `thresholded`, `risk_aware` below the score floor, `ci_max_attempts` exhausted, or the size gate) suppresses an automatic review on a push that **genuinely changed load-bearing code**:
106
+ - Under `once_per_pr`, `thresholded`, or `risk_aware`, a skipped push can inherit a carried `success` status from `report.head`, so `next_action` reads `"done"` even though `report.head !== head` (the commits `report.head..head` were never reviewed).
107
+ - Under `ci_max_attempts` or the size/budget gate, the automatic run is blocked and `report.head !== head`.
108
+
109
+ Whenever `report.head !== head`, inspect `git diff <report.head>..<head>`:
110
+ - If that unreviewed delta introduced **new business logic, state-machine or concurrency changes, auth/security/isolation edits, or a non-trivial refactor** (for example, fixing a finding required redesigning a function rather than adding a guard), an extra review **is** justified:
111
+ - When `next_action` is `"review"` or `"override-or-fix"` (and within the forced-run bound below), trigger `gh pr comment <n> --body "/crysk review"` and subscribe with `npx -y crysk status --pr <n> --wait --json` — or, if `next_action` is `"done"` on a carried green status (or the forced-run bound is reached), explicitly **recommend running `/crysk review`** to the user and name the exact files/changes in `report.head..head` that warrant a fresh pass before merging.
112
+
113
+ ### C. Suspecting a flawed integration or design (stop patching, rethink the root cause)
114
+
115
+ Reaching zero findings after several rounds of band-aid fixes is a failure if the underlying design was wrong from the start. Contrast this with `### A` (where later rounds only surface contrived nits): here the findings are **real**, and the volume or churn is telling you the approach itself is broken.
116
+
117
+ Suspect a flawed integration or architecture when **either** of these signals appears. The number of findings alone is not a signal: a first round with many real findings on one new feature is normal polish.
118
+
119
+ 1. **Whack-a-mole loops (fixes spawning new real findings):** By Round 2+, fixing the previous round's findings introduces *new*, legitimate blocking findings in the next review pass, on the same seam — a sign that patches are fighting the architecture rather than closing isolated defects (or a finding returns at higher severity in the summary report).
120
+ 2. **Broken foundational assumption:** Two or more findings show that the code's mental model of an external API, lifecycle, concurrency guarantee, or module ownership does not hold (for example, the code infers from outside a system what that system already knows).
121
+
122
+ **Action when triggered:**
123
+ - **Halt the incremental fix-and-push loop before replying or patching.** Do **not** post `applied` replies for fixes that will not be pushed, and do not stack another round of tactical band-aids just to force the gate green. If unpushed local fix attempts exist, do not push them.
124
+ - If `/crysk stop` was posted to pause automatic reviews while refactoring, remember that `/crysk stop` is persistent. Once the clean redesign is implemented and pushed, comment `/crysk review` on the PR to lift the stop and ensure CI reviews the new architecture.
125
+ - Step back, identify the single root architectural or integration decision that caused the cluster of findings, and stop to report the diagnosis to the user (with the concrete alternative design or clean refactor plan) before continuing.
126
+
127
+ ## Which command spelling to post
128
+
129
+ This skill names the commands as `/crysk review`, `/crysk recheck` and `/crysk override`. A
130
+ workflow set up before the rename to Crysk listens only for `/pr-hero review`, `/pr-hero recheck`
131
+ and `/pr-hero override`, and ignores `/crysk` comments. Comment triggers run the workflow on the
132
+ default branch, so check that file once per PR before posting any command. The workflow file is
133
+ `crysk.yml`, or `pr-hero.yml` in a repository set up before the rename (never both), so try either:
134
+
135
+ ```bash
136
+ for f in crysk.yml pr-hero.yml; do
137
+ gh api "repos/{owner}/{repo}/contents/.github/workflows/$f" --jq .content 2>/dev/null | base64 -d | grep -q "'/crysk review'" && exit 0
138
+ done; exit 1
139
+ ```
140
+
141
+ Exit 0 means the workflow accepts `/crysk`: post the `/crysk` form. Otherwise post the same
142
+ command with `/pr-hero` in place of `/crysk`. If the workflow lives under another file name,
143
+ read that file instead.
144
+
145
+ ## The loop, end to end
146
+
147
+ **Run this as a continuous autonomous loop (`while next_action !== "done"`).** Never end your turn or stop to ask the human for permission between `triage`, fixing code, `git push`, `recheck`, `review`, and waiting for CI to finish. Stop only when `next_action === "done"` or one of the hard escalation stops below triggers (repeated gate/runner failure, 6 forced runs on one head, 2 consecutive `inconclusive` heads, a suspected flawed design (### C), or `override-or-fix` with nothing left you can fix).
148
+
149
+ 0. **Subscribe to and read the PR's settled state.** Run:
150
+
151
+ ```bash
152
+ npx -y crysk status --pr <n> --wait --json
153
+ ```
154
+
155
+ It is read-only (reads GitHub through `gh`, writes nothing) and **deterministic**:
156
+ - When the head is already settled, it returns immediately on the first poll without sleeping.
157
+ - When a review is in flight (`next_action === "wait"`) **or** booting in the 3-minute startup grace window right after a `git push`, `/crysk review`, or `/crysk recheck`, `--wait` polls every 15s until the review finishes and emits the settled JSON in one call. Never invent your own `sleep` loop.
158
+
159
+ Act on its `next_action` and immediately loop back to step 0 until `done`:
160
+ - `wait`: if `--wait` was omitted, re-run with `--wait` and let it block until the review finishes.
161
+ - `review`: no review has run on this head, the last one did not finish, the CI adjudicator
162
+ upheld every dismissal and the next review will stop counting them, or the automatic review
163
+ budget for this PR is used up (or the review policy is manual-only). **Exception — budget used up on a routine fix-up:** when the reason is that the automatic review budget is used up and the latest push only fixed already-triaged findings (see "Stopping diminishing returns" above), do **not** force another review; stop the loop and report that the PR is ready for `/crysk override` and merge. Otherwise check the forced-run bound
164
+ below, comment `gh pr comment <n> --body "/crysk review"`, and immediately run step 0 with `--wait`.
165
+ - `triage`: a live blocking finding on this head has no triage reply at the head it was posted
166
+ on, or the gate is green and a finding posted on this head has no reply yet (advisory findings
167
+ need one too). Run the triage batch below (steps 1–6), which judges every finding, applies real fixes in the tree, posts all replies, and either pushes the fixes or triggers `recheck` before looping back to step 0 with `--wait`.
168
+ - `fix`: a blocking finding is tagged `applied`, or a blocking finding has no comment thread
169
+ (`comment_id` is null: a summary-only row, or one never posted inline). Commit and `git push` the fix, then immediately run step 0 with `--wait` so the next review verifies it. A thread-less finding cannot be answered with `triage reply`, so fix it or ask a maintainer for `/crysk override`.
170
+ - `recheck`: blocking findings are answered `dismissed` (with no pending code fixes to push) and the CI adjudicator has not ruled on
171
+ them on this head (or ruled `inconclusive`). Comment `gh pr comment <n> --body "/crysk recheck"`, then immediately run step 0 with `--wait` and follow "Closing a dismissal" below.
172
+ - `override-or-fix`: the gate is red and nothing is left for `triage` or `recheck`. Read the
173
+ `reason` and act on the case it names; never override it yourself:
174
+ - the head was size- or budget-skipped (the gate description starts "crysk skipped the
175
+ review", or "pr-hero skipped the review" on a status an older action wrote): comment `/crysk review`, then run step 0 with `--wait`;
176
+ - the review is "partial again" with the same hunters failing: fix the failing hunter's route
177
+ (model or credential), or ask a maintainer to override;
178
+ - every blocking finding is already answered but none can clear without a fix (a dismissal the
179
+ CI adjudicator rejected, a `deferred` / `misclassified` tag, or a `dismissed` finding with no
180
+ review thread, which no adjudicator can rule on): if the adjudicator's rejection exposed a real defect you missed, fix, commit, and `git push` (then step 0 `--wait`); if the finding is `deferred`, `misclassified`, or still contrived/absurd ("Stopping diminishing returns" above), **do not edit code to appease it** — exit the loop and tell the maintainer the PR is ready for `/crysk override` and merge;
181
+ - the red gate names no live blocking finding on this head (the `reason` quotes the gate
182
+ description): read that description and act on what it says; when it names nothing you can
183
+ fix, ask a maintainer.
184
+ - `done`: nothing is owed on this head. The gate passed (or an override unlocked it) and every
185
+ finding posted on this head has a reply. Before exiting, check whether `report.head && report.head !== head` (a green status carried over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`): if `git diff <report.head>..<head>` contains non-trivial logic or risky changes ("Requesting or suggesting another review" above), recommend `/crysk review` naming those changes; otherwise exit the loop and report that the PR is ready to merge.
186
+
187
+ **Bound the forced runs.** `/crysk review` and `/crysk recheck` each run a full paid review
188
+ that bypasses the size, budget and admission gates (`ci_max_attempts` included), and a gate
189
+ `error` (expired token, missing credential, crash) makes step 0 say `review` again forever.
190
+ Before posting either, count the ones already on this head, never from memory: the comments in
191
+ `gh pr view <n> --json comments` whose body is exactly `/crysk review`, `/crysk recheck`,
192
+ or their legacy spellings `/pr-hero review` and `/pr-hero recheck` (both still start a run), and whose `createdAt` is at or after the oldest `crysk` or `pr-hero` status on the head
193
+ (`gh api "repos/{owner}/{repo}/commits/<head>/statuses?per_page=100" --jq '[.[] | select(.context == "crysk" or .context == "pr-hero")] | last.created_at'`;
194
+ no status yet means none counted). Each reason step 0 gives gets its command once per head:
195
+ one `/crysk review` each for a skipped head, a partial review, a used-up budget, a gate
196
+ `error`, and an `upheld` dismissal; one `/crysk recheck` per pending dismissal, plus one retry
197
+ when that run leaves no ruling or an `inconclusive` one. When the same reason comes back after
198
+ its command already ran (a second `error` with the same description, a second partial, a second
199
+ recheck with no ruling or `inconclusive` again), stop and hand it to a human. The hard ceiling
200
+ is six per head; reaching it goes to a human too.
201
+
202
+ `findings[]` lists each posted finding with its `id`, `path`, `line`, `head`, `live_on_head`, and
203
+ its newest `triage` (`null` when none), and `ci_verdict`. `comment_id` can be null: a live row of
204
+ the summary's state block that no comment carries (summary-only, or never posted inline). Its
205
+ `head` is null too, and it has no thread to reply in: the CI adjudicator's ruling on that newest
206
+ reply on this head (`upheld`, `rejected`, `inconclusive`, or `null`). `triage` is only the newest reply, so a finding can be
207
+ answered at its own head and then re-answered at a later head. The thread (step 2 below) settles
208
+ the per-head question, and the escalation count still reads the thread's prior markers.
209
+
210
+ For EVERY `<!-- crysk-finding ` comment on this PR that has not already been triaged for the
211
+ current head:
212
+
213
+ 1. **Read the finding.** Fetch the comment body (the marker plus Crysk's claim/severity/tier
214
+ text) and its GitHub comment id. New posts put that marker on an **inline review
215
+ comment**. A leftover top-level issue comment with the same marker may still exist on
216
+ an old PR (pre-W2); the driver still binds those by marker. A finding that appears
217
+ only under `Comments Outside Diff` in the summary is not in this list — skip it.
218
+ 2. **Read the marker's `head=`.** This IS the budget unit — see "One adjudication per finding per
219
+ HEAD" below. If a triage reply already exists in this thread carrying the SAME head, skip it:
220
+ it is already answered for this code.
221
+ 3. **Judge the finding against the repository, then pick exactly one tag**: `applied`,
222
+ `dismissed`, `deferred`, or `misclassified` (table below). The comment is a claim, not a
223
+ task. You may reject it. Before touching code, replying, or applying fixes, evaluate whether the cluster of findings indicates a flawed integration or broken design (### C) rather than isolated defects — if so, halt the loop and report the diagnosis without posting replies or patching. When you confirm the defect is real, isolated, and in scope (`applied`), make the fix in the working tree now (and run the relevant tests), before posting the `applied` reply; **do not `git push` until you have replied to every finding on this head** (step 6).
224
+ 4. **For `dismissed`, `deferred`, and `misclassified`**: spawn the isolated adjudicator (see
225
+ "The adjudicator spawn" below) and include its verdict in your reply. `applied` never spawns
226
+ one.
227
+ 5. **Reply through the driver**, not with `gh`. Write reasoning prose to a
228
+ file and run:
229
+
230
+ ```bash
231
+ npx -y crysk triage reply --pr <n> --from <run-dir> --finding F00N \
232
+ --tag <tag> --body-file <reasoning.md> [--verdict <v>] [--issue <n>]
233
+ ```
234
+
235
+ The driver resolves the parent from the posted `<!-- crysk-finding`
236
+ marker (never a comment id, never the nearest line), prepends the triage
237
+ marker and the visible badge, posts the reply, records the triage event
238
+ transactionally in the canonical product store (`finding_triage` table in
239
+ `~/.crysk/prhero.db`), and — when the parent is an inline review
240
+ comment — resolves that review thread. If the driver says no posted marker
241
+ matches this `F00N`, the finding lives in the summary bucket (or was
242
+ never posted): stop. Do not fall back to `gh`. `applied` takes no
243
+ `--verdict`. `dismissed` / `deferred` / `misclassified` require
244
+ `--verdict` from the adjudicator. `--issue` is optional and only valid
245
+ with `--tag deferred`.
246
+ 6. **Advance the loop in one batch once all findings on this head are answered:**
247
+ - **If you made clean code fixes (`applied` or unthreaded blocking fixes):** if you decided this push needs no further review ("Stopping diminishing returns", rule 4), post `/crysk stop` before pushing, and after the push do **not** wait for a re-review: none will run. Report that the fixes are pushed and the PR is ready for `/crysk override` and merge (a carried green gate needs no override). Otherwise, commit and `git push` all fixes in a single push, then immediately run `npx -y crysk status --pr <n> --wait --json` to subscribe to the re-review on the new head. Do **not** run `/crysk recheck` before pushing: a new push invalidates prior-head recheck rulings and wastes a CI run.
248
+ - **If no code changes were needed:** run `npx -y crysk status --pr <n> --wait --json` and execute its `next_action` (`recheck` when blocking findings were `dismissed`, or `done` when the gate is already green).
249
+
250
+ *(Note: The MCP server is strictly read-only for querying runs, findings, and
251
+ past triage records via `crysk_get_triage` and `crysk_get_findings`. All
252
+ mutations — posting comments, resolving threads, and updating the database —
253
+ must be performed via `npx -y crysk triage reply`.)*
254
+
255
+ **Greptile re-review:** Greptile updates its existing PR comment in place —
256
+ it does not post a second one. Do not wait for a new Greptile comment to
257
+ appear; poll for a body change on the existing one.
258
+
259
+ ## Closing a dismissal: `/crysk recheck`
260
+
261
+ Your local adjudicator (step 4) is a check on yourself before you post: its verdict goes in your
262
+ reply's marker, and the gate ignores it, because you ran it. The gate trusts only the CI
263
+ adjudicator. When step 0 says `recheck`:
264
+
265
+ 1. Comment `gh pr comment <n> --body "/crysk recheck"`. It runs a review of the head and, for each
266
+ blocking finding whose newest reply is `dismissed` (at most 5 per run), an adjudicator in CI that
267
+ reads your argument and the repository at that head. You may comment it yourself: you only supply
268
+ the argument, the CI adjudicator rules. (`/crysk override` is the opposite: never yours to post.)
269
+ 2. Wait with `npx -y crysk status --pr <n> --wait --json` until the run settles. Each ruling is a reply on the finding's thread,
270
+ from `github-actions[bot]`, whose first line is
271
+ `<!-- crysk-adjudication verdict=<v> reply=<your reply's id> head=<sha> -->`. Step 0's
272
+ `ci_verdict` reads it for you.
273
+ 3. Act on the verdict:
274
+ - `upheld`: the dismissal stands. The recheck run itself does not change its own count; step 0
275
+ now says `review`. Comment `/crysk review`, then run `npx -y crysk status --pr <n> --wait --json`, and that review no longer counts the finding.
276
+ - `rejected`: the finding stands. Re-read the adjudicator's evidence. Fix it, or, if you still hold
277
+ it is wrong, ask a human (they may override). Do not re-post the same argument.
278
+ - `inconclusive`: the repository did not settle it either way. On the same head you cannot post
279
+ a stronger argument: the driver skips any second triage reply at a head that already has one
280
+ (`skip post: … already triaged at this head`), and the next recheck re-adjudicates your
281
+ original reply. Recheck once more; a second `inconclusive` on this head goes to a human. A
282
+ stronger argument needs a new head: after a push, reply `dismissed` again with the new
283
+ evidence, then recheck.
284
+ - No ruling at all after the run: the adjudicator step failed. Nothing was posted and the
285
+ dismissal is still pending; recheck once more. A second recheck with no ruling goes to a
286
+ human (see "Bound the forced runs" in step 0).
287
+ 4. A ruling counts only on the head it was given. After any push, step 0 asks for a recheck again.
288
+
289
+ Only an inline finding can be rechecked: the CI adjudicator answers on the finding's own review
290
+ thread. A legacy top-level finding (no review thread) cannot be cleared by a dismissal; step 0 says
291
+ `override-or-fix` for it.
292
+
293
+ ## The four tags
294
+
295
+ | tag | what it claims | what it must supply |
296
+ |---|---|---|
297
+ | `applied` | Fixed in this PR. | Nothing else — the re-review verifies it independently, so it pays no adjudicator. |
298
+ | `dismissed` | The finding is wrong. | POSITIVE DISPROOF WITH CITED CODE. "I did it on purpose" is not evidence; "this line already covers it, here" is. |
299
+ | `deferred` | The finding is right, but fixing it is out of this PR's scope. | Reasoning that says why, and what you are doing instead. A GitHub issue number is optional (`--issue`) — do not invent a tracking issue just to satisfy the tag. |
300
+ | `misclassified` | The finding is real, but Crysk typed it wrong (severity, tier, or `causal_disposition`). | Name which field is wrong and why. This is the highest-value signal the loop produces — it points at a hunter/refuter defect, not a repository one. |
301
+
302
+ Pick exactly one. There is no preferred tag. If you are tempted to pick two, the finding is
303
+ `misclassified` (the label is wrong) rather than `dismissed` (the claim is wrong) — do not
304
+ split the difference.
305
+
306
+ ### `applied`
307
+
308
+ Only after you independently confirmed the defect in the repository and fixed it in this PR.
309
+ Then reply. Do not restate the diff; a one-line pointer (commit sha or file) is enough. No
310
+ adjudicator. If you have not confirmed it, this is the wrong tag.
311
+
312
+ ### `dismissed`
313
+
314
+ You are claiming Crysk is wrong. Cite the exact line(s) that already handle the case, or the
315
+ exact reason the claimed defect cannot occur. Then spawn the adjudicator — its burden of proof
316
+ rule is the same one you must meet, and it is the disinterested check on your own claim.
317
+
318
+ ### `deferred`
319
+
320
+ Reply with why this is out of scope and what you are doing instead. If you
321
+ already have a tracking issue, pass `--issue <n>`; if you do not, omit it.
322
+ Do not create a GitHub issue just to fill the marker — some agents run on
323
+ providers that are not GitHub, and the coding agent decides whether an issue
324
+ belongs anywhere.
325
+
326
+ ### `misclassified`
327
+
328
+ Name the exact field (`severity`, `tier`, or `causal_disposition`) and what it should be instead,
329
+ with the evidence. The finding itself is not wrong — only its classification is.
330
+
331
+ ## The adjudicator spawn — isolation is load-bearing
332
+
333
+ For `dismissed`, `deferred`, and `misclassified`, spawn a FRESH, ISOLATED sub-agent using the
334
+ system prompt in `adjudicator.md` (same directory as this file).
335
+
336
+ **The isolation requirement, stated plainly: the adjudicator receives ONLY**
337
+
338
+ - the finding (claim, path, line, severity/tier as Crysk posted it),
339
+ - your argument (the case you are about to reply with), and
340
+ - read-only access to the repository at this PR's head.
341
+
342
+ **It must NEVER receive your own reasoning context** — not your conversation history, not your
343
+ scratch notes, not "why I believe this". Its entire value is having nothing to defend. An
344
+ adjudicator that inherited your context would simply agree with itself.
345
+
346
+ The adjudicator returns exactly one of `upheld`, `rejected`, or `inconclusive` — see
347
+ `adjudicator.md` for what each means and the burden-of-proof rule behind them. Pass that
348
+ exact word as `--verdict` on `npx -y crysk triage reply` (and mention it in the reasoning
349
+ prose). The driver writes it on the marker; the escalation rule reads it back from there.
350
+
351
+ ## One adjudication per finding per HEAD
352
+
353
+ This needs no new state. The finding's own marker already carries `head=<sha>`, so the bound is
354
+ read directly off the posted comments — do not invent a separate tracking file or counter.
355
+
356
+ - Same head, already triaged → skip. Nothing changed, nothing to re-judge.
357
+ - Head changed AND the new commits touched this finding's lines → re-triage is legitimate; this is
358
+ the one case that pays for another adjudicator run.
359
+ - Head changed but did NOT touch those lines → the prior verdict stands; do not re-triage.
360
+
361
+ ## The escalation stops
362
+
363
+ Escalate to a human and stop the loop only when one of these hard triggers fires:
364
+ - **Flawed integration or design (### C):** Whack-a-mole findings on the same seam across review rounds, or broken foundational assumptions. Stop patching, do not push tactical band-aids, and report the architectural diagnosis and refactor plan to the human. If a `/crysk stop` was posted to pause reviews during refactoring, comment `/crysk review` once the clean redesign lands to lift the stop; otherwise let CI review the pushed redesign normally.
365
+ - **Inconclusive adjudication after 2 consecutive heads:** After **2 consecutive heads** land at `inconclusive` for the same finding, STOP triaging it and
366
+ say so in the reply: it escalates to a human. Do not spawn a third adjudicator round hoping for a
367
+ different answer — if two different heads with real code changes between them did not settle it,
368
+ a third will not, and by then the thread carries enough material for a person to rule in a minute.
369
+
370
+ **The count is read off the finding's PRIOR triage markers, not remembered or estimated.** Fetch
371
+ this finding's own reply thread, parse every `<!-- crysk-triage ` marker already posted in it in
372
+ order, and read their `verdict=` fields — the same field this round's reply will also carry. If
373
+ the most recent one is `verdict=inconclusive` AND the one before it is also `verdict=inconclusive`
374
+ (two markers, both `inconclusive`, both belonging to a head change that legitimately re-triaged —
375
+ see "One adjudication per finding per HEAD" above), this round is the escalation, not a third
376
+ adjudicator spawn. This is what makes the rule checkable: the markers ARE the state, there is
377
+ nothing else to consult.
378
+
379
+ ## What you write vs what the driver posts
380
+
381
+ `--body-file` is **reasoning prose only**. Do not put a `<!-- crysk-triage` marker or a
382
+ badge line in that file — the driver prepends both, picks the parent comment from the posted
383
+ `<!-- crysk-finding` marker, records the decision to the canonical store (`finding_triage`
384
+ table), and resolves the inline review thread when there is one.
385
+ Passing a GitHub comment id, or posting with `gh api … in_reply_to`, is how replies landed
386
+ under Greptile on Musive #1724. Do not do that. Do not reply on
387
+ `<!-- crysk-report -->` either: that is the summary, including Outside Diff.
388
+
389
+ `--from` is the Crysk run directory that produced these findings (`findings.json`). `--finding`
390
+ is the finding id (`F001`, …) from that file — never a comment id.
391
+
392
+ **When the review ran in CI, that directory is not on your machine.** A GitHub Actions review
393
+ writes it to `~/.crysk/repos/<host>/<owner>/<repo>/runs/pr-<n>-<sha>-1` on an ephemeral runner
394
+ that is destroyed when the job ends. The workflow uploads it as an artifact; download it before
395
+ you triage:
396
+
397
+ ```bash
398
+ # The artifact is crysk-run-<pr>-<head-sha>; a run of an action release from before the rename
399
+ # uploaded pr-hero-run-<pr>-<head-sha>. Try the new name first, then the old one.
400
+ # Each line printed is "<run-id> <artifact-name>": download with the name on the same line.
401
+ for NAME in crysk-run-<pr>-<head-sha> pr-hero-run-<pr>-<head-sha>; do
402
+ gh api "repos/{owner}/{repo}/actions/artifacts?name=$NAME" \
403
+ --jq '[.artifacts[] | select(.expired | not)] | sort_by(.created_at) | reverse | .[] | "\(.workflow_run.id) \(.name)"'
404
+ done
405
+ gh run download <run-id> -n <artifact-name> -D "crysk-run-<run-id>"
406
+ ```
407
+
408
+ Look the run up by artifact name, not with `gh run list --branch`: a `/crysk review` or
409
+ `/crysk recheck` run is an `issue_comment` event, which GitHub files under the default branch, so
410
+ a branch listing never shows it, and that run usually holds the findings. Several runs can upload
411
+ the same name for one head (the automatic review, then a forced review or recheck; `overwrite: true`
412
+ in `action.yml` only dedupes within one run). Try the candidates newest first and keep the first one
413
+ `npx -y crysk triage reply ... --dry-run` binds (its success line starts with `plan: reply to`; do not match on "marker match", which the "no posted … marker matches" error also contains). Download each candidate
414
+ into its own fresh directory, as above: reusing one directory mixes `findings.json` from one run
415
+ with the patches of another, and the bind then judges files no single run wrote.
416
+
417
+ Then pass `--from crysk-run-<run-id>` for the candidate that bound. `gh run download` unpacks the run directory's *contents*, so the
418
+ `--from` target is the directory you downloaded into — not a `pr-<n>-<sha>-1` path inside it. If
419
+ the artifact is missing (a size- or budget-gated review writes no run directory, and so does a
420
+ run where every hunter died), you have no `--from` input: say so and stop rather than inventing
421
+ one. Full detail: `docs/github-actions.md` → "Triaging a CI review".
422
+
423
+ The posted body looks like this (driver-owned; shown so you know what a human will see):
424
+
425
+ ### `applied`
426
+
427
+ ```
428
+ <!-- crysk-triage tag=applied head=e3ab386a63020c6f5c21d814d176ff33849eef8d actor=agent -->
429
+
430
+ ✅ **APPLIED** · agent
431
+
432
+ Fixed in this PR — see 3f9a2c1: `parseConfig` now validates `retries` before use.
433
+ ```
434
+
435
+ `--body-file` for that reply is only the last paragraph.
436
+
437
+ ### `dismissed` (needs `--verdict`)
438
+
439
+ ```
440
+ <!-- crysk-triage tag=dismissed head=e3ab386a63020c6f5c21d814d176ff33849eef8d actor=agent verdict=upheld -->
441
+
442
+ ❌ **DISMISSED** · agent · adjudicator: upheld
443
+
444
+ The finding claims `parseConfig` can throw when `raw.retries` is undefined. It cannot:
445
+ `config.ts:42` already guards it — `const retries = raw.retries ?? 3;` — and that line predates
446
+ this PR. The isolated adjudicator confirmed the citation independently and returned `upheld`.
447
+ ```
448
+
449
+ ### `deferred` (needs `--verdict`; `--issue` optional)
450
+
451
+ ```
452
+ <!-- crysk-triage tag=deferred head=e3ab386a63020c6f5c21d814d176ff33849eef8d actor=agent verdict=upheld -->
453
+
454
+ 📋 **DEFERRED** · agent · adjudicator: upheld
455
+
456
+ The finding is correct — `retryQueue.ts` has no backoff cap — but fixing it means redesigning the
457
+ retry policy, which is out of scope for this PR.
458
+ ```
459
+
460
+ ### `misclassified` (needs `--verdict`)
461
+
462
+ ```
463
+ <!-- crysk-triage tag=misclassified head=e3ab386a63020c6f5c21d814d176ff33849eef8d actor=agent verdict=upheld -->
464
+
465
+ 🏷️ **MISCLASSIFIED** · agent · adjudicator: upheld
466
+
467
+ The defect is real, but `causal_disposition` is wrong: this is filed `introduced` and it is
468
+ pre-existing — `ghPrList` (watch.ts:243) has carried this exact unbounded `gh` hang since before
469
+ this PR. The engine typed it wrong, not the code.
470
+ ```
471
+
472
+ ## Rules
473
+
474
+ - You own the judgment. A Crysk finding is a claim to verify, never an order. `applied` is
475
+ not the default tag.
476
+ - One tag per finding, no exceptions.
477
+ - `dismissed`, `deferred`, `misclassified` all require a spawned, isolated adjudicator; `applied`
478
+ never does.
479
+ - The adjudicator never sees your reasoning context — only the finding, your argument, and the
480
+ repo.
481
+ - Never call `gh` to post or resolve a triage reply. Run `npx -y crysk triage reply`. (Commenting
482
+ `/crysk recheck` or `/crysk review` with `gh pr comment` is not a triage reply, and is how you ask for them.)
483
+ If that command posted the reply and then failed to resolve, re-run the
484
+ **same** command — same-head skip retries resolve only. Do not `gh`.
485
+ - Never triage a finding that only exists under `### Comments Outside Diff` in the
486
+ summary. It has no thread this slice (W2). If `npx -y crysk triage reply` reports no
487
+ matching marker, stop.
488
+ - `dismissed`, `deferred`, and `misclassified` without `--verdict` are malformed. `applied` WITH
489
+ `--verdict` is equally malformed.
490
+ - Never re-triage a finding whose head is unchanged since its last triage on this PR (the driver
491
+ skips a same-head re-post).
492
+ - Never post `/crysk review` or `/crysk recheck` past the bound in step 0: count the ones already
493
+ on the head (never from memory), six at most, and hand a repeated failure to a human sooner.
494
+ - After 2 consecutive `inconclusive` heads — read off the finding's own prior triage markers, not
495
+ memory — stop and hand the finding to a human.
496
+ - If whack-a-mole findings or broken foundational assumptions indicate a flawed integration or architecture (### C), stop patching and report to the user instead of stacking band-aids.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: crysk-pr
3
+ description: "Open or update a GitHub pull request with a structured title and reviewer-focused description, then automatically subscribe to the Crysk review via `crysk status --pr <n> --wait --json` and hand off to `crysk-loop` if findings are reported. Trigger: open a PR, create a PR, gh pr create, submit PR, push branch and open PR, ship PR, crear PR, abrir PR."
4
+ license: Apache-2.0
5
+ metadata:
6
+ author: juanmaagd
7
+ version: "1.0"
8
+ ---
9
+
10
+ ## When to Use
11
+
12
+ Load this skill whenever the user asks to open, create, submit, or update a pull request (or push a branch and open a PR).
13
+
14
+ ## Step 1: Branch, Pre-Push Checks & Repo Conventions
15
+
16
+ 1. **Protect integration branches:** Never commit or push directly to the default branch, or to the integration branch the repository declares (for example `dev` in a repo whose rules say so). If currently on one, create a focused branch first (`feat/<slug>`, `fix/<slug>`, `chore/<slug>`, `refactor/<slug>`).
17
+ 2. **Resolve target base branch:**
18
+ - Check `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, or an active project PR skill (such as `branch-pr` or `gh-stack`) for the required target branch (e.g. `dev` vs `main`).
19
+ - If the repo defines no rule, inspect whether an active `dev` integration branch exists or fall back to `gh repo view --json defaultBranchRef --jq .defaultBranchRef.name`.
20
+ 3. **Run local gates before pushing:** Run the project's fast verification commands (tests, typecheck, linter) before pushing the branch (`git push -u origin HEAD`).
21
+
22
+ ## Step 2: PR Title & Description (Repo Template or Built-in Fallback)
23
+
24
+ 1. **Check repo rules first:**
25
+ - If the repository has `.github/pull_request_template.md`, `.github/PULL_REQUEST_TEMPLATE/`, or instructions in `AGENTS.md` / `CONTRIBUTING.md` / an active PR skill, follow that structure.
26
+ 2. **Fallback template (when the repository has no PR template or rules):**
27
+ - Never rely on a bare `gh pr create --fill` dump.
28
+ - **Title:** Conventional Commit format (`<type>(<scope>): <imperative summary>`, max 72 chars), stating *what* changed clearly.
29
+ - **Body:** Pass via `--body-file` (or a quoted heredoc) using this structure:
30
+
31
+ ```markdown
32
+ ## Summary
33
+ - **What & Why:** 1–3 concise bullets explaining the problem solved or capability added and why it was needed.
34
+
35
+ ## Key Changes
36
+ - `<path/or/module>` — what changed and any non-obvious design or tradeoff decision.
37
+
38
+ ## Verification
39
+ - Exact local commands executed (`test`, `typecheck`, `lint`) and their results.
40
+
41
+ ## Related Issues
42
+ - `Closes #<id>` / `Refs #<id>` (or `None`).
43
+ ```
44
+
45
+ - Attribution lines (`Co-Authored-By`, generated-by footers) follow the repository's rules and the user's own instructions; this skill adds none and removes none.
46
+
47
+ 3. **Create (or locate) the PR:**
48
+ - Run `gh pr create --base <base> --title "<title>" --body-file <file>` (or `gh pr view --json number,url` if a PR for the current branch is already open and you just pushed new commits).
49
+ - Capture the pull request number `<n>`.
50
+
51
+ ## Step 3: Auto-Subscribe to `crysk` & Enter the Triage Loop (No Human Friction)
52
+
53
+ Check whether the repository uses Crysk (e.g., `.github/workflows/crysk.yml` (`pr-hero.yml` before the rename) or `.crysk/` (`.prhero/` before the rename) exists in the repo, or `crysk` (`pr-hero` before the rename) status checks run on PRs). If not, report the PR URL and stop.
54
+
55
+ When `crysk` is active on the repository, **never stop right after `gh pr create`**. Immediately continue in the same turn:
56
+
57
+ 1. **Subscribe to the initial review from second zero:**
58
+ ```bash
59
+ npx -y crysk status --pr <n> --wait --json
60
+ ```
61
+ `--wait` holds automatically during the 3-minute startup grace window while `gate.state` is `"none"` (waiting for GitHub Actions to pick up the new PR), continues polling every 15s while `gate.state` is `"pending"`, and returns as soon as the review settles.
62
+
63
+ 2. **Route on `next_action`:**
64
+ - **`next_action === "done"`:** Check whether `report.head` is non-null and `report.head !== head` (a green status carried forward over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`). If so and `git diff <report.head>..<head>` contains non-trivial logic or risky changes, explicitly recommend running `/crysk review` to the user naming those changes. Otherwise, the review passed the gate with zero untriaged findings: report the PR URL and clean review summary to the user.
65
+ - **`next_action !== "done"` (`"triage"`, `"fix"`, `"recheck"`, `"review"`, `"override-or-fix"`):**
66
+ Immediately load the `crysk-loop` skill (`skills/crysk-loop/SKILL.md`) and run its autonomous loop (`while (next_action !== "done")`) to judge findings, reply, push verified fixes, and wait for re-review until the PR is ready to merge.