@rafinery/cli 0.8.16 → 0.10.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/CHANGELOG.md +81 -0
- package/bin/rafa.mjs +11 -0
- package/blueprint/.claude/agents/atlas.md +21 -3
- package/blueprint/.claude/agents/bloom.md +2 -2
- package/blueprint/.claude/agents/prism.md +42 -3
- package/blueprint/.claude/agents/sage.md +1 -1
- package/blueprint/.claude/commands/rafa.md +24 -13
- package/blueprint/.claude/rafa/contract.md +6 -0
- package/blueprint/.claude/rafa/hooks/brain-commit.mjs +4 -0
- package/blueprint/.claude/rafa/hooks/session-start.mjs +66 -0
- package/blueprint/.claude/skills/rafa-build/SKILL.md +111 -20
- package/blueprint/.claude/skills/rafa-improve/SKILL.md +22 -0
- package/blueprint/.claude/skills/rafa-leverage/SKILL.md +6 -1
- package/blueprint/.claude/skills/rafa-plan/SKILL.md +36 -1
- package/blueprint/.claude/skills/rafa-review/SKILL.md +16 -2
- package/blueprint/.claude/skills/rafa-sage/SKILL.md +8 -2
- package/blueprint/.claude/skills/rafa-scan/SKILL.md +4 -1
- package/lib/brain-repo.mjs +1 -1
- package/lib/checkpoint.mjs +12 -10
- package/lib/distiller/doctrine.mjs +5 -16
- package/lib/doctor.mjs +19 -1
- package/lib/facts.mjs +130 -0
- package/lib/gate/compile.mjs +12 -0
- package/lib/gate/verify-citations.mjs +78 -1
- package/lib/hydrate.mjs +45 -0
- package/lib/init.mjs +9 -1
- package/lib/leverage/engine.mjs +32 -3
- package/lib/leverage.mjs +11 -2
- package/lib/loop-cache.mjs +67 -0
- package/lib/mcp-client.mjs +12 -0
- package/lib/push.mjs +9 -1
- package/lib/reflex.mjs +5 -1
- package/lib/releases.mjs +51 -0
- package/lib/review.mjs +32 -6
- package/lib/session-facts.mjs +108 -0
- package/lib/skill-deps.mjs +377 -0
- package/lib/update.mjs +9 -0
- package/package.json +3 -2
- package/skills-bundle/frontend-design/LICENSE.txt +177 -0
- package/skills-bundle/frontend-design/SKILL.md +55 -0
- package/{LICENSE → skills-bundle/grill-me/LICENSE} +6 -6
- package/skills-bundle/grill-me/SKILL.md +7 -0
- package/skills-bundle/grill-me/agents/openai.yaml +5 -0
- package/skills-bundle/grilling/SKILL.md +53 -0
- package/skills-bundle/improve-codebase-architecture/HTML-REPORT.md +123 -0
- package/skills-bundle/improve-codebase-architecture/LICENSE +21 -0
- package/skills-bundle/improve-codebase-architecture/SKILL.md +71 -0
- package/skills-bundle/improve-codebase-architecture/agents/openai.yaml +5 -0
- package/skills-bundle/requesting-code-review/LICENSE +21 -0
- package/skills-bundle/requesting-code-review/SKILL.md +95 -0
- package/skills-bundle/requesting-code-review/code-reviewer.md +172 -0
- package/skills-bundle/skills-manifest.json +72 -0
- package/skills-bundle/tdd/LICENSE +21 -0
- package/skills-bundle/tdd/SKILL.md +36 -0
- package/skills-bundle/tdd/agents/openai.yaml +3 -0
- package/skills-bundle/tdd/mocking.md +59 -0
- package/skills-bundle/tdd/tests.md +77 -0
- package/skills-bundle/vercel-composition-patterns/AGENTS.md +946 -0
- package/skills-bundle/vercel-composition-patterns/README.md +60 -0
- package/skills-bundle/vercel-composition-patterns/SKILL.md +89 -0
- package/skills-bundle/vercel-composition-patterns/metadata.json +11 -0
- package/skills-bundle/vercel-composition-patterns/rules/_sections.md +29 -0
- package/skills-bundle/vercel-composition-patterns/rules/_template.md +24 -0
- package/skills-bundle/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/skills-bundle/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
- package/skills-bundle/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/skills-bundle/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/skills-bundle/vercel-composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/skills-bundle/vercel-composition-patterns/rules/state-context-interface.md +191 -0
- package/skills-bundle/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/skills-bundle/vercel-composition-patterns/rules/state-lift-state.md +125 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Matt Pocock
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grilling
|
|
3
|
+
description: A relentless, one-question-at-a-time interview that pressure-tests a plan or design until it survives. Invoked by /grill-me, run by rafa's prism plan-gate, or used directly on any draft before committing to it.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Grilling — the adversarial interview
|
|
7
|
+
|
|
8
|
+
Authored by rafinery (wave 6) to complete the vendored `grill-me` launcher,
|
|
9
|
+
which invokes `/grilling` by name. The same procedure runs inside rafa's prism
|
|
10
|
+
plan-gate; this standalone form is for devs grilling anything by hand.
|
|
11
|
+
|
|
12
|
+
You are not here to improve the plan. You are here to find where it breaks.
|
|
13
|
+
Improvement is the author's job, after you've made the weakness undeniable.
|
|
14
|
+
|
|
15
|
+
## Rules of the interview
|
|
16
|
+
|
|
17
|
+
1. **One probe at a time.** Ask a single, concrete question; wait for the
|
|
18
|
+
answer; follow the thread before opening a new one. A barrage lets weak
|
|
19
|
+
answers hide in volume.
|
|
20
|
+
2. **Attack the plan, never the person.** Every question targets a claim,
|
|
21
|
+
dependency, or omission in the artifact — quote the exact line you're
|
|
22
|
+
probing.
|
|
23
|
+
3. **No leading the witness.** Ask what breaks it, not "have you considered
|
|
24
|
+
X?" with the fix embedded. The author finds the fix; you find the hole.
|
|
25
|
+
4. **Concrete beats abstract.** "What happens when the webhook retries twice
|
|
26
|
+
in the same second?" beats "what about concurrency?"
|
|
27
|
+
5. **Survival ends it.** Stop when the plan survives **three consecutive
|
|
28
|
+
probes** without needing a change — or when a probe forces a change, which
|
|
29
|
+
resets the count. A plan that keeps changing isn't done being grilled.
|
|
30
|
+
|
|
31
|
+
## The probe ladder (work top to bottom)
|
|
32
|
+
|
|
33
|
+
- **Grounding** — which claims rest on something verified, and which on
|
|
34
|
+
something assumed? Name the assumption; ask for its evidence.
|
|
35
|
+
- **Unstated dependencies** — what must already exist/be true for step N to
|
|
36
|
+
work, and where is that declared? (In rafa plans: a missing `blocked_by`.)
|
|
37
|
+
- **Failure modes** — for each step: what happens when it half-completes, runs
|
|
38
|
+
twice, or runs against stale state? Which failures are silent?
|
|
39
|
+
- **Vacuous acceptance** — can the Done-check/success criterion pass while the
|
|
40
|
+
feature is actually broken? A check that recomputes its expectation the way
|
|
41
|
+
the code does, or that a no-op implementation satisfies, is tautological.
|
|
42
|
+
- **YAGNI** — which parts exist because the intent needs them, and which
|
|
43
|
+
because they seemed thorough? Ask what breaks if a part is deleted.
|
|
44
|
+
- **The deletion test** — for any new module/abstraction: would deleting it
|
|
45
|
+
concentrate complexity somewhere honest, or just smear it around?
|
|
46
|
+
|
|
47
|
+
## Output
|
|
48
|
+
|
|
49
|
+
End with a verdict, not a summary: **SURVIVED** (three consecutive clean
|
|
50
|
+
probes — say which probes it survived) or **CHANGED** (list each probe that
|
|
51
|
+
forced a change, one line each, quoting the plan line it hit). Never end with
|
|
52
|
+
"looks good" — a grilling that found nothing must say which probes were run
|
|
53
|
+
and survived.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# HTML Report Format
|
|
2
|
+
|
|
3
|
+
The architectural review is rendered as a single self-contained HTML file in the OS temp directory. Tailwind and Mermaid both come from CDNs. Mermaid handles graph-shaped diagrams reliably; hand-built divs and inline SVG handle the more editorial visuals (mass diagrams, cross-sections). Mix the two — don't lean on Mermaid for everything, it'll start to look generic.
|
|
4
|
+
|
|
5
|
+
## Scaffold
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!doctype html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="utf-8" />
|
|
12
|
+
<title>Architecture review — {{repo name}}</title>
|
|
13
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
14
|
+
<script type="module">
|
|
15
|
+
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
|
|
16
|
+
mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
|
|
17
|
+
</script>
|
|
18
|
+
<style>
|
|
19
|
+
/* small custom layer for things Tailwind doesn't cover cleanly:
|
|
20
|
+
dashed seam lines, hand-drawn-feeling arrow heads, etc. */
|
|
21
|
+
.seam { stroke-dasharray: 4 4; }
|
|
22
|
+
.leak { stroke: #dc2626; }
|
|
23
|
+
.deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body class="bg-stone-50 text-slate-900 font-sans">
|
|
27
|
+
<main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
|
|
28
|
+
<header>...</header>
|
|
29
|
+
<section id="candidates" class="space-y-10">...</section>
|
|
30
|
+
<section id="top-recommendation">...</section>
|
|
31
|
+
</main>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Header
|
|
37
|
+
|
|
38
|
+
Repo name, date, and a compact legend: solid box = module, dashed line = seam, red arrow = leakage, thick dark box = deep module. No introduction paragraph — straight into the candidates.
|
|
39
|
+
|
|
40
|
+
## Candidate card
|
|
41
|
+
|
|
42
|
+
The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms (from the `/codebase-design` skill) without ceremony.
|
|
43
|
+
|
|
44
|
+
Each candidate is one `<article>`:
|
|
45
|
+
|
|
46
|
+
- **Title** — short, names the deepening (e.g. "Collapse the Order intake pipeline").
|
|
47
|
+
- **Badge row** — recommendation strength (`Strong` = emerald, `Worth exploring` = amber, `Speculative` = slate), plus a tag for the dependency category (`in-process`, `local-substitutable`, `ports & adapters`, `mock`).
|
|
48
|
+
- **Files** — monospaced list, `font-mono text-sm`.
|
|
49
|
+
- **Before / After diagram** — the centrepiece. Two columns, side by side. See patterns below.
|
|
50
|
+
- **Problem** — one sentence. What hurts.
|
|
51
|
+
- **Solution** — one sentence. What changes.
|
|
52
|
+
- **Wins** — bullets, ≤6 words each. e.g. "Tests hit one interface", "Pricing logic stops leaking", "Delete 4 shallow wrappers".
|
|
53
|
+
- **ADR callout** (if applicable) — one line in an amber-tinted box.
|
|
54
|
+
|
|
55
|
+
No paragraphs of explanation. If the diagram needs a paragraph to be understood, redraw the diagram.
|
|
56
|
+
|
|
57
|
+
## Diagram patterns
|
|
58
|
+
|
|
59
|
+
Pick the pattern that fits the candidate. Mix them. Don't make every diagram look the same — variety is part of the point.
|
|
60
|
+
|
|
61
|
+
### Mermaid graph (the workhorse for dependencies / call flow)
|
|
62
|
+
|
|
63
|
+
Use a Mermaid `flowchart` or `graph` when the point is "X calls Y calls Z, and look at the mess." Wrap it in a Tailwind-styled card so it doesn't feel parachuted in. Style with classDef to colour leakage edges red and the deep module dark. Sequence diagrams work well for "before: 6 round-trips; after: 1."
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
|
67
|
+
<pre class="mermaid">
|
|
68
|
+
flowchart LR
|
|
69
|
+
A[OrderHandler] --> B[OrderValidator]
|
|
70
|
+
B --> C[OrderRepo]
|
|
71
|
+
C -.leak.-> D[PricingClient]
|
|
72
|
+
classDef leak stroke:#dc2626,stroke-width:2px;
|
|
73
|
+
class C,D leak
|
|
74
|
+
</pre>
|
|
75
|
+
</div>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Hand-built boxes-and-arrows (when Mermaid's layout fights you)
|
|
79
|
+
|
|
80
|
+
Modules as `<div>`s with borders and labels. Arrows as inline SVG `<line>` or `<path>` elements positioned absolutely over a relative container. Reach for this when you want the "after" diagram to feel like one thick-bordered deep module with greyed-out internals — Mermaid won't render that with the right weight.
|
|
81
|
+
|
|
82
|
+
### Cross-section (good for layered shallowness)
|
|
83
|
+
|
|
84
|
+
Stack horizontal bands (`h-12 border-l-4`) to show layers a call passes through. Before: 6 thin layers each doing nothing. After: 1 thick band labelled with the consolidated responsibility.
|
|
85
|
+
|
|
86
|
+
### Mass diagram (good for "interface as wide as implementation")
|
|
87
|
+
|
|
88
|
+
Two rectangles per module — one for interface surface area, one for implementation. Before: interface rectangle is nearly as tall as the implementation rectangle (shallow). After: interface rectangle is short, implementation rectangle is tall (deep).
|
|
89
|
+
|
|
90
|
+
### Call-graph collapse
|
|
91
|
+
|
|
92
|
+
Before: a tree of function calls rendered as nested boxes. After: the same tree collapsed into one box, with the now-internal calls shown faded inside it.
|
|
93
|
+
|
|
94
|
+
## Style guidance
|
|
95
|
+
|
|
96
|
+
- Lean editorial, not corporate-dashboard. Generous whitespace. Serif optional for headings (`font-serif` works well with stone/slate).
|
|
97
|
+
- Colour sparingly: one accent (emerald or indigo) plus red for leakage and amber for warnings.
|
|
98
|
+
- Keep diagrams ~320px tall so before/after sits comfortably side by side without scrolling.
|
|
99
|
+
- Use `text-xs uppercase tracking-wider` for module labels inside diagrams — they should read as schematic, not as UI.
|
|
100
|
+
- The only scripts are the Tailwind CDN and the Mermaid ESM import. The report is otherwise static — no app code, no interactivity beyond Mermaid's own rendering.
|
|
101
|
+
|
|
102
|
+
## Top recommendation section
|
|
103
|
+
|
|
104
|
+
One larger card. Candidate name, one sentence on why, anchor link to its card. That's it.
|
|
105
|
+
|
|
106
|
+
## Tone
|
|
107
|
+
|
|
108
|
+
Plain English, concise — but the architectural nouns and verbs come straight from the `/codebase-design` skill. Concision is not an excuse to drift.
|
|
109
|
+
|
|
110
|
+
**Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
|
|
111
|
+
|
|
112
|
+
**Never substitute:** component, service, unit (for module) · API, signature (for interface) · boundary (for seam) · layer, wrapper (for module, when you mean module).
|
|
113
|
+
|
|
114
|
+
**Phrasings that fit the style:**
|
|
115
|
+
|
|
116
|
+
- "Order intake module is shallow — interface nearly matches the implementation."
|
|
117
|
+
- "Pricing leaks across the seam."
|
|
118
|
+
- "Deepen: one interface, one place to test."
|
|
119
|
+
- "Two adapters justify the seam: HTTP in prod, in-memory in tests."
|
|
120
|
+
|
|
121
|
+
**Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"* — those terms aren't in the glossary and don't earn their place.
|
|
122
|
+
|
|
123
|
+
No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in the `/codebase-design` glossary, reach for one that is before inventing a new one.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Pocock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: improve-codebase-architecture
|
|
3
|
+
description: Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Improve Codebase Architecture
|
|
8
|
+
|
|
9
|
+
Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
|
|
10
|
+
|
|
11
|
+
This command is _informed_ by the project's domain model and built on a shared design vocabulary:
|
|
12
|
+
|
|
13
|
+
- Run the `/codebase-design` skill for the architecture vocabulary (**module**, **interface**, **depth**, **seam**, **adapter**, **leverage**, **locality**) and its principles (the deletion test, "the interface is the test surface", "one adapter = hypothetical seam, two = real"). Use these terms exactly in every suggestion — don't drift into "component," "service," "API," or "boundary."
|
|
14
|
+
- The domain language in `CONTEXT.md` gives names to good seams; ADRs in `docs/adr/` record decisions this command should not re-litigate.
|
|
15
|
+
|
|
16
|
+
## Process
|
|
17
|
+
|
|
18
|
+
### 1. Explore
|
|
19
|
+
|
|
20
|
+
**Scope before you scan — YAGNI.** Deepening a module pays off by making future changes to it easier, so put extra weight on the parts of the codebase that have recently changed. Decide *where* to look before you look:
|
|
21
|
+
|
|
22
|
+
- If the user named a direction — a module, a subsystem, a pain point — take it, and skip the inference below.
|
|
23
|
+
- Otherwise, walk back a good stretch of the commit history (`git log --oneline`) to find the codebase's hot spots — the files and areas that keep coming up — and let those paths pull your attention first. If the changes are scattered with no clear hot spot, widen the net.
|
|
24
|
+
|
|
25
|
+
Read the project's domain glossary (`CONTEXT.md`) and any ADRs in the area you're touching first.
|
|
26
|
+
|
|
27
|
+
Then use the Agent tool with `subagent_type=Explore` to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
|
|
28
|
+
|
|
29
|
+
- Where does understanding one concept require bouncing between many small modules?
|
|
30
|
+
- Where are modules **shallow** — interface nearly as complex as the implementation?
|
|
31
|
+
- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
|
|
32
|
+
- Where do tightly-coupled modules leak across their seams?
|
|
33
|
+
- Which parts of the codebase are untested, or hard to test through their current interface?
|
|
34
|
+
|
|
35
|
+
Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
|
|
36
|
+
|
|
37
|
+
### 2. Present candidates as an HTML report
|
|
38
|
+
|
|
39
|
+
Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from `$TMPDIR`, falling back to `/tmp` (or `%TEMP%` on Windows), and write to `<tmpdir>/architecture-review-<timestamp>.html` so each run gets a fresh file. Open it for the user — `xdg-open <path>` on Linux, `open <path>` on macOS, `start <path>` on Windows — and tell them the absolute path.
|
|
40
|
+
|
|
41
|
+
The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
|
|
42
|
+
|
|
43
|
+
For each candidate, render a card with:
|
|
44
|
+
|
|
45
|
+
- **Files** — which files/modules are involved
|
|
46
|
+
- **Problem** — why the current architecture is causing friction
|
|
47
|
+
- **Solution** — plain English description of what would change
|
|
48
|
+
- **Benefits** — explained in terms of locality and leverage, and how tests would improve
|
|
49
|
+
- **Before / After diagram** — side-by-side, custom-drawn, illustrating the shallowness and the deepening
|
|
50
|
+
- **Recommendation strength** — one of `Strong`, `Worth exploring`, `Speculative`, rendered as a badge
|
|
51
|
+
|
|
52
|
+
End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
|
|
53
|
+
|
|
54
|
+
**Use CONTEXT.md vocabulary for the domain, and the `/codebase-design` vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
|
55
|
+
|
|
56
|
+
**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
|
57
|
+
|
|
58
|
+
See [HTML-REPORT.md](HTML-REPORT.md) for the full HTML scaffold, diagram patterns, and styling guidance.
|
|
59
|
+
|
|
60
|
+
Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"
|
|
61
|
+
|
|
62
|
+
### 3. Grilling loop
|
|
63
|
+
|
|
64
|
+
Once the user picks a candidate, run the `/grilling` skill to walk the decision tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
|
|
65
|
+
|
|
66
|
+
Side effects happen inline as decisions crystallize — run the `/domain-modeling` skill to keep the domain model current as you go:
|
|
67
|
+
|
|
68
|
+
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md`. Create the file lazily if it doesn't exist.
|
|
69
|
+
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
|
70
|
+
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones.
|
|
71
|
+
- **Want to explore alternative interfaces for the deepened module?** Run the `/codebase-design` skill and use its design-it-twice parallel sub-agent pattern.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jesse Vincent
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: requesting-code-review
|
|
3
|
+
description: Use when completing tasks, implementing major features, or before merging to verify work meets requirements
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Requesting Code Review
|
|
7
|
+
|
|
8
|
+
Dispatch a code reviewer subagent to catch issues before they cascade. The reviewer gets precisely crafted context for evaluation — never your session's history.
|
|
9
|
+
|
|
10
|
+
**Core principle:** Review early, review often.
|
|
11
|
+
|
|
12
|
+
## When to Request Review
|
|
13
|
+
|
|
14
|
+
**Mandatory:**
|
|
15
|
+
- After each task in subagent-driven development
|
|
16
|
+
- After completing major feature
|
|
17
|
+
- Before merge to main
|
|
18
|
+
|
|
19
|
+
**Optional but valuable:**
|
|
20
|
+
- When stuck (fresh perspective)
|
|
21
|
+
- Before refactoring (baseline check)
|
|
22
|
+
- After fixing complex bug
|
|
23
|
+
|
|
24
|
+
## How to Request
|
|
25
|
+
|
|
26
|
+
**1. Get git SHAs:**
|
|
27
|
+
```bash
|
|
28
|
+
BASE_SHA=$(git rev-parse HEAD~1) # or origin/main
|
|
29
|
+
HEAD_SHA=$(git rev-parse HEAD)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**2. Dispatch code reviewer subagent:**
|
|
33
|
+
|
|
34
|
+
Dispatch a `general-purpose` subagent, filling the template at [code-reviewer.md](code-reviewer.md)
|
|
35
|
+
|
|
36
|
+
**Placeholders:**
|
|
37
|
+
- `{DESCRIPTION}` - Brief summary of what you built
|
|
38
|
+
- `{PLAN_OR_REQUIREMENTS}` - What it should do
|
|
39
|
+
- `{BASE_SHA}` - Starting commit
|
|
40
|
+
- `{HEAD_SHA}` - Ending commit
|
|
41
|
+
|
|
42
|
+
**3. Act on feedback:**
|
|
43
|
+
- Fix Critical issues immediately
|
|
44
|
+
- Fix Important issues before proceeding
|
|
45
|
+
- Note Minor issues for later
|
|
46
|
+
- Push back if reviewer is wrong (with reasoning)
|
|
47
|
+
|
|
48
|
+
## Example
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
[Just completed Task 2: Add verification function]
|
|
52
|
+
|
|
53
|
+
You: Let me request code review before proceeding.
|
|
54
|
+
|
|
55
|
+
BASE_SHA=$(git log --oneline | grep "Task 1" | head -1 | awk '{print $1}')
|
|
56
|
+
HEAD_SHA=$(git rev-parse HEAD)
|
|
57
|
+
|
|
58
|
+
[Dispatch code reviewer subagent]
|
|
59
|
+
DESCRIPTION: Added verifyIndex() and repairIndex() with 4 issue types
|
|
60
|
+
PLAN_OR_REQUIREMENTS: Task 2 from docs/superpowers/plans/deployment-plan.md
|
|
61
|
+
BASE_SHA: a7981ec
|
|
62
|
+
HEAD_SHA: 3df7661
|
|
63
|
+
|
|
64
|
+
[Subagent returns]:
|
|
65
|
+
Strengths: Clean architecture, real tests
|
|
66
|
+
Issues:
|
|
67
|
+
Important: Missing progress indicators
|
|
68
|
+
Minor: Magic number (100) for reporting interval
|
|
69
|
+
Assessment: Ready to proceed
|
|
70
|
+
|
|
71
|
+
You: [Fix progress indicators]
|
|
72
|
+
[Continue to Task 3]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Common Rationalizations
|
|
76
|
+
|
|
77
|
+
| Excuse | Reality |
|
|
78
|
+
|--------|---------|
|
|
79
|
+
| "I'll just review the diff myself instead of dispatching a reviewer" | You're the coordinator — reviewing the diff inline burns the context window you need to keep driving the work. Dispatch a reviewer subagent: the diff and the evaluation live in its context, and only the findings come back to you. |
|
|
80
|
+
| "The reviewer needs my whole session history to understand the change" | Hand it precisely crafted context, never your session's history. That keeps the reviewer on the work product, not your thought process. |
|
|
81
|
+
|
|
82
|
+
## Red Flags
|
|
83
|
+
|
|
84
|
+
**Never:**
|
|
85
|
+
- Skip review because "it's simple"
|
|
86
|
+
- Ignore Critical issues
|
|
87
|
+
- Proceed with unfixed Important issues
|
|
88
|
+
- Argue with valid technical feedback
|
|
89
|
+
|
|
90
|
+
**If reviewer wrong:**
|
|
91
|
+
- Push back with technical reasoning
|
|
92
|
+
- Show code/tests that prove it works
|
|
93
|
+
- Request clarification
|
|
94
|
+
|
|
95
|
+
See template at: [code-reviewer.md](code-reviewer.md)
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Code Reviewer Prompt Template
|
|
2
|
+
|
|
3
|
+
Use this template when dispatching a code reviewer subagent.
|
|
4
|
+
|
|
5
|
+
**Purpose:** Review completed work against requirements and code quality standards before it cascades into more work.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Subagent (general-purpose):
|
|
9
|
+
description: "Review code changes"
|
|
10
|
+
prompt: |
|
|
11
|
+
You are a Senior Code Reviewer with expertise in software architecture,
|
|
12
|
+
design patterns, and best practices. Your job is to review completed work
|
|
13
|
+
against its plan or requirements and identify issues before they cascade.
|
|
14
|
+
|
|
15
|
+
## What Was Implemented
|
|
16
|
+
|
|
17
|
+
[DESCRIPTION]
|
|
18
|
+
|
|
19
|
+
## Requirements / Plan
|
|
20
|
+
|
|
21
|
+
[PLAN_OR_REQUIREMENTS]
|
|
22
|
+
|
|
23
|
+
## Git Range to Review
|
|
24
|
+
|
|
25
|
+
**Base:** [BASE_SHA]
|
|
26
|
+
**Head:** [HEAD_SHA]
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git diff --stat [BASE_SHA]..[HEAD_SHA]
|
|
30
|
+
git diff [BASE_SHA]..[HEAD_SHA]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Read-Only Review
|
|
34
|
+
|
|
35
|
+
Your review is read-only on this checkout. Do not mutate the working tree, the index, HEAD, or branch state in any way. Use tools like `git show`, `git diff`, and `git log` to inspect history. If you need a working copy of a different revision, check it out into a separate temporary directory (e.g. `git worktree add /tmp/review-[SHA] [SHA]`) — never move HEAD on this checkout.
|
|
36
|
+
|
|
37
|
+
## What to Check
|
|
38
|
+
|
|
39
|
+
**Plan alignment:**
|
|
40
|
+
- Does the implementation match the plan / requirements?
|
|
41
|
+
- Are deviations justified improvements, or problematic departures?
|
|
42
|
+
- Is all planned functionality present?
|
|
43
|
+
|
|
44
|
+
**Code quality:**
|
|
45
|
+
- Clean separation of concerns?
|
|
46
|
+
- Proper error handling?
|
|
47
|
+
- Type safety where applicable?
|
|
48
|
+
- DRY without premature abstraction?
|
|
49
|
+
- Edge cases handled?
|
|
50
|
+
|
|
51
|
+
**Architecture:**
|
|
52
|
+
- Sound design decisions?
|
|
53
|
+
- Reasonable scalability and performance?
|
|
54
|
+
- Security concerns?
|
|
55
|
+
- Integrates cleanly with surrounding code?
|
|
56
|
+
|
|
57
|
+
**Testing:**
|
|
58
|
+
- Tests verify real behavior, not mocks?
|
|
59
|
+
- Edge cases covered?
|
|
60
|
+
- Integration tests where they matter?
|
|
61
|
+
- All tests passing?
|
|
62
|
+
|
|
63
|
+
**Production readiness:**
|
|
64
|
+
- Migration strategy if schema changed?
|
|
65
|
+
- Backward compatibility considered?
|
|
66
|
+
- Documentation complete?
|
|
67
|
+
- No obvious bugs?
|
|
68
|
+
|
|
69
|
+
## Calibration
|
|
70
|
+
|
|
71
|
+
Categorize issues by actual severity. Not everything is Critical.
|
|
72
|
+
Acknowledge what was done well before listing issues — accurate praise
|
|
73
|
+
helps the implementer trust the rest of the feedback.
|
|
74
|
+
|
|
75
|
+
If you find significant deviations from the plan, flag them specifically
|
|
76
|
+
so the implementer can confirm whether the deviation was intentional.
|
|
77
|
+
If you find issues with the plan itself rather than the implementation,
|
|
78
|
+
say so.
|
|
79
|
+
|
|
80
|
+
## Output Format
|
|
81
|
+
|
|
82
|
+
### Strengths
|
|
83
|
+
[What's well done? Be specific.]
|
|
84
|
+
|
|
85
|
+
### Issues
|
|
86
|
+
|
|
87
|
+
#### Critical (Must Fix)
|
|
88
|
+
[Bugs, security issues, data loss risks, broken functionality]
|
|
89
|
+
|
|
90
|
+
#### Important (Should Fix)
|
|
91
|
+
[Architecture problems, missing features, poor error handling, test gaps]
|
|
92
|
+
|
|
93
|
+
#### Minor (Nice to Have)
|
|
94
|
+
[Code style, optimization opportunities, documentation polish]
|
|
95
|
+
|
|
96
|
+
For each issue:
|
|
97
|
+
- File:line reference
|
|
98
|
+
- What's wrong
|
|
99
|
+
- Why it matters
|
|
100
|
+
- How to fix (if not obvious)
|
|
101
|
+
|
|
102
|
+
### Recommendations
|
|
103
|
+
[Improvements for code quality, architecture, or process]
|
|
104
|
+
|
|
105
|
+
### Assessment
|
|
106
|
+
|
|
107
|
+
**Ready to merge?** [Yes | No | With fixes]
|
|
108
|
+
|
|
109
|
+
**Reasoning:** [1-2 sentence technical assessment]
|
|
110
|
+
|
|
111
|
+
## Critical Rules
|
|
112
|
+
|
|
113
|
+
**DO:**
|
|
114
|
+
- Categorize by actual severity
|
|
115
|
+
- Be specific (file:line, not vague)
|
|
116
|
+
- Explain WHY each issue matters
|
|
117
|
+
- Acknowledge strengths
|
|
118
|
+
- Give a clear verdict
|
|
119
|
+
|
|
120
|
+
**DON'T:**
|
|
121
|
+
- Say "looks good" without checking
|
|
122
|
+
- Mark nitpicks as Critical
|
|
123
|
+
- Give feedback on code you didn't actually read
|
|
124
|
+
- Be vague ("improve error handling")
|
|
125
|
+
- Avoid giving a clear verdict
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Placeholders:**
|
|
129
|
+
- `[DESCRIPTION]` — brief summary of what was built
|
|
130
|
+
- `[PLAN_OR_REQUIREMENTS]` — what it should do (plan file path, task text, or requirements)
|
|
131
|
+
- `[BASE_SHA]` — starting commit
|
|
132
|
+
- `[HEAD_SHA]` — ending commit
|
|
133
|
+
|
|
134
|
+
**Reviewer returns:** Strengths, Issues (Critical / Important / Minor), Recommendations, Assessment
|
|
135
|
+
|
|
136
|
+
## Example Output
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
### Strengths
|
|
140
|
+
- Clean database schema with proper migrations (db.ts:15-42)
|
|
141
|
+
- Comprehensive test coverage (18 tests, all edge cases)
|
|
142
|
+
- Good error handling with fallbacks (summarizer.ts:85-92)
|
|
143
|
+
|
|
144
|
+
### Issues
|
|
145
|
+
|
|
146
|
+
#### Important
|
|
147
|
+
1. **Missing help text in CLI wrapper**
|
|
148
|
+
- File: index-conversations:1-31
|
|
149
|
+
- Issue: No --help flag, users won't discover --concurrency
|
|
150
|
+
- Fix: Add --help case with usage examples
|
|
151
|
+
|
|
152
|
+
2. **Date validation missing**
|
|
153
|
+
- File: search.ts:25-27
|
|
154
|
+
- Issue: Invalid dates silently return no results
|
|
155
|
+
- Fix: Validate ISO format, throw error with example
|
|
156
|
+
|
|
157
|
+
#### Minor
|
|
158
|
+
1. **Progress indicators**
|
|
159
|
+
- File: indexer.ts:130
|
|
160
|
+
- Issue: No "X of Y" counter for long operations
|
|
161
|
+
- Impact: Users don't know how long to wait
|
|
162
|
+
|
|
163
|
+
### Recommendations
|
|
164
|
+
- Add progress reporting for user experience
|
|
165
|
+
- Consider config file for excluded projects (portability)
|
|
166
|
+
|
|
167
|
+
### Assessment
|
|
168
|
+
|
|
169
|
+
**Ready to merge: With fixes**
|
|
170
|
+
|
|
171
|
+
**Reasoning:** Core implementation is solid with good architecture and tests. Important issues (help text, date validation) are easily fixed and don't affect core functionality.
|
|
172
|
+
```
|