@greenrenge/skills 0.2.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.
package/catalog.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "orchestration": {
22
22
  "order": 4,
23
23
  "title": "Orchestration & Ticket Delivery",
24
- "tagline": "Spec-to-tickets scheme (with mattpocock/skills), T3 ticket orchestration, handoffs, and security remediation.",
24
+ "tagline": "Spec-to-tickets scheme (with mattpocock/skills), harness-agnostic & T3 ticket orchestration, handoffs, and security remediation.",
25
25
  "optIn": false
26
26
  },
27
27
  "web-ui": {
@@ -71,8 +71,9 @@
71
71
  },
72
72
  "orchestration": {
73
73
  "category": "orchestration",
74
- "description": "Full ticket delivery & T3 orchestration suite (t3-ticket-orchestrator, ticket-scheme + mattpocock/skills, t3-thread-bridge, t3-successor-handoff, security-remediation-epic).",
74
+ "description": "Full ticket delivery & orchestration suite (ticket-orchestrator, t3-ticket-orchestrator, ticket-scheme + mattpocock/skills, t3-thread-bridge, t3-successor-handoff, security-remediation-epic).",
75
75
  "items": [
76
+ "ticket-orchestrator",
76
77
  "t3-ticket-orchestrator",
77
78
  "ticket-scheme",
78
79
  "to-spec",
@@ -133,6 +134,42 @@
133
134
  ]
134
135
  }
135
136
  },
137
+ "recipes": {
138
+ "security-cron": {
139
+ "title": "Scheduled Security Remediation",
140
+ "description": "Harness-agnostic dependency-vulnerability remediation prompt + overlapping security & orchestration skills + scheduler wiring (T3, Claude Code, OS cron/systemd/launchd, GitHub Actions, or prompt-only).",
141
+ "baseSkills": [
142
+ "security-remediation-epic",
143
+ "ticket-orchestrator",
144
+ "ticket-scheme"
145
+ ],
146
+ "overlays": {
147
+ "t3": [
148
+ "t3-ticket-orchestrator",
149
+ "t3-thread-bridge",
150
+ "t3-successor-handoff"
151
+ ],
152
+ "ocr": [
153
+ "open-code-review",
154
+ "open-code-review-rules"
155
+ ]
156
+ },
157
+ "schedules": [
158
+ "t3",
159
+ "claude-code",
160
+ "os-cron",
161
+ "github-actions",
162
+ "prompt-only"
163
+ ],
164
+ "harnesses": [
165
+ "t3",
166
+ "claude",
167
+ "codex",
168
+ "opencode",
169
+ "generic"
170
+ ]
171
+ }
172
+ },
136
173
  "skills": {
137
174
  "skill-maintainer": {
138
175
  "kind": "bundled",
@@ -288,6 +325,29 @@
288
325
  "harness": "t3-code"
289
326
  }
290
327
  },
328
+ "ticket-orchestrator": {
329
+ "kind": "bundled",
330
+ "category": "orchestration",
331
+ "description": "Harness-agnostic ticket-queue orchestrator (T3 Code parity, Claude Code worktree Agent, Codex, OpenCode, or CLI).",
332
+ "dependsOn": [
333
+ "ticket-scheme"
334
+ ],
335
+ "optionalSkills": [
336
+ "t3-ticket-orchestrator",
337
+ "t3-thread-bridge",
338
+ "t3-successor-handoff",
339
+ "pr-lens",
340
+ "diagram-router",
341
+ "open-code-review"
342
+ ],
343
+ "requires": {
344
+ "tools": [
345
+ "git",
346
+ "gh"
347
+ ],
348
+ "runContract": true
349
+ }
350
+ },
291
351
  "t3-ticket-orchestrator": {
292
352
  "kind": "bundled",
293
353
  "category": "orchestration",
@@ -316,6 +376,7 @@
316
376
  "category": "orchestration",
317
377
  "description": "Five-phase dependency-vulnerability remediation run (discover, exposure, matrix, fix, verify).",
318
378
  "optionalSkills": [
379
+ "ticket-orchestrator",
319
380
  "t3-ticket-orchestrator"
320
381
  ],
321
382
  "requires": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greenrenge/skills",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Curated portable agent skills, categorized bundles, and onboarding CLI wrapped around skillfold (Claude Code, Codex, OpenCode, Cursor, Gemini).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "node": ">=20"
10
10
  },
11
11
  "bin": {
12
- "greenrenge-skills": "./bin/cli.mjs"
12
+ "greenrenge-skills": "bin/cli.mjs"
13
13
  },
14
14
  "files": [
15
15
  "bin",
@@ -44,9 +44,10 @@
44
44
  "ticket-scheme": "./skills/ticket-scheme",
45
45
  "t3-thread-bridge": "./skills/t3-thread-bridge",
46
46
  "t3-successor-handoff": "./skills/t3-successor-handoff",
47
+ "ticket-orchestrator": "./skills/ticket-orchestrator",
47
48
  "t3-ticket-orchestrator": "./skills/t3-ticket-orchestrator",
48
49
  "security-remediation-epic": "./skills/security-remediation-epic",
49
50
  "frontend-design": "./skills/frontend-design"
50
51
  },
51
- "greenrengeContentDigest": "b55971c8c94c42cee15d274d6535b2b29c562bbd3d0d1ab412e3e2feea29f822"
52
+ "greenrengeContentDigest": "39b5fd5d1a13fd1a42de5bbd11e8603bf6a776023f00079ab70edeab4e67d670"
52
53
  }
@@ -1,33 +1,100 @@
1
- # Scheduling prompt — security remediation epic
1
+ # Scheduling prompt — security remediation epic (harness-agnostic)
2
2
 
