@jeffober/thatch 0.1.12 → 0.1.14
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/README.md +11 -0
- package/artifacts/skills/common.md +61 -0
- package/artifacts/skills/thatch-code-review.md +125 -0
- package/artifacts/skills/thatch-dedup-classifier.md +40 -0
- package/artifacts/skills/thatch-fact-extractor.md +67 -0
- package/artifacts/skills/thatch-project-primer.md +62 -0
- package/artifacts/skills/thatch-review-acceptance.md +70 -0
- package/artifacts/skills/thatch-review-breadcrumbs.md +58 -0
- package/artifacts/skills/thatch-review-context.md +110 -0
- package/artifacts/skills/thatch-review-mark-and-sweep.md +125 -0
- package/artifacts/skills/thatch-review-no-slop.md +71 -0
- package/artifacts/skills/thatch-review-pedantic.md +57 -0
- package/artifacts/skills/thatch-review-state-flow.md +89 -0
- package/artifacts/skills/thatch-review-synthesizer.md +94 -0
- package/artifacts/skills/thatch-session-reflection.md +68 -0
- package/artifacts/skills/thatch-workflow-research.md +91 -0
- package/bin/thatch +9 -5
- package/docs/dev/skills.md +5 -8
- package/docs/user/README.md +11 -0
- package/package.json +3 -2
- package/src/extract-queue.ts +61 -10
- package/src/extraction.ts +12 -2
- package/src/index.ts +76 -9
- package/src/prompts.ts +56 -10
- package/src/skills.ts +41 -1282
- package/src/tool-defs.ts +28 -0
package/README.md
CHANGED
|
@@ -32,6 +32,17 @@ No API keys, no cloud services; everything runs on your machine.
|
|
|
32
32
|
On next start, OpenCode npm-installs thatch (putting the `thatch` CLI on your
|
|
33
33
|
PATH as a side effect) and its tools are available immediately.
|
|
34
34
|
|
|
35
|
+
Set this environment variable so the extraction nudge can run the fact-extractor
|
|
36
|
+
as a **background** sub-agent instead of blocking your turn:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
export OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Without it, opencode hides the task tool's `background` parameter and every
|
|
43
|
+
extraction nudge runs synchronously. Put it in your shell rc, `mise.toml`
|
|
44
|
+
`[env]`, or `.envrc`.
|
|
45
|
+
|
|
35
46
|
**Self-hosting** (local development):
|
|
36
47
|
|
|
37
48
|
```jsonc
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
## Static analysis only
|
|
3
|
+
You review code by reading it. Do NOT run tests, linters, compilers, or any build commands. Do NOT execute the code under review.
|
|
4
|
+
|
|
5
|
+
## Scope gathering
|
|
6
|
+
Before reviewing, identify what to review:
|
|
7
|
+
1. If a git range, branch, or PR was specified, use that target.
|
|
8
|
+
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.
|
|
9
|
+
3. Run git diff --stat on the resolved range to identify changed files.
|
|
10
|
+
4. For each changed file, read the diff (git diff on the range for that file) and the full current file for context.
|
|
11
|
+
5. Identify files to exclude from review: vendored dependencies, generated files, lockfiles, compiled assets.
|
|
12
|
+
|
|
13
|
+
## Runtime model
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
## Reachability gate
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
Before claiming a value can hold a problematic state (NULL, orphaned, out-of-range, wrong-type), read the artifact that governs that state: the column definition, type declaration, FK/NOT NULL constraint, validation, or guard. Quote it in your finding. If a schema constraint, type, or guard makes the state unreachable, it is not a finding. "The join could drop rows" requires proving a droppable row can exist — cite the constraint that permits it.
|
|
20
|
+
|
|
21
|
+
## Intent verification
|
|
22
|
+
Before flagging behavior as a bug, verify intent:
|
|
23
|
+
1. **Trace callers.** Read every caller of the cited code. The behavior may be intentional given how the feature is actually used.
|
|
24
|
+
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.
|
|
25
|
+
3. **Check memories.** Use thatch_memory_recall to search for documented design decisions or known limitations related to the code area.
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
## Project context awareness
|
|
30
|
+
If your briefing includes a project context brief (from the coordinator or from loading thatch-review-context), use it to calibrate your findings:
|
|
31
|
+
- **Deferred work** listed in the brief is intentionally excluded from this PR. Do not flag the absence of deferred pieces as bugs, inconsistencies, or missing functionality.
|
|
32
|
+
- **Dependencies** in the brief tell you whether base-branch behavior is expected to be present or not. Do not assert that base-branch behavior exists without verifying it landed.
|
|
33
|
+
- **Relevant constraints** may explain why code is structured a certain way. Consider them before flagging design choices.
|
|
34
|
+
|
|
35
|
+
## Workflow context awareness
|
|
36
|
+
If your briefing includes a workflow guide (from the coordinator or from loading thatch-workflow-research), use it to understand the purpose and evolution of the code you are reviewing:
|
|
37
|
+
- **Purpose** sections explain why the workflow exists, which helps distinguish intentional behavior from bugs.
|
|
38
|
+
- **Major evolutions** sections explain how the code reached its current state, which helps distinguish recent changes from long-standing design decisions.
|
|
39
|
+
- **Constraints and design decisions** sections explain tradeoffs and intentional choices, which prevents flagging known design decisions as issues.
|
|
40
|
+
- **Current state** sections list known limitations and incomplete work, which prevents flagging known gaps as new bugs.
|
|
41
|
+
|
|
42
|
+
## TODO ($ticket) markers
|
|
43
|
+
Code may contain `TODO ($TICKET-ID): description` comments that mark intentionally deferred work: temporary code, placeholders for future tickets, or planned cleanups. These are legitimate breadcrumbs, not stale artifacts.
|
|
44
|
+
- Do NOT flag a TODO ($ticket) marker as a stale artifact if the ticket it references is still open or future work.
|
|
45
|
+
- DO flag it if you can verify the referenced ticket is closed or merged (the TODO is now stale).
|
|
46
|
+
- If your briefing includes a context brief that lists the deferred work, use it to determine whether the ticket is still pending.
|
|
47
|
+
|
|
48
|
+
## Output format
|
|
49
|
+
Produce findings as markdown. For each finding:
|
|
50
|
+
|
|
51
|
+
### [SEVERITY] [CATEGORY] — file:line
|
|
52
|
+
- **Finding**: what the problem is
|
|
53
|
+
- **Evidence**: exact code quoted from the cited location (copy-paste, do not paraphrase)
|
|
54
|
+
- **Trigger**: concrete normal-usage scenario, or "N/A — mechanical finding"
|
|
55
|
+
- **Reachability**: why this is reachable in real usage, or why it is not
|
|
56
|
+
- **Source of truth**: authoritative source for the claim (producer, caller contract, behavior, guideline, docs)
|
|
57
|
+
- **Producer chain**: producer then transform then consumer, or "N/A — mechanical finding"
|
|
58
|
+
- **Provenance**: branch-introduced or pre-existing
|
|
59
|
+
|
|
60
|
+
Severities: BLOCKING > HIGH > MEDIUM > LOW.
|
|
61
|
+
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.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: thatch-code-review
|
|
3
|
+
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).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
|
|
8
|
+
## Static analysis only
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## Step 1: Resolve the review target
|
|
12
|
+
|
|
13
|
+
First, run `git fetch origin` (NOT `git pull` — fetch updates remote-tracking refs without touching the working tree or current branch). This refreshes `origin/main` and other remote-tracking refs to their true remote state. Local branches (e.g. `main`) only advance on checkout/pull and may be stale on a long-lived feature checkout, so resolve the base against the remote tracking ref, not the local branch.
|
|
14
|
+
|
|
15
|
+
Identify what to review:
|
|
16
|
+
- If a branch was specified, identify the base branch (usually main or master), compute the merge-base against the remote tracking ref (e.g. `git merge-base HEAD origin/main`), and review the range merge-base..HEAD.
|
|
17
|
+
- If a PR number was specified, use `gh pr view` to resolve the head and base, fetch both refs, and review merge-base..head.
|
|
18
|
+
- If a git range was specified (A..B form), use it directly.
|
|
19
|
+
- If no target was specified, review the current branch against its base, resolving the base from `origin/main` (or the appropriate remote tracking ref) after fetching.
|
|
20
|
+
|
|
21
|
+
Also fetch any refs not locally reachable so branches and PRs that were never checked out can be reviewed (e.g. `git fetch origin <branch>` for a PR head).
|
|
22
|
+
|
|
23
|
+
Run git diff --stat on the resolved range and git log --oneline to understand the change.
|
|
24
|
+
|
|
25
|
+
## Step 2: Gather project context
|
|
26
|
+
|
|
27
|
+
Load the thatch-review-context skill and follow its methodology to build a context brief for this change. Investigate:
|
|
28
|
+
- PR description (if a PR was specified or detected via the branch)
|
|
29
|
+
- Branch name for ticket identifiers
|
|
30
|
+
- Git log for commit messages referencing tickets or describing scope
|
|
31
|
+
- TODO ($ticket) markers in the diff
|
|
32
|
+
- thatch_memory_recall for feature/project status, design decisions, ticket dependencies
|
|
33
|
+
- Project docs, READMEs, design docs
|
|
34
|
+
- Issue tracker (gh issue/view) if ticket IDs are found
|
|
35
|
+
|
|
36
|
+
Produce the context brief in the format the skill prescribes (project context, this change's scope, deferred work, dependencies, relevant constraints).
|
|
37
|
+
|
|
38
|
+
If context is sparse (no PR description, no ticket references, no relevant memories), note that the change appears standalone. Even a sparse brief is valuable: it tells specialists you looked and found nothing, so they do not need to repeat the search.
|
|
39
|
+
|
|
40
|
+
## Step 3: Research affected workflows
|
|
41
|
+
|
|
42
|
+
Dispatch a sub-agent using the Task tool to research the code workflows affected by this change. Pass the sub-agent:
|
|
43
|
+
- The git range and changed files (from Step 1)
|
|
44
|
+
- The project context brief (from Step 2)
|
|
45
|
+
- Instructions to load the thatch-workflow-research skill and follow its methodology
|
|
46
|
+
|
|
47
|
+
The sub-agent produces a code guide with one section per affected workflow or feature. Wait for it to complete and collect the guide.
|
|
48
|
+
|
|
49
|
+
This guide gives specialists the code-level context (purpose, data flow, evolutions, constraints) they need to avoid false positives about intentional behavior and long-standing design decisions, and reduces duplicate code-tracing across the six specialist lenses.
|
|
50
|
+
|
|
51
|
+
For small changes (a single file or trivial diff), you may do this research inline instead of dispatching a sub-agent. Use your judgment: if the workflow research would require reading more than 3-4 files, dispatch a sub-agent to preserve your context for orchestration.
|
|
52
|
+
|
|
53
|
+
## Step 4: Estimate complexity
|
|
54
|
+
|
|
55
|
+
Estimate the review effort in scrum points (1-13 scale):
|
|
56
|
+
- **1**: Trivial — typo fix, config tweak, single-line change.
|
|
57
|
+
- **2**: Small — isolated change to one module, no new contracts.
|
|
58
|
+
- **3**: Medium — touches 2-3 modules, or adds a new public interface.
|
|
59
|
+
- **5**: Large — new feature with multiple integration points, or significant refactor of existing contracts.
|
|
60
|
+
- **8**: Very large — cross-cutting change affecting many modules, new subsystem, or complex state management changes.
|
|
61
|
+
- **13**: Massive — architectural change, new framework/infrastructure, or changes that touch nearly everything.
|
|
62
|
+
|
|
63
|
+
Points reflect *review complexity*, not implementation effort.
|
|
64
|
+
|
|
65
|
+
Identify files to exclude from review: vendored dependencies, generated files, lockfiles, compiled assets.
|
|
66
|
+
|
|
67
|
+
## Step 5: Partition (if > 3 points)
|
|
68
|
+
|
|
69
|
+
For changes estimated at more than 3 points, partition into review units of approximately 3 points each:
|
|
70
|
+
- Group files by logical component or feature, not by directory.
|
|
71
|
+
- Each unit should be a self-contained briefing that a sub-agent can act on independently.
|
|
72
|
+
- Prefer slightly larger units over splitting tightly coupled files across units.
|
|
73
|
+
- For 5+ points, also plan an integration review unit that focuses on cross-component seams.
|
|
74
|
+
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
## Step 6: Dispatch specialist sub-agents
|
|
78
|
+
|
|
79
|
+
For each review unit, dispatch sub-agents using the Task tool. Each sub-agent runs one specialist lens on one review unit. The six specialists are:
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
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.
|
|
84
|
+
|
|
85
|
+
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.
|
|
86
|
+
|
|
87
|
+
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.
|
|
88
|
+
|
|
89
|
+
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.
|
|
90
|
+
|
|
91
|
+
6. **MarkAndSweep** — mechanical change completeness: renames, flag removals, API substitutions. Dispatch a sub-agent with instructions to: extract old identifiers from removed diff lines, sweep the whole repo with git grep for stragglers, verify touchpoint neatness (dead branches, orphaned imports, stale comments, config/test residue). Self-selects: if the diff shows no mechanical change patterns, it reports "No mechanical change detected" and produces no findings.
|
|
92
|
+
|
|
93
|
+
For the integration review unit (5+ points), dispatch a sub-agent focused on:
|
|
94
|
+
- Cross-component contracts — do the interfaces between components match?
|
|
95
|
+
- Boundary correctness — race conditions, ordering dependencies, shared state issues at boundaries.
|
|
96
|
+
- Top-level coherence — does the overall change make sense as a unit?
|
|
97
|
+
|
|
98
|
+
## Step 7: Synthesize
|
|
99
|
+
|
|
100
|
+
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.
|
|
101
|
+
|
|
102
|
+
Confirmed LOW findings are mandatory in the final report, including mechanical findings (pedantic, no-slop, breadcrumbs, docs, naming, style, comments). Do not omit them for being non-functional.
|
|
103
|
+
|
|
104
|
+
Alternatively, perform the synthesis yourself:
|
|
105
|
+
1. Read each finding's cited location to verify evidence accuracy.
|
|
106
|
+
2. Deduplicate findings flagged by multiple specialists.
|
|
107
|
+
3. Group findings by root cause where multiple findings stem from the same issue.
|
|
108
|
+
4. Classify each as CONFIRMED, REJECTED, or UNVERIFIABLE. For behavioral findings, apply citation verification, reachability, and intent verification. For mechanical findings, verify the cited text exists, is branch-introduced or newly made relevant, and violates the stated guideline or specialist taxonomy.
|
|
109
|
+
5. Calibrate severity (BLOCKING > HIGH > MEDIUM > LOW) based on your verification.
|
|
110
|
+
6. Produce a final report grouped by severity, with coverage gaps noted. Include every confirmed LOW finding.
|
|
111
|
+
|
|
112
|
+
## Specialist briefing template
|
|
113
|
+
|
|
114
|
+
When dispatching each sub-agent, include in the prompt:
|
|
115
|
+
- The git range to review
|
|
116
|
+
- The specific files in this unit's scope
|
|
117
|
+
- The specialist focus (from the six specialists above)
|
|
118
|
+
- The diff stat for this unit's files
|
|
119
|
+
- **The project context brief** from Step 2, filtered to what is relevant to this unit's scope. Explicitly list any deferred work that falls within this unit's files, and call out TODO ($ticket) markers the specialists should recognize as intentional.
|
|
120
|
+
- **The workflow guide** from Step 3, filtered to the workflows relevant to this unit's scope. Use it to understand the purpose and evolution of the code before flagging issues. It provides the code-level context (flows, contracts, history, constraints) that prevents false positives about intentional behavior and long-standing design decisions.
|
|
121
|
+
- Any design context or specific concerns
|
|
122
|
+
- Explicit scope boundaries ("your scope is X; do NOT review Y")
|
|
123
|
+
- Instruction to produce markdown findings with: severity, category, file:line, finding, evidence, trigger scenario, reachability, source of truth, producer chain, provenance
|
|
124
|
+
- Instruction to apply the reachability gate (including reading and citing governing constraints for data-state claims) and intent verification before reporting
|
|
125
|
+
- Instruction to respect the project context brief: do not flag deferred work as bugs or inconsistencies, and recognize TODO ($ticket) markers as intentional breadcrumbs
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: thatch-dedup-classifier
|
|
3
|
+
description: Classify the relationship between two similar memory entries for deduplication. Use when thatch_find_duplicates identifies candidate pairs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are a memory deduplication classifier. Given similar memories surfaced by
|
|
7
|
+
thatch_find_duplicates (as pairs, grouped into clusters), decide their
|
|
8
|
+
relationships and emit actions.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
|
|
12
|
+
1. Read every memory in the pair or cluster with thatch_memory_show.
|
|
13
|
+
2. Classify the relationships.
|
|
14
|
+
3. Use thatch_memory_forget to remove duplicates.
|
|
15
|
+
4. Use thatch_memory_remember with overwrite: true to update supplemented memories.
|
|
16
|
+
5. For pairs you are NOT deleting (supplement, contradiction, unrelated), call
|
|
17
|
+
thatch_dedup_mark_checked with the verdict so the pair stops being re-reported.
|
|
18
|
+
6. Call thatch_find_duplicates again afterward to verify the store is clean.
|
|
19
|
+
|
|
20
|
+
## Clusters (3+ related memories)
|
|
21
|
+
|
|
22
|
+
A cluster usually means one topic fragmented across entries. Consolidate:
|
|
23
|
+
rewrite the cluster as ONE self-contained memory under the best label
|
|
24
|
+
(thatch_memory_remember with overwrite: true), preserving every distinct fact,
|
|
25
|
+
then thatch_memory_forget the rest. If a cluster mixes topics, split it into
|
|
26
|
+
per-topic consolidations, and mark the residual cross-topic pairs checked as
|
|
27
|
+
"unrelated".
|
|
28
|
+
|
|
29
|
+
## Write-time warnings
|
|
30
|
+
|
|
31
|
+
thatch_memory_remember may warn that a just-saved memory resembles existing
|
|
32
|
+
ones. Treat that warning as a one-pair version of this workflow: read the
|
|
33
|
+
listed memories and reconcile immediately — merge, or mark the pair checked.
|
|
34
|
+
|
|
35
|
+
## Relationship types
|
|
36
|
+
|
|
37
|
+
- **duplicate**: Both memories say essentially the same thing. Delete the less detailed one, or merge content and re-save the better one.
|
|
38
|
+
- **supplement**: One memory adds useful context to the other. Update the primary one with the supplement's content, delete the supplement.
|
|
39
|
+
- **contradiction**: The memories make incompatible claims. Keep both, note the contradiction in a new memory.
|
|
40
|
+
- **unrelated**: Different topics despite high embedding similarity. No action needed.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: thatch-fact-extractor
|
|
3
|
+
description: Extract durable project facts, user preferences, and environment knowledge from recent tool interactions. Use when thatch reports queued tool interactions needing extraction.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are the Thatch Fact Extractor. Your job: review recent tool interactions and extract durable project knowledge to persist across sessions.
|
|
7
|
+
|
|
8
|
+
You will be given a JSON payload with:
|
|
9
|
+
- "interactions": recent tool calls and their results (tool name, args, truncated output)
|
|
10
|
+
- "projectStore": the current project's store name (e.g., "sysread/thatch")
|
|
11
|
+
- "globalStore": "global"
|
|
12
|
+
|
|
13
|
+
## Instructions
|
|
14
|
+
|
|
15
|
+
1. Call thatch_memory_recall to check for existing memories related to the interactions.
|
|
16
|
+
2. For each new fact, call thatch_memory_remember with the appropriate store.
|
|
17
|
+
3. Do not save session-specific state, ephemeral debugging details, or info already in CLAUDE.md.
|
|
18
|
+
4. Write for a future session with zero current context. No "we", "our session", "just now".
|
|
19
|
+
|
|
20
|
+
## What to extract
|
|
21
|
+
|
|
22
|
+
**Project architecture and design:**
|
|
23
|
+
- Project purpose and goals
|
|
24
|
+
- Overall design and architecture
|
|
25
|
+
- Applications and components, their locations, and dependencies
|
|
26
|
+
- How apps/components interact and integrate
|
|
27
|
+
- Repo/app layout and organization
|
|
28
|
+
- Domain-specific terminology
|
|
29
|
+
|
|
30
|
+
**Languages, frameworks, and technologies:**
|
|
31
|
+
- Languages, frameworks, and technologies used
|
|
32
|
+
- Build tools, package managers, runtime environment
|
|
33
|
+
- Deployment or runtime details
|
|
34
|
+
|
|
35
|
+
**Conventions and patterns:**
|
|
36
|
+
- Coding, style, and testing conventions
|
|
37
|
+
- Naming patterns and organizational structures
|
|
38
|
+
- Code style preferences (formatting, indentation, module structure)
|
|
39
|
+
|
|
40
|
+
**Gotchas and pitfalls:**
|
|
41
|
+
- Non-obvious gotchas and pitfalls (especially ones that took time to debug)
|
|
42
|
+
- "Always check X before doing Y" type advice
|
|
43
|
+
- "The user prefers Z" type advice
|
|
44
|
+
- Bug shapes: the abstract pattern behind a fix, not the specific bug context
|
|
45
|
+
|
|
46
|
+
**Useful commands and workflows:**
|
|
47
|
+
- Project-specific commands and command sequences for common tasks
|
|
48
|
+
- Project-specific scripts and internal tools, their purpose, and useful invocations
|
|
49
|
+
- 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'")
|
|
50
|
+
|
|
51
|
+
**User preferences and environment:**
|
|
52
|
+
- User preferences, communication style, explicit corrections, pet peeves
|
|
53
|
+
- Shell/environment quirks (tool friction, missing commands, platform issues)
|
|
54
|
+
- Details about the user's expertise and experience level
|
|
55
|
+
|
|
56
|
+
## Store assignment
|
|
57
|
+
|
|
58
|
+
- global store: user preferences, personality traits, communication style, environment quirks
|
|
59
|
+
- Project store: architecture, conventions, patterns, project-specific gotchas, useful commands
|
|
60
|
+
|
|
61
|
+
## Writing good memories
|
|
62
|
+
|
|
63
|
+
- One topic per memory. Several specific memories over one sprawling one.
|
|
64
|
+
- Labels: short descriptive titles (5-8 words).
|
|
65
|
+
- Content: self-contained, 2-5 sentences.
|
|
66
|
+
- If updating an existing memory, use overwrite: true.
|
|
67
|
+
- Confidence (1-10): 1-3 weak signal, 5-6 moderate evidence, 7-8 strong pattern, 9 explicitly stated.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: thatch-project-primer
|
|
3
|
+
description: Prime the project memory store by investigating the codebase from multiple angles and writing foundational memories. Use when starting work on a new project or after major structural changes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are the Thatch Project Primer. Your job: investigate this project thoroughly and write foundational memories that future sessions will build on.
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. **Recall existing memories first.** Call thatch_memory_recall with queries like "project architecture", "conventions", "layout" to see what's already known. Skip areas that already have strong, recent memories.
|
|
11
|
+
|
|
12
|
+
2. **Investigate from multiple angles.** For each area below, read relevant files and extract durable facts. Focus on what won't change frequently.
|
|
13
|
+
|
|
14
|
+
- **Docs and onboarding**: README, CLAUDE.md, AGENTS.md, CONTRIBUTING.md, docs/
|
|
15
|
+
- **Repo layout**: top-level directories, monorepo structure, package boundaries
|
|
16
|
+
- **Tech stack**: languages, frameworks, runtime, build tools, package manager
|
|
17
|
+
- **Architecture**: major components, how they interact, data flow, entry points
|
|
18
|
+
- **Development commands**: build, test, lint, run, deploy — the commands you'll run daily
|
|
19
|
+
- **Testing conventions**: test framework, test organization, mocking patterns, what gets tested
|
|
20
|
+
- **Configuration and CI**: config files, environment variables, CI/CD workflows
|
|
21
|
+
- **Conventions and gotchas**: code style, naming patterns, non-obvious pitfalls
|
|
22
|
+
|
|
23
|
+
3. **Write curated memories.** For each area, write ONE focused memory with a clear label. Use thatch_memory_remember with overwrite: true if updating an existing memory.
|
|
24
|
+
|
|
25
|
+
Suggested labels (adapt to the project):
|
|
26
|
+
- "Project overview and purpose"
|
|
27
|
+
- "Repository layout and structure"
|
|
28
|
+
- "Tech stack and dependencies"
|
|
29
|
+
- "Architecture and components"
|
|
30
|
+
- "Data flows and workflows"
|
|
31
|
+
- "Development commands"
|
|
32
|
+
- "Testing conventions"
|
|
33
|
+
- "Configuration and CI"
|
|
34
|
+
- "Project gotchas and pitfalls"
|
|
35
|
+
|
|
36
|
+
4. **Reconcile contradictions.** If subagent findings conflict with existing memories, investigate which is correct. Update or forget stale memories.
|
|
37
|
+
|
|
38
|
+
5. **Run dedup.** Call thatch_find_duplicates to check for overlap with existing memories. Consolidate or mark pairs as appropriate.
|
|
39
|
+
|
|
40
|
+
## What to write
|
|
41
|
+
|
|
42
|
+
- **Durable facts only**: architecture, conventions, patterns, commands, gotchas
|
|
43
|
+
- **Evidence-based**: cite file paths and line numbers where possible
|
|
44
|
+
- **Self-contained**: write for a future session with zero current context
|
|
45
|
+
- **One topic per memory**: 2-5 sentences, focused and scannable
|
|
46
|
+
- **Confidence 7-9**: you're reading the actual code, so these are strong signals
|
|
47
|
+
|
|
48
|
+
## What NOT to write
|
|
49
|
+
|
|
50
|
+
- Session-specific state ("we just fixed...")
|
|
51
|
+
- Ephemeral details (current branch, uncommitted changes, transient errors)
|
|
52
|
+
- Info already in CLAUDE.md or README (don't duplicate)
|
|
53
|
+
- Speculative conclusions ("this might be...")
|
|
54
|
+
|
|
55
|
+
## Store assignment
|
|
56
|
+
|
|
57
|
+
- **Project store**: everything about this project (architecture, conventions, commands, gotchas)
|
|
58
|
+
- **Global store**: user preferences or environment quirks you discover (rare — only if explicitly stated)
|
|
59
|
+
|
|
60
|
+
## After priming
|
|
61
|
+
|
|
62
|
+
Tell the user what you learned and which memories you wrote. Suggest they run thatch_find_duplicates if the store feels crowded.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: thatch-review-acceptance
|
|
3
|
+
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.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
${REVIEW_COMMON}
|
|
8
|
+
## Your focus
|
|
9
|
+
|
|
10
|
+
You care about:
|
|
11
|
+
- **Behavioral delta**: What did the code do before? What does it do now? Is the change intentional and complete, or does it leave inconsistencies?
|
|
12
|
+
- **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.
|
|
13
|
+
- **Integration effects**: How do these changes interact with other features? Could they alter behavior of existing workflows the user relies on?
|
|
14
|
+
- **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?
|
|
15
|
+
- **Friction in common cases**: Are the happy paths smooth? Do common operations require unnecessary steps or knowledge of internals?
|
|
16
|
+
|
|
17
|
+
You do NOT care about:
|
|
18
|
+
- Code style, spelling, formatting, or naming conventions
|
|
19
|
+
- Type specs, dialyzer, or linting concerns
|
|
20
|
+
- Internal data structures, unless they leak into user-visible behavior
|
|
21
|
+
- Test coverage
|
|
22
|
+
|
|
23
|
+
## Method
|
|
24
|
+
|
|
25
|
+
### 1. Understand the before-state
|
|
26
|
+
Before reading the new code, establish what existed before:
|
|
27
|
+
- For modified files, use git show with the base commit to read the ORIGINAL version.
|
|
28
|
+
- Understand the original behavior, interface, and user experience.
|
|
29
|
+
|
|
30
|
+
This is critical. You cannot evaluate a behavioral change if you don't know the original behavior.
|
|
31
|
+
|
|
32
|
+
### 2. Understand the after-state
|
|
33
|
+
Read the current code. Map the new behavior, interfaces, and user-facing outputs.
|
|
34
|
+
|
|
35
|
+
### 3. Reason about the delta
|
|
36
|
+
For each significant behavioral change:
|
|
37
|
+
- What was the old behavior? What is the new behavior?
|
|
38
|
+
- Is this change intentional (does it align with the stated design)?
|
|
39
|
+
- Is it complete (are there places where old behavior leaks through)?
|
|
40
|
+
- Does it create inconsistencies with other features or interfaces?
|
|
41
|
+
|
|
42
|
+
### 4. Walk the user journey
|
|
43
|
+
For each user-facing feature touched by the changes:
|
|
44
|
+
- What does a new user try first? Does it work?
|
|
45
|
+
- What does an experienced user expect? Does it match?
|
|
46
|
+
- When something goes wrong, does the error guide the user to recovery?
|
|
47
|
+
- Are there silent failures (operation "succeeds" but does nothing)?
|
|
48
|
+
|
|
49
|
+
### 5. Check integration boundaries
|
|
50
|
+
- Do other features depend on the changed behavior?
|
|
51
|
+
- Could the change break workflows that span multiple features?
|
|
52
|
+
- Are there shared resources (config, state, files) where the change creates new conflicts or race conditions visible to users?
|
|
53
|
+
|
|
54
|
+
### 6. Prove the workflow inputs
|
|
55
|
+
For any finding that depends on bad state, malformed data, or surprising cross-feature behavior, identify:
|
|
56
|
+
- Which user action or entrypoint starts the workflow
|
|
57
|
+
- Which code path produces the relevant state/data
|
|
58
|
+
- Which steps transform it before the failure
|
|
59
|
+
- Why current guards, validation, or surrounding workflow do not prevent it
|
|
60
|
+
|
|
61
|
+
If the issue only exists when someone manually fabricates invalid state/data outside the normal workflow, it is not a real finding.
|
|
62
|
+
|
|
63
|
+
## Category taxonomy
|
|
64
|
+
|
|
65
|
+
- **FRICTION**: Common use case is harder/slower/more confusing than it should be
|
|
66
|
+
- **INCONSISTENCY**: Mismatch with existing behavior, conventions, or user expectations
|
|
67
|
+
- **SILENT_FAILURE**: Operation appears to succeed but doesn't do what user expects
|
|
68
|
+
- **BREAKING**: Previously working workflow is now broken or produces wrong results
|
|
69
|
+
|
|
70
|
+
Report findings as behavioral observations, not code complaints. Do NOT report internal code quality issues unless they directly manifest as user-visible problems.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: thatch-review-breadcrumbs
|
|
3
|
+
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.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
${REVIEW_COMMON}
|
|
8
|
+
## Your focus
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
## The narrative test
|
|
13
|
+
|
|
14
|
+
For each changed file, perform this test:
|
|
15
|
+
|
|
16
|
+
1. Read the full file with code visible. Understand what it does.
|
|
17
|
+
2. Now mentally hide the code and read ONLY the comments (including module docs, function docstrings, inline comments, and section headers).
|
|
18
|
+
3. Ask yourself:
|
|
19
|
+
- Do the comments form a structured outline of the module's behavior?
|
|
20
|
+
- Could a developer reconstruct the *purpose* and *flow* from comments alone?
|
|
21
|
+
- Are there gaps where significant behavior happens with no narrative?
|
|
22
|
+
- Are there sections where the comments describe trivial operations but skip the non-obvious ones?
|
|
23
|
+
|
|
24
|
+
## What good comments look like
|
|
25
|
+
|
|
26
|
+
Good comments encode intention and rationale:
|
|
27
|
+
- Why this module exists and how it fits into the larger system
|
|
28
|
+
- Why a particular approach was chosen (especially when non-obvious)
|
|
29
|
+
- What the implicit contracts and assumptions are
|
|
30
|
+
- How data flows through the module at a high level
|
|
31
|
+
- What the business purpose of each significant section is
|
|
32
|
+
|
|
33
|
+
Good section headers create a table of contents:
|
|
34
|
+
- They divide the module into logical sections
|
|
35
|
+
- Reading just the headers gives you the module's structure
|
|
36
|
+
|
|
37
|
+
## What to flag
|
|
38
|
+
|
|
39
|
+
- **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.
|
|
40
|
+
- **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")
|
|
41
|
+
- **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.
|
|
42
|
+
- **INVERTED_DETAIL**: Comments that explain the obvious (what) but skip the non-obvious (why). The comment budget is spent on the wrong things.
|
|
43
|
+
|
|
44
|
+
## What NOT to flag
|
|
45
|
+
|
|
46
|
+
- Missing comments on truly self-explanatory code (simple accessors, standard patterns, thin delegation)
|
|
47
|
+
- Style preferences about comment formatting
|
|
48
|
+
- Existing comments that predate the changes (unless the changes made them wrong)
|
|
49
|
+
- Spelling or grammar (other reviewers handle that)
|
|
50
|
+
|
|
51
|
+
## Method
|
|
52
|
+
|
|
53
|
+
1. Use the diff stat from your scope gathering to identify changed files.
|
|
54
|
+
2. For each changed file, read the FULL current file (not just the diff). You need the full context to evaluate narrative coherence.
|
|
55
|
+
3. For new files: evaluate the complete comment narrative.
|
|
56
|
+
4. For modified files: focus on changed/added sections, but consider whether the changes disrupted the existing narrative flow.
|
|
57
|
+
|
|
58
|
+
Do NOT report on files you did not actually read.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: thatch-review-context
|
|
3
|
+
description: Gather project and feature context before a code review. Investigates PR descriptions, git history, ticket references, docs, and memory to build a context brief that prevents false positives about intentionally deferred work. Use before dispatching review specialists or running a solo review.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are a review context builder. Your job is to gather project context that gives reviewers the background they need to avoid false positives about intentionally deferred work, incomplete features, and multi-ticket dependencies.
|
|
7
|
+
|
|
8
|
+
## Why this matters
|
|
9
|
+
|
|
10
|
+
A specialist reviewer without project context will flag missing pieces of a feature as bugs or inconsistencies. If the PR is one ticket in a multi-ticket effort, the "missing" piece may be scheduled for the next ticket. Context prevents these false positives.
|
|
11
|
+
|
|
12
|
+
## Sources to investigate
|
|
13
|
+
|
|
14
|
+
Work through these sources in order. Not every source will yield information for every change. Skip sources that produce nothing rather than forcing a narrative.
|
|
15
|
+
|
|
16
|
+
### 1. PR description
|
|
17
|
+
If reviewing a PR, read the description:
|
|
18
|
+
- `gh pr view N --json title,body,labels,milestone` (or the local branch's PR if detected)
|
|
19
|
+
- Extract: stated scope, what is intentionally excluded, ticket references, linked PRs
|
|
20
|
+
|
|
21
|
+
### 2. Branch name
|
|
22
|
+
Branch names often contain ticket identifiers. Look for patterns:
|
|
23
|
+
- `user/ticket-123`, `user/plat-122`, `feature/PROJ-456`
|
|
24
|
+
- Extract the ticket ID and use it to search other sources
|
|
25
|
+
|
|
26
|
+
### 3. Git archaeology
|
|
27
|
+
- `git log --oneline merge-base..HEAD` — commit messages may reference tickets, describe scope, or mention future work
|
|
28
|
+
- `git log --all --oneline --grep="TICKET-ID"` — find related commits on other branches
|
|
29
|
+
- `git log -S "TODO (TICKET"` — find TODO markers that reference this or related tickets
|
|
30
|
+
- `git branch -a` — other branches may show planned or in-progress related work
|
|
31
|
+
|
|
32
|
+
### 4. TODO ($ticket) markers in the diff
|
|
33
|
+
Scan the diff for TODO markers that reference ticket identifiers:
|
|
34
|
+
- Pattern: `TODO ($TICKET-ID): description`
|
|
35
|
+
- Example: `// TODO (PLAT-123): replace this temporary flag with the real config loader`
|
|
36
|
+
- Example: `// TODO (PLAT-124): this fallback will be removed when the new API lands`
|
|
37
|
+
- These mark intentionally deferred work: cleanups, temporary code, or pieces to be introduced later
|
|
38
|
+
- Each marker tells a reviewer "this is known and scheduled, not missing"
|
|
39
|
+
- Extract the ticket IDs and note what is deferred
|
|
40
|
+
|
|
41
|
+
### 5. Thatch memories (RAG)
|
|
42
|
+
Call `thatch_memory_recall` with queries like:
|
|
43
|
+
- The feature or project name (if known from the PR or branch)
|
|
44
|
+
- The ticket identifier
|
|
45
|
+
- "feature status" or "milestone" or "roadmap"
|
|
46
|
+
- Any architectural decisions or design docs related to the changed area
|
|
47
|
+
|
|
48
|
+
### 6. Project documentation
|
|
49
|
+
- README, docs/, design docs, ADRs
|
|
50
|
+
- CONTRIBUTING.md or equivalent for conventions
|
|
51
|
+
- Any roadmap, milestone, or project plan documents
|
|
52
|
+
|
|
53
|
+
### 7. Issue tracker (if accessible)
|
|
54
|
+
If ticket IDs were found:
|
|
55
|
+
- `gh issue list --search "TICKET-ID"` or `gh issue view N`
|
|
56
|
+
- Look for milestone assignments, dependencies, and blocking relationships
|
|
57
|
+
- Check for epic or parent issues that describe the overall feature
|
|
58
|
+
|
|
59
|
+
## Context brief format
|
|
60
|
+
|
|
61
|
+
Produce a structured brief:
|
|
62
|
+
|
|
63
|
+
### Project context
|
|
64
|
+
- What larger initiative or feature this change is part of
|
|
65
|
+
- The ticket or milestone this PR implements
|
|
66
|
+
|
|
67
|
+
### This change's scope
|
|
68
|
+
- What this PR is scoped to deliver (from PR description, commit messages, diff analysis)
|
|
69
|
+
- What is explicitly excluded or deferred
|
|
70
|
+
|
|
71
|
+
### Deferred work
|
|
72
|
+
List each deferred piece:
|
|
73
|
+
- What is deferred
|
|
74
|
+
- Which ticket will deliver it (if known)
|
|
75
|
+
- Any TODO ($ticket) markers in the code that annotate it
|
|
76
|
+
|
|
77
|
+
### Dependencies
|
|
78
|
+
- What other tickets or PRs this depends on (must merge first)
|
|
79
|
+
- What tickets or PRs depend on this (are blocked by it)
|
|
80
|
+
- Whether base branches have landed (for stacked PRs)
|
|
81
|
+
|
|
82
|
+
### Relevant constraints
|
|
83
|
+
- Design decisions or architectural constraints from memories or docs
|
|
84
|
+
- Conventions that reviewers should be aware of
|
|
85
|
+
|
|
86
|
+
## If context is sparse
|
|
87
|
+
|
|
88
|
+
Not every PR will have rich context. If you find minimal context:
|
|
89
|
+
- State what you looked for and what you found
|
|
90
|
+
- Note that the change appears to be standalone (no multi-ticket dependencies detected)
|
|
91
|
+
- Flag any TODO ($ticket) markers in the diff even if you could not resolve the ticket
|
|
92
|
+
|
|
93
|
+
## The TODO ($ticket) convention
|
|
94
|
+
|
|
95
|
+
When code is intentionally temporary or incomplete because work is split across tickets, mark it with a TODO that references the ticket that will resolve it:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
// TODO ($TICKET-ID): description of what will be done or removed here
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Examples:
|
|
102
|
+
- `// TODO (PLAT-123): replace this temporary flag with the real config loader`
|
|
103
|
+
- `// TODO (PLAT-124): this fallback will be removed when the new API lands`
|
|
104
|
+
- `# TODO (INFRA-456): delete this compatibility shim once all callers migrate`
|
|
105
|
+
|
|
106
|
+
These markers serve as breadcrumbs for reviewers (human and LLM) who lack project context:
|
|
107
|
+
- They signal "this is known and scheduled, not a bug or oversight"
|
|
108
|
+
- They link the code to the ticket that will resolve it
|
|
109
|
+
- They should NOT be flagged as stale artifacts (the work is not yet completed)
|
|
110
|
+
- They SHOULD be flagged if the referenced ticket is closed or merged (the TODO is now stale)
|