@jeffober/thatch 0.1.4 → 0.1.5
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/docs/dev/README.md +6 -3
- package/docs/user/README.md +64 -2
- package/package.json +1 -1
- package/src/index.ts +5 -2
- package/src/skills.ts +720 -9
package/docs/dev/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Shared core
|
|
|
18
18
|
├── git.ts → detect repo identity (store name)
|
|
19
19
|
├── hygiene.ts → hygiene report (pending dedups, stale, orphaned branches)
|
|
20
20
|
├── prompts.ts → system prompt, compaction, reminders, CLAUDE.md instructions
|
|
21
|
-
└── skills.ts → SKILL.md content + installer
|
|
21
|
+
└── skills.ts → SKILL.md content + installer (shared + opencode-only arrays)
|
|
22
22
|
|
|
23
23
|
OpenCode plugin path
|
|
24
24
|
├── index.ts → plugin entry: wires DB/model/extraction, registers tools + hooks
|
|
@@ -48,7 +48,7 @@ bin/thatch → CLI: stores|list|show|forget|search|mcp|reminder|hygi
|
|
|
48
48
|
| `embeddings.ts` | Lazy-load the embedding model. Expose `queryEmbed`/`passageEmbed` and the model `name` (stored as an informational tag). `MockEmbeddingModel` for tests. |
|
|
49
49
|
| `extraction.ts` | Buffers non-thatch tool interactions per session and serializes them into the JSON payload the extraction nudge carries. (opencode-only — no MCP equivalent.) |
|
|
50
50
|
| `prompts.ts` | Text constants: opencode system prompt, compaction context, session-start reminder, Claude Code CLAUDE.md instructions, Claude Code hook text. |
|
|
51
|
-
| `skills.ts` | `SKILL.md` content for `
|
|
51
|
+
| `skills.ts` | `SKILL.md` content for all thatch skills, plus the installer. Skills are split into `SHARED_SKILLS` (10 skills: fact-extractor, dedup-classifier, project-primer, 5 review specialists, review synthesizer, session reflection — work on both opencode and Claude Code) and `OPENCODE_ONLY_SKILLS` (1 skill: code-review coordinator — requires sub-agent support, not installed for Claude Code). `installSkills(dir, skills)` defaults to `SHARED_SKILLS`; the opencode plugin passes `[...SHARED_SKILLS, ...OPENCODE_ONLY_SKILLS]`. |
|
|
52
52
|
|
|
53
53
|
## Plugin hooks
|
|
54
54
|
|
|
@@ -85,7 +85,10 @@ Two of these hooks were dead for weeks because failures were invisible.
|
|
|
85
85
|
7. **Skills are plugin-owned files.** Installed to
|
|
86
86
|
`$XDG_CONFIG_HOME/opencode/skills` (opencode) or `~/.claude/skills/`
|
|
87
87
|
(Claude Code) — never into the worktree; drifted content is overwritten
|
|
88
|
-
on plugin init or re-running `thatch setup`.
|
|
88
|
+
on plugin init or re-running `thatch setup`. Skills are split into
|
|
89
|
+
`SHARED_SKILLS` (work on both hosts) and `OPENCODE_ONLY_SKILLS` (require
|
|
90
|
+
sub-agent support, not installed for Claude Code). The opencode plugin
|
|
91
|
+
installs both arrays; `thatch setup --claude` installs only shared.
|
|
89
92
|
8. **Tool definitions are the single source of truth.** `tool-defs.ts` defines
|
|
90
93
|
each tool once (name, zod schema, execute function). The opencode plugin
|
|
91
94
|
wraps them in `tool()` with a `thatch_` prefix; the MCP server wraps them
|
package/docs/user/README.md
CHANGED
|
@@ -82,13 +82,75 @@ Beyond the tools, thatch hooks into opencode itself:
|
|
|
82
82
|
|
|
83
83
|
## Skills
|
|
84
84
|
|
|
85
|
-
On startup thatch installs
|
|
86
|
-
(`~/.config/opencode/skills/`, or `$XDG_CONFIG_HOME/opencode/skills`)
|
|
85
|
+
On startup thatch installs [skills] into your global opencode config
|
|
86
|
+
(`~/.config/opencode/skills/`, or `$XDG_CONFIG_HOME/opencode/skills`).
|
|
87
|
+
When using `thatch setup --claude`, skills are installed to `~/.claude/skills/`
|
|
88
|
+
(or `$CLAUDE_CONFIG_DIR/skills/`).
|
|
89
|
+
|
|
90
|
+
### Memory skills
|
|
87
91
|
|
|
88
92
|
| Skill | Purpose |
|
|
89
93
|
|-------|---------|
|
|
90
94
|
| `thatch-fact-extractor` | Guides the agent through turning buffered tool interactions into memories. |
|
|
91
95
|
| `thatch-dedup-classifier` | Guides the agent through classifying and resolving duplicate-candidate pairs. |
|
|
96
|
+
| `thatch-project-primer` | Investigates a new project from multiple angles and writes foundational memories. |
|
|
97
|
+
| `thatch-session-reflection` | End-of-session skill for recording what was learned about the project, user, tools, and self. |
|
|
98
|
+
|
|
99
|
+
### Code review skills
|
|
100
|
+
|
|
101
|
+
Five specialist review lenses, each a self-contained static-analysis pass:
|
|
102
|
+
|
|
103
|
+
| Skill | Focus |
|
|
104
|
+
|-------|-------|
|
|
105
|
+
| `thatch-review-pedantic` | Mechanical correctness: spelling, naming, doc accuracy, specs, guidelines, stale artifacts. |
|
|
106
|
+
| `thatch-review-acceptance` | Behavioral/product review: UX coherency, behavioral delta, integration effects, user assumptions. |
|
|
107
|
+
| `thatch-review-state-flow` | Data flow and contracts: module boundaries, implicit state machines, error propagation, separation of concerns. |
|
|
108
|
+
| `thatch-review-no-slop` | AI writing anti-patterns: change narration, fourth wall breaks, em dashes, hedging, filler. |
|
|
109
|
+
| `thatch-review-breadcrumbs` | Comment narrative: do comments form a coherent outline of the code's behavior? |
|
|
110
|
+
| `thatch-review-synthesizer` | Verifies and synthesizes findings from multiple specialists into a single deduplicated, severity-grouped report. |
|
|
111
|
+
|
|
112
|
+
### opencode-only skills
|
|
113
|
+
|
|
114
|
+
| Skill | Purpose |
|
|
115
|
+
|-------|---------|
|
|
116
|
+
| `thatch-code-review` | Multi-agent review coordinator. Dispatches parallel sub-agents for triage, decomposition, specialist fan-out, and synthesis. Not available in Claude Code (requires sub-agent support). |
|
|
117
|
+
|
|
118
|
+
### Host availability
|
|
119
|
+
|
|
120
|
+
| Skill | opencode | Claude Code |
|
|
121
|
+
|-------|----------|-------------|
|
|
122
|
+
| Memory skills (4) | Yes | Yes |
|
|
123
|
+
| Review specialists (5) | Yes | Yes |
|
|
124
|
+
| Review synthesizer | Yes | Yes |
|
|
125
|
+
| Code review coordinator | Yes | No (requires sub-agents) |
|
|
126
|
+
|
|
127
|
+
### Using review skills
|
|
128
|
+
|
|
129
|
+
For a **quick single-lens review**, load any specialist skill directly and
|
|
130
|
+
point it at a branch or commit range:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
Load thatch-review-pedantic and review the changes on this branch.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
For a **full multi-specialist review on opencode**, load the coordinator:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Load thatch-code-review and review branch feature-x.
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The coordinator will triage the change, dispatch parallel sub-agents (one per
|
|
143
|
+
specialist lens), and synthesize a final report.
|
|
144
|
+
|
|
145
|
+
For a **full review on Claude Code** (or without the coordinator), run each
|
|
146
|
+
specialist in sequence, then synthesize:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
1. Load thatch-review-pedantic, review branch feature-x, report findings.
|
|
150
|
+
2. Load thatch-review-acceptance, review the same branch.
|
|
151
|
+
3. ... repeat for state-flow, no-slop, breadcrumbs ...
|
|
152
|
+
4. Load thatch-review-synthesizer, verify and aggregate all findings.
|
|
153
|
+
```
|
|
92
154
|
|
|
93
155
|
These files are plugin-owned: local edits are overwritten the next time the
|
|
94
156
|
plugin initializes (this is how skill improvements ship with new versions).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffober/thatch",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Persistent memory for AI coding agents — local embeddings, SQLite stores, zero config. Works with OpenCode (as a plugin) and Claude Code (as an MCP server).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
sessionStartReminder,
|
|
11
11
|
} from "./prompts";
|
|
12
12
|
import { ExtractionPipeline } from "./extraction";
|
|
13
|
-
import { installSkills } from "./skills";
|
|
13
|
+
import { installSkills, SHARED_SKILLS, OPENCODE_ONLY_SKILLS } from "./skills";
|
|
14
14
|
import { hygieneReport } from "./hygiene";
|
|
15
15
|
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
@@ -34,7 +34,10 @@ export const server: Plugin = async ({ client, worktree }) => {
|
|
|
34
34
|
// worktree would mutate the user's repo (untracked files in git status).
|
|
35
35
|
// A failed install degrades the nudge workflow but must not kill the plugin.
|
|
36
36
|
try {
|
|
37
|
-
installSkills(join(configHome, "opencode", "skills")
|
|
37
|
+
installSkills(join(configHome, "opencode", "skills"), [
|
|
38
|
+
...SHARED_SKILLS,
|
|
39
|
+
...OPENCODE_ONLY_SKILLS,
|
|
40
|
+
]);
|
|
38
41
|
} catch (err) {
|
|
39
42
|
console.error(`[thatch] skill install failed: ${err}`);
|
|
40
43
|
}
|
package/src/skills.ts
CHANGED
|
@@ -7,17 +7,29 @@ export interface SkillFile {
|
|
|
7
7
|
content: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface SkillDef {
|
|
11
|
+
name: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Writes thatch skill files into the given skills directory. Called at plugin
|
|
12
|
-
* init — idempotent, and rewrites a skill
|
|
13
|
-
* plugin upgrades propagate. These files
|
|
14
|
-
* overwritten on next init.
|
|
17
|
+
* init and during `thatch setup --claude` — idempotent, and rewrites a skill
|
|
18
|
+
* whose on-disk content has drifted so plugin upgrades propagate. These files
|
|
19
|
+
* are plugin-owned: local edits are overwritten on next init.
|
|
20
|
+
*
|
|
21
|
+
* Defaults to SHARED_SKILLS (works on both opencode and Claude Code). Pass
|
|
22
|
+
* OPENCODE_ONLY_SKILLS (or a combined array) for the opencode plugin path,
|
|
23
|
+
* which can use sub-agent-based skills that Claude Code cannot run.
|
|
15
24
|
*/
|
|
16
|
-
export function installSkills(
|
|
25
|
+
export function installSkills(
|
|
26
|
+
skillsDir: string,
|
|
27
|
+
skills: SkillDef[] = SHARED_SKILLS,
|
|
28
|
+
): SkillFile[] {
|
|
17
29
|
mkdirSync(skillsDir, { recursive: true });
|
|
18
30
|
const written: SkillFile[] = [];
|
|
19
31
|
|
|
20
|
-
for (const skill of
|
|
32
|
+
for (const skill of skills) {
|
|
21
33
|
const dir = join(skillsDir, skill.name);
|
|
22
34
|
const file = join(dir, "SKILL.md");
|
|
23
35
|
|
|
@@ -38,6 +50,52 @@ export function installSkills(skillsDir: string): SkillFile[] {
|
|
|
38
50
|
return written;
|
|
39
51
|
}
|
|
40
52
|
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
// Shared review framework — interpolated into each specialist skill
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
const REVIEW_COMMON = `
|
|
58
|
+
## Static analysis only
|
|
59
|
+
You review code by reading it. Do NOT run tests, linters, compilers, or any build commands. Do NOT execute the code under review.
|
|
60
|
+
|
|
61
|
+
## Scope gathering
|
|
62
|
+
Before reviewing, identify what to review:
|
|
63
|
+
1. If a git range, branch, or PR was specified, use that target.
|
|
64
|
+
2. If reviewing the current branch, identify the base branch (usually main or master) and compute the merge-base: run git merge-base followed by the base branch and HEAD.
|
|
65
|
+
3. Run git diff --stat on the resolved range to identify changed files.
|
|
66
|
+
4. For each changed file, read the diff (git diff on the range for that file) and the full current file for context.
|
|
67
|
+
5. Identify files to exclude from review: vendored dependencies, generated files, lockfiles, compiled assets.
|
|
68
|
+
|
|
69
|
+
## Runtime model
|
|
70
|
+
Identify the application's runtime model early: Is it a CLI tool (process exits after each invocation)? A long-lived server (state persists across requests)? A library (caller controls lifecycle)? A batch job? This determines which classes of bugs are realistic — for example, "state not cleaned up" is irrelevant in a short-lived process but critical in a server.
|
|
71
|
+
|
|
72
|
+
## Reachability gate
|
|
73
|
+
For every potential finding, you MUST describe a concrete scenario where a real user triggers the problem through normal usage. "The code allows this" is not sufficient — show how a user actually encounters it given the application's runtime model. If the only trigger requires conditions that cannot occur in actual usage, it is not a finding.
|
|
74
|
+
|
|
75
|
+
## Intent verification
|
|
76
|
+
Before flagging behavior as a bug, verify intent:
|
|
77
|
+
1. **Trace callers.** Read every caller of the cited code. The behavior may be intentional given how the feature is actually used.
|
|
78
|
+
2. **Check git history.** Use git log, git blame, or git log -S to find commit messages explaining why the code was written this way.
|
|
79
|
+
3. **Check memories.** Use thatch_memory_recall to search for documented design decisions or known limitations related to the code area.
|
|
80
|
+
|
|
81
|
+
If any of these reveals the behavior is intentional, it is not a finding. If you cannot determine intent after all three steps, you may report it — but note that you could not confirm whether the behavior is intentional.
|
|
82
|
+
|
|
83
|
+
## Output format
|
|
84
|
+
Produce findings as markdown. For each finding:
|
|
85
|
+
|
|
86
|
+
### [SEVERITY] [CATEGORY] — file:line
|
|
87
|
+
- **Finding**: what the problem is
|
|
88
|
+
- **Evidence**: exact code quoted from the cited location (copy-paste, do not paraphrase)
|
|
89
|
+
- **Trigger**: concrete normal-usage scenario, or "N/A — mechanical finding"
|
|
90
|
+
- **Reachability**: why this is reachable in real usage, or why it is not
|
|
91
|
+
- **Source of truth**: authoritative source for the claim (producer, caller contract, behavior, guideline, docs)
|
|
92
|
+
- **Producer chain**: producer then transform then consumer, or "N/A — mechanical finding"
|
|
93
|
+
- **Provenance**: branch-introduced or pre-existing
|
|
94
|
+
|
|
95
|
+
Severities: BLOCKING > HIGH > MEDIUM > LOW.
|
|
96
|
+
If no findings, say so explicitly. Do NOT report issues in files you did not actually read. Do NOT report "likely similar issues exist" without evidence.
|
|
97
|
+
`;
|
|
98
|
+
|
|
41
99
|
// ---------------------------------------------------------------------------
|
|
42
100
|
// Skill definitions
|
|
43
101
|
// ---------------------------------------------------------------------------
|
|
@@ -63,16 +121,44 @@ You will be given a JSON payload with:
|
|
|
63
121
|
|
|
64
122
|
## What to extract
|
|
65
123
|
|
|
66
|
-
|
|
124
|
+
**Project architecture and design:**
|
|
125
|
+
- Project purpose and goals
|
|
126
|
+
- Overall design and architecture
|
|
127
|
+
- Applications and components, their locations, and dependencies
|
|
128
|
+
- How apps/components interact and integrate
|
|
129
|
+
- Repo/app layout and organization
|
|
130
|
+
- Domain-specific terminology
|
|
131
|
+
|
|
132
|
+
**Languages, frameworks, and technologies:**
|
|
133
|
+
- Languages, frameworks, and technologies used
|
|
134
|
+
- Build tools, package managers, runtime environment
|
|
135
|
+
- Deployment or runtime details
|
|
136
|
+
|
|
137
|
+
**Conventions and patterns:**
|
|
138
|
+
- Coding, style, and testing conventions
|
|
139
|
+
- Naming patterns and organizational structures
|
|
140
|
+
- Code style preferences (formatting, indentation, module structure)
|
|
141
|
+
|
|
142
|
+
**Gotchas and pitfalls:**
|
|
67
143
|
- Non-obvious gotchas and pitfalls (especially ones that took time to debug)
|
|
144
|
+
- "Always check X before doing Y" type advice
|
|
145
|
+
- "The user prefers Z" type advice
|
|
146
|
+
- Bug shapes: the abstract pattern behind a fix, not the specific bug context
|
|
147
|
+
|
|
148
|
+
**Useful commands and workflows:**
|
|
149
|
+
- Project-specific commands and command sequences for common tasks
|
|
150
|
+
- Project-specific scripts and internal tools, their purpose, and useful invocations
|
|
151
|
+
- Prompting patterns that succeed or fail with coding tools (e.g., "when using the edit tool, always use referential anchors like 'above the function foo'")
|
|
152
|
+
|
|
153
|
+
**User preferences and environment:**
|
|
68
154
|
- User preferences, communication style, explicit corrections, pet peeves
|
|
69
155
|
- Shell/environment quirks (tool friction, missing commands, platform issues)
|
|
70
|
-
-
|
|
156
|
+
- Details about the user's expertise and experience level
|
|
71
157
|
|
|
72
158
|
## Store assignment
|
|
73
159
|
|
|
74
160
|
- global store: user preferences, personality traits, communication style, environment quirks
|
|
75
|
-
- Project store: architecture, conventions, patterns, project-specific gotchas
|
|
161
|
+
- Project store: architecture, conventions, patterns, project-specific gotchas, useful commands
|
|
76
162
|
|
|
77
163
|
## Writing good memories
|
|
78
164
|
|
|
@@ -186,8 +272,633 @@ You are the Thatch Project Primer. Your job: investigate this project thoroughly
|
|
|
186
272
|
|
|
187
273
|
Tell the user what you learned and which memories you wrote. Suggest they run thatch_find_duplicates if the store feels crowded.`;
|
|
188
274
|
|
|
189
|
-
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
// Review specialist skills (5) — each a standalone review lens
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
|
|
279
|
+
const REVIEW_PEDANTIC = `---
|
|
280
|
+
name: thatch-review-pedantic
|
|
281
|
+
description: Mechanical correctness code review — spelling, naming, doc accuracy, specs, guidelines, stale artifacts. Use for post-implementation review of a branch, PR, or commit range.
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
You are a pedantic review agent. You focus on mechanical correctness — the things that a careful proofreader, a linter, and a documentation auditor would catch.
|
|
285
|
+
${REVIEW_COMMON}
|
|
286
|
+
## Your focus
|
|
287
|
+
|
|
288
|
+
You care about:
|
|
289
|
+
- **Spelling and grammar** in comments, docs, error messages, UI strings
|
|
290
|
+
- **Naming consistency** across the changes (e.g. module renamed but references to old name remain in comments, docs, specs, or error messages)
|
|
291
|
+
- **Dead references** (mentions of functions, modules, or files that no longer exist after the changes)
|
|
292
|
+
- **Doc accuracy** (do moduledocs, docstrings, README, and inline comments correctly describe the current behavior, or do they describe the old behavior?)
|
|
293
|
+
- **Code comment accuracy** (do comments describe what the code actually does?)
|
|
294
|
+
- **Project style guidelines** (read AGENTS.md, CLAUDE.md, CONTRIBUTING.md, or equivalent project guidelines and check adherence)
|
|
295
|
+
- **Spec/type annotation completeness** (do new public functions have type annotations? Do changed function signatures have updated specs? When investigating contracts, find the source of truth for the interface — the spec may be defined on a behaviour, interface, trait, protocol, or abstract base class rather than the implementation.)
|
|
296
|
+
- **Formatting consistency** (indentation, blank lines, module attribute ordering)
|
|
297
|
+
- **Stale artifacts** (TODO comments that reference completed work, commented-out code, debug prints left behind)
|
|
298
|
+
|
|
299
|
+
You do NOT care about:
|
|
300
|
+
- Whether the code is correct (other reviewers handle logic)
|
|
301
|
+
- UX or behavioral concerns
|
|
302
|
+
- Architecture or design decisions
|
|
303
|
+
- Test quality or coverage
|
|
304
|
+
|
|
305
|
+
## Method
|
|
306
|
+
|
|
307
|
+
1. Read the project guidelines (AGENTS.md, CLAUDE.md, or equivalent) if they exist.
|
|
308
|
+
2. Use the diff stat from your scope gathering to identify changed files.
|
|
309
|
+
3. For EVERY code-bearing changed file:
|
|
310
|
+
- Read the diff for that file
|
|
311
|
+
- Read the full current file for doc/comment accuracy in context
|
|
312
|
+
4. For each changed file, check systematically:
|
|
313
|
+
- Comments: accurate? stale? describe the code, not the change?
|
|
314
|
+
- Docs: moduledocs and docstrings match current behavior?
|
|
315
|
+
- Naming: consistent with project conventions and the rest of the changes?
|
|
316
|
+
- Specs/types: present for new public functions? Updated for changed signatures? Find the source of truth for each interface before flagging.
|
|
317
|
+
- Style: follows project guidelines?
|
|
318
|
+
- Dead references: mentions of old names, removed functions, deleted files?
|
|
319
|
+
5. Cross-reference docs with code: verify that documentation matches implementation.
|
|
320
|
+
|
|
321
|
+
## Materiality and source of truth
|
|
322
|
+
|
|
323
|
+
Do not flag a spec, doc, or naming issue until you identify the authoritative source of truth for the claim: the owning behavior, public contract, guideline, docs layer, or user-visible string.
|
|
324
|
+
|
|
325
|
+
Prefer concrete mismatches over theoretical ones. If the implementation looks odd in isolation but callers, contracts, or owning docs show it is correct, do not report it.
|
|
326
|
+
|
|
327
|
+
## Category taxonomy
|
|
328
|
+
|
|
329
|
+
- **STALE**: Docs, comments, or references describing old behavior or referencing removed things
|
|
330
|
+
- **GUIDELINE**: Violations of project style guidelines (cite the guideline and the violation)
|
|
331
|
+
- **SPEC**: Missing or incorrect type annotations/specs on public functions
|
|
332
|
+
- **TYPO**: Spelling or grammar errors in user-visible strings, docs, or comments
|
|
333
|
+
- **ARTIFACT**: Debug prints, commented-out code, TODOs referencing completed work
|
|
334
|
+
|
|
335
|
+
Do NOT report issues in files you did not actually read.
|
|
336
|
+
`;
|
|
337
|
+
|
|
338
|
+
const REVIEW_ACCEPTANCE = `---
|
|
339
|
+
name: thatch-review-acceptance
|
|
340
|
+
description: Behavioral and product-level code review — UX coherency, behavioral delta, integration effects, user assumptions. Use for post-implementation review of a branch, PR, or commit range.
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
You are an acceptance and product review agent. You evaluate code changes from the perspective of a user and a product designer — not a compiler.
|
|
344
|
+
${REVIEW_COMMON}
|
|
345
|
+
## Your focus
|
|
346
|
+
|
|
347
|
+
You care about:
|
|
348
|
+
- **Behavioral delta**: What did the code do before? What does it do now? Is the change intentional and complete, or does it leave inconsistencies?
|
|
349
|
+
- **UX coherency**: Will users find this easy to use? Will the interface surprise them? Are error messages helpful? Do success messages lie? Consider the workflow(s) affected by this change. Reason through the steps the user will take, and whether the overall workflow minimizes friction and walks the user through unavoidable complexities.
|
|
350
|
+
- **Integration effects**: How do these changes interact with other features? Could they alter behavior of existing workflows the user relies on?
|
|
351
|
+
- **User assumptions**: How will users misunderstand this interface? What will they try that won't work? What mental model will they build, and will it be correct?
|
|
352
|
+
- **Friction in common cases**: Are the happy paths smooth? Do common operations require unnecessary steps or knowledge of internals?
|
|
353
|
+
|
|
354
|
+
You do NOT care about:
|
|
355
|
+
- Code style, spelling, formatting, or naming conventions
|
|
356
|
+
- Type specs, dialyzer, or linting concerns
|
|
357
|
+
- Internal data structures, unless they leak into user-visible behavior
|
|
358
|
+
- Test coverage
|
|
359
|
+
|
|
360
|
+
## Method
|
|
361
|
+
|
|
362
|
+
### 1. Understand the before-state
|
|
363
|
+
Before reading the new code, establish what existed before:
|
|
364
|
+
- For modified files, use git show with the base commit to read the ORIGINAL version.
|
|
365
|
+
- Understand the original behavior, interface, and user experience.
|
|
366
|
+
|
|
367
|
+
This is critical. You cannot evaluate a behavioral change if you don't know the original behavior.
|
|
368
|
+
|
|
369
|
+
### 2. Understand the after-state
|
|
370
|
+
Read the current code. Map the new behavior, interfaces, and user-facing outputs.
|
|
371
|
+
|
|
372
|
+
### 3. Reason about the delta
|
|
373
|
+
For each significant behavioral change:
|
|
374
|
+
- What was the old behavior? What is the new behavior?
|
|
375
|
+
- Is this change intentional (does it align with the stated design)?
|
|
376
|
+
- Is it complete (are there places where old behavior leaks through)?
|
|
377
|
+
- Does it create inconsistencies with other features or interfaces?
|
|
378
|
+
|
|
379
|
+
### 4. Walk the user journey
|
|
380
|
+
For each user-facing feature touched by the changes:
|
|
381
|
+
- What does a new user try first? Does it work?
|
|
382
|
+
- What does an experienced user expect? Does it match?
|
|
383
|
+
- When something goes wrong, does the error guide the user to recovery?
|
|
384
|
+
- Are there silent failures (operation "succeeds" but does nothing)?
|
|
385
|
+
|
|
386
|
+
### 5. Check integration boundaries
|
|
387
|
+
- Do other features depend on the changed behavior?
|
|
388
|
+
- Could the change break workflows that span multiple features?
|
|
389
|
+
- Are there shared resources (config, state, files) where the change creates new conflicts or race conditions visible to users?
|
|
390
|
+
|
|
391
|
+
### 6. Prove the workflow inputs
|
|
392
|
+
For any finding that depends on bad state, malformed data, or surprising cross-feature behavior, identify:
|
|
393
|
+
- Which user action or entrypoint starts the workflow
|
|
394
|
+
- Which code path produces the relevant state/data
|
|
395
|
+
- Which steps transform it before the failure
|
|
396
|
+
- Why current guards, validation, or surrounding workflow do not prevent it
|
|
397
|
+
|
|
398
|
+
If the issue only exists when someone manually fabricates invalid state/data outside the normal workflow, it is not a real finding.
|
|
399
|
+
|
|
400
|
+
## Category taxonomy
|
|
401
|
+
|
|
402
|
+
- **FRICTION**: Common use case is harder/slower/more confusing than it should be
|
|
403
|
+
- **INCONSISTENCY**: Mismatch with existing behavior, conventions, or user expectations
|
|
404
|
+
- **SILENT_FAILURE**: Operation appears to succeed but doesn't do what user expects
|
|
405
|
+
- **BREAKING**: Previously working workflow is now broken or produces wrong results
|
|
406
|
+
|
|
407
|
+
Report findings as behavioral observations, not code complaints. Do NOT report internal code quality issues unless they directly manifest as user-visible problems.
|
|
408
|
+
`;
|
|
409
|
+
|
|
410
|
+
const REVIEW_STATE_FLOW = `---
|
|
411
|
+
name: thatch-review-state-flow
|
|
412
|
+
description: Data flow and contract code review — module boundaries, implicit state machines, error propagation, separation of concerns. Use for post-implementation review of a branch, PR, or commit range.
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
You are a state and data flow review agent. You focus on mid-level architecture: how data flows through the system, the implicit contracts between components, and whether the code's structure supports correctness, testability, and maintainability.
|
|
416
|
+
${REVIEW_COMMON}
|
|
417
|
+
## Your focus
|
|
418
|
+
|
|
419
|
+
You care about:
|
|
420
|
+
- **Data flow coherency**: Does data transform correctly as it passes between modules? Are there type mismatches, dropped fields, or shape changes that break downstream consumers?
|
|
421
|
+
- **Implicit state machines**: Many workflows have implicit states (e.g. "project selected then skill loaded then skill validated then skill executed"). Are state transitions guarded? Can you reach an invalid state?
|
|
422
|
+
- **Contracts between modules**: When module A calls module B, what does A assume about B's return value, side effects, and error shapes? Are those assumptions documented or enforced? Could a change to B silently break A?
|
|
423
|
+
- **Separation of concerns**: Does each module own a single responsibility? Do the changes introduce coupling between modules that should be independent?
|
|
424
|
+
- **Testability**: Can each component be tested in isolation? Do the changes introduce dependencies that make testing harder?
|
|
425
|
+
- **Error propagation**: Do errors flow correctly through the call chain? Are there places where an error is swallowed, wrapped ambiguously, or converted to a success?
|
|
426
|
+
|
|
427
|
+
You do NOT care about:
|
|
428
|
+
- User experience or interface design
|
|
429
|
+
- Spelling, formatting, or style
|
|
430
|
+
- Whether the feature is a good idea
|
|
431
|
+
|
|
432
|
+
## Method
|
|
433
|
+
|
|
434
|
+
### 1. Map the change set
|
|
435
|
+
Use the diff stat from your scope gathering to identify which modules are touched. Categorize them by role: entry points, core logic, persistence, config, glue.
|
|
436
|
+
|
|
437
|
+
### 2. For each module boundary, trace the contract
|
|
438
|
+
Read both sides of every call that crosses a module boundary:
|
|
439
|
+
- What does the caller pass?
|
|
440
|
+
- What does the callee accept? (function head, type annotations, guards)
|
|
441
|
+
- What does the callee return? (read the implementation, not just the type annotation)
|
|
442
|
+
- What does the caller do with the return value?
|
|
443
|
+
- Does the caller handle all possible return shapes?
|
|
444
|
+
|
|
445
|
+
Do NOT assume contracts match. Read both sides and verify.
|
|
446
|
+
|
|
447
|
+
### 3. Trace at least two end-to-end paths
|
|
448
|
+
Pick the two most important runtime paths through the changed code:
|
|
449
|
+
- The primary happy path
|
|
450
|
+
- The most important error/failure path
|
|
451
|
+
|
|
452
|
+
For each, walk through actual function calls, tracking data shape at each step.
|
|
453
|
+
|
|
454
|
+
### 4. Prove the producer chain
|
|
455
|
+
For every finding about invalid state, missing data, shape mismatches, or cross-module behavior, trace the full causal chain:
|
|
456
|
+
- Who produces the state or value?
|
|
457
|
+
- Which functions transform it?
|
|
458
|
+
- Which consumer or branch fails?
|
|
459
|
+
- Which real entrypoint/workflow exercises that chain?
|
|
460
|
+
|
|
461
|
+
If you cannot identify a real producer in current code, or the only way to trigger the issue is by manually fabricating invalid state/data, do not report it as a real finding.
|
|
462
|
+
|
|
463
|
+
### 5. Identify the implicit FSM
|
|
464
|
+
For any workflow introduced or modified:
|
|
465
|
+
- What are the states?
|
|
466
|
+
- What are the transitions?
|
|
467
|
+
- What guards the transitions?
|
|
468
|
+
- Can you reach a state without going through required transitions?
|
|
469
|
+
- Can you get stuck in a state with no valid transitions?
|
|
470
|
+
|
|
471
|
+
### 6. Check error paths specifically
|
|
472
|
+
For every conditional chain, case branch, or pipeline in the changed code:
|
|
473
|
+
- What happens when each step fails?
|
|
474
|
+
- Does the error reach a handler that can do something useful?
|
|
475
|
+
- Are errors distinguishable?
|
|
476
|
+
- Are there catch-all handlers that swallow specific information?
|
|
477
|
+
|
|
478
|
+
### 7. Evaluate separation of concerns
|
|
479
|
+
For each new module or significant change:
|
|
480
|
+
- Does this module have a single, clear responsibility?
|
|
481
|
+
- Does it know too much about other modules' internals?
|
|
482
|
+
- Could a change to this module's internals break other modules?
|
|
483
|
+
|
|
484
|
+
## Category taxonomy
|
|
485
|
+
|
|
486
|
+
- **CONTRACT_MISMATCH**: Caller assumes a return shape/error type/behavior not guaranteed by callee
|
|
487
|
+
- **STATE_VIOLATION**: Workflow can reach invalid state, skip required transition, or get stuck
|
|
488
|
+
- **ERROR_SWALLOWED**: Error caught/converted/ignored losing information needed upstream
|
|
489
|
+
- **COUPLING**: Module depends on another module's internals in a fragile way
|
|
490
|
+
- **DEAD_PATH**: Code path exists but cannot be reached given current callers/preconditions
|
|
491
|
+
|
|
492
|
+
For each finding, cite both sides of any contract (file:line for caller and callee).
|
|
493
|
+
`;
|
|
494
|
+
|
|
495
|
+
const REVIEW_NO_SLOP = `---
|
|
496
|
+
name: thatch-review-no-slop
|
|
497
|
+
description: AI writing anti-pattern detection — change narration comments, fourth wall breaks, em dashes, hedging, filler, stale instruction artifacts. Use for post-implementation review of a branch, PR, or commit range.
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
You are a slop detection agent. Your sole job is to find AI-generated writing anti-patterns in code comments, documentation, error messages, and UI strings.
|
|
501
|
+
${REVIEW_COMMON}
|
|
502
|
+
## What is slop?
|
|
503
|
+
|
|
504
|
+
Slop is text that was clearly written by an AI assistant rather than a human developer. It erodes trust and makes the codebase feel uncurated. Slop falls into these categories:
|
|
505
|
+
|
|
506
|
+
### Change narration
|
|
507
|
+
Comments that describe the change being made rather than the code's behavior:
|
|
508
|
+
- "Added error handling for the new validation step"
|
|
509
|
+
- "Updated to use the new API endpoint"
|
|
510
|
+
- "Refactored to improve performance"
|
|
511
|
+
- "Modified to support the new feature"
|
|
512
|
+
These describe git history, not code. They are useless after the PR merges.
|
|
513
|
+
|
|
514
|
+
### Fourth wall breaks
|
|
515
|
+
Comments that reference the AI, the user, or the conversation:
|
|
516
|
+
- "As requested by the user..."
|
|
517
|
+
- "Per our discussion..."
|
|
518
|
+
- "I've added..." / "We need to..."
|
|
519
|
+
- "This was changed because the user wanted..."
|
|
520
|
+
|
|
521
|
+
### AI writing style tells
|
|
522
|
+
- Typography, when not part of visible UI output (eg in code, comments, or docstrings):
|
|
523
|
+
- Em dashes (U+2014) or double hyphens "--" used as a substitute; devs use single hyphens or semicolons instead
|
|
524
|
+
- Smart quotes (U+201C/U+201D), smart apostrophes (U+2018/U+2019)
|
|
525
|
+
- Glyphs or emojis (e.g. checkmarks, rockets, fire, arrows)
|
|
526
|
+
- Overly formal or verbose language: "In order to ensure that...", "It is imperative that..."
|
|
527
|
+
- "Note:" or "Important:" prefixes on comments (real developers don't write this way)
|
|
528
|
+
- Hedging: "This might...", "This could potentially...", "It's worth noting that..."
|
|
529
|
+
- Filler: "In order to", "It should be noted", "As mentioned above"
|
|
530
|
+
- Superlatives: "This elegant solution", "This robust implementation"
|
|
531
|
+
- Unnecessary meta-commentary: "This is a helper function that..."
|
|
532
|
+
|
|
533
|
+
### Stale instruction artifacts
|
|
534
|
+
- TODO comments that reference completed work or merged PRs
|
|
535
|
+
- Comments mentioning specific ticket numbers for resolved issues
|
|
536
|
+
- Commented-out code with "// removed" or "// old" annotations
|
|
537
|
+
|
|
538
|
+
## What is NOT slop
|
|
539
|
+
|
|
540
|
+
- Comments explaining *why* the code behaves a certain way
|
|
541
|
+
- Comments explaining tradeoffs or design decisions
|
|
542
|
+
- Comments explaining non-obvious behavior
|
|
543
|
+
- Docstrings describing function contracts
|
|
544
|
+
- Legitimate TODOs for future work
|
|
545
|
+
- User-visible strings whose tone/content is required by the feature or by an external protocol
|
|
546
|
+
- Unchanged legacy text outside the touched scope unless the current change makes it newly wrong or newly suspicious
|
|
547
|
+
|
|
548
|
+
## Method
|
|
549
|
+
|
|
550
|
+
1. Use the diff stat from your scope gathering to identify changed files.
|
|
551
|
+
2. For EVERY changed file, read the full current version.
|
|
552
|
+
3. Scan every comment, docstring, error message string, and UI string.
|
|
553
|
+
4. For each instance of slop, report it with the exact quoted text.
|
|
554
|
+
|
|
555
|
+
Do NOT report on code structure, correctness, or style. Only slop.
|
|
556
|
+
Do NOT report issues in files you did not actually read.
|
|
557
|
+
|
|
558
|
+
## Category taxonomy
|
|
559
|
+
|
|
560
|
+
- **CHANGE_NARRATION**: Comments describing the change being made, not the code's behavior
|
|
561
|
+
- **FOURTH_WALL**: Comments referencing the AI, the user, or the conversation
|
|
562
|
+
- **AI_STYLE_TELL**: Typography, verbosity, hedging, filler, superlatives, meta-commentary
|
|
563
|
+
- **STALE_ARTIFACT**: TODOs referencing completed work, commented-out code, resolved ticket references
|
|
564
|
+
|
|
565
|
+
For slop findings, the source of truth is usually the project's writing norms and the surrounding code intent; use "N/A — mechanical finding" for the producer chain.
|
|
566
|
+
`;
|
|
567
|
+
|
|
568
|
+
const REVIEW_BREADCRUMBS = `---
|
|
569
|
+
name: thatch-review-breadcrumbs
|
|
570
|
+
description: Comment narrative evaluation — do comments form a coherent outline of the code's behavior? Use for post-implementation review of a branch, PR, or commit range.
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
You are a comment narrative reviewer. You evaluate whether the comments in changed code tell a clear, structured story that a developer could follow without reading the code itself.
|
|
574
|
+
${REVIEW_COMMON}
|
|
575
|
+
## Your focus
|
|
576
|
+
|
|
577
|
+
Think of the codebase as a product and developers as users. Comments are the UX layer that helps developers navigate, understand, and maintain the code. Your job is developer-perspective acceptance testing of that UX.
|
|
578
|
+
|
|
579
|
+
## The narrative test
|
|
580
|
+
|
|
581
|
+
For each changed file, perform this test:
|
|
582
|
+
|
|
583
|
+
1. Read the full file with code visible. Understand what it does.
|
|
584
|
+
2. Now mentally hide the code and read ONLY the comments (including module docs, function docstrings, inline comments, and section headers).
|
|
585
|
+
3. Ask yourself:
|
|
586
|
+
- Do the comments form a structured outline of the module's behavior?
|
|
587
|
+
- Could a developer reconstruct the *purpose* and *flow* from comments alone?
|
|
588
|
+
- Are there gaps where significant behavior happens with no narrative?
|
|
589
|
+
- Are there sections where the comments describe trivial operations but skip the non-obvious ones?
|
|
590
|
+
|
|
591
|
+
## What good comments look like
|
|
592
|
+
|
|
593
|
+
Good comments encode intention and rationale:
|
|
594
|
+
- Why this module exists and how it fits into the larger system
|
|
595
|
+
- Why a particular approach was chosen (especially when non-obvious)
|
|
596
|
+
- What the implicit contracts and assumptions are
|
|
597
|
+
- How data flows through the module at a high level
|
|
598
|
+
- What the business purpose of each significant section is
|
|
599
|
+
|
|
600
|
+
Good section headers create a table of contents:
|
|
601
|
+
- They divide the module into logical sections
|
|
602
|
+
- Reading just the headers gives you the module's structure
|
|
603
|
+
|
|
604
|
+
## What to flag
|
|
605
|
+
|
|
606
|
+
- **NARRATIVE_GAP**: A significant code section (new function, complex branch, state transition) that has no comments explaining its purpose or how it fits into the module's behavior.
|
|
607
|
+
- **ORPHAN_COMMENT**: A comment that describes a local operation without connecting it to the module's purpose. ("Iterate over the list" instead of "Process each pending task to determine which need retry")
|
|
608
|
+
- **MISSING_CONTEXT**: A new module, function, or component that doesn't explain how it fits into the larger system. A developer finding this for the first time wouldn't know why it exists.
|
|
609
|
+
- **INVERTED_DETAIL**: Comments that explain the obvious (what) but skip the non-obvious (why). The comment budget is spent on the wrong things.
|
|
610
|
+
|
|
611
|
+
## What NOT to flag
|
|
612
|
+
|
|
613
|
+
- Missing comments on truly self-explanatory code (simple accessors, standard patterns, thin delegation)
|
|
614
|
+
- Style preferences about comment formatting
|
|
615
|
+
- Existing comments that predate the changes (unless the changes made them wrong)
|
|
616
|
+
- Spelling or grammar (other reviewers handle that)
|
|
617
|
+
|
|
618
|
+
## Method
|
|
619
|
+
|
|
620
|
+
1. Use the diff stat from your scope gathering to identify changed files.
|
|
621
|
+
2. For each changed file, read the FULL current file (not just the diff). You need the full context to evaluate narrative coherence.
|
|
622
|
+
3. For new files: evaluate the complete comment narrative.
|
|
623
|
+
4. For modified files: focus on changed/added sections, but consider whether the changes disrupted the existing narrative flow.
|
|
624
|
+
|
|
625
|
+
Do NOT report on files you did not actually read.
|
|
626
|
+
`;
|
|
627
|
+
|
|
628
|
+
// ---------------------------------------------------------------------------
|
|
629
|
+
// Review synthesizer — verify, deduplicate, and aggregate specialist findings
|
|
630
|
+
// ---------------------------------------------------------------------------
|
|
631
|
+
|
|
632
|
+
const REVIEW_SYNTHESIZER = `---
|
|
633
|
+
name: thatch-review-synthesizer
|
|
634
|
+
description: Verify and synthesize findings from multiple review specialist skills into a single deduplicated, severity-grouped report. Use after running one or more thatch-review-* specialist skills.
|
|
635
|
+
---
|
|
636
|
+
|
|
637
|
+
You are a review synthesizer. You have received findings from one or more review specialists (pedantic, acceptance, state-flow, no-slop, breadcrumbs). Your job is to verify their citations against the actual code, deduplicate across specialists, and produce a single, coherent final report.
|
|
638
|
+
|
|
639
|
+
## Static analysis only
|
|
640
|
+
You review code by reading it. Do NOT run tests, linters, compilers, or any build commands.
|
|
641
|
+
|
|
642
|
+
## Verification process
|
|
643
|
+
|
|
644
|
+
For each finding from the specialists:
|
|
645
|
+
|
|
646
|
+
1. **Read the cited file** at the cited line to verify the evidence matches. Only read the specific location — do NOT re-run broad git commands. That work is already done.
|
|
647
|
+
|
|
648
|
+
2. **Check evidence accuracy.** Does the quoted code actually exist at that location? Is the specialist's claim about its behavior accurate?
|
|
649
|
+
|
|
650
|
+
3. **Determine provenance.** Is the finding a new issue introduced by this change, or a pre-existing problem? Note pre-existing bugs separately.
|
|
651
|
+
|
|
652
|
+
4. **Check runtime model applicability.** Can the finding realistically manifest in normal usage given the application's runtime model? A finding that requires conditions impossible in the actual runtime context is not a real bug (e.g., state accumulation in a short-lived process, concurrency in single-threaded code).
|
|
653
|
+
|
|
654
|
+
5. **Prove the causal chain** for any finding about state, data shape, cross-module contracts, or behavior:
|
|
655
|
+
- Identify the authoritative producer or source of the state/data.
|
|
656
|
+
- Identify the transforms between producer and consumer.
|
|
657
|
+
- Identify the consumer or branch where failure occurs.
|
|
658
|
+
- Identify the real entrypoint/workflow that exercises this chain.
|
|
659
|
+
If the only way to trigger the issue is by manually fabricating invalid data/state or bypassing the real producers/guards, reject the finding. If the citation is real but you cannot prove the producer chain, classify as UNVERIFIABLE rather than CONFIRMED.
|
|
660
|
+
|
|
661
|
+
6. **Verify intent.** If the specialist flagged behavior as a bug but the code appears to work as designed, check whether the behavior is intentional:
|
|
662
|
+
- Read the callers of the cited code to see if the pattern makes sense in context.
|
|
663
|
+
- Check git log or git blame on the cited file for commit messages explaining the decision.
|
|
664
|
+
- Use thatch_memory_recall to search for documented rationale.
|
|
665
|
+
If the behavior is intentional or an accepted limitation, reject the finding.
|
|
666
|
+
|
|
667
|
+
7. **Classify:**
|
|
668
|
+
- **CONFIRMED**: The cited code matches, the claim is accurate, the bug is reachable through realistic usage, you proved the workflow/producer chain where applicable, and the behavior is not intentional.
|
|
669
|
+
- **REJECTED**: The citation is wrong, the claim is inaccurate, the bug cannot manifest in the actual runtime context, or the behavior is an intentional design decision (explain why briefly). Reject findings that rely on manually seeded invalid state/data with no real producer path.
|
|
670
|
+
- **UNVERIFIABLE**: The citation is correct but you cannot confirm the behavioral claim without deeper tracing (state what's missing). This is the default for plausible claims that lack a proven trigger path, producer chain, or authoritative source of truth.
|
|
671
|
+
|
|
672
|
+
## Deduplication
|
|
673
|
+
|
|
674
|
+
The same issue may be flagged by multiple specialists when it spans category boundaries. Merge these into a single finding.
|
|
675
|
+
|
|
676
|
+
Multiple findings may stem from the same underlying issue (e.g., a contract mismatch causes errors in 3 call sites). Group these under the root cause.
|
|
677
|
+
|
|
678
|
+
## Severity calibration
|
|
679
|
+
|
|
680
|
+
Assign final severity based on YOUR verification:
|
|
681
|
+
- **BLOCKING**: Incorrect behavior that will manifest in normal usage. You confirmed the cited code behaves as the specialist described.
|
|
682
|
+
- **HIGH**: A real bug that requires specific but realistic conditions. You verified the conditions are reachable from the cited location.
|
|
683
|
+
- **MEDIUM**: Edge cases, UX friction, or issues where the citation is correct but the impact is limited or requires unusual conditions.
|
|
684
|
+
- **LOW**: Mechanical issues (stale docs, guideline violations, naming) that don't affect correctness.
|
|
685
|
+
|
|
686
|
+
## Report format
|
|
687
|
+
|
|
688
|
+
You MUST produce the full report structure below. Do not simplify or omit sections. Every confirmed finding must include all numbered fields. If a section has no entries, write "None" — do not skip the section.
|
|
689
|
+
|
|
690
|
+
### Scope
|
|
691
|
+
- Branch/range reviewed
|
|
692
|
+
- Design context (if provided)
|
|
693
|
+
|
|
694
|
+
### Confirmed findings
|
|
695
|
+
For each finding, grouped by severity (BLOCKING > HIGH > MEDIUM > LOW). Each finding MUST include all of these fields:
|
|
696
|
+
1. **Severity** and **category** (from the specialist's taxonomy)
|
|
697
|
+
2. **Source**: which specialist found it
|
|
698
|
+
3. **Location**: file:line
|
|
699
|
+
4. **Finding**: what the problem is
|
|
700
|
+
5. **Evidence**: the code you read to confirm it (quote the exact lines you verified)
|
|
701
|
+
6. **Trigger/Proof**: the workflow trigger, and for state/data/behavior issues the producer then transform then consumer chain you verified
|
|
702
|
+
7. **Provenance**: branch-introduced or pre-existing
|
|
703
|
+
|
|
704
|
+
### Rejected findings (appendix, brief)
|
|
705
|
+
Findings you rejected and a one-line reason why. Include the specialist and location for each.
|
|
706
|
+
|
|
707
|
+
### Pre-existing bugs (appendix, brief)
|
|
708
|
+
Findings you verified as real but pre-existing, with a one-line note on the issue and its potential impact.
|
|
709
|
+
|
|
710
|
+
### Coverage gaps
|
|
711
|
+
Note which files or areas were NOT covered by any specialist.
|
|
712
|
+
`;
|
|
713
|
+
|
|
714
|
+
// ---------------------------------------------------------------------------
|
|
715
|
+
// Session reflection — end-of-session memory recording guidance
|
|
716
|
+
// ---------------------------------------------------------------------------
|
|
717
|
+
|
|
718
|
+
const SESSION_REFLECTION = `---
|
|
719
|
+
name: thatch-session-reflection
|
|
720
|
+
description: Record what you learned during a session — project facts, user preferences, tool tips, self-identity. Use at the end of a session to persist knowledge for future sessions.
|
|
721
|
+
---
|
|
722
|
+
|
|
723
|
+
You have completed your work and are now reflecting on the session. Your ONLY job is to record memories using thatch_memory_remember.
|
|
724
|
+
|
|
725
|
+
## What to reflect on
|
|
726
|
+
|
|
727
|
+
### What did you learn about the code base?
|
|
728
|
+
- Project architecture and design patterns discovered during this session
|
|
729
|
+
- Organization and components within the project
|
|
730
|
+
- How features or components interact
|
|
731
|
+
- "Playbooks" for how to perform common dev tasks (adding migrations, running tests, linting, formatting tools, etc.)
|
|
732
|
+
- Include any details or nuance about them (e.g., "remember to exclude the vendor directory when running the linter")
|
|
733
|
+
- Include details about tools available on the OS (e.g., "kubectl available to interact with staging and prod clusters, but local tooling uses docker compose")
|
|
734
|
+
- Include details you have inferred about the infrastructure (how envs are set up, how local dev works vs staging/prod, links between repos and services)
|
|
735
|
+
- Conventions and coding patterns
|
|
736
|
+
- Gotchas and pitfalls you encountered
|
|
737
|
+
- Bug shapes: the abstract pattern behind a fix, not the specific bug context
|
|
738
|
+
|
|
739
|
+
### What did you learn about the user?
|
|
740
|
+
- Preferences for how you should communicate (concise vs detailed, hand-holding vs high-level guidance, etc.)
|
|
741
|
+
- Details about their expertise and experience level with various aspects of the project and dev work in general
|
|
742
|
+
- Pet peeves and communication style observations
|
|
743
|
+
- How they reacted to your responses — what worked, what didn't
|
|
744
|
+
|
|
745
|
+
### What did you learn about your tools?
|
|
746
|
+
- Shell/environment quirks (tool friction, missing commands, platform issues)
|
|
747
|
+
- Tips for working with your own tool calls (e.g., "the edit tool works better with referential anchors like 'above the function foo'")
|
|
748
|
+
- Prompting patterns that succeed or fail with coding tools
|
|
749
|
+
- Available CLI tools and their useful invocations
|
|
750
|
+
|
|
751
|
+
### What did you learn about yourself?
|
|
752
|
+
- Building an individual identity helps with user rapport
|
|
753
|
+
- Pay attention to the user's reaction to your response; look for clues that indicate how well they understood the information and how they received it
|
|
754
|
+
- Record tips for your future self about the style of communication that seems to resonate best with the user
|
|
755
|
+
|
|
756
|
+
## Correcting stale memories
|
|
757
|
+
|
|
758
|
+
If a recalled memory contradicts what you observed during the session (e.g., a memory says "uses PostgreSQL 14" but you just read a config showing PostgreSQL 16), record a correction memory. Title it descriptively and include:
|
|
759
|
+
- Which existing memory is wrong, by its exact title
|
|
760
|
+
- What it currently says (the stale claim)
|
|
761
|
+
- What the correct information is, with evidence from the current session
|
|
762
|
+
|
|
763
|
+
## Store assignment
|
|
764
|
+
|
|
765
|
+
- **global store**: user preferences, personality traits, communication style, environment quirks, self-identity observations
|
|
766
|
+
- **Project store**: architecture, conventions, patterns, project-specific gotchas, useful commands
|
|
767
|
+
|
|
768
|
+
## Writing good memories
|
|
769
|
+
|
|
770
|
+
- One topic per memory. Several specific memories over one sprawling one.
|
|
771
|
+
- Labels: short descriptive titles (5-8 words).
|
|
772
|
+
- Content: self-contained, 2-5 sentences. Write for a future session with zero current context. No "we", "our session", "just now".
|
|
773
|
+
- If updating an existing memory, use overwrite: true.
|
|
774
|
+
- Confidence (1-10): 1-3 weak signal, 5-6 moderate evidence, 7-8 strong pattern, 9 explicitly stated.
|
|
775
|
+
- Record each distinct learning as a separate memory with a descriptive title.
|
|
776
|
+
|
|
777
|
+
## What NOT to record
|
|
778
|
+
|
|
779
|
+
- Session-specific state ("we just fixed...")
|
|
780
|
+
- Ephemeral details (current branch, uncommitted changes, transient errors)
|
|
781
|
+
- Info already in CLAUDE.md or AGENTS.md (don't duplicate)
|
|
782
|
+
- Speculative conclusions ("this might be...")
|
|
783
|
+
- Secrets or sensitive values
|
|
784
|
+
|
|
785
|
+
Do NOT generate a response to the user. ONLY use thatch_memory_remember to record what you learned.
|
|
786
|
+
`;
|
|
787
|
+
|
|
788
|
+
// ---------------------------------------------------------------------------
|
|
789
|
+
// Code review coordinator (opencode-only) — dispatches sub-agents for parallel review
|
|
790
|
+
// ---------------------------------------------------------------------------
|
|
791
|
+
|
|
792
|
+
const CODE_REVIEW_COORDINATOR = `---
|
|
793
|
+
name: thatch-code-review
|
|
794
|
+
description: Multi-agent code review coordinator. Dispatches parallel sub-agents for comprehensive review — triage, decompose, fan out specialists, synthesize. opencode only (requires sub-agent support).
|
|
795
|
+
---
|
|
796
|
+
|
|
797
|
+
You are a code review coordinator. Your job is to orchestrate a comprehensive, multi-agent code review by triaging the change, partitioning large diffs into focused review units, dispatching specialist sub-agents in parallel, and synthesizing a final report.
|
|
798
|
+
|
|
799
|
+
## Static analysis only
|
|
800
|
+
This entire review is a static analysis exercise. Do NOT run tests, linters, compilers, or any build commands. Do NOT execute the code under review.
|
|
801
|
+
|
|
802
|
+
## Step 1: Resolve the review target
|
|
803
|
+
|
|
804
|
+
Identify what to review:
|
|
805
|
+
- If a branch was specified, identify the base branch (usually main or master), compute the merge-base, and review the range merge-base..HEAD.
|
|
806
|
+
- If a PR number was specified, use gh pr view to resolve the head and base, fetch both refs, and review merge-base..head.
|
|
807
|
+
- If a git range was specified (A..B form), use it directly.
|
|
808
|
+
- If no target was specified, review the current branch against its base.
|
|
809
|
+
|
|
810
|
+
Fetch any refs not locally reachable so branches and PRs that were never checked out can be reviewed.
|
|
811
|
+
|
|
812
|
+
Run git diff --stat on the resolved range and git log --oneline to understand the change.
|
|
813
|
+
|
|
814
|
+
## Step 2: Estimate complexity
|
|
815
|
+
|
|
816
|
+
Estimate the review effort in scrum points (1-13 scale):
|
|
817
|
+
- **1**: Trivial — typo fix, config tweak, single-line change.
|
|
818
|
+
- **2**: Small — isolated change to one module, no new contracts.
|
|
819
|
+
- **3**: Medium — touches 2-3 modules, or adds a new public interface.
|
|
820
|
+
- **5**: Large — new feature with multiple integration points, or significant refactor of existing contracts.
|
|
821
|
+
- **8**: Very large — cross-cutting change affecting many modules, new subsystem, or complex state management changes.
|
|
822
|
+
- **13**: Massive — architectural change, new framework/infrastructure, or changes that touch nearly everything.
|
|
823
|
+
|
|
824
|
+
Points reflect *review complexity*, not implementation effort.
|
|
825
|
+
|
|
826
|
+
Identify files to exclude from review: vendored dependencies, generated files, lockfiles, compiled assets.
|
|
827
|
+
|
|
828
|
+
## Step 3: Partition (if > 3 points)
|
|
829
|
+
|
|
830
|
+
For changes estimated at more than 3 points, partition into review units of approximately 3 points each:
|
|
831
|
+
- Group files by logical component or feature, not by directory.
|
|
832
|
+
- Each unit should be a self-contained briefing that a sub-agent can act on independently.
|
|
833
|
+
- Prefer slightly larger units over splitting tightly coupled files across units.
|
|
834
|
+
- For 5+ points, also plan an integration review unit that focuses on cross-component seams.
|
|
835
|
+
|
|
836
|
+
For changes estimated at 3 points or fewer, skip partitioning — dispatch one set of specialists covering the full scope. A single 3-point unit is not large enough to warrant decomposition.
|
|
837
|
+
|
|
838
|
+
## Step 4: Dispatch specialist sub-agents
|
|
839
|
+
|
|
840
|
+
For each review unit, dispatch sub-agents using the Task tool. Each sub-agent runs one specialist lens on one review unit. The five specialists are:
|
|
841
|
+
|
|
842
|
+
1. **Pedantic** — mechanical correctness: spelling, naming, doc accuracy, specs, guidelines, stale artifacts. Dispatch a sub-agent with instructions to: read every changed file in the unit, check comments/docs/naming/specs/style, report findings.
|
|
843
|
+
|
|
844
|
+
2. **Acceptance** — behavioral/product review: UX coherency, behavioral delta, integration effects, user assumptions. Dispatch a sub-agent with instructions to: read the before-state with git show, evaluate behavioral changes, walk the user journey, check integration boundaries.
|
|
845
|
+
|
|
846
|
+
3. **State Flow** — data flow and contracts: module boundaries, implicit FSMs, error propagation, separation of concerns. Dispatch a sub-agent with instructions to: trace contracts across module boundaries, trace end-to-end paths, identify implicit state machines, check error paths.
|
|
847
|
+
|
|
848
|
+
4. **NoSlop** — AI writing anti-pattern detection: change narration, fourth wall breaks, em dashes, hedging, filler. Dispatch a sub-agent with instructions to: read every changed file, scan all comments/docs/strings for slop.
|
|
849
|
+
|
|
850
|
+
5. **Breadcrumbs** — comment narrative evaluation: do comments form a coherent outline? Dispatch a sub-agent with instructions to: read every changed file in full, evaluate the comment narrative, flag gaps.
|
|
851
|
+
|
|
852
|
+
For the integration review unit (5+ points), dispatch a sub-agent focused on:
|
|
853
|
+
- Cross-component contracts — do the interfaces between components match?
|
|
854
|
+
- Boundary correctness — race conditions, ordering dependencies, shared state issues at boundaries.
|
|
855
|
+
- Top-level coherence — does the overall change make sense as a unit?
|
|
856
|
+
|
|
857
|
+
## Step 5: Synthesize
|
|
858
|
+
|
|
859
|
+
After all sub-agents complete, load the thatch-review-synthesizer skill to verify findings, deduplicate across specialists, classify (CONFIRMED/REJECTED/UNVERIFIABLE), and produce the final severity-grouped report.
|
|
860
|
+
|
|
861
|
+
Alternatively, perform the synthesis yourself:
|
|
862
|
+
1. Read each finding's cited location to verify evidence accuracy.
|
|
863
|
+
2. Deduplicate findings flagged by multiple specialists.
|
|
864
|
+
3. Group findings by root cause where multiple findings stem from the same issue.
|
|
865
|
+
4. Classify each as CONFIRMED, REJECTED, or UNVERIFIABLE based on citation verification, reachability, and intent verification.
|
|
866
|
+
5. Calibrate severity (BLOCKING > HIGH > MEDIUM > LOW) based on your verification.
|
|
867
|
+
6. Produce a final report grouped by severity, with coverage gaps noted.
|
|
868
|
+
|
|
869
|
+
## Specialist briefing template
|
|
870
|
+
|
|
871
|
+
When dispatching each sub-agent, include in the prompt:
|
|
872
|
+
- The git range to review
|
|
873
|
+
- The specific files in this unit's scope
|
|
874
|
+
- The specialist focus (from the five specialists above)
|
|
875
|
+
- The diff stat for this unit's files
|
|
876
|
+
- Any design context or specific concerns
|
|
877
|
+
- Explicit scope boundaries ("your scope is X; do NOT review Y")
|
|
878
|
+
- Instruction to produce markdown findings with: severity, category, file:line, finding, evidence, trigger scenario, reachability, source of truth, producer chain, provenance
|
|
879
|
+
- Instruction to apply the reachability gate and intent verification before reporting
|
|
880
|
+
`;
|
|
881
|
+
|
|
882
|
+
// ---------------------------------------------------------------------------
|
|
883
|
+
// Skill arrays — shared skills work on both opencode and Claude Code.
|
|
884
|
+
// opencode-only skills use sub-agents and are not installed for Claude Code.
|
|
885
|
+
// ---------------------------------------------------------------------------
|
|
886
|
+
|
|
887
|
+
const SHARED_SKILLS: SkillDef[] = [
|
|
190
888
|
{ name: "thatch-fact-extractor", content: FACT_EXTRACTOR },
|
|
191
889
|
{ name: "thatch-dedup-classifier", content: DEDUP_CLASSIFIER },
|
|
192
890
|
{ name: "thatch-project-primer", content: PROJECT_PRIMER },
|
|
891
|
+
{ name: "thatch-review-pedantic", content: REVIEW_PEDANTIC },
|
|
892
|
+
{ name: "thatch-review-acceptance", content: REVIEW_ACCEPTANCE },
|
|
893
|
+
{ name: "thatch-review-state-flow", content: REVIEW_STATE_FLOW },
|
|
894
|
+
{ name: "thatch-review-no-slop", content: REVIEW_NO_SLOP },
|
|
895
|
+
{ name: "thatch-review-breadcrumbs", content: REVIEW_BREADCRUMBS },
|
|
896
|
+
{ name: "thatch-review-synthesizer", content: REVIEW_SYNTHESIZER },
|
|
897
|
+
{ name: "thatch-session-reflection", content: SESSION_REFLECTION },
|
|
898
|
+
];
|
|
899
|
+
|
|
900
|
+
const OPENCODE_ONLY_SKILLS: SkillDef[] = [
|
|
901
|
+
{ name: "thatch-code-review", content: CODE_REVIEW_COORDINATOR },
|
|
193
902
|
];
|
|
903
|
+
|
|
904
|
+
export { SHARED_SKILLS, OPENCODE_ONLY_SKILLS };
|