3
- Paste into T3 Code scheduling, filling `{owner}/{repo}`. The host skill
4
- `security-remediation-epic` owns the method; this prompt carries the repo-specific
5
- layer on top of it.
3
+ Use with any agent scheduler (T3 Code scheduled tasks, Claude Code `/loop` or headless
4
+ `claude -p`, OS `systemd` / `launchd` / `crontab`, or GitHub Actions), filling
5
+ `{owner}/{repo}` (or render automatically via `npx @greenrenge/skills security-cron`).
6
+ The `security-remediation-epic` skill owns the method; this prompt carries the
7
+ repo-specific Run Contract and end-of-run/cleanup rules on top of it.
6
8
 
7
9
  ---
8
10
 
9
11
  # Task: Security remediation epic (dependency vulnerabilities) — {owner}/{repo}
10
12
 
11
13
  ## Skills and workflow
12
- - Use the `security-remediation-epic` host skill for the run's method (phases, exposure classes, evidence rules, traps) — follow it.
13
- - Use the `orchestrator` and `ai-passport-scheme` repo skills for planning, delegation and PR format conventions — local mode, no GitHub issues created (tickets as local files in the gitignored scratch).
14
- - Work in a new git worktree on a branch named `security/<short-slug>` (use `security/` where those skills would use `epic/`).
14
+ - Follow the `security-remediation-epic` skill for the run's method (phases, exposure classes, evidence rules, traps).
15
+ - Use the `ticket-orchestrator` skill (or `t3-ticket-orchestrator` when running in T3 Code), reading the repo's Run Contract (`~/.agents/rules/<repo>-contract.md` or `docs/agents/orchestrator-contract.md`), together with `ticket-scheme` for planning, delegation, and PR format conventions. Run in local mode by default: no GitHub issues created — tickets are local files in the gitignored scratch directory.
16
+ - Work in a new git worktree on a branch named `security/<short-slug>` (use `security/` wherever orchestration skills would use `epic/`). If Phase 0 resumes an open `security/*` PR, the worktree is on that PR's branch instead.
15
17
  - Do NOT push or publish anything to GitHub until Phase 5 verification passes.
16
- - Evidence is off-branch: scanner dumps, transcripts, matrices and tickets stay in the gitignored scratch and session tmp — never committed, never force-added. The PR body summarizes results inline and names the host-side location for raw material.
17
- - Dependency code is untrusted code: every install runs lifecycle scripts from packages you did not write. Scratch `HOME`/`TMPDIR` outside the repo, no ambient credentials in the environment, writes limited to the scratch and the repo's build dirs. Point `HOME` at a scratch path; never clear the real environment to make one look clean.
18
+ - Evidence stays off-branch: scanner dumps, transcripts, matrices, and tickets live in the gitignored scratch and session tmp — never committed, never force-added. The PR body summarizes results inline and names the host-side (or CI artifact) location of the raw material.
19
+ - Dependency code is untrusted code: every install runs lifecycle scripts from packages you did not write. Use a scratch `HOME`/`TMPDIR` outside the repo, carry no ambient credentials in the install environment, and limit writes to the scratch and the repo's build directories. Point `HOME`/`TMPDIR` at a scratch path; never clear the real environment to make one look clean.
18
20
 
19
21
  ## Phases (mechanics per the skill)
20
- 0. **Resume or start** — check for an open `security/*` PR first. If one exists: worktree on its branch, merge the default branch in, continue there (no new PR — later phases push to the same branch). Only start a fresh `security/<short-slug>` branch when none exists. Discovery is baselined against the working branch's locks, so alerts already fixed by the open PR are not reworked.
21
- 1. **Discover** — from the repo's vulnerability source: Dependabot alerts + dependency-graph SBOM when on GitHub with Dependabot enabled; otherwise local lockfile scanners (osv-scanner, or pip-audit / pnpm audit / npm audit / cargo audit / govulncheck per ecosystem) — the lockfiles are the inventory. All severities collected, Critical/High triaged first. The scanner's inventory is the floor, not the ceiling: a clean scan means "no known advisory matches", never "no known vulnerable package".
22
- 2. **Exposure analysis per alert** — direct/transitive + parent chain, runtime/build/dev scope, call-site reachability, attacker-controlled input paths; verdict (Exploitable / Conditionally exploitable / Not reachable / **Undetermined**) with file:line justification. Include the client–image skew check. **Every *Not reachable* verdict is handed to a fresh reader whose only job is to disprove it** — it re-reads the cited lines itself and is not given the first reader's conclusion as a premise; a failed disproof is recorded as the verdict's justification, a successful one re-classifies the alert. Exploitable/Conditionally exploitable verdicts are not re-graded. Undetermined carries no severity, is never an acceptance, and is listed as an open item with its missing fact. Bound the phase: count alerts, work Critical→High→Medium→Low, stop at the bound, and record every alert not analysed as a named gap.
23
- 3. **Risk assessment** — severity × exposure matrix over the **decided** alerts; action per alert. Policy: every alert rated Medium or higher after exposure analysis MUST be fixed; anything accepted below that line needs written justification. Undetermined alerts sit beside the matrix as open, unresolved, unaccepted — never folded into "below the line".
24
- 4. **Fix, evidence-based only** — before/after scanner output plus regression proof (repo verify line green; the same inputs through old and new stack give the same answers; the app boots and affected flows behave as before). No self-reported success. Blockers are surfaced, never hidden. **A scoped override is a refusal**: name who legitimately uses the refused version range (other packages in the subtree, workspace members pinning it directly, plugins and extra groups sharing the lockfile) and why the refusal is acceptable for each, before recommending it.
25
- 5. **Final verification (orchestrator)** — independently re-run from scratch: fresh install from the new locks (isolated per the ground rule above), full build, tests, app startup, re-scan. The scan is clean when it reports no alert the fix set was supposed to close — accepted and Undetermined alerts are expected to still appear, and naming them is the point. Only after this passes, push — to the resumed PR's branch when continuing (no new PR, incremental note in its body), or branch + PR when the run started fresh.
26
- 6. **End of run — no human waits** — per the skill's end-of-run rule: watch the PR, answer every bot-review round (one batched push per round, verify line green before pushing), and when the round is answered with required checks green, unwatch and **settle the thread** — the human merge decision is not waited on. Blocked states (bot turn budget exhausted, behaviour fork) also settle, with the blocker documented. Never merge or close the PR yourself.
27
-
28
- ## PR body requirements
22
+
23
+ 0. **Resume or start**
24
+ - Check for an open `security/*` PR first (`gh pr list --state open --json headRefName,number,title,createdAt`).
25
+ - If one exists: create a worktree on its branch, merge the default branch in, and continue there. No new PR; later phases push to the same branch.
26
+ - Only when none exists, start a fresh `security/<short-slug>` branch from the default branch.
27
+ - Baseline discovery against the working branch's lockfiles so alerts already fixed by the open PR are not reworked.
28
+
29
+ 1. **Discover**
30
+ - Source: Dependabot alerts + dependency-graph SBOM when on GitHub with Dependabot enabled; otherwise local lockfile scanners (`osv-scanner`, or `pip-audit` / `pnpm audit` / `npm audit` / `cargo audit` / `govulncheck` per ecosystem). The lockfiles are the inventory.
31
+ - Collect all severities; triage Critical/High first.
32
+ - The scanner's inventory is the floor, not the ceiling: a clean scan means "no known advisory matches", never "no known vulnerable package".
33
+
34
+ 2. **Exposure analysis per alert**
35
+ - Direct vs transitive, with parent chain.
36
+ - Runtime / build / dev scope.
37
+ - Call-site reachability and attacker-controlled input paths.
38
+ - Verdict: `Exploitable` / `Conditionally exploitable` / `Not reachable` / `Undetermined`, with `file:line` justification.
39
+ - Include the client–image skew check.
40
+ - **Every *Not reachable* verdict is handed to a fresh reader whose only job is to disprove it** — it re-reads the cited lines itself without taking the first reader's conclusion as a premise; a failed disproof is recorded as the verdict's justification, and a successful disproof re-classifies the alert. `Exploitable` / `Conditionally exploitable` verdicts are not re-graded. `Undetermined` carries no severity, is never an acceptance, and is listed as an open item with its missing fact.
41
+ - Bound the phase: count alerts, work Critical→High→Medium→Low, stop at the bound, and record every alert not analysed as a named gap.
42
+
43
+ 3. **Risk assessment**
44
+ - Build a severity × exposure matrix over the **decided** alerts with an action per alert.
45
+ - Policy: every alert rated **Medium or higher** after exposure analysis MUST be fixed. Anything accepted below that line needs written justification. `Undetermined` alerts sit beside the matrix as open, unresolved, and unaccepted — never folded into "below the line".
46
+ - **Decision gate:** if no alert requires a fix, take the **No-fix path** below instead of continuing to Phase 4.
47
+
48
+ 4. **Fix, evidence-based only**
49
+ - Provide before/after scanner output plus regression proof: repo verify line green; the same inputs through the old and new stack give the same answers; the app boots and affected flows behave as before.
50
+ - No self-reported success. Surface blockers, never hide them.
51
+ - **A scoped override is a refusal**: name who legitimately uses the refused version range (other packages in the subtree, workspace members pinning it directly, plugins and extra groups sharing the lockfile) and why the refusal is acceptable for each before recommending it.
52
+
53
+ 5. **Final verification (orchestrator)**
54
+ - Independently re-run from scratch: fresh install from the new lockfiles (isolated per the untrusted-code ground rule), full build, tests, app startup, re-scan.
55
+ - The scan is clean when it reports no alert the fix set was supposed to close — accepted and `Undetermined` alerts are expected to still appear, and naming them is the point.
56
+ - Only after this passes, push:
57
+ - to the resumed PR's branch when continuing (no new PR, add an incremental note to its body), or
58
+ - branch + PR when the run started fresh.
59
+
60
+ 6. **End of run — no human waits**
61
+ - **T3 Code harness** (`watch_pull_request` / `t3_thread_organize` available): watch the PR and answer every bot-review round (one batched push per round, verify line green before pushing). When the round is answered with required checks green, unwatch and **settle the thread** — never wait on a human merge decision. Blocked states (bot turn budget exhausted, behaviour fork) also settle with the blocker documented.
62
+ - **Non-T3 harness** (Claude Code, Codex, OpenCode, CI / OS cron): verify CI checks (`gh pr checks`), emit the structured final report with PR URL and evidence paths, and exit cleanly without polling or waiting on humans.
63
+ - Never merge or close the PR yourself.
64
+ - Then run the **Cleanup** steps below.
65
+
66
+ ## No-fix path (nothing needs fixing this run)
67
+ Applies when, after Phase 3, any of these holds:
68
+ - discovery found no alerts;
69
+ - every decided alert is below the fix threshold (Medium) after exposure analysis and has a written justification (and no Undetermined alerts require escalation);
70
+ - every Medium+ alert is already fixed by the resumed open PR.
71
+
72
+ Steps:
73
+ 1. **Confirm independently.** Re-scan the working branch's lockfiles from scratch and confirm the result matches the Phase 1–3 conclusion. Do not trust earlier output.
74
+ 2. **Write a short run report** in the gitignored scratch: scanner/version used, date, alert counts by severity, the matrix, any Undetermined/unanalysed gaps, and a one-line justification per accepted alert.
75
+ 3. **Publish nothing new.**
76
+ - No branch push, no new PR, no empty commit.
77
+ - If resuming an open PR, push/comment only if its body needs a brief incremental note ("re-scanned, no further action required"); otherwise leave it untouched.
78
+ - Never merge or close any PR.
79
+ 4. **Conclude cleanly:** in T3 Code, settle the thread (`t3_thread_organize`, action `settle`); in other harnesses, output the final summary: outcome ("no fix required"), counts, any accepted-with-justification or Undetermined items, the PR link if resumed, and the path of the run report. No human response is awaited.
80
+ 5. Run **Cleanup**.
81
+
82
+ ## Cleanup (every end state: no-fix, completed, or blocked)
83
+ - Unwatch any PR watchers (when on T3 Code) and stop any background processes, dev servers, or containers started during the run.
84
+ - Remove the run's worktree (`git worktree remove`, then `git worktree prune`).
85
+ - Delete the local `security/<short-slug>` branch only if it was created this run AND has no commits and no pushed remote. Never delete a branch backing an open PR, and never delete anything holding unpushed commits (if any exist, keep them and mention it in the closing summary).
86
+ - Clear session tmp and build artifacts (`node_modules`, build outputs, caches) created in the worktree.
87
+ - Keep in the gitignored scratch only the evidence worth retaining (run report, matrix, before/after scanner output, transcripts the PR body points to). Delete intermediate scratch such as tickets and temp dumps.
88
+ - Verify that the main checkout is clean (`git status`), the default branch is untouched, and nothing from the scratch is tracked or staged.
89
+ - List what was removed and what was kept (with paths) in the final closing note.
90
+
91
+ ## PR body requirements (when a PR is created or updated)
29
92
  - Summary and the risk matrix.
30
93
  - Table of alerts: fixed / mitigated / accepted, with rationale.
31
- - **Every alert the run did not analyse** (the cost bound's gap) and **every Undetermined alert** (the missing fact and who can settle it), each listed as an open item — neither list is optional and neither is summarised away.
32
- - Flow-by-flow human verification guide — for each changed package or impacted flow: what changed and why it matters; which user-facing or system flow is affected; exact manual steps with expected result; pointer to the automated evidence (inline key numbers; raw transcripts live on the run host).
94
+ - **Every alert the run did not analyse** (the cost bound's gap) and **every `Undetermined` alert** (the missing fact and who can settle it), each listed as an open item — neither list is optional and neither is summarised away.
95
+ - Flow-by-flow human verification guide — for each changed package or impacted flow:
96
+ - what changed and why it matters;
97
+ - which user-facing or system flow is affected;
98
+ - exact manual steps with the expected result;
99
+ - pointer to the automated evidence (inline key numbers; raw transcripts live on the run host or CI artifact).
33
100
  - Rollback notes.
@@ -0,0 +1,349 @@
1
+ ---
2
+ name: ticket-orchestrator
3
+ description: Harness-agnostic orchestrated ticket-queue runner driving tracker tickets (GitHub Issues or local scratch files) through isolated git worktrees — merging each finished ticket locally into a dedicated base/epic branch, pushing after every merge, running orchestrator-side verification and OCR review, and opening one final PR into the target branch. Adapts seamlessly to T3 Code (full parity with t3-ticket-orchestrator via top-level T3 threads, ping-back, ledger, PR watch, and settle), Claude Code (worktree Agent), Codex, OpenCode, or sequential CLI sessions. Use when the user says go on a ticket queue, asks to continue or resume orchestration, or when deciding which ticket launches, blocks, or unblocks next.
4
+ metadata:
5
+ opencode/autoinvoke: true
6
+ ---
7
+
8
+ # Orchestrate a ticket queue (harness-agnostic)
9
+
10
+ The run's shape: **you** are the orchestrator, isolated workers (one per ticket, each in its
11
+ own git worktree) do the implementation, a **base branch** is the one integration line, and
12
+ the **target branch** — what the base was forked from, `main` in a first-generation run — is
13
+ untouchable until the final PR. The tracker (GitHub Issues or local gitignored scratch
14
+ tickets) is the run's state: derive order from the dependency edges and open/closed tickets,
15
+ never from memory.
16
+
17
+ The queue is produced by the repo's planning skill (`ticket-scheme` or the Run Contract's
18
+ `plan_skill` — decision-complete tickets, batch prefixes, branch footers, a Way-of-work
19
+ block each); this skill runs that queue. A ticket that cannot be implemented as written is
20
+ the run's one failure mode — everything else is execution.
21
+
22
+ ## Repo & Run Contract (injected by invoking prompt, repo `AGENTS.md`, or `~/.agents/rules/<repo>-contract.md`)
23
+
24
+ This skill is repo- and harness-agnostic. Read these repo-specific values from the invoking
25
+ prompt, the repo's `AGENTS.md`, or `~/.agents/rules/<repo>-contract.md` before starting:
26
+
27
+ | Slot | Meaning | Example |
28
+ |---|---|---|
29
+ | `plan_skill` | Skill that authored the ticket queue | `ticket-scheme` |
30
+ | `implement_command` | Worker skill/command opening each brief | `/implement` (if present in repo) |
31
+ | `bootstrap_command` | Heavy/canonical checkout setup at run start | `tools/bootstrap.sh --heavy` |
32
+ | `env_flags` | Env vars fresh worktrees need | `NX_DAEMON=false` |
33
+ | `verify_targets` | Exact target list from the PR-gating CI job | `lint, test, test-integration, build` |
34
+ | `evidence_skill` | Optional live-stack evidence skill for serving paths | `<repo>-evidence` |
35
+ | `pr_review_label` | Optional label triggering the repo's review bot | `agent-review` |
36
+ | `gate_config_paths` | Repo gate configs whose change re-fires gate proofs | `pyproject.toml`, `.opencodereview/rule.json`, `tools/check-*.py` |
37
+
38
+ ## Gate
39
+
40
+ A run starts on the user's explicit go (or an explicit scheduled prompt); a paused run
41
+ resumes when they say continue. When workers run asynchronously, report state and end the
42
+ turn — never poll workers in a loop.
43
+
44
+ ## Harness adapters (detect once at run start)
45
+
46
+ Select the adapter matching the tools actually available in your current session. The
47
+ engineering discipline, branches, gates, invariants, OCR review, PR diagram, and harvest are
48
+ **identical** across every adapter — only the worker transport and PR-watch lifecycle adapt.
49
+
50
+ ### Harness adapter: T3 Code (full parity with `t3-ticket-orchestrator`)
51
+
52
+ Active whenever T3 Code thread/PR tools (`t3_thread_launch`, `t3_thread_update`,
53
+ `t3_thread_list`, `t3_thread_send`, `t3_thread_wait`, `t3_thread_organize`,
54
+ `link_pull_request`, `watch_pull_request`) are available:
55
+
56
+ 1. **First act: name yourself.** The thread list is the run's dashboard — rename your own
57
+ thread before any other work, and keep that name current for the whole run:
58
+ - Before the final PR exists: `Orchestrator: <run name> → ticket #<N>`
59
+ - After the final PR opens: `Orchestrator: <run name> → PR #<number>`
60
+ Rename with `t3_thread_update` (`action: 'rename'`, `title`, no `threadId`). Verify via
61
+ `t3_thread_list` that your thread carries the title you sent (`opencode.session_rename`
62
+ renames the OpenCode session only).
63
+ 2. **Workers are top-level T3 threads** (never subagents or delegates for tickets). Launch
64
+ each ready ticket via `t3_thread_launch` with a worktree strategy on branch
65
+ `agent-<kit>/<NN>-<slug>`, `baseRef` set to the base branch, `startFromOrigin: true`, and
66
+ a readable title `Implement #<N> — <short subject>`. Inherit your active provider and
67
+ model unless the user names another.
68
+ 3. **Wake contract & ledger.** Include the orchestrator's own thread id (from
69
+ `t3_thread_list`'s `currentThreadId`) and the `t3_thread_send` (`mode: 'auto'`) ping-back
70
+ clause in every brief. Register every worker in the `t3-thread-bridge` ledger at launch
71
+ and `ack` it at close so `ledger check` sweeps silent threads. After launching, run one
72
+ short `t3_thread_wait` per worker to confirm it started and arm the platform's completion
73
+ wake — never depend on ping-back alone. End the turn on the wait's timeout.
74
+ 4. **Mid-run steer, resume, and settle.** Send mid-run ticket corrections via
75
+ `t3_thread_send` (`mode: 'steer'`) naming only what changed. Resume an idle thread whose
76
+ branch is short of the work with a short continue message (`t3_thread_send`, `mode:
77
+ 'auto'`) — never relaunch it. After merging a worker's branch, settle its thread
78
+ (`t3_thread_organize`, `action: 'settle'`).
79
+ 5. **Final PR watch & landing.** Immediately `link_pull_request` and `watch_pull_request` on
80
+ the final PR (required, not conditional — PR events are the run's reliable wake). Stay on
81
+ the watch until the PR merges or closes (or until the invoking prompt's end-of-run rule
82
+ settles it, e.g. scheduled security runs settling after bot review rounds pass); fix small
83
+ bot findings on the base as **one batched push per round** and reply in their threads. On merge
84
+ or close: confirm landing, delete the PR's diagram comment(s), call
85
+ `unwatch_pull_request`, run Harvest, and hand back.
86
+
87
+ ### Harness adapter: Claude Code
88
+
89
+ Active when running in Claude Code without T3 MCP tools:
90
+
91
+ 1. **Run status header.** Maintain `<scratch>/<kit>/status.md` (gitignored) with the current
92
+ phase, `Orchestrator: <run name> → ticket #<N>` (or `→ PR #<number>`), base branch, and
93
+ ticket table.
94
+ 2. **Workers via `Agent` (`isolation: "worktree"`) or explicit git worktrees.** After
95
+ cutting and pushing the base branch, dispatch independent unblocked tickets in parallel
96
+ using Claude Code's `Agent` tool with `isolation: "worktree"` (foreground per batch so
97
+ each worker finishes and returns cleanly), or create deterministic worktrees with
98
+ `git worktree add <scratch-wt>/<NN> -b agent-<kit>/<NN>-<slug> origin/<base>` and pass
99
+ the worktree path to each worker.
100
+ 3. **Verify & merge synchronously.** Inspect each returned worker's branch (`git log`/diff
101
+ and ticket gates) before merging `--no-ff` into base, running `verify_targets`, pushing
102
+ base, and removing the worktree.
103
+ 4. **Final PR & checks.** Open the PR, post the diagram comment, check CI via `gh pr checks`,
104
+ answer any requested review round synchronously when invoked, run Harvest, and hand back
105
+ without polling loops.
106
+
107
+ ### Harness adapter: Codex, OpenCode, Antigravity, or generic CLI
108
+
109
+ Active when running in any other agent harness or headless CLI (`codex exec`, `opencode run`,
110
+ `claude -p`, etc.):
111
+
112
+ 1. **Run status ledger.** Maintain `<scratch>/<kit>/status.md` (gitignored) recording base
113
+ branch, target branch, ticket states, branch names, and evidence paths.
114
+ 2. **Isolated git worktree per ticket.** Create one worktree per ready ticket:
115
+ `git worktree add <scratch-wt>/<NN> -b agent-<kit>/<NN>-<slug> origin/<base>`. If the
116
+ harness provides native subagents, dispatch independent batch tickets in parallel with
117
+ each subagent scoped strictly to its worktree; otherwise execute tickets sequentially,
118
+ one worktree per ticket, writing a concise `handoff` note between tickets so context stays
119
+ clean.
120
+ 3. **Same gates, no polling.** Run the exact same merge (`--no-ff`), `git check-ignore`,
121
+ verify, push, OCR gate, PR diagram comment, PR creation, and Harvest steps; hand back
122
+ cleanly without polling.
123
+
124
+ ## The run
125
+
126
+ 1. **Setup, once.** Cut the base branch from `origin/<target>` — the target this run will
127
+ finally PR into (`main` for a first-generation run, the parent epic branch for a kit cut
128
+ under one, or `security/<short-slug>` when invoked by a security remediation run) — name
129
+ it with the user when unset (`epic/<topic>` is the default pattern), and push it
130
+ immediately. Then edit the queue's tickets: the `Base Branch` footer becomes the base
131
+ branch, a supersession note under each ticket's Way-of-work block states that `gh` is
132
+ authenticated (when using GitHub Issues), there is no per-ticket PR, and done means
133
+ commits on the agent branch — and **drop the per-ticket OCR gate** (OCR now runs once,
134
+ orchestrator-side, on the full base branch before the final PR; see step 4).
135
+ Bring the checkout's verify environment to the repo's canonical shape once at setup —
136
+ using the Run Contract's `bootstrap_command` when defined — so drift found mid-run is
137
+ fixed at the environment. The run's gates and their proofs are ledged in
138
+ `references/proving-the-gates.md` beside this skill: proofs run orchestrator-side, never
139
+ inside a worker loop, and re-fire when any path in `gate_config_paths` or this skill's
140
+ gate lines changes.
141
+
142
+ 2. **Launch, per ticket.** Gate on blockers (GitHub native dependencies, else the ticket's
143
+ `Blocked by`; an operational prerequisite — a runbook step the ticket requires — gates
144
+ the launch the same way). Independent tickets may run in parallel without an artificial
145
+ in-flight cap when the active harness supports parallel isolated workers — launch every
146
+ ticket the merged set has unblocked. Cut each ticket's worktree on branch
147
+ `agent-<kit>/<NN>-<slug>` from `<base branch>` (`startFromOrigin: true`) with readable
148
+ title `Implement #<N> — <short subject>`. Every brief carries:
149
+ - the ticket reference (URL, or absolute host path outside every repo in local-files mode
150
+ — never pasted inline),
151
+ - the worktree and branch facts,
152
+ - the **environment facts** (bootstrap mode the worktree needs, fresh-worktree `env_flags`
153
+ from the Run Contract, which suites need the heavy env, and that a light-env failure of
154
+ a heavy suite is the environment's, not the code's),
155
+ - the evidence-dir contract (gitignored, never staged),
156
+ - the wake contract (for T3 Code), and
157
+ - the stop rule (a decision that cannot be implemented as written is reported, never
158
+ re-decided silently).
159
+ On any worker completion, **the branch is the report** — read `git log`/diff and run the
160
+ ticket gates on it first; read the worker's hand-off prose only after the branch convinces
161
+ you.
162
+
163
+ 3. **On each worker's finish.** A worker that finishes short of the work — branch incomplete,
164
+ context intact — is resumed with a short continue message when the harness supports
165
+ resuming (never relaunched unnecessarily). Merge its agent branch into the base branch
166
+ locally (`--no-ff`, message naming the ticket); a merge conflict of *wording* — two
167
+ tickets telling one story in different vocabularies — resolves by combining both truths,
168
+ the incoming ticket's prose adapting to the vocabulary already on the base. Then run the
169
+ repo's verify line, **push the base branch immediately**, close the ticket with a comment
170
+ (or mark it closed in the local scratch tracker), remove the worktree, settle/close the
171
+ worker per the active harness adapter, and launch every ticket this merge unblocked.
172
+
173
+ **The pushed tree carries no ignored path.** Before every commit and every push, the
174
+ staged paths must pass `git check-ignore`:
175
+ `git diff --cached --name-only | git check-ignore --stdin` answers nothing, or the commit
176
+ stops and the path comes out (`git restore --staged`). At push time the same probe runs
177
+ over the tip — `git ls-tree -r HEAD --name-only | git check-ignore --stdin` — because a
178
+ worker may force-add past the commit gate (`git add -f .scratch/…`: a ticket ordering
179
+ that is a fork to report, never to obey; evidence lives on the ticket or off-branch). A
180
+ tool that writes a new preview directory lands its ignore line in the same change that
181
+ first commits beside it — `git add -A` sweeps whatever no line names yet.
182
+
183
+ **Drift merges; a fork stops.** A conflict whose other side came from upstream — the
184
+ target moved under them — is drift: re-apply the run's intent onto the newer upstream
185
+ shape, disclose the per-file resolution, and merge. A conflict over a *contract*, where
186
+ two tickets changed the same behaviour, is a fork: stop with the merge uncommitted,
187
+ surface it to the user, and never pick a side silently.
188
+
189
+ **Ticket gates, when present.** Beside the verify line, run
190
+ `tools/check-blast-radius.py --base <merge-base> --head <agent branch> --area <ticket's area label> [--allow …]`
191
+ and `tools/check-facts.py --tickets <kit dir> --base … --head …` when the tools exist.
192
+ Exit 1 is a **fork to report** — surface it on the ticket, never auto-fail the merge.
193
+ Spot-check two claims from the hand-off's claims ledger per merge, preferring
194
+ machine-checkable evidence (a command plus its digest) over prose claims.
195
+
196
+ **CI's line is the verify line.** Copy `verify_targets` directly from the CI job that
197
+ gates the PR. A local run of a shorter list leaves its missing target unproven. A target
198
+ that cannot run here — a heavy environment this host refuses, a native crash in one
199
+ process — gets reproduced at the base and named in the ticket's close comment.
200
+
201
+ **Foreign code lands by behaviour.** When a ticket extracts modules from another branch,
202
+ pin the behaviour and the file set, and read the target branch's conventions — lint
203
+ contracts, one-runner rules, banned imports — before pinning identity: a copy that
204
+ violates them cannot land. Where the two disagree, the target's conventions win and the
205
+ foreign branch gets a follow-up ticket to adopt them; the ticket says the extracted files
206
+ are deliberately adapted.
207
+
208
+ **On a blocked report (the STOP path).** Verify the stop is clean first — the branch
209
+ carries no commits and the tree is clean; then remove the worktree, or keep it when a
210
+ rerun is expected (the rerun cuts a fresh one from the updated base, and the measurements
211
+ live in the ticket, not in the worktree). Comment the fork on the ticket with the options
212
+ and one recommendation, relabel it `ready-for-human`, and leave the decision to the user:
213
+ a decision that spawns a follow-up ticket re-queues the stopped ticket behind it, and a
214
+ decision to drop closes it wontfix.
215
+
216
+ 4. **Drained.** Merge `origin/<target>` — the branch this run's base was forked from,
217
+ recorded at setup — into the base first: the PR's checks must never be the first place
218
+ the combination runs. Re-run `verify_targets` on the combined tree, push.
219
+
220
+ **OCR review, once for the run.** When `command -v ocr` is available, run
221
+ `ocr review --from origin/<target> --to <base branch> --audience agent --background "<run subject>"`
222
+ on the full base branch — the epic-level diff, the single OCR gate for the run (per-ticket
223
+ OCR is retired). Fix each finding or record its rejection reason in the run's closing
224
+ note, then re-run once. A run whose every request failed is reported as
225
+ `"OCR gate: not run — <reason>"`; the gate passes only on a completed run. The reviewer
226
+ may request a test only by naming an uncovered fact from the run's Facts to prove, with
227
+ its silent-breakage path.
228
+
229
+ **Evidence before ready.** When the Run Contract defines an `evidence_skill` and the run
230
+ changes a live serving or runtime path, run that evidence skill before declaring the PR
231
+ ready: wire the real local dependency stack, exercise the live path, capture verbatim
232
+ transcripts and resource measurements, and tear everything down. Findings become tickets
233
+ of their own. Always state what the evidence does and does not prove.
234
+
235
+ **Open one final PR** (`base branch → <target>`), adding the Run Contract's
236
+ `pr_review_label` when configured (`gh pr create --label <pr_review_label>`), with the
237
+ body opening on the merge-danger line:
238
+ `Merge danger: <one-way|two-way> door — blast radius <areas touched>`.
239
+ Update your run title (`→ PR #<number>`), post the PR diagram comment (below), and follow
240
+ the active harness adapter's PR-watch / bot-review lifecycle.
241
+
242
+ **Harvest before the run ends:** walk the run's review findings — OCR rejections, bot
243
+ threads, spot-check misses, fork reports; every finding that recurred ≥2× across the run
244
+ becomes a rule (a `rule.json` entry, an evidence-bar line, a banned-api entry, or a
245
+ ticket-template line), each new rule proven per `references/proving-the-gates.md`, and
246
+ findings seen once are listed as candidates in the run's closing note.
247
+
248
+ ## The PR's diagram comment
249
+
250
+ Every run's PR carries one diagram comment — a picture of what the run changed — posted
251
+ when the PR opens, patched when a bot-fix push changes the diff, deleted when the PR lands
252
+ or dies. It never touches the base branch: no review-turn spend, nothing to re-vendor.
253
+
254
+ Generate the SVG with `pr-lens` (deterministic: validated graph document, delta semantics)
255
+ or, when the run's story is narrative rather than mechanics, a worker under `diagram-router`.
256
+
257
+ **The module picture.** A run that re-architects how modules relate — a new seam, a moved
258
+ dependency, not just added files — also posts a **C4 component-level diagram** of the code it
259
+ touched (`<!-- diagram:c4:v1 -->`), drawn from repo evidence under `diagram-router`. Upload
260
+ each SVG as a **user-attachment** and post an idempotent marker comment:
261
+
262
+ ```bash
263
+ REPO_ID=$(gh api repos/$REPO -q .id)
264
+ TOKEN="$(gh auth token)"
265
+ ASSET=$(curl -sS -X POST \
266
+ "https://uploads.github.com/user-attachments/assets?name=diagram.svg&content_type=image%2Fsvg%2Bxml&repository_id=$REPO_ID" \
267
+ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/octet-stream" \
268
+ -H "Accept: application/vnd.github+json" --data-binary @diagram.svg | jq -r .url)
269
+ printf '<!-- diagram:v1 -->\n<details open>\n<summary>PR diagram</summary>\n\n![diagram](%s)\n\n</details>\n' "$ASSET" >/tmp/pr-diagram.md
270
+ CID=$(gh api "repos/$REPO/issues/$PR/comments" -q '.[] | select(.body|startswith("<!-- diagram:v1 -->"))|.id' | head -1)
271
+ if [ -n "$CID" ]; then gh api --method PATCH "repos/$REPO/issues/comments/$CID" -F body=@/tmp/pr-diagram.md
272
+ else gh api --method POST "repos/$REPO/issues/$PR/comments" -F body=@/tmp/pr-diagram.md; fi
273
+ ```
274
+
275
+ - Percent-encode `content_type` (`image%2Fsvg%2Bxml`); plain spelling returns 422.
276
+ - `gh auth token` satisfies the endpoint; installation tokens (`ghs_`) may be rejected — test
277
+ one upload and fall back to a text/mermaid fence if rejected.
278
+ - A private repository's attachment answers 404 to an anonymous fetch; verify with the auth
279
+ header.
280
+ - On merge or close, delete the marker comment(s):
281
+ ```bash
282
+ gh api "repos/$REPO/issues/$PR/comments" -q '.[] | select(.body|startswith("<!-- diagram:v1 -->"))|.id' \
283
+ | xargs -r -n1 gh api --method DELETE "repos/$REPO/issues/comments/{}"
284
+ ```
285
+
286
+ ## Invariants
287
+
288
+ - The target branch is never merged into, locally or remotely, mid-run.
289
+ - One ticket per isolated worker/worktree; the worker follows its ticket strictly —
290
+ acceptance list and Way-of-work — inside its own worktree. The OCR gate is retired from
291
+ the per-ticket Way-of-work; it runs once, orchestrator-side, on the full base branch before
292
+ the final PR.
293
+ - Every implementing worker works under `implement` (opening with `implement_command`, e.g.
294
+ `/implement`), with `tdd` at pre-agreed seams and `code-review` at the end inside the
295
+ ticket's Way-of-work.
296
+ - The only remote objects are the base branch (pushed after every merge) and the final PR;
297
+ no per-ticket PRs, no per-ticket pushes.
298
+ - After the final PR opens, the base branch takes only bot-fix pushes (conserving review-bot
299
+ turn budgets): anything else waits for the next run's PR unless explicitly ordered onto
300
+ this one (in which case it runs as an ordinary ticket and patches the diagram comment).
301
+ - **Plan vocabulary stays in prose.** Temporary qualifiers (`interim`, `provisional`,
302
+ `temporary`, `legacy`) belong to prose, never to shipped identifiers.
303
+ - Worker briefs are crafted per ticket and always carry: ticket reference, worktree/branch
304
+ facts, environment facts, evidence-dir contract (gitignored, never staged), "follow the
305
+ ticket strictly", done = report (no PR, no push), and the stop rule. In local-files mode
306
+ stage tickets at a host path outside every repo and point to them by absolute path — never
307
+ paste a ticket inline.
308
+ - All repository artifacts are English only (issues, commits, PRs, briefs, docs, skills).
309
+ - Mid-run corrections name exactly what changed in the ticket and nothing else.
310
+
311
+ ## Worker brief templates
312
+
313
+ ### T3 Code worker brief
314
+
315
+ ```
316
+ /implement — the work is ticket <N>: <ticket URL or absolute local path>, followed strictly
317
+ (every acceptance item and its full Way-of-work). Wake contract: the moment you are done or
318
+ blocked you MUST t3_thread_send the orchestrator thread (block at the end of this brief) — a
319
+ finished run that never pinged counts as a failed run. Read it with `gh issue view <N>` (or
320
+ read the absolute path in local mode); its Way-of-work's no-gh constraint is superseded by
321
+ the note directly under it. You are in a fresh worktree on <branch> cut from <base branch>;
322
+ work only here. <one or two repo context pointers>. <environment facts: bootstrap mode,
323
+ env_flags, which suites need the heavy env>. Done = every acceptance item green, the repo's
324
+ full lint/test/build green, commits on this branch — no PR, no push, and nothing
325
+ `git check-ignore` names ever staged (a ticket ordering an ignored path into the tree is a
326
+ fork to report, not to obey). Finish with a short report; if a ticket decision cannot be
327
+ implemented as written, stop and report the conflict instead of re-deciding.
328
+
329
+ When your report is ready — or you hit a blocker the ticket cannot resolve — send it to the
330
+ orchestrator thread first: `t3_thread_send` with threadId `<orchestrator-thread-id>`, mode
331
+ `auto`, message `ticket <N> done: <one line>` (or `ticket <N> blocked: <one line>`); then
332
+ finish your turn with the full report as briefed.
333
+ ```
334
+
335
+ ### Portable / non-T3 worker brief (Claude Code, Codex, OpenCode, CLI)
336
+
337
+ ```
338
+ /implement — the work is ticket <N>: <ticket URL or absolute local path>, followed strictly
339
+ (every acceptance item and its full Way-of-work). You are in a fresh git worktree at
340
+ <worktree path> on branch <branch> cut from <base branch>; work only inside this worktree.
341
+ <one or two repo context pointers>. <environment facts: bootstrap mode, env_flags, which
342
+ suites need the heavy env>. Evidence artifacts go in <kit evidence dir> (gitignored, never
343
+ staged). Done = every acceptance item green, the ticket's verify checks green, commits on
344
+ this branch — no PR, no push, and nothing `git check-ignore` names ever staged (a ticket
345
+ ordering an ignored path into the tree is a fork to report, not to obey). Finish with a
346
+ concise structured report (commits, verify commands + results, claims ledger); if a ticket
347
+ decision cannot be implemented as written, stop with a clean tree and report the conflict
348
+ instead of re-deciding.
349
+ ```