@greenrenge/skills 0.0.0-stage → 0.2.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -2
  3. package/bin/cli.mjs +525 -0
  4. package/bin/lib/onboard.mjs +1168 -0
  5. package/bin/lib/probe.mjs +631 -0
  6. package/catalog.json +590 -0
  7. package/package.json +50 -4
  8. package/skills/deck-story/SKILL.md +258 -0
  9. package/skills/deck-story/check-svg-text.mjs +94 -0
  10. package/skills/deck-story/check.mjs +348 -0
  11. package/skills/diagram-router/LICENSE +21 -0
  12. package/skills/diagram-router/SKILL.md +193 -0
  13. package/skills/diagram-router/THIRD_PARTY_NOTICES.md +15 -0
  14. package/skills/diagram-router/references/channels.md +213 -0
  15. package/skills/diagram-router/references/evals.md +85 -0
  16. package/skills/diagram-router/references/gathering.md +101 -0
  17. package/skills/diagram-router/references/prior-art.md +65 -0
  18. package/skills/diagram-router/references/routing.md +166 -0
  19. package/skills/diagram-router/skill-release.json +17 -0
  20. package/skills/frontend-design/SKILL.md +443 -0
  21. package/skills/frontend-design/references/rtl.md +72 -0
  22. package/skills/frontend-design/scripts/.upstream-sha +1 -0
  23. package/skills/frontend-design/scripts/LICENSE +21 -0
  24. package/skills/frontend-design/scripts/README.md +24 -0
  25. package/skills/frontend-design/scripts/gates.md +243 -0
  26. package/skills/frontend-design/scripts/sloplint-render.mjs +1283 -0
  27. package/skills/frontend-design/scripts/sloplint.mjs +4426 -0
  28. package/skills/open-code-review-rules/SKILL.md +59 -0
  29. package/skills/open-code-review-rules/references/ocr-allowlists.json +161 -0
  30. package/skills/open-code-review-rules/references/ocr-rule-semantics.md +39 -0
  31. package/skills/open-code-review-rules/scripts/verify_ocr_rules.py +836 -0
  32. package/skills/plain-english-mode/SKILL.md +41 -0
  33. package/skills/pr-diagram-portfolio/SKILL.md +75 -0
  34. package/skills/pr-diagram-portfolio/references/angle-framework.md +124 -0
  35. package/skills/pr-diagram-portfolio/references/portfolio-delivery.md +79 -0
  36. package/skills/pr-diagram-portfolio/scripts/restore_still_css.py +180 -0
  37. package/skills/pr-lens/LICENSE-upstream +21 -0
  38. package/skills/pr-lens/SKILL.md +99 -0
  39. package/skills/pr-lens/VENDOR.md +47 -0
  40. package/skills/pr-lens/package-lock.json +91 -0
  41. package/skills/pr-lens/package.json +9 -0
  42. package/skills/pr-lens/references/config.md +90 -0
  43. package/skills/pr-lens/references/example.graph.json +580 -0
  44. package/skills/pr-lens/references/graph-document.md +233 -0
  45. package/skills/pr-lens/skill-release.json +16 -0
  46. package/skills/security-remediation-epic/SKILL.md +316 -0
  47. package/skills/security-remediation-epic/prompt-template.md +33 -0
  48. package/skills/skill-maintainer/SKILL.md +99 -0
  49. package/skills/skill-maintainer/references/placement-and-coupling.md +43 -0
  50. package/skills/skill-maintainer/scripts/audit_skills.py +297 -0
  51. package/skills/t3-successor-handoff/SKILL.md +141 -0
  52. package/skills/t3-thread-bridge/SKILL.md +175 -0
  53. package/skills/t3-thread-bridge/references/launch-recipes.md +123 -0
  54. package/skills/t3-thread-bridge/references/ping-back.md +108 -0
  55. package/skills/t3-thread-bridge/scripts/thread_ledger.py +203 -0
  56. package/skills/t3-ticket-orchestrator/SKILL.md +304 -0
  57. package/skills/t3-ticket-orchestrator/references/proving-the-gates.md +63 -0
  58. package/skills/ticket-scheme/SKILL.md +144 -0
  59. package/skills/ulw-plan/SKILL.md +98 -0
  60. package/skills/ulw-plan/references/full-workflow.md +255 -0
  61. package/skills/ulw-plan/references/intent-clear.md +44 -0
  62. package/skills/ulw-plan/references/intent-unclear.md +44 -0
  63. package/skills/ulw-plan/scripts/plan-templates.mjs +180 -0
  64. package/skills/ulw-plan/scripts/scaffold-plan.mjs +187 -0
@@ -0,0 +1,213 @@
1
+ # Output channels
2
+
3
+ The channel decides the mechanics, not the picture. Pick the channel **before**
4
+ producing the artefact, because some channels constrain the artefact itself.
5
+
6
+ ## The matrix
7
+
8
+ | Situation | Channel | Exact form |
9
+ |---|---|---|
10
+ | "show me now" in this thread | `inline-html` | `html_preview({html})` → `html_render({html, title, height})`; html ≤512,000 chars; no page background, no outer card, no side padding |
11
+ | default "here is the diagram" | `file` | write the file, `browser.preview({path})`, reply with the absolute path and `![diagram](/abs/path.png)` |
12
+ | "in the PR" / "diagram the PR" | `pr-comment` | upload the PNG as a user-attachment (PAT-only endpoint), or commit it and link the **root-relative** `![](/OWNER/REPO/blob/<ref>/<path>?raw=true)` — SHA-pin the ref to dodge the 5-min stale cache; **never inline `<svg>`**, never a fenced ` ```svg ` block, never `../blob/...` (breaks on the Files-changed tab) |
13
+ | "in the README / docs" | `repo-asset` | `docs/diagrams/` (or `docs/assets/diagrams/`); SVG canonical, PNG for embedding; relative link from the README |
14
+ | "in the terminal / a log" | `terminal-text` | fenced code block, Unicode box-drawing or ASCII, ≤~100 cols, no emoji |
15
+ | "editable, low-fidelity, CI" | `mermaid-block` | a fenced ```mermaid block — GitHub renders it natively, no asset |
16
+ | "I want to see it in my own terminal" | `file` + command | write the PNG, then print the command: `chafa diagram.png` (not installed here) or `~/.local/bin/chromium` |
17
+
18
+ ## GitHub rendering rules — the ones people get wrong
19
+
20
+ Everything in this section was **measured against production** (a 100-tag probe
21
+ posted as a real PR comment and parsed out of the server-rendered page;
22
+ `POST /markdown` is *not* the production renderer — it kept a `<video>` that
23
+ production strips — so never use the API to verify rendering). Full probe and
24
+ citations: `<scratch-dir>/pr598/github-html-rendering.md`.
25
+
26
+ **There is no published allowlist that matches production.** github/markup does
27
+ no sanitization; html-pipeline is a frozen 2015 fork GitHub no longer uses. The
28
+ measured truth (2026-11-06):
29
+
30
+ - **KEPT:** `a b blockquote br code dd del details div dl dt em h1–h6 hr i img
31
+ ins kbd li mark ol p picture pre q rp rt ruby s samp section source span
32
+ strike strong sub summary sup table td th tr tt ul var`
33
+ - **STRIPPED** (tag gone, text kept): `svg` `small` `time` `u` `figure`
34
+ `figcaption` `caption` `nav` `header` `footer` `object` `template` `math` …
35
+ - **ESCAPED to literal text:** `iframe` `script` `style` `textarea`
36
+ - **DROPPED entirely:** `embed` `video` `meta` `link` `param` `wbr`
37
+ - Attributes: `id` kept (rewritten to `user-content-<id>`); `style` `class`
38
+ `onclick` `onerror` `target` `data-*` `aria-label` **dropped**;
39
+ `javascript:` href removes the whole `<a>`; `data:` URIs lose their `src`.
40
+ - **No per-surface difference:** PR description, issue comment, and inline
41
+ review comment render byte-identically.
42
+
43
+ So: inline `<svg>` is stripped (its text survives), and a fenced ` ```svg `
44
+ block is a **syntax-highlighted code block** — XML source, not a picture. Both
45
+ are common mistakes. **CodeRabbit's "HTML in comments" is exactly the KEPT
46
+ subset above** — `<details>/<summary>`, `<dl>/<dd>`, tables, `<picture>` — plus
47
+ externally hosted images. No bot magic.
48
+
49
+ ### The image link — use the root-relative form
50
+
51
+ ```markdown
52
+ ![what it shows](/OWNER/REPO/blob/<ref>/docs/diagrams/pr-598.png?raw=true)
53
+ ```
54
+
55
+ - **Root-relative (`/OWNER/REPO/blob/...`) is depth-independent** — it works in
56
+ the PR description, in comments, **and on the Files-changed tab**.
57
+ - The GitHub-documented `../blob/<branch>/<path>?raw=true` works on the
58
+ Conversation tab only: on the Files-changed tab the page base is
59
+ `/OWNER/REPO/pull/<n>/`, so `..` resolves to `/OWNER/REPO/pull/blob/...` →
60
+ **broken image** (measured).
61
+ - A plain relative path (`docs/diagrams/pr-598.png`) never resolves in a body —
62
+ the base is the page, not the repo.
63
+ - `?raw=true` is mandatory: without it the blob URL returns the code-view HTML
64
+ page, which is a broken image. `?raw=1` behaves identically.
65
+ - **Private repos:** raw/blob/attachment URLs all 404 for anonymous readers;
66
+ the `<img>` request carries the *reader's* credentials, so a bot's token
67
+ grants the reader nothing.
68
+
69
+ ### The stale-cache trap (committed images)
70
+
71
+ A re-commit that changes bytes at the **same path on the same branch** serves
72
+ the **old** bytes for ~2–5 minutes (`cache-control: max-age=300`; measured:
73
+ stale at t+120 s, fresh at t+150 s). Query-string cache-busting does **not**
74
+ work — the redirect drops the extra parameter. The reliable fixes:
75
+
76
+ 1. **SHA-pin the URL:** `![](/OWNER/REPO/blob/<commit-sha>/<path>?raw=true)` —
77
+ content-addressed, immutable, cache-safe. (The SHA is only known after the
78
+ commit, so the comment must be posted after committing.)
79
+ 2. **Or upload the image instead** (next section) — a fresh UUID every time.
80
+
81
+ ### The bot path: upload as a user-attachment
82
+
83
+ The cleanest way to put an image in a PR comment is to **upload it** — no
84
+ branch coupling, no staleness, an immutable UUID URL, repo-scoped visibility.
85
+ This is what `gh --attach` uses internally:
86
+
87
+ ```bash
88
+ curl -X POST \
89
+ "https://uploads.github.com/user-attachments/assets?name=diagram.png&content_type=image/png&repository_id=<id>" \
90
+ -H "Authorization: Bearer $PAT" \
91
+ --data-binary @diagram.png
92
+ # 201 → {"url": "https://github.com/user-attachments/assets/<uuid>"}
93
+ ```
94
+
95
+ Caveats: a **PAT or OAuth token is required** — `ghs_` Actions/App installation
96
+ tokens are rejected ("unsupported authentication type"); there is no public
97
+ REST endpoint for this (the browser upload UI is session-only). A freshly
98
+ uploaded asset 404s anonymously until referenced in a published comment; in a
99
+ private repo it is token-gated forever (that is correct behaviour, not a bug).
100
+
101
+ ### Posting
102
+
103
+ ```bash
104
+ gh pr comment <number> --body-file /tmp/comment.md
105
+ ```
106
+
107
+ The image must already exist — committed to the head branch (SHA-pinned link),
108
+ or uploaded (attachment URL). If the checkout is not on the head branch, commit
109
+ the asset there first (a separate commit is fine), or drag the file into the
110
+ GitHub comment box, which uploads it as an attachment without a commit.
111
+
112
+ ### PNG vs SVG — and the dark-mode fix
113
+
114
+ - **PNG** is the default: one file, renders identically in both themes.
115
+ - **SVG** is served as `image/svg+xml` and renders with its own colours baked
116
+ in — a light-background diagram is a pale rectangle in GitHub's dark theme.
117
+ **The fix is `<picture>`** (both tags are in the KEPT list): GitHub wraps a
118
+ `<picture>` in `<themed-picture>` and honours
119
+ `media="(prefers-color-scheme: dark)"` — ship two SVG variants and let the
120
+ reader's theme pick:
121
+ ```markdown
122
+ <picture>
123
+ <source media="(prefers-color-scheme: dark)" srcset="/O/R/blob/<ref>/docs/diagrams/x-dark.svg?raw=true">
124
+ <img src="/O/R/blob/<ref>/docs/diagrams/x.svg?raw=true" alt="the diagram">
125
+ </picture>
126
+ ```
127
+ - An SVG linked from GitHub must carry **no `@import` of remote fonts** — the
128
+ image context blocks external fetches and the text silently falls back.
129
+ Export with system fonts:
130
+ ```bash
131
+ python3 ~/.agents/skills/diagram-design/scripts/export_svg.py --system-fonts in.html out.svg
132
+ ```
133
+ - **HTML files never render.** Raw serves `text/plain` + `nosniff`; `/blob/`
134
+ serves the code-view page. `<iframe>` is escaped and CSP allows only GitHub's
135
+ own hosts — an interactive HTML page can only ever be a **link**, paired with
136
+ a static thumbnail in the body.
137
+ - **Mermaid fences render natively** — themed, zero assets, zero permissions;
138
+ the best channel for a small static diagram (it is CodeRabbit's own pattern).
139
+
140
+ ## Repo conventions for committed diagrams
141
+
142
+ ```
143
+ docs/diagrams/
144
+ <topic>.svg # canonical, vector, hand-editable
145
+ <topic>.png # embedded copy, regenerated from the SVG
146
+ <topic>.html # optional: the generator's source, if a skill produced one
147
+ ```
148
+
149
+ - SVG is canonical; PNG is the embedding artifact. Both come from the same source.
150
+ - Put a provenance header in the SVG:
151
+ `<!-- Generated by the diagram-router skill. DO NOT EDIT. Source: <path> -->`
152
+ - Link from the README relatively: `![architecture](docs/diagrams/architecture.png)`.
153
+ - If the picture is generated, regenerate it in CI and fail the build when the
154
+ committed file differs (`git diff --exit-code`), so the picture cannot drift from
155
+ the code it describes.
156
+ - Keep the diagram next to the code it describes — `docs/` of the owning project.
157
+
158
+ ## Rendering on this host — what works and what does not
159
+
160
+ `python3` here has **no `playwright` module**, so two of the sibling skills' PNG
161
+ pipelines fail on import. **The substitute depends on what the sibling emits** —
162
+ each skill produces a different artifact, so one fallback does not fit all:
163
+
164
+ | Sibling | Emits | Its own PNG path | Working substitute here |
165
+ |---|---|---|---|
166
+ | `diagram-design` | self-contained HTML with inline SVG | `scripts/export_png.py` — **fails** (no playwright) | `scripts/export_svg.py` (works, pure Python) → `magick in.svg out.png` |
167
+ | `stack-diagram` | self-contained HTML, canvas element | `scripts/render_png.py` — **fails** (no playwright) | **chromium screenshot of the HTML** (it has no SVG export — do not try `magick` on its HTML) |
168
+ | `archify` | self-contained HTML with inline SVG | its own export path (see `~/.agents/skills/archify/references/delivery-contract.md`) | chromium screenshot of the HTML, or extract the `<svg>` and `magick` it |
169
+
170
+ Tools present: `magick` (ImageMagick with the librsvg delegate) at `/usr/bin/magick`
171
+ · `~/.local/bin/chromium` (Playwright-managed wrapper) · `convert`.
172
+
173
+ ```bash
174
+ # SVG → PNG (diagram-design, and any extracted SVG)
175
+ magick in.svg out.png
176
+
177
+ # HTML → PNG (stack-diagram, archify, anything HTML)
178
+ ~/.local/bin/chromium --headless --no-sandbox --disable-gpu --hide-scrollbars \
179
+ --force-device-scale-factor=2 --window-size=1200,680 \
180
+ --screenshot=out.png "file://$PWD/page.html"
181
+ ```
182
+
183
+ For an HTML artefact whose SVG has a fixed pixel width, the screenshot clips at
184
+ narrow widths — render at the artefact's natural width, or make the SVG fluid
185
+ (`width:100%; height:auto`) before capturing.
186
+
187
+ **Always look at the rendered PNG.** Automated gates catch structure; only your
188
+ eyes catch a label sitting on a line.
189
+
190
+ ## Terminal channel
191
+
192
+ The only zero-install terminal output is text you write yourself:
193
+
194
+ ```
195
+ ┌──────────────┐ POST /authenticate ┌──────────────┐
196
+ │ iOS app │ ───────────────────────────▶ │ ml-serving │
197
+ └──────────────┘ └──────────────┘
198
+ ```
199
+
200
+ - ≤ ~100 columns, ASCII or Unicode box-drawing, **no emoji**.
201
+ - Do not paste ANSI art into a chat reply — the client renders it as escape
202
+ sequences.
203
+ - If the user wants a picture in *their* terminal, write a PNG and give them the
204
+ command (`chafa`, `timg`, `viu` — none are installed here; `d2` and `mermaid`
205
+ are absent too, so a terminal-native diagram is not currently available without
206
+ an install).
207
+
208
+ ## Rules
209
+
210
+ - Never produce extra exports unprompted. One channel per request; ask for more.
211
+ - The HTML source stays the source of truth; exports are derived from it.
212
+ - Say which render path you used, and say "not visually reviewed" if you did not
213
+ look.
@@ -0,0 +1,85 @@
1
+ # Trigger evaluation set
2
+
3
+ The router only works if it fires when a picture is wanted and the form is
4
+ undecided — and stays quiet when a sibling already owns the request. There is no
5
+ eval harness on this host, so this is a self-built one: 20 queries, scored as a
6
+ binary classifier, run before and after any change to the router's `description`.
7
+
8
+ ## The 20 queries
9
+
10
+ ### Should trigger (12) — real user phrasings
11
+
12
+ | # | Query | Expected route |
13
+ |---|---|---|
14
+ | 1 | "diagram this" | FORM undecided → route card |
15
+ | 2 | "make this visual" | FORM undecided → route card |
16
+ | 3 | "picture the deploy for me" | `stack-diagram` (deploy topology) |
17
+ | 4 | "diagram the PR" | `diagram-design` (architecture delta) |
18
+ | 5 | "explain this as a page" | `archify` (explainer) |
19
+ | 6 | "what should this look like?" | FORM undecided → route card |
20
+ | 7 | "can you show me how the request flows?" | `archify` (sequence/workflow) |
21
+ | 8 | "turn this into something a new hire can read" | `archify` (explainer) or editorial |
22
+ | 9 | "I need a picture of the architecture for the README" | FORM + CHANNEL(repo-asset) |
23
+ | 10 | "visualise the numbers in this report" | `diagram-design` (analytical) |
24
+ | 11 | "make me something I can paste in the PR comment" | FORM + CHANNEL(pr-comment) |
25
+ | 12 | "explain this more simply" | gate first — text may win |
26
+
27
+ ### Should not trigger (8) — sibling territory, dashboards, plain text
28
+
29
+ | # | Query | Owned by |
30
+ |---|---|---|
31
+ | 13 | "draw an AWS architecture diagram with the service logos" | `stack-diagram` (named form + format) |
32
+ | 14 | "convert this Mermaid file into the editorial style" | `diagram-design` (import) |
33
+ | 15 | "make a Sankey of the traffic split" | `diagram-design` (named form) |
34
+ | 16 | "build me a dashboard for our metrics" | not a diagram — dashboards are excluded |
35
+ | 17 | "chart last month's numbers by day" | live data / charts of live data |
36
+ | 18 | "what does this function return?" | plain-text answer |
37
+ | 19 | "write the SVG for this diagram by hand" | a named format, one skill's territory |
38
+ | 20 | "list every endpoint in the service" | a list is a list |
39
+
40
+ ## Scoring
41
+
42
+ Run each query with the router installed and record `fires: yes/no` plus the route
43
+ chosen.
44
+
45
+ - **recall** over the 12 should-trigger queries ≥ 0.70 (≥9 of 12).
46
+ - **precision** over the 8 should-not-trigger queries: inspect **every** false
47
+ positive by hand. A false positive is worse than a miss here — a router that
48
+ hijacks a sibling's request costs the user a wrong pipeline.
49
+ - Report the confusion matrix; keep the per-query table in the commit message of
50
+ any change to `description`.
51
+
52
+ ## Baseline comparison
53
+
54
+ Run the same 20 queries **with the router uninstalled** (move the directory out of
55
+ `~/.agents/skills/` and back). A router that fires but changes nothing — same
56
+ routing, same artefact — has failed: it added a trigger without adding a
57
+ decision. The baseline table is what proves the router earns its place.
58
+
59
+ ## Changing the description
60
+
61
+ Rules learned from measuring the three siblings:
62
+
63
+ 1. **No type vocabulary.** "sequence", "ERD", "state machine", "timeline",
64
+ "architecture" are already claimed — `architecture` by all three. Repeating
65
+ them in a fourth description is what makes the trigger space worse.
66
+ 2. **Routing verbs instead**: decide, picture, visual, explain, show.
67
+ 3. **One explicit negative clause naming the siblings** — that clause is what
68
+ makes a sibling's request land on the sibling.
69
+ 4. **Third person, front-loaded**, ≤1024 characters (the spec's cap).
70
+ 5. **Only the six spec fields** (`name`, `description`, `license`,
71
+ `compatibility`, `metadata`, `allowed-tools`). `when_to_use` is a Claude Code
72
+ extension and **fails upload to the Skills API** — do not use it here.
73
+
74
+ ## The sibling handoff clause
75
+
76
+ The router and the three siblings both describing "architecture" is a trigger
77
+ race. Each sibling carries a clause pointing back:
78
+
79
+ > For requests where the visual form or output format is still undecided, or
80
+ > where the destination is a PR body, README, terminal or repository asset, use
81
+ > the `diagram-router` skill first.
82
+
83
+ Keep those clauses in the siblings' descriptions whenever you edit them. Without
84
+ them, this router is a fourth voice in a room where one word is already claimed
85
+ three times.
@@ -0,0 +1,101 @@
1
+ # Gathering — the brief, the fan-out, the evidence standard
2
+
3
+ A diagram is only as good as its claims. Every box on it should be traceable to
4
+ something the reader can open.
5
+
6
+ ## When to gather at all
7
+
8
+ | Situation | Action |
9
+ |---|---|
10
+ | The facts are already in the conversation or in a file you just read | skip — go straight to drawing |
11
+ | The subject is a codebase, a PR, a paper, a web page | gather — you cannot draw from memory |
12
+ | The request names specific components you have not verified | gather, even for one box |
13
+
14
+ Gathering is not "research everything". It is "get the specific claims right".
15
+
16
+ ## The delegation contract
17
+
18
+ Fire 1–3 read-only children **in one response** so they run in parallel. Each
19
+ prompt must be self-contained — a child has no context from this thread.
20
+
21
+ ```
22
+ TASK: <one objective, measurable>
23
+ DELIVERABLE: <exact output format> — write to <absolute path>
24
+ SCOPE: <in scope> / OUT OF SCOPE: <explicitly not>
25
+ SOURCES: <which tools and which sources are authoritative>
26
+ EVIDENCE: <each fact must carry its source path or command output; "all checks pass" is not evidence>
27
+ UNKNOWNS: <mark every gap; do not infer>
28
+ VERIFY: <how you will confirm the deliverable>
29
+ FALLBACK: <if you have no tools, return what you can and say what is missing>
30
+ ```
31
+
32
+ Rules that matter:
33
+
34
+ 1. **Parallel, one response.** Sequential children cost a turn each.
35
+ 2. **Read-only children.** A child that edits product code while you are drawing
36
+ is a race. Say "do not modify anything outside <path>" and mean it.
37
+ 3. **Never re-search a child's topic yourself.** Once delegated, the answer
38
+ belongs to the child's brief; your job is to verify, not to redo.
39
+ 4. **Children return claims; you verify.** A child's "it works" is not evidence —
40
+ a child's pasted output is.
41
+ 5. **Every fact carries a source.** A file path, a line range, a command's output.
42
+ 6. **Unknowns are marked, never filled.** "The chart does not pin the model
43
+ version" is a legitimate diagram note; inventing a version is not.
44
+ 7. **Inline sequential fallback.** If spawning is unavailable, gather yourself
45
+ with the same standard. The gather step may never be skipped because a tool
46
+ was missing — only degraded.
47
+
48
+ ## Child roles that pay off
49
+
50
+ | Role | Objective | Typical sources |
51
+ |---|---|---|
52
+ | **code reader** | what the code actually does, per file/function | the repo, the diff |
53
+ | **evidence reader** | what the docs, ADRs, or ticket say | repo docs, ADRs, the PR body |
54
+ | **outside reader** | what the world says (standards, prior art, upstream docs) | web search, the upstream project |
55
+
56
+ Three children is the practical ceiling: more and the merge cost exceeds the gain.
57
+
58
+ ## The merged brief
59
+
60
+ Before drawing, you should hold **one brief** with:
61
+
62
+ - the story in one paragraph — what the reader must understand afterwards;
63
+ - the elements, each with its source;
64
+ - the unknowns, marked;
65
+ - the exclusions — what is deliberately not in the picture, and why;
66
+ - the route card's FORM and FIDELITY, so the drawing step does not re-decide.
67
+
68
+ Keep the brief in a file when it is long (>30 lines). A file survives; a chat
69
+ summary gets compressed away.
70
+
71
+ ## Evidence standards by claim type
72
+
73
+ | Claim | Acceptable evidence |
74
+ |---|---|
75
+ | a component exists | file path + the symbol or line range |
76
+ | an endpoint's behaviour | the handler code, or a test that asserts it |
77
+ | a configuration value | the values file / chart / env default, quoted |
78
+ | a runtime fact | a command's output (a log, a query result), not a plan |
79
+ | a number in the picture | the file and line that holds it |
80
+ | an absence | a search that came back empty, described ("no `X` in `apps/**`") |
81
+
82
+ ## Cost discipline
83
+
84
+ - Read the diff's **shape** first (`--stat`, `--name-only`), then the docstrings of
85
+ the files that grew, then the specific hunks. A large PR read line-by-line
86
+ wastes the whole context and finds less.
87
+ - The repository's own `AGENTS.md` and `CONTEXT.md` are usually the fastest route
88
+ to the narrative — they are written for exactly this.
89
+ - Two children doing different angles beat one child doing a wide sweep.
90
+
91
+ ## The fidelity ledger
92
+
93
+ The reader of the diagram cannot see what is missing. The person who asked for it
94
+ must. Ship one short list with the artefact:
95
+
96
+ ```
97
+ Merged: the two capture endpoints into one "capture" node (same shape, different verb).
98
+ Collapsed: the five-step judge chain into one labelled arrow (the budget was 9 nodes).
99
+ Dropped: the 500-on-broken-bundle branch (no room; it is a sentence in the PR body).
100
+ Invented: nothing.
101
+ ```
@@ -0,0 +1,65 @@
1
+ # Prior art — what other PR-diagram skills do, and what we take
2
+
3
+ Surveyed while replacing the repo's `render-pr-diagram` skill. Kept here so the
4
+ next maintainer knows these were considered, not missed.
5
+
6
+ ## PR Lens (`coldteadotai/pr-lens`)
7
+
8
+ <https://github.com/coldteadotai/pr-lens> — MIT, ~212 stars, npm
9
+ `@coldtea/pr-lens-cli`. The closest published competitor to this router's
10
+ PR-diagram path.
11
+
12
+ **Its pipeline:** the agent reads the diff and writes `.pr-lens/graph.json` — a
13
+ structured graph document (components, relationships, bounded to *only* what the
14
+ diff touches) — then a deterministic CLI takes over:
15
+
16
+ ```bash
17
+ npx pr-lens validate .pr-lens/graph.json # the graph contract, machine-checked
18
+ npx pr-lens render .pr-lens/graph.json --theme dark
19
+ ```
20
+
21
+ Rendering emits SVGs plus `manifest.json` and `drawn.graph.json` (what was
22
+ actually drawn). Posting to the PR requires explicit human approval.
23
+
24
+ **What it gets right, and what we adopt:**
25
+
26
+ | Idea | Status here |
27
+ |---|---|
28
+ | A **structured intermediate** (graph.json) instead of prose-to-pixels | Partially adopted — our route card + merged brief are the intermediate; they are checkable by criteria, though not machine-validated |
29
+ | **Validate before render** — a gate that catches agent sloppiness before the picture exists | Adopted — every sibling has its own gate (`archify finalize`, `diagram-design self_check.py`, `stack-diagram build.py`), and the router refuses to ship unverified output |
30
+ | **Provenance of what was drawn** (`drawn.graph.json`, manifest) | Adopted in spirit — the fidelity ledger reports merged/collapsed/dropped beside every artefact |
31
+ | **Diff-bounded scope** — describe only what the change touches | Adopted — `gathering.md` reads the diff's shape first and refuses to widen |
32
+ | **Human approval before posting** to a PR | Adopted — the router prepares the markdown and never posts without consent |
33
+ | Deterministic renderer (the agent never touches pixels) | **Adopted as a sibling renderer** (2026-11-06, host skill `pr-lens`) — not a replacement: it renders mechanics (blast radius, delta semantics, call structure); the editorial siblings keep the stories. Measured A/B on kpc PR #598: it won delta-consistency and the free sequence lens; it lost narrative, label placement, and any fact that must be *seen* |
34
+ | Runtime `npm install` of the toolchain | **Adopted with the supply chain pinned**: exact versions + a committed lockfile, installed by `npm ci` into `~/.cache/pr-lens` outside the skills tree — never a floating install at use time |
35
+
36
+ **Resolution (2026-11-06):** PR Lens is now installed as the host skill
37
+ `pr-lens` — wrapped, pinned, and routed to from here for the mechanics stories.
38
+ The editorial siblings keep everything narrative. The integration is the one
39
+ this file proposed: the router decides, PR Lens renders.
40
+
41
+ ## The repo's old `render-pr-diagram` (superseded)
42
+
43
+ A 48-line skill: read the diff's shape, read module docstrings, hand-write one
44
+ data-flow SVG, commit it under `docs/`, deliver it in the PR reply.
45
+
46
+ **Kept:** its reading discipline — diff shape first, the owning project's
47
+ `AGENTS.md` and module docstrings as the narrative, targeted hunks last — lives
48
+ on in `gathering.md` almost verbatim. Its hand-written-SVG path remains valid
49
+ for zero-dependency cases (that is `diagram-design`'s territory now).
50
+
51
+ **Fixed:** its delivery rule. It said to deliver "inside a fenced ```svg block —
52
+ GitHub sanitizes inline `<svg>` in comments, so the fence is the usable form."
53
+ The premise is right and the conclusion is wrong. Measured against GitHub's
54
+ **production** renderer (a tag-by-tag probe posted as a real PR comment and
55
+ parsed from the server-rendered page, 2026-11-06 — `POST /markdown` is *not*
56
+ the production renderer and must not be used to verify):
57
+
58
+ | Form | GitHub renders |
59
+ |---|---|
60
+ | fenced ` ```svg ` block | `<pre class="notranslate">` — **XML source, syntax-highlighted; not a picture** |
61
+ | inline `<svg>…</svg>` | **stripped** (on the measured strip list); only inner text survives |
62
+ | `![](/OWNER/REPO/blob/<ref>/<path>?raw=true)` | `<img src="…">` — **a picture** |
63
+
64
+ So every diagram that skill ever delivered in a fenced block showed the reader
65
+ markup, not the diagram.
@@ -0,0 +1,166 @@
1
+ # Routing matrix
2
+
3
+ How to fill the FORM slot, and where each sibling's territory actually starts and
4
+ stops. The precedence in `SKILL.md` §1 is the short version; this is the detail.
5
+
6
+ ## Sibling base directories
7
+
8
+ A sibling's files are referenced by their absolute path, never relative to this
9
+ skill — `references/<file>.md` in a sibling means something different in every sibling.
10
+
11
+ | Skill | Base directory |
12
+ |---|---|
13
+ | `archify` | `~/.agents/skills/archify/` |
14
+ | `stack-diagram` | `~/.agents/skills/stack-diagram/` |
15
+ | `diagram-design` | `~/.agents/skills/diagram-design/` |
16
+ | `pr-lens` | `~/.agents/skills/pr-lens/` |
17
+
18
+ ## Territory map
19
+
20
+ ### `archify` — software as it behaves
21
+
22
+ Ten types plus an explainer mode. It is the right choice when the subject is a
23
+ system's **structure or behaviour**, and the reader wants to understand how it
24
+ works rather than where it sits.
25
+
26
+ | Form | Use it for |
27
+ |---|---|
28
+ | `architecture` | components and connections in one snapshot; nested scopes |
29
+ | `workflow` | a sequence of steps with decisions |
30
+ | `sequence` | time-ordered messages between actors (an API call chain, a request lifecycle) |
31
+ | `dataflow` | how data moves through stages |
32
+ | `lifecycle` | phases, states, retries, terminal outcomes |
33
+ | `erd` | entities, fields, relationships |
34
+ | `tree` | hierarchy |
35
+ | `class` | classes with operations, inheritance, composition |
36
+ | `timeline` | events positioned in time |
37
+ | `waterfall` | a start total bridged to an end total by signed contributions |
38
+ | `explainer` | "explain this as a page" — a one-page answer with panels and native diagrams |
39
+
40
+ Strengths: explorable (zoom, route, lens controls), dark/light, motion, a strict
41
+ validation pipeline (`finalize` → validate / deliver / check / browser-check), and a
42
+ `guide` command that maps a scenario to a type.
43
+
44
+ Weakness: 842 KB self-contained HTML — too heavy for a PR body, and heavy to load
45
+ for a reader who only needs a picture. Export a still for sharing.
46
+
47
+ ### `stack-diagram` — where it runs
48
+
49
+ The only skill with **real brand logos**, AWS-style group containers, and
50
+ orthogonal arrows. It also produces PNG natively, which is why it is the fastest
51
+ path to a shareable image.
52
+
53
+ | Form | Use it for |
54
+ |---|---|
55
+ | cloud/infra topology | zones, VPCs, clusters, ingress, registries, object storage, GPU pods |
56
+ | service topology | which service calls which, across group boundaries |
57
+ | stack overview | a tech-stack picture with vendor marks |
58
+
59
+ Strengths: logos make the picture instantly readable; PNG output; an
60
+ AWS-region/subnet-aware drawing grammar.
61
+
62
+ Weakness: one narrow frame. If the story is *what happens in the request* rather
63
+ than *what is deployed where*, the diagram flattens — an earlier run on PR #598
64
+ collapsed a five-step inference pipeline into a single labelled edge.
65
+
66
+ ### `pr-lens` — the deterministic PR renderer
67
+
68
+ Not a design system: a **schema + validator + fixed renderer**. You author a
69
+ strict graph document (nodes with `files`+line ranges, one delta vocabulary,
70
+ honest `unchanged` neighbours); `pr-lens validate` enforces the contract;
71
+ `pr-lens render` produces identical SVGs every run, in GitHub's own light/dark
72
+ palette with delta semantics (green added, amber changed, red removed, dimmed
73
+ unchanged) and a genuine sequence data-flow lens.
74
+
75
+ | Form | Use it for |
76
+ |---|---|
77
+ | architecture (blast radius) | every tier a PR touches, with what changed and what was left alone |
78
+ | data-flow (sequence) | the change's call structure, delta-coloured |
79
+
80
+ **Choose it when the story is mechanics** — what the PR touched, added, removed,
81
+ left alone — and when the same picture must appear on every PR identically
82
+ (CI-grade). **Do not choose it when the story is the PR's argument**: it has no
83
+ field for before/after pairing, outcome taxonomies, or gate structures — those
84
+ sink into prose the SVG does not draw. Its layout engine also cannot notice an
85
+ edge label landing on a card; every render must be inspected.
86
+
87
+ Measured A/B (kpc PR #598, 2026-11-06): beat the editorial skills on delta
88
+ consistency, blast-radius honesty, and the free sequence lens; lost on
89
+ narrative, label collisions, and any fact that must be *seen* rather than
90
+ inferred. Full verdict: `references/prior-art.md`.
91
+
92
+ ### `diagram-design` — the broadest catalogue
93
+
94
+ 45 visual types and 9 semantic patterns, with an editorial design system
95
+ (Instrument Serif / Geist), a strict complexity budget, and import routes for
96
+ Mermaid, .drawio and .excalidraw.
97
+
98
+ | Group | Forms (sample) |
99
+ |---|---|
100
+ | analytical | bar, dumbbell, waterfall, line (slopegraph, ridgeline, streamgraph, bump), heatmap, treemap, marimekko, scatter (bubble, beeswarm, box plot), radar, polar, Gantt |
101
+ | behavioural | flowchart, state machine, swimlane, process, data flow, sequence, lifecycle phase map, nested, loop |
102
+ | structural | architecture, **architecture delta**, dependency graph, deployment, DP integration, DP security matrix, high-level, medallion |
103
+ | editorial | journey, service blueprint, story map, kanban, Wardley map, fishbone, quadrant, pyramid/funnel, Venn, layer stack, org chart, tree, exploded axonometric, axonometric plan, UML class, DB schema |
104
+
105
+ Two things it does that the others do not:
106
+
107
+ - **Architecture delta** — synchronized before/after topologies with a changes
108
+ ledger. This is the right form for "what did this PR change" and for any
109
+ before/after comparison; the ledger doubles as the summary.
110
+ - **Import** — hand it a Mermaid block, a .drawio file, or an .excalidraw file and
111
+ it redraws them in the editorial system.
112
+
113
+ Weakness: the complexity budget (≤9 nodes, ≤12 arrows, ≤2 accent elements) forces
114
+ compression. A dense runtime trace loses detail — in the PR #598 run it dropped a
115
+ 500-error branch and did not enumerate the outcome dialect.
116
+
117
+ ## Semantic patterns (diagram-design)
118
+
119
+ Load the sibling's pattern file — `~/.agents/skills/diagram-design/references/semantic-patterns.md`
120
+ — when *behaviour, state,
121
+ enforcement or risk* carries the meaning. The patterns override the type's
122
+ vocabulary and tighten the budget:
123
+
124
+ fan-in queue/bottleneck → data flow · stage framework with semantic slots →
125
+ process · unstructured input → structured artifact → data flow · paired policy
126
+ traces → flowchart · secure paved road → architecture · governance/control
127
+ catalog → layer stack · compensating security layers → layer stack · traceable
128
+ block decomposition → tree · lifecycle phase map → state machine.
129
+
130
+ ## Tie-breakers in practice
131
+
132
+ | The request mentions | Route to |
133
+ |---|---|
134
+ | "AWS", "GCP", "cluster", "namespace", "who talks to what service" | `stack-diagram` |
135
+ | "before and after", "what changed in this PR", "diff of the topology" | `diagram-design` (architecture delta) |
136
+ | "the request lifecycle", "the call order", "step by step", "what happens when X" | `archify` (sequence/workflow) |
137
+ | "the data", "our numbers", "trend", "breakdown", "compare these" | `diagram-design` (analytical forms) |
138
+ | "explain this to a new hire", "one page", "make it a page" | `archify` (explainer) |
139
+ | "the user journey", "our process", "the strategy", "the roadmap" | `diagram-design` |
140
+ | "convert this mermaid", "make this drawio presentable" | `diagram-design` (import) |
141
+ | "every PR gets the same diagram", "blast radius", "what did this touch and leave alone" | `pr-lens` |
142
+ | "the PR's story / before vs after / what changed *and why it matters*" | `diagram-design` (architecture delta), or `pr-lens` for mechanics + a delta overlay |
143
+ | "in the PR", "in the README", "in my terminal" | decide FORM by the story, then set CHANNEL per `references/channels.md` |
144
+
145
+ ## Choosing fidelity
146
+
147
+ | FIDELITY | Node budget | Use when |
148
+ |---|---|---|
149
+ | `faithful` | ≤24 nodes (zoned) | a reference picture; split above 24 |
150
+ | `balanced` | ≤12 | the default for a shared review |
151
+ | `simplified` | ≤7 | a PR body, a chat reply, a first impression |
152
+
153
+ Above the budget the answer is two pictures (overview + detail), not a denser one.
154
+ Audience changes wording and annotation density, never the node count.
155
+
156
+ ## The de-confliction rule
157
+
158
+ The three descriptions overlap: "architecture" is claimed by all three, and ten
159
+ type names are double-claimed. When two skills could serve the request, pick by
160
+ **the question the reader has**:
161
+
162
+ - "where does it live" → `stack-diagram`
163
+ - "what changed, mechanically" (blast radius, every run identical) → `pr-lens`; "what changed, narratively" (the argument, before/after meaning) → `diagram-design` (delta)
164
+ - "how does it work" → `archify`
165
+ - "what do the numbers say" → `diagram-design`
166
+ - "explain this as a page" → `archify` (explainer)
@@ -0,0 +1,17 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "skillId": "diagram-router",
4
+ "channel": "local",
5
+ "version": "1.0.0",
6
+ "source": {
7
+ "repository": null,
8
+ "note": "Host-built router over archify, stack-diagram and diagram-design. Design note: DESIGN-NOTE.md in this directory (the cited research this skill was built from)."
9
+ },
10
+ "license": "MIT",
11
+ "dependsOn": [
12
+ "archify",
13
+ "stack-diagram",
14
+ "diagram-design"
15
+ ],
16
+ "notes": "The router does not draw. It routes to a sibling skill; the siblings carry a handoff clause back to it."
17
+ }