kataster 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/acceptance-tester.md +53 -0
- package/.claude/agents/code-reviewer.md +56 -0
- package/.claude/agents/domain-architect.md +40 -0
- package/.claude/agents/lead-dev.md +50 -0
- package/.claude/agents/product-owner.md +39 -0
- package/.claude/agents/repo-analyst.md +78 -0
- package/.claude/agents/requirements-engineer.md +44 -0
- package/.claude/agents/ux-designer.md +64 -0
- package/.claude/hooks/bash-guard.ts +92 -0
- package/.claude/hooks/code-check.ts +37 -0
- package/.claude/hooks/path-guard.ts +34 -0
- package/.claude/hooks/path-rules.ts +66 -0
- package/.claude/hooks/project-check.ts +108 -0
- package/.claude/hooks/protect-files.ts +55 -0
- package/.claude/hooks/session-start.ts +213 -0
- package/.claude/hooks/stop-gate.ts +56 -0
- package/.claude/hooks/validate-docs.ts +58 -0
- package/.claude/lib/architecture.ts +736 -0
- package/.claude/lib/backlog-github.ts +454 -0
- package/.claude/lib/backlog-jira.ts +347 -0
- package/.claude/lib/backlog-sync.ts +42 -0
- package/.claude/lib/backlog.ts +396 -0
- package/.claude/lib/bazel.ts +212 -0
- package/.claude/lib/config.ts +122 -0
- package/.claude/lib/discovery.ts +821 -0
- package/.claude/lib/engineering.ts +406 -0
- package/.claude/lib/nx.ts +129 -0
- package/.claude/lib/repo.ts +1194 -0
- package/.claude/lib/toolgraph.ts +74 -0
- package/.claude/lib/turbo.ts +166 -0
- package/.claude/package-lock.json +427 -0
- package/.claude/package.json +21 -0
- package/.claude/settings.json +82 -0
- package/.claude/skills/adopt/SKILL.md +283 -0
- package/.claude/skills/adopt/scripts/boundary-check.ts +156 -0
- package/.claude/skills/adopt/scripts/package-doc.ts +71 -0
- package/.claude/skills/adopt/scripts/repo-map.ts +123 -0
- package/.claude/skills/adopt/scripts/rule-doc.ts +80 -0
- package/.claude/skills/architect/ADR-FORMAT.md +97 -0
- package/.claude/skills/architect/SKILL.md +64 -0
- package/.claude/skills/architect/TECH-STACK.md +21 -0
- package/.claude/skills/backlog/SKILL.md +198 -0
- package/.claude/skills/backlog/scripts/backlog-pull.ts +45 -0
- package/.claude/skills/backlog/scripts/backlog-push.ts +38 -0
- package/.claude/skills/backlog/scripts/backlog-status.ts +32 -0
- package/.claude/skills/backlog/scripts/jira-import.ts +40 -0
- package/.claude/skills/backlog/scripts/jira-plan.ts +26 -0
- package/.claude/skills/backlog/scripts/jira-record.ts +41 -0
- package/.claude/skills/bootstrap/SKILL.md +119 -0
- package/.claude/skills/codebase-design/DEEPENING.md +37 -0
- package/.claude/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/.claude/skills/codebase-design/SKILL.md +114 -0
- package/.claude/skills/domain-model/CONTEXT-FORMAT.md +47 -0
- package/.claude/skills/domain-model/SKILL.md +64 -0
- package/.claude/skills/domain-model/templates/data-model.md +29 -0
- package/.claude/skills/engineering-conventions/SKILL.md +31 -0
- package/.claude/skills/event-storming/SKILL.md +44 -0
- package/.claude/skills/event-storming/schema/events.schema.json +124 -0
- package/.claude/skills/event-storming/scripts/render-event-storming.ts +11 -0
- package/.claude/skills/event-storming/scripts/validate-events.ts +11 -0
- package/.claude/skills/event-storming/templates/events.example.yaml +91 -0
- package/.claude/skills/feature/SKILL.md +86 -0
- package/.claude/skills/feature/scripts/intake.ts +356 -0
- package/.claude/skills/grill-me/SKILL.md +7 -0
- package/.claude/skills/grill-with-docs/SKILL.md +7 -0
- package/.claude/skills/grilling/SKILL.md +30 -0
- package/.claude/skills/groom-backlog/SKILL.md +93 -0
- package/.claude/skills/groom-backlog/scripts/backlog-health.ts +238 -0
- package/.claude/skills/implement/SKILL.md +129 -0
- package/.claude/skills/implement/scripts/affected.ts +245 -0
- package/.claude/skills/implement/scripts/check-commands.ts +37 -0
- package/.claude/skills/implement/scripts/check-language.ts +15 -0
- package/.claude/skills/implement/scripts/check-scenarios.ts +59 -0
- package/.claude/skills/implement/scripts/next-story.ts +23 -0
- package/.claude/skills/implement/scripts/story-context.ts +135 -0
- package/.claude/skills/implement/scripts/story-status.ts +47 -0
- package/.claude/skills/implement/scripts/verify.ts +92 -0
- package/.claude/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
- package/.claude/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/.claude/skills/retro/SKILL.md +53 -0
- package/.claude/skills/review-stories/SKILL.md +31 -0
- package/.claude/skills/shape/SKILL.md +193 -0
- package/.claude/skills/tdd/SKILL.md +38 -0
- package/.claude/skills/tdd/mocking.md +59 -0
- package/.claude/skills/tdd/tests.md +77 -0
- package/.claude/skills/user-stories/SKILL.md +138 -0
- package/.claude/skills/user-stories/schema/story.schema.json +39 -0
- package/.claude/skills/user-stories/scripts/render-backlog.ts +4 -0
- package/.claude/skills/user-stories/scripts/validate-stories.ts +13 -0
- package/.claude/skills/user-stories/templates/story-template.md +38 -0
- package/.claude/skills/ux-design/SKILL.md +107 -0
- package/.claude/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
- package/.claude/skills/writing-for-agents/SKILL.md +81 -0
- package/.claude/tsconfig.json +15 -0
- package/.opencode/agents/acceptance-tester.md +64 -0
- package/.opencode/agents/code-reviewer.md +69 -0
- package/.opencode/agents/domain-architect.md +59 -0
- package/.opencode/agents/lead-dev.md +67 -0
- package/.opencode/agents/product-owner.md +59 -0
- package/.opencode/agents/repo-analyst.md +86 -0
- package/.opencode/agents/requirements-engineer.md +58 -0
- package/.opencode/agents/ux-designer.md +83 -0
- package/.opencode/commands/adopt.md +7 -0
- package/.opencode/commands/backlog-sync.md +7 -0
- package/.opencode/commands/bootstrap.md +7 -0
- package/.opencode/commands/event-storming.md +7 -0
- package/.opencode/commands/feature.md +7 -0
- package/.opencode/commands/grill-me.md +7 -0
- package/.opencode/commands/grill-with-docs.md +7 -0
- package/.opencode/commands/groom-backlog.md +7 -0
- package/.opencode/commands/implement.md +7 -0
- package/.opencode/commands/improve-codebase-architecture.md +7 -0
- package/.opencode/commands/retro.md +7 -0
- package/.opencode/commands/review-stories.md +7 -0
- package/.opencode/commands/shape.md +7 -0
- package/.opencode/opencode.jsonc +15 -0
- package/.opencode/plugins/kataster/index.ts +283 -0
- package/AGENTS.md +21 -0
- package/CHANGELOG.md +82 -0
- package/LICENSE +21 -0
- package/README.md +324 -2
- package/bin/kataster.mjs +7 -0
- package/extras/skills/shadcn/SKILL.md +277 -0
- package/extras/skills/shadcn/agents/openai.yml +5 -0
- package/extras/skills/shadcn/assets/shadcn-small.png +0 -0
- package/extras/skills/shadcn/assets/shadcn.png +0 -0
- package/extras/skills/shadcn/cli.md +290 -0
- package/extras/skills/shadcn/customization.md +209 -0
- package/extras/skills/shadcn/evals/evals.json +77 -0
- package/extras/skills/shadcn/mcp.md +105 -0
- package/extras/skills/shadcn/registry.md +277 -0
- package/extras/skills/shadcn/rules/base-vs-radix.md +306 -0
- package/extras/skills/shadcn/rules/chat.md +250 -0
- package/extras/skills/shadcn/rules/composition.md +213 -0
- package/extras/skills/shadcn/rules/forms.md +192 -0
- package/extras/skills/shadcn/rules/icons.md +101 -0
- package/extras/skills/shadcn/rules/styling.md +185 -0
- package/guide/README.md +9 -0
- package/guide/brownfield.md +242 -0
- package/guide/concepts.md +109 -0
- package/guide/greenfield.md +84 -0
- package/guide/install.md +144 -0
- package/guide/release.md +62 -0
- package/package.json +56 -4
- package/src/cli.mjs +302 -0
- package/src/detect.mjs +237 -0
- package/src/install.mjs +427 -0
- package/src/repo.mjs +129 -0
- package/src/util.mjs +110 -0
- package/templates/CONTEXT.md +21 -0
- package/templates/conventions.md +63 -0
- package/templates/docs/adr/README.md +7 -0
- package/templates/docs/architecture/data-model.md +31 -0
- package/templates/docs/domain/context-map.md +21 -0
- package/templates/docs/domain/events.yaml +23 -0
- package/templates/docs/product/initiatives/README.md +41 -0
- package/templates/docs/product/ux-guidelines.md +27 -0
- package/templates/docs/product/vision.md +36 -0
- package/templates/docs/reviews/.gitkeep +0 -0
- package/templates/docs/stories/OPEN_QUESTIONS.md +8 -0
- package/templates/docs/stories/README.md +26 -0
- package/templates/docs/workflow.md +135 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ubiquitous language in the code: flags words that CONTEXT.md lists under `_Avoid_`
|
|
3
|
+
* - in message catalog values (files in messages/, locales/ or i18n/ starting with the artifact language)
|
|
4
|
+
* - in identifiers declared in application code (generic programming words like "id" or "type" are skipped)
|
|
5
|
+
*
|
|
6
|
+
* Advisory: findings are warnings and never fail the build. A line containing `language-ok` is skipped
|
|
7
|
+
* (e.g. a third-party library's `user` object).
|
|
8
|
+
*
|
|
9
|
+
* Usage: node check-language.ts
|
|
10
|
+
*/
|
|
11
|
+
import * as e from "../../../lib/engineering.ts";
|
|
12
|
+
|
|
13
|
+
const findings = e.languageFindings();
|
|
14
|
+
for (const f of findings) console.log(`WARNING ${f.file} (${f.where}): '${f.word}' – the glossary says '${f.preferred}'`);
|
|
15
|
+
console.log(findings.length ? `${findings.length} language warning(s).` : "Glossary language OK.");
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traceability between acceptance criteria and tests.
|
|
3
|
+
* Every scenario of a story that is in progress or done needs a test titled exactly `ST-NNN: <scenario title>`.
|
|
4
|
+
*
|
|
5
|
+
* ERROR a done story with a scenario without a test – unless a later story superseded the scenario
|
|
6
|
+
* ERROR a test title `ST-NNN: …` that matches no scenario (renamed scenario, typo, unknown story)
|
|
7
|
+
* ERROR a superseded scenario (docs/stories/superseded-scenarios.json) that is stale: no such scenario, the
|
|
8
|
+
* superseding story not in progress or done, or a test for it still there
|
|
9
|
+
* INFO scenarios still missing for stories in progress
|
|
10
|
+
*
|
|
11
|
+
* Usage: node check-scenarios.ts [ST-NNN] (with an ID: only that story, missing tests are listed)
|
|
12
|
+
*/
|
|
13
|
+
import * as d from "../../../lib/discovery.ts";
|
|
14
|
+
import * as e from "../../../lib/engineering.ts";
|
|
15
|
+
|
|
16
|
+
const only = process.argv[2]?.toUpperCase();
|
|
17
|
+
const stories = e.storiesById();
|
|
18
|
+
const titles = e.testTitles();
|
|
19
|
+
const report = new d.Report();
|
|
20
|
+
const info: string[] = [];
|
|
21
|
+
const superseded = e.supersededScenarios();
|
|
22
|
+
|
|
23
|
+
for (const [id, scenarios] of superseded) {
|
|
24
|
+
const story = stories.get(id);
|
|
25
|
+
const own = story ? e.scenarioTitles(story) : [];
|
|
26
|
+
for (const [scenario, by] of scenarios) {
|
|
27
|
+
if (!own.includes(scenario)) report.error(id, `superseded scenario "${scenario}" is no scenario of ${id}`);
|
|
28
|
+
const superseding = stories.get(by);
|
|
29
|
+
if (!superseding || !["in-progress", "done"].includes(superseding.meta.status)) {
|
|
30
|
+
report.error(id, `scenario "${scenario}" is superseded by ${by}, which is neither in progress nor done`);
|
|
31
|
+
}
|
|
32
|
+
if (titles.some((t) => t.title === e.testTitle(id, scenario).replace(/\s+/g, " "))) {
|
|
33
|
+
report.error(id, `superseded scenario "${scenario}" still has a test – remove the test or the entry`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (const [id, s] of stories) {
|
|
39
|
+
if (only ? id !== only : !["in-progress", "done"].includes(s.meta.status) || s.meta.type !== "story") continue;
|
|
40
|
+
const { covered, missing: untested } = e.scenarioCoverage(s, titles);
|
|
41
|
+
const missing = untested.filter((sc) => !superseded.get(id)?.has(sc));
|
|
42
|
+
for (const sc of missing) {
|
|
43
|
+
if (s.meta.status === "done") report.error(id, `scenario without test: "${e.testTitle(id, sc)}"`);
|
|
44
|
+
else info.push(`${id}: missing test "${e.testTitle(id, sc)}"`);
|
|
45
|
+
}
|
|
46
|
+
info.push(`${id}: ${covered.length}/${covered.length + missing.length} scenarios covered`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const known = new Set<string>();
|
|
50
|
+
for (const [id, s] of stories) for (const sc of e.scenarioTitles(s)) known.add(e.testTitle(id, sc).replace(/\s+/g, " "));
|
|
51
|
+
for (const t of titles) {
|
|
52
|
+
if (only && !t.title.startsWith(`${only}:`)) continue;
|
|
53
|
+
if (!known.has(t.title)) report.error(t.file, `test title "${t.title}" matches no scenario of any story`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (const line of info) console.log(`INFO ${line}`);
|
|
57
|
+
for (const line of report.lines()) console.log(line);
|
|
58
|
+
console.log(report.ok ? "Scenario traceability OK." : `${report.errors.length} error(s).`);
|
|
59
|
+
process.exit(report.ok ? 0 : 1);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints the story to work on: a story already in progress, otherwise the first `ready` story
|
|
3
|
+
* in backlog order whose dependencies are all done.
|
|
4
|
+
*
|
|
5
|
+
* Usage: node next-story.ts [--json]
|
|
6
|
+
*/
|
|
7
|
+
import * as d from "../../../lib/discovery.ts";
|
|
8
|
+
import * as e from "../../../lib/engineering.ts";
|
|
9
|
+
|
|
10
|
+
const { inProgress, next, blocked } = e.nextStory();
|
|
11
|
+
const brief = (s: d.Story) => ({ id: d.storyId(s), title: s.meta.title, type: s.meta.type, size: s.meta.size, path: d.rel(s.path) });
|
|
12
|
+
|
|
13
|
+
if (process.argv.includes("--json")) {
|
|
14
|
+
console.log(JSON.stringify({ inProgress: inProgress.map(brief), next: next && brief(next), blocked: blocked.length }, null, 2));
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
for (const s of inProgress) console.log(`IN PROGRESS ${d.storyId(s)} – ${s.meta.title} (${d.rel(s.path)}) – finish this first`);
|
|
18
|
+
if (next) {
|
|
19
|
+
console.log(`NEXT ${d.storyId(next)} – ${next.meta.title} [${next.meta.type}, ${next.meta.size}] (${d.rel(next.path)})`);
|
|
20
|
+
} else {
|
|
21
|
+
console.log("NEXT none – no ready story has all its dependencies done");
|
|
22
|
+
}
|
|
23
|
+
console.log(`${blocked.length} ready stories are waiting for dependencies.`);
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the context pack for one story as Markdown: everything the implementation needs from discovery,
|
|
3
|
+
* collected deterministically instead of by searching.
|
|
4
|
+
*
|
|
5
|
+
* - the story itself and the exact test titles its scenarios need
|
|
6
|
+
* - dependencies and their status
|
|
7
|
+
* - from events.yaml: linked events, the commands producing them (with rules), their aggregates (with invariants),
|
|
8
|
+
* policies triggered by the events, every other ID the story mentions (read models, policies, hotspots, …)
|
|
9
|
+
* and the hotspots referring to any of these
|
|
10
|
+
* - glossary entries of every CONTEXT.md term the story uses
|
|
11
|
+
* - the data model sections of the aggregates involved
|
|
12
|
+
* - ADRs: those the story mentions in full, the others as a list
|
|
13
|
+
* - answered open questions about the story
|
|
14
|
+
*
|
|
15
|
+
* Usage: node story-context.ts ST-010 [> file]
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { stringify } from "yaml";
|
|
20
|
+
import * as d from "../../../lib/discovery.ts";
|
|
21
|
+
import * as e from "../../../lib/engineering.ts";
|
|
22
|
+
|
|
23
|
+
const id = process.argv[2]?.toUpperCase();
|
|
24
|
+
if (!id) {
|
|
25
|
+
console.error("Usage: node story-context.ts ST-NNN");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
let story: d.Story;
|
|
29
|
+
try {
|
|
30
|
+
story = e.findStory(id);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error(String(err instanceof Error ? err.message : err));
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const stories = e.storiesById();
|
|
36
|
+
const list = (v: unknown): string[] => (Array.isArray(v) ? v : []);
|
|
37
|
+
const read = (p: string): string => (existsSync(p) ? readFileSync(p, "utf8") : "");
|
|
38
|
+
const storyText = read(story.path);
|
|
39
|
+
const out: string[] = [`# Context pack – ${id}: ${story.meta.title}`, ""];
|
|
40
|
+
|
|
41
|
+
// Story
|
|
42
|
+
out.push("## Story file", "", `\`${d.rel(story.path)}\``, "", "````markdown", storyText.trimEnd(), "````", "");
|
|
43
|
+
if (story.meta.type === "story") {
|
|
44
|
+
out.push("## Test titles (exact)", "", "Every scenario gets one test with exactly this title:", "");
|
|
45
|
+
for (const sc of e.scenarioTitles(story)) out.push(`- \`${e.testTitle(id, sc)}\``);
|
|
46
|
+
out.push("");
|
|
47
|
+
} else {
|
|
48
|
+
out.push("## Acceptance checklist", "", "Tick each item (`- [x]`) in the story file when it is done.", "");
|
|
49
|
+
}
|
|
50
|
+
const deps = list(story.meta.depends_on);
|
|
51
|
+
if (deps.length) {
|
|
52
|
+
out.push("## Dependencies", "");
|
|
53
|
+
for (const dep of deps) {
|
|
54
|
+
const s = stories.get(dep);
|
|
55
|
+
out.push(`- ${dep} – ${s?.meta.title ?? "(missing)"} – **${s?.meta.status ?? "?"}**`);
|
|
56
|
+
}
|
|
57
|
+
out.push("");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Domain model
|
|
61
|
+
const model = d.loadEventsModel();
|
|
62
|
+
const aggregates = new Set<string>();
|
|
63
|
+
if (model) {
|
|
64
|
+
const idx = d.indexModel(model);
|
|
65
|
+
const items = (key: string): d.Obj[] => (model[key] ?? []) as d.Obj[];
|
|
66
|
+
const picked = new Map<string, d.Obj>();
|
|
67
|
+
const pick = (x: string) => {
|
|
68
|
+
const item = idx.get(x);
|
|
69
|
+
if (item) picked.set(x, item);
|
|
70
|
+
};
|
|
71
|
+
const events = list(story.meta.events);
|
|
72
|
+
events.forEach(pick);
|
|
73
|
+
for (const c of items("commands")) if (list(c.produces).some((ev) => events.includes(ev))) pick(c.id);
|
|
74
|
+
for (const p of items("policies")) if (list(p.when).some((ev) => events.includes(ev))) pick(p.id);
|
|
75
|
+
for (const m of storyText.matchAll(/\b(?:AGG|EVT|CMD|POL|RM|HS|ACT|EXT)-[A-Za-z0-9]+\b/g)) pick(m[0]);
|
|
76
|
+
for (const item of picked.values()) if (item.aggregate) aggregates.add(item.aggregate);
|
|
77
|
+
aggregates.forEach(pick);
|
|
78
|
+
const ids = new Set(picked.keys());
|
|
79
|
+
for (const h of items("hotspots")) if (list(h.refs).some((r) => ids.has(r))) pick(h.id);
|
|
80
|
+
|
|
81
|
+
const order = ["EVT", "CMD", "AGG", "POL", "RM", "ACT", "EXT", "HS"];
|
|
82
|
+
const sorted = [...picked.values()].sort(
|
|
83
|
+
(a, b) => order.indexOf(a.id.split("-")[0]) - order.indexOf(b.id.split("-")[0]) || a.id.localeCompare(b.id),
|
|
84
|
+
);
|
|
85
|
+
out.push("## Event storming model (`docs/domain/events.yaml`)", "", "```yaml", stringify(sorted, { lineWidth: 0 }).trimEnd(), "```", "");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Glossary
|
|
89
|
+
const glossary = read(join(d.ROOT, "CONTEXT.md"));
|
|
90
|
+
if (glossary) {
|
|
91
|
+
const entries: string[] = [];
|
|
92
|
+
const blocks = glossary.split(/\n(?=\*\*[^*]+\*\*:?\s*\n)/);
|
|
93
|
+
const lowerStory = storyText.toLowerCase();
|
|
94
|
+
for (const block of blocks.slice(1)) {
|
|
95
|
+
const term = /^\*\*(.+?)\*\*/.exec(block)?.[1].replace(/:$/, "");
|
|
96
|
+
if (!term) continue;
|
|
97
|
+
const re = new RegExp(`\\b${term.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i");
|
|
98
|
+
if (re.test(lowerStory)) entries.push(block.split(/\n(?=#)/)[0].trim());
|
|
99
|
+
}
|
|
100
|
+
if (entries.length) out.push("## Glossary (`CONTEXT.md`, terms used by the story)", "", ...entries.flatMap((x) => [x, ""]));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Data model
|
|
104
|
+
const dataModel = read(join(d.ROOT, "docs", "architecture", "data-model.md"));
|
|
105
|
+
if (dataModel && aggregates.size) {
|
|
106
|
+
const secs = dataModel.split(/\n(?=## )/);
|
|
107
|
+
const hits = secs.filter((s) => [...aggregates].some((a) => s.split("\n")[0].includes(`\`${a}\``)));
|
|
108
|
+
if (hits.length) out.push("## Data model (`docs/architecture/data-model.md`)", "", ...hits.flatMap((s) => [s.trim().replace(/^## /, "### "), ""]));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ADRs
|
|
112
|
+
const adrDir = join(d.ROOT, "docs", "adr");
|
|
113
|
+
if (existsSync(adrDir)) {
|
|
114
|
+
const adrs = readdirSync(adrDir).filter((f) => /^\d{4}-.*\.md$/.test(f)).sort();
|
|
115
|
+
const mentioned = adrs.filter((f) => {
|
|
116
|
+
const n = f.slice(0, 4);
|
|
117
|
+
return storyText.includes(f) || new RegExp(`\\bADR[ -]?${n}\\b`).test(storyText);
|
|
118
|
+
});
|
|
119
|
+
out.push("## ADRs (`docs/adr/`)", "");
|
|
120
|
+
for (const f of adrs) {
|
|
121
|
+
const text = read(join(adrDir, f));
|
|
122
|
+
const title = /^# (.+)$/m.exec(text)?.[1] ?? f;
|
|
123
|
+
const status = /^status:\s*(.+)$/m.exec(text)?.[1] ?? "?";
|
|
124
|
+
out.push(`- \`${f}\` – ${title} – ${status}${mentioned.includes(f) ? " – **mentioned by the story, full text below**" : ""}`);
|
|
125
|
+
}
|
|
126
|
+
out.push("");
|
|
127
|
+
for (const f of mentioned) out.push(`### ${f}`, "", read(join(adrDir, f)).replace(/^---[\s\S]*?---\n/, "").trim().replace(/^# .*\n/, ""), "");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Open questions
|
|
131
|
+
const oq = read(join(d.STORIES_DIR, "OPEN_QUESTIONS.md"));
|
|
132
|
+
const rows = oq.split("\n").filter((l) => l.startsWith("|") && new RegExp(`\\b${id}\\b`).test(l));
|
|
133
|
+
if (rows.length) out.push("## Open questions about this story", "", "| Story/artifact | Question | Since | Answer |", "|---|---|---|---|", ...rows, "");
|
|
134
|
+
|
|
135
|
+
console.log(out.join("\n"));
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moves a story to a new status, enforcing the workflow and its preconditions:
|
|
3
|
+
* in-progress / done – all depends_on are done
|
|
4
|
+
* done (story) – every Gherkin scenario has a test titled `ST-NNN: <scenario title>`
|
|
5
|
+
* done (all types) – every checklist item in the acceptance criteria is ticked (`- [x]`) – also a story's foundation checklist
|
|
6
|
+
* done is final – changes become a new story
|
|
7
|
+
* superseded – from draft, review or ready: done elsewhere or replaced by a new planning; final as well
|
|
8
|
+
*
|
|
9
|
+
* Usage: node story-status.ts ST-010 in-progress|ready|done|review|superseded
|
|
10
|
+
*/
|
|
11
|
+
import * as d from "../../../lib/discovery.ts";
|
|
12
|
+
import * as e from "../../../lib/engineering.ts";
|
|
13
|
+
import { syncStatusAfterChange } from "../../../lib/backlog-sync.ts";
|
|
14
|
+
|
|
15
|
+
const [id, to] = process.argv.slice(2);
|
|
16
|
+
if (!id || !to || !(d.STATUSES as readonly string[]).includes(to)) {
|
|
17
|
+
console.error(`Usage: node story-status.ts ST-NNN <${d.STATUSES.join("|")}>`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const stories = e.storiesById();
|
|
21
|
+
const story = stories.get(id.toUpperCase());
|
|
22
|
+
if (!story) {
|
|
23
|
+
console.error(`Story '${id}' not found in docs/stories/.`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
const from = String(story.meta.status);
|
|
27
|
+
const errs = e.transitionErrors(story, from, to, stories);
|
|
28
|
+
if (errs.length) {
|
|
29
|
+
console.error(`${d.storyId(story)} cannot go from '${from}' to '${to}':\n${errs.map((x) => ` - ${x}`).join("\n")}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
e.writeStatus(story, to);
|
|
33
|
+
|
|
34
|
+
const report = new d.Report();
|
|
35
|
+
d.validateStories(report, story.path, true);
|
|
36
|
+
if (!report.ok) {
|
|
37
|
+
e.writeStatus(story, from);
|
|
38
|
+
console.error(`Validation failed, status left at '${from}':\n${report.lines().join("\n")}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
d.writeBacklogMd();
|
|
42
|
+
console.log(`${d.storyId(story)}: ${from} → ${to}`);
|
|
43
|
+
|
|
44
|
+
// With a tracker the local mirror is only half the change. GitHub can follow from here (gh); for Jira this prints
|
|
45
|
+
// the MCP transition the agent has to run. A failure here never rolls the status back.
|
|
46
|
+
const tracker = syncStatusAfterChange({ ...story, meta: { ...story.meta, status: to } }, to);
|
|
47
|
+
if (tracker) console.log(tracker);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one quality gate – used by /implement, CI (`verify` in the project's task runner) and developers.
|
|
3
|
+
*
|
|
4
|
+
* 1. Project checks, from `commands` in `.claude/project.json` (falling back to the root package.json
|
|
5
|
+
* scripts): lint (incl. module boundary rules), typecheck, test (with --e2e also test:e2e)
|
|
6
|
+
* 2. Discovery artifacts: events.yaml and stories are valid
|
|
7
|
+
* 3. Traceability: scenario ↔ test titles, domain IDs in the code
|
|
8
|
+
* 4. Glossary language (warnings only)
|
|
9
|
+
*
|
|
10
|
+
* Writes the result to .claude/state/last-verify.json (shown at session start). Exit 1 if any step failed.
|
|
11
|
+
*
|
|
12
|
+
* Usage: node verify.ts [--e2e]
|
|
13
|
+
*/
|
|
14
|
+
import { spawnSync } from "node:child_process";
|
|
15
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import * as d from "../../../lib/discovery.ts";
|
|
18
|
+
import * as e from "../../../lib/engineering.ts";
|
|
19
|
+
|
|
20
|
+
const here = import.meta.dirname;
|
|
21
|
+
const steps: e.VerifyState["steps"] = [];
|
|
22
|
+
|
|
23
|
+
function run(name: string, command: string, args: string[] = [], advisory = false): void {
|
|
24
|
+
console.log(`\n━━ ${name} ━━`);
|
|
25
|
+
const r = spawnSync(command, args, { cwd: d.ROOT, stdio: "inherit" });
|
|
26
|
+
const ok = r.status === 0;
|
|
27
|
+
steps.push({ name, ok: ok || advisory });
|
|
28
|
+
if (!ok) console.log(advisory ? `⚠ ${name} (advisory, not blocking)` : `✗ ${name} failed`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function shell(name: string, command: string): void {
|
|
32
|
+
console.log(`\n━━ ${name} ━━\n$ ${command}`);
|
|
33
|
+
const r = spawnSync(command, { cwd: d.ROOT, stdio: "inherit", shell: true });
|
|
34
|
+
const ok = r.status === 0;
|
|
35
|
+
steps.push({ name, ok });
|
|
36
|
+
if (!ok) console.log(`✗ ${name} failed`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Commands from the project profile; empty values are skipped. */
|
|
40
|
+
function profileCommands(): Record<string, string> {
|
|
41
|
+
const file = join(d.ROOT, ".claude", "project.json");
|
|
42
|
+
if (!existsSync(file)) return {};
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(readFileSync(file, "utf8")).commands ?? {};
|
|
45
|
+
} catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const commands = profileCommands();
|
|
51
|
+
const appSteps = ["lint", "typecheck", "test", ...(process.argv.includes("--e2e") ? ["e2e"] : [])];
|
|
52
|
+
const scripts = e.appScripts();
|
|
53
|
+
const configured = appSteps.filter((s) => commands[s]);
|
|
54
|
+
const fallback = appSteps.filter((s) => !commands[s] && scripts[s]);
|
|
55
|
+
|
|
56
|
+
if (!configured.length && !fallback.length) {
|
|
57
|
+
console.log(
|
|
58
|
+
"━━ project ━━\nNo lint/typecheck/test commands configured in `.claude/project.json` and no root package.json scripts – project checks skipped.",
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
for (const s of configured) shell(s, commands[s]);
|
|
62
|
+
for (const s of fallback) run(`npm run ${s}`, "npm", ["run", s]);
|
|
63
|
+
for (const s of appSteps.filter((s) => !commands[s] && !scripts[s])) {
|
|
64
|
+
if (Object.keys(commands).length || Object.keys(scripts).length) {
|
|
65
|
+
console.log(`\n━━ ${s} ━━\nno '${s}' command configured – skipped`);
|
|
66
|
+
steps.push({ name: s, ok: true, skipped: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const node = process.execPath;
|
|
71
|
+
const disc = join(here, "..", "..");
|
|
72
|
+
run("events.yaml", node, [join(disc, "event-storming", "scripts", "validate-events.ts")]);
|
|
73
|
+
run("stories", node, [join(disc, "user-stories", "scripts", "validate-stories.ts")]);
|
|
74
|
+
// The map is generated; staleness is a warning (adoption may not have run yet), not a failed gate.
|
|
75
|
+
run("repository map", node, [join(disc, "adopt", "scripts", "repo-map.ts"), "--check"], true);
|
|
76
|
+
run("path-scoped rules", node, [join(disc, "adopt", "scripts", "rule-doc.ts"), "--check"], true);
|
|
77
|
+
run("project checks", node, [join(d.ROOT, ".claude", "hooks", "project-check.ts"), "--phase", "stop"]);
|
|
78
|
+
run("scenario ↔ test traceability", node, [join(here, "check-scenarios.ts")]);
|
|
79
|
+
run("domain ID traceability", node, [join(here, "check-commands.ts")]);
|
|
80
|
+
run("glossary language", node, [join(here, "check-language.ts")], true);
|
|
81
|
+
|
|
82
|
+
const ok = steps.every((s) => s.ok);
|
|
83
|
+
e.writeVerifyState({
|
|
84
|
+
at: new Date().toISOString(),
|
|
85
|
+
branch: e.git("rev-parse", "--abbrev-ref", "HEAD"),
|
|
86
|
+
commit: e.git("rev-parse", "--short", "HEAD"),
|
|
87
|
+
dirty: (e.git("status", "--porcelain") ?? "") !== "",
|
|
88
|
+
ok,
|
|
89
|
+
steps,
|
|
90
|
+
});
|
|
91
|
+
console.log(`\n${ok ? "✓ verify passed" : "✗ verify FAILED: " + steps.filter((s) => !s.ok).map((s) => s.name).join(", ")}`);
|
|
92
|
+
process.exit(ok ? 0 : 1);
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# HTML Report Format
|
|
2
|
+
|
|
3
|
+
The architectural review is rendered as a single self-contained HTML file in the OS temp directory. Tailwind and Mermaid both come from CDNs. Mermaid handles graph-shaped diagrams reliably; hand-built divs and inline SVG handle the more editorial visuals (mass diagrams, cross-sections). Mix the two: don't lean on Mermaid for everything, it'll start to look generic.
|
|
4
|
+
|
|
5
|
+
## Scaffold
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!doctype html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="utf-8" />
|
|
12
|
+
<title>Architecture review for {{repo name}}</title>
|
|
13
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
14
|
+
<script type="module">
|
|
15
|
+
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
|
|
16
|
+
mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
|
|
17
|
+
</script>
|
|
18
|
+
<style>
|
|
19
|
+
/* small custom layer for things Tailwind doesn't cover cleanly:
|
|
20
|
+
dashed seam lines, hand-drawn-feeling arrow heads, etc. */
|
|
21
|
+
.seam { stroke-dasharray: 4 4; }
|
|
22
|
+
.leak { stroke: #dc2626; }
|
|
23
|
+
.deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body class="bg-stone-50 text-slate-900 font-sans">
|
|
27
|
+
<main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
|
|
28
|
+
<header>...</header>
|
|
29
|
+
<section id="candidates" class="space-y-10">...</section>
|
|
30
|
+
<section id="top-recommendation">...</section>
|
|
31
|
+
</main>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Header
|
|
37
|
+
|
|
38
|
+
Repo name, date, and a compact legend: solid box = module, dashed line = seam, red arrow = leakage, thick dark box = deep module. No introduction paragraph. Straight into the candidates.
|
|
39
|
+
|
|
40
|
+
## Candidate card
|
|
41
|
+
|
|
42
|
+
The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms (from the `/codebase-design` skill) without ceremony.
|
|
43
|
+
|
|
44
|
+
Each candidate is one `<article>`:
|
|
45
|
+
|
|
46
|
+
- **Title**: short, names the deepening (e.g. "Collapse the Order intake pipeline").
|
|
47
|
+
- **Badge row**: recommendation strength (`Strong` = emerald, `Worth exploring` = amber, `Speculative` = slate), plus a tag for the dependency category (`in-process`, `local-substitutable`, `ports & adapters`, `mock`).
|
|
48
|
+
- **Files**: monospaced list, `font-mono text-sm`.
|
|
49
|
+
- **Before / After diagram**: the centrepiece. Two columns, side by side. See patterns below.
|
|
50
|
+
- **Problem**: one sentence. What hurts.
|
|
51
|
+
- **Solution**: one sentence. What changes.
|
|
52
|
+
- **Wins**: bullets, ≤6 words each. e.g. "Tests hit one interface", "Pricing logic stops leaking", "Delete 4 shallow wrappers".
|
|
53
|
+
- **ADR callout** (if applicable): one line in an amber-tinted box.
|
|
54
|
+
|
|
55
|
+
No paragraphs of explanation. If the diagram needs a paragraph to be understood, redraw the diagram.
|
|
56
|
+
|
|
57
|
+
## Diagram patterns
|
|
58
|
+
|
|
59
|
+
Pick the pattern that fits the candidate. Mix them. Don't make every diagram look the same. Variety is part of the point.
|
|
60
|
+
|
|
61
|
+
### Mermaid graph (the workhorse for dependencies / call flow)
|
|
62
|
+
|
|
63
|
+
Use a Mermaid `flowchart` or `graph` when the point is "X calls Y calls Z, and look at the mess." Wrap it in a Tailwind-styled card so it doesn't feel parachuted in. Style with classDef to colour leakage edges red and the deep module dark. Sequence diagrams work well for "before: 6 round-trips; after: 1."
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
|
67
|
+
<pre class="mermaid">
|
|
68
|
+
flowchart LR
|
|
69
|
+
A[OrderHandler] --> B[OrderValidator]
|
|
70
|
+
B --> C[OrderRepo]
|
|
71
|
+
C -.leak.-> D[PricingClient]
|
|
72
|
+
classDef leak stroke:#dc2626,stroke-width:2px;
|
|
73
|
+
class C,D leak
|
|
74
|
+
</pre>
|
|
75
|
+
</div>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Hand-built boxes-and-arrows (when Mermaid's layout fights you)
|
|
79
|
+
|
|
80
|
+
Modules as `<div>`s with borders and labels. Arrows as inline SVG `<line>` or `<path>` elements positioned absolutely over a relative container. Reach for this when you want the "after" diagram to feel like one thick-bordered deep module with greyed-out internals, since Mermaid won't render that with the right weight.
|
|
81
|
+
|
|
82
|
+
### Cross-section (good for layered shallowness)
|
|
83
|
+
|
|
84
|
+
Stack horizontal bands (`h-12 border-l-4`) to show layers a call passes through. Before: 6 thin layers each doing nothing. After: 1 thick band labelled with the consolidated responsibility.
|
|
85
|
+
|
|
86
|
+
### Mass diagram (good for "interface as wide as implementation")
|
|
87
|
+
|
|
88
|
+
Two rectangles per module: one for interface surface area, one for implementation. Before: interface rectangle is nearly as tall as the implementation rectangle (shallow). After: interface rectangle is short, implementation rectangle is tall (deep).
|
|
89
|
+
|
|
90
|
+
### Call-graph collapse
|
|
91
|
+
|
|
92
|
+
Before: a tree of function calls rendered as nested boxes. After: the same tree collapsed into one box, with the now-internal calls shown faded inside it.
|
|
93
|
+
|
|
94
|
+
## Style guidance
|
|
95
|
+
|
|
96
|
+
- Lean editorial, not corporate-dashboard. Generous whitespace. Serif optional for headings (`font-serif` works well with stone/slate).
|
|
97
|
+
- Colour sparingly: one accent (emerald or indigo) plus red for leakage and amber for warnings.
|
|
98
|
+
- Keep diagrams ~320px tall so before/after sits comfortably side by side without scrolling.
|
|
99
|
+
- Use `text-xs uppercase tracking-wider` for module labels inside diagrams, so they read as schematic, not as UI.
|
|
100
|
+
- The only scripts are the Tailwind CDN and the Mermaid ESM import. The report is otherwise static: no app code, no interactivity beyond Mermaid's own rendering.
|
|
101
|
+
|
|
102
|
+
## Top recommendation section
|
|
103
|
+
|
|
104
|
+
One larger card. Candidate name, one sentence on why, anchor link to its card. That's it.
|
|
105
|
+
|
|
106
|
+
## Tone
|
|
107
|
+
|
|
108
|
+
Plain English, concise, but the architectural nouns and verbs come straight from the `/codebase-design` skill. Concision is not an excuse to drift.
|
|
109
|
+
|
|
110
|
+
**Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
|
|
111
|
+
|
|
112
|
+
**Never substitute:** component, service, unit (for module) · API, signature (for interface) · boundary (for seam) · layer, wrapper (for module, when you mean module).
|
|
113
|
+
|
|
114
|
+
**Phrasings that fit the style:**
|
|
115
|
+
|
|
116
|
+
- "Order intake module is shallow: interface nearly matches the implementation."
|
|
117
|
+
- "Pricing leaks across the seam."
|
|
118
|
+
- "Deepen: one interface, one place to test."
|
|
119
|
+
- "Two adapters justify the seam: HTTP in prod, in-memory in tests."
|
|
120
|
+
|
|
121
|
+
**Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"*, because those terms aren't in the glossary and don't earn their place.
|
|
122
|
+
|
|
123
|
+
No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in the `/codebase-design` glossary, reach for one that is before inventing a new one.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: improve-codebase-architecture
|
|
3
|
+
description: Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Improve Codebase Architecture
|
|
8
|
+
|
|
9
|
+
Surface architectural friction and propose **deepening opportunities**: refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
|
|
10
|
+
|
|
11
|
+
This command is _informed_ by the project's domain model and built on a shared design vocabulary:
|
|
12
|
+
|
|
13
|
+
- Call the `skill` tool with `codebase-design` for the architecture vocabulary (**module**, **interface**, **depth**, **seam**, **adapter**, **leverage**, **locality**) and its principles (the deletion test, "the interface is the test surface", "one adapter = hypothetical seam, two = real"). Use these terms exactly in every suggestion, and don't drift into "component," "service," "API," or "boundary."
|
|
14
|
+
- The domain language in `CONTEXT.md` gives names to good seams; ADRs in `docs/adr/` record decisions this command should not re-litigate.
|
|
15
|
+
|
|
16
|
+
## Process
|
|
17
|
+
|
|
18
|
+
### 1. Explore
|
|
19
|
+
|
|
20
|
+
**Scope before you scan: YAGNI.** Deepening a module pays off by making future changes to it easier, so put extra weight on the parts of the codebase that have recently changed. Decide *where* to look before you look:
|
|
21
|
+
|
|
22
|
+
- If the user named a direction (a module, a subsystem, a pain point), take it, and skip the inference below.
|
|
23
|
+
- Otherwise, walk back a good stretch of the commit history (`git log --oneline`) to find the codebase's hot spots, the files and areas that keep coming up, and let those paths pull your attention first. If the changes are scattered with no clear hot spot, widen the net.
|
|
24
|
+
|
|
25
|
+
Read the project's domain glossary (`CONTEXT.md`) and any ADRs in the area you're touching first.
|
|
26
|
+
|
|
27
|
+
Then spawn a sub-agent to walk the codebase. Don't follow rigid heuristics; explore organically and note where you experience friction:
|
|
28
|
+
|
|
29
|
+
- Where does understanding one concept require bouncing between many small modules?
|
|
30
|
+
- Where are modules **shallow**, with an interface nearly as complex as the implementation?
|
|
31
|
+
- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
|
|
32
|
+
- Where do tightly-coupled modules leak across their seams?
|
|
33
|
+
- Which parts of the codebase are untested, or hard to test through their current interface?
|
|
34
|
+
|
|
35
|
+
Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
|
|
36
|
+
|
|
37
|
+
### 2. Present candidates as an HTML report
|
|
38
|
+
|
|
39
|
+
Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from `$TMPDIR`, falling back to `/tmp` (or `%TEMP%` on Windows), and write to `<tmpdir>/architecture-review-<timestamp>.html` so each run gets a fresh file. Open it for the user (`xdg-open <path>` on Linux – under WSL `wslview <path>` or `explorer.exe "$(wslpath -w <path>)"` –, `open <path>` on macOS, `start <path>` on Windows) and tell them the absolute path.
|
|
40
|
+
|
|
41
|
+
The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals: use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
|
|
42
|
+
|
|
43
|
+
For each candidate, render a card with:
|
|
44
|
+
|
|
45
|
+
- **Files**: which files/modules are involved
|
|
46
|
+
- **Problem**: why the current architecture is causing friction
|
|
47
|
+
- **Solution**: plain English description of what would change
|
|
48
|
+
- **Benefits**: explained in terms of locality and leverage, and how tests would improve
|
|
49
|
+
- **Before / After diagram**: side-by-side, custom-drawn, illustrating the shallowness and the deepening
|
|
50
|
+
- **Recommendation strength**: one of `Strong`, `Worth exploring`, `Speculative`, rendered as a badge
|
|
51
|
+
|
|
52
|
+
End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
|
|
53
|
+
|
|
54
|
+
**Use CONTEXT.md vocabulary for the domain, and the `/codebase-design` vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module," not "the FooBarHandler," and not "the Order service."
|
|
55
|
+
|
|
56
|
+
**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: _"contradicts ADR-0007, but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
|
57
|
+
|
|
58
|
+
See [HTML-REPORT.md](HTML-REPORT.md) for the full HTML scaffold, diagram patterns, and styling guidance.
|
|
59
|
+
|
|
60
|
+
Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"
|
|
61
|
+
|
|
62
|
+
### 3. Grilling loop
|
|
63
|
+
|
|
64
|
+
Once the user picks a candidate, call the `skill` tool with `grilling` to walk the decision tree with them: constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
|
|
65
|
+
|
|
66
|
+
Side effects happen inline as decisions crystallize; call the `skill` tool with `domain-model` to keep the domain model current as you go:
|
|
67
|
+
|
|
68
|
+
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md`. Create the file lazily if it doesn't exist.
|
|
69
|
+
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
|
70
|
+
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing; skip ephemeral reasons ("not worth it right now") and self-evident ones.
|
|
71
|
+
- **Want to explore alternative interfaces for the deepened module?** Call the `skill` tool with `codebase-design` and use its design-it-twice parallel sub-agent pattern.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: retro
|
|
3
|
+
description: "Conduct a retrospective on a coding session."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The user has asked for a **retrospective**. You are suggesting improvements to the coding agent's **environment** to improve future runs.
|
|
8
|
+
|
|
9
|
+
## Steps
|
|
10
|
+
|
|
11
|
+
1. Call the `skill` tool with `writing-for-agents` for the writing style guide.
|
|
12
|
+
|
|
13
|
+
2. Read the primary sources for the session the user specifies. This may mean searching through session history on this machine (the current session, or the OpenCode session store under `~/.local/share/opencode/` when running in OpenCode; sessions run on another machine are not there – ask the user). If the user doesn't specify a session, default to the current one.
|
|
14
|
+
|
|
15
|
+
3. Look for candidates for improvement in these categories.
|
|
16
|
+
|
|
17
|
+
- **Navigation**: how easy was it for the agent to find the right files? Are there hidden dependencies between files? Would a **navigation pointer** make it easier? _Use when_ the session took a long time to find a piece of information.
|
|
18
|
+
- **Automated checks**: are there automated checks that could catch errors the agent made? Linting, typing, tests, filesystem linters? Read the repo's own check command first (its `package.json`/build-tool `lint`/`check` scripts, its CI workflow), so a check that already exists but sits unwired or silently broken is the finding, not a reinvention. A repo with no **guardrail** (no pre-commit hook and no CI job running its lint/typecheck/test command) is itself a finding: an un-linted repo is a standing missed opportunity, not a neutral default. _Use when_ the agent made a mistake an automated check could have caught, or the repo has no guardrail at all.
|
|
19
|
+
- **Coding standards**: should the **reviewer agent** be given a new rule to enforce? Should an existing rule be removed or clarified? Classify the violation first: a **mechanical** one (a fixed syntactic pattern, a banned API, an import shape, a file-location rule) gets a deterministic check, full stop: a custom rule in the repo's own linter, a new pre-commit hook, or a new CI job, whichever the repo's language and existing guardrail make cheapest. Default to building the check over writing the rule. Reserve `CODING_STANDARDS.md` for genuine **judgement calls** (cross-file consistency, "matches the surrounding style," anything no guardrail could ever substitute for). _Use when_ the reviewer agent failed to catch a mistake.
|
|
20
|
+
- **Global AGENTS.md**: are there any steering instructions that should be moved to coding standards (or automated checks) instead? _Use when_ the AGENTS.md file is particularly large - in the repo OR the user's global scope.
|
|
21
|
+
- **Tool economy**: did the agent make expensive tool calls that could be streamlined? Is there any custom tooling (CLI's, MCP's) that is particularly token-inefficient? _Use when_ the agent made an expensive tool call.
|
|
22
|
+
- **No-ops**: look for instructions in steering files that don't modify the agent's behavior. _Use when_ the steering files are large and unwieldy.
|
|
23
|
+
- **Information access**: look for opportunities to increase the agent's access to information. Teeing dev server logs, readonly access to third-party services. _Use when_ a crucial piece of information was not available to the agent.
|
|
24
|
+
|
|
25
|
+
4. Present these candidates to the user, in order of severity. Removing or simplifying a rule, check or instruction is a candidate on equal footing with adding one, and "the environment held up, nothing to change" is a complete result. Each candidate names the concrete mistake in the session it would have prevented. The user picks; change nothing before they do.
|
|
26
|
+
|
|
27
|
+
## Reference
|
|
28
|
+
|
|
29
|
+
### Implementation vs Review
|
|
30
|
+
|
|
31
|
+
Remember that all work goes through two stages: implementation and review. The implementation agent has the most **context pressure**. They are responsible for exploration, writing code, and debugging failures.
|
|
32
|
+
|
|
33
|
+
The review agent has the least context pressure - it receives a diff, so no exploration needed. It often does not need to write code or debug.
|
|
34
|
+
|
|
35
|
+
This means that the review agent should be responsible for imposing coding standards, not the implementation agent.
|
|
36
|
+
|
|
37
|
+
### Files
|
|
38
|
+
|
|
39
|
+
You have access to several files in the repo:
|
|
40
|
+
|
|
41
|
+
- `CLAUDE.md`/`AGENTS.md`: these files are pushed to the context window of any agent working in this repo. They should be used incredibly sparingly, usually only for **navigation pointers** to other files.
|
|
42
|
+
- `CODING_STANDARDS.md`: this file is read during review, not implementation. Add **navigation pointers** to docs folders if the standards file gets more than 1,000 lines long.
|
|
43
|
+
- Docs: use docs as references files, pointed to by other files. Look for existing docs before writing new ones.
|
|
44
|
+
- Skills: use skills for docs (since their description goes into the agent's context window), or for user-invoked commands. Follow the advice in the `writing-for-agents` skill.
|
|
45
|
+
|
|
46
|
+
### In this project
|
|
47
|
+
|
|
48
|
+
The files above map onto this repository:
|
|
49
|
+
|
|
50
|
+
- `AGENTS.md` (or `CLAUDE.md` when Claude Code is also used) is the always-loaded file.
|
|
51
|
+
- The coding standards are `docs/engineering/conventions.md`; the review agents are `.opencode/agents/code-reviewer.md` and `.opencode/agents/acceptance-tester.md`.
|
|
52
|
+
- The check command is `node .claude/skills/implement/scripts/verify.ts`; the guardrails are `.claude/hooks/*.ts`, wired for OpenCode in `.opencode/plugins/kataster/index.ts` (and for Claude Code in `.claude/settings.json`), and CI in `.github/workflows/`.
|
|
53
|
+
- The rules in `AGENTS.md` bind the retro's proposals too, e.g. the follow-up hurdle and tooling in `.claude/` as TypeScript run directly by Node.
|