domain-knowledge-kit 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/.github/skills/{flow-implementer → dkk-flow-implementer}/skill.md +17 -8
  2. package/.github/skills/{story-analyst → dkk-story-analyst}/skill.md +23 -13
  3. package/README.md +5 -0
  4. package/dist/cli.js +20 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/features/agent/commands/init.d.ts.map +1 -1
  7. package/dist/features/agent/commands/init.js +141 -3
  8. package/dist/features/agent/commands/init.js.map +1 -1
  9. package/dist/features/agent/commands/prime.d.ts +11 -0
  10. package/dist/features/agent/commands/prime.d.ts.map +1 -1
  11. package/dist/features/agent/commands/prime.js +122 -10
  12. package/dist/features/agent/commands/prime.js.map +1 -1
  13. package/dist/features/federation/commands/consumers.d.ts +40 -0
  14. package/dist/features/federation/commands/consumers.d.ts.map +1 -0
  15. package/dist/features/federation/commands/consumers.js +126 -0
  16. package/dist/features/federation/commands/consumers.js.map +1 -0
  17. package/dist/features/federation/commands/peers-add.d.ts +14 -0
  18. package/dist/features/federation/commands/peers-add.d.ts.map +1 -0
  19. package/dist/features/federation/commands/peers-add.js +79 -0
  20. package/dist/features/federation/commands/peers-add.js.map +1 -0
  21. package/dist/features/federation/commands/peers-list.d.ts +8 -0
  22. package/dist/features/federation/commands/peers-list.d.ts.map +1 -0
  23. package/dist/features/federation/commands/peers-list.js +51 -0
  24. package/dist/features/federation/commands/peers-list.js.map +1 -0
  25. package/dist/features/federation/commands/peers-status.d.ts +8 -0
  26. package/dist/features/federation/commands/peers-status.d.ts.map +1 -0
  27. package/dist/features/federation/commands/peers-status.js +78 -0
  28. package/dist/features/federation/commands/peers-status.js.map +1 -0
  29. package/dist/features/federation/commands/pull.d.ts +18 -0
  30. package/dist/features/federation/commands/pull.d.ts.map +1 -0
  31. package/dist/features/federation/commands/pull.js +153 -0
  32. package/dist/features/federation/commands/pull.js.map +1 -0
  33. package/dist/features/federation/git-fetcher.d.ts +45 -0
  34. package/dist/features/federation/git-fetcher.d.ts.map +1 -0
  35. package/dist/features/federation/git-fetcher.js +70 -0
  36. package/dist/features/federation/git-fetcher.js.map +1 -0
  37. package/dist/features/federation/loader.d.ts +60 -0
  38. package/dist/features/federation/loader.d.ts.map +1 -0
  39. package/dist/features/federation/loader.js +193 -0
  40. package/dist/features/federation/loader.js.map +1 -0
  41. package/dist/features/federation/lock.d.ts +12 -0
  42. package/dist/features/federation/lock.d.ts.map +1 -0
  43. package/dist/features/federation/lock.js +48 -0
  44. package/dist/features/federation/lock.js.map +1 -0
  45. package/dist/features/federation/tests/git-fetcher.test.d.ts +2 -0
  46. package/dist/features/federation/tests/git-fetcher.test.d.ts.map +1 -0
  47. package/dist/features/federation/tests/git-fetcher.test.js +167 -0
  48. package/dist/features/federation/tests/git-fetcher.test.js.map +1 -0
  49. package/dist/features/federation/tests/loader.test.d.ts +2 -0
  50. package/dist/features/federation/tests/loader.test.d.ts.map +1 -0
  51. package/dist/features/federation/tests/loader.test.js +144 -0
  52. package/dist/features/federation/tests/loader.test.js.map +1 -0
  53. package/dist/features/federation/tests/phase5.test.d.ts +2 -0
  54. package/dist/features/federation/tests/phase5.test.d.ts.map +1 -0
  55. package/dist/features/federation/tests/phase5.test.js +137 -0
  56. package/dist/features/federation/tests/phase5.test.js.map +1 -0
  57. package/dist/features/federation/tests/schema-load.test.d.ts +2 -0
  58. package/dist/features/federation/tests/schema-load.test.d.ts.map +1 -0
  59. package/dist/features/federation/tests/schema-load.test.js +97 -0
  60. package/dist/features/federation/tests/schema-load.test.js.map +1 -0
  61. package/dist/features/federation/tests/validator.test.d.ts +2 -0
  62. package/dist/features/federation/tests/validator.test.d.ts.map +1 -0
  63. package/dist/features/federation/tests/validator.test.js +319 -0
  64. package/dist/features/federation/tests/validator.test.js.map +1 -0
  65. package/dist/features/mcp/commands/serve.d.ts +10 -0
  66. package/dist/features/mcp/commands/serve.d.ts.map +1 -0
  67. package/dist/features/mcp/commands/serve.js +12 -0
  68. package/dist/features/mcp/commands/serve.js.map +1 -0
  69. package/dist/features/mcp/server.d.ts +15 -0
  70. package/dist/features/mcp/server.d.ts.map +1 -0
  71. package/dist/features/mcp/server.js +438 -0
  72. package/dist/features/mcp/server.js.map +1 -0
  73. package/dist/features/pipeline/commands/validate.d.ts.map +1 -1
  74. package/dist/features/pipeline/commands/validate.js +7 -0
  75. package/dist/features/pipeline/commands/validate.js.map +1 -1
  76. package/dist/features/pipeline/indexer.d.ts +28 -2
  77. package/dist/features/pipeline/indexer.d.ts.map +1 -1
  78. package/dist/features/pipeline/indexer.js +84 -29
  79. package/dist/features/pipeline/indexer.js.map +1 -1
  80. package/dist/features/pipeline/validator.d.ts +10 -0
  81. package/dist/features/pipeline/validator.d.ts.map +1 -1
  82. package/dist/features/pipeline/validator.js +274 -27
  83. package/dist/features/pipeline/validator.js.map +1 -1
  84. package/dist/features/query/commands/list.d.ts +10 -0
  85. package/dist/features/query/commands/list.d.ts.map +1 -1
  86. package/dist/features/query/commands/list.js +1 -1
  87. package/dist/features/query/commands/list.js.map +1 -1
  88. package/dist/features/query/commands/locate.d.ts +1 -0
  89. package/dist/features/query/commands/locate.d.ts.map +1 -1
  90. package/dist/features/query/commands/locate.js +1 -1
  91. package/dist/features/query/commands/locate.js.map +1 -1
  92. package/dist/features/query/commands/search.d.ts.map +1 -1
  93. package/dist/features/query/commands/search.js +2 -0
  94. package/dist/features/query/commands/search.js.map +1 -1
  95. package/dist/features/query/commands/show.d.ts +15 -0
  96. package/dist/features/query/commands/show.d.ts.map +1 -1
  97. package/dist/features/query/commands/show.js +116 -58
  98. package/dist/features/query/commands/show.js.map +1 -1
  99. package/dist/features/query/commands/story.d.ts +70 -0
  100. package/dist/features/query/commands/story.d.ts.map +1 -1
  101. package/dist/features/query/commands/story.js +3 -2
  102. package/dist/features/query/commands/story.js.map +1 -1
  103. package/dist/features/query/commands/summary.d.ts +3 -0
  104. package/dist/features/query/commands/summary.d.ts.map +1 -1
  105. package/dist/features/query/commands/summary.js +1 -1
  106. package/dist/features/query/commands/summary.js.map +1 -1
  107. package/dist/features/query/searcher.d.ts +18 -1
  108. package/dist/features/query/searcher.d.ts.map +1 -1
  109. package/dist/features/query/searcher.js +11 -2
  110. package/dist/features/query/searcher.js.map +1 -1
  111. package/dist/features/scaffold/commands/service-init.d.ts +12 -0
  112. package/dist/features/scaffold/commands/service-init.d.ts.map +1 -0
  113. package/dist/features/scaffold/commands/service-init.js +69 -0
  114. package/dist/features/scaffold/commands/service-init.js.map +1 -0
  115. package/dist/shared/graph.d.ts +8 -0
  116. package/dist/shared/graph.d.ts.map +1 -1
  117. package/dist/shared/graph.js +180 -112
  118. package/dist/shared/graph.js.map +1 -1
  119. package/dist/shared/index.d.ts +4 -1
  120. package/dist/shared/index.d.ts.map +1 -1
  121. package/dist/shared/index.js +6 -1
  122. package/dist/shared/index.js.map +1 -1
  123. package/dist/shared/loader.d.ts +22 -0
  124. package/dist/shared/loader.d.ts.map +1 -1
  125. package/dist/shared/loader.js +31 -1
  126. package/dist/shared/loader.js.map +1 -1
  127. package/dist/shared/paths.d.ts +59 -7
  128. package/dist/shared/paths.d.ts.map +1 -1
  129. package/dist/shared/paths.js +93 -11
  130. package/dist/shared/paths.js.map +1 -1
  131. package/dist/shared/refs.d.ts +96 -0
  132. package/dist/shared/refs.d.ts.map +1 -0
  133. package/dist/shared/refs.js +182 -0
  134. package/dist/shared/refs.js.map +1 -0
  135. package/dist/shared/service-id.d.ts +11 -0
  136. package/dist/shared/service-id.d.ts.map +1 -0
  137. package/dist/shared/service-id.js +64 -0
  138. package/dist/shared/service-id.js.map +1 -0
  139. package/dist/shared/tests/paths.test.d.ts +2 -0
  140. package/dist/shared/tests/paths.test.d.ts.map +1 -0
  141. package/dist/shared/tests/paths.test.js +111 -0
  142. package/dist/shared/tests/paths.test.js.map +1 -0
  143. package/dist/shared/tests/refs.test.d.ts +2 -0
  144. package/dist/shared/tests/refs.test.d.ts.map +1 -0
  145. package/dist/shared/tests/refs.test.js +104 -0
  146. package/dist/shared/tests/refs.test.js.map +1 -0
  147. package/dist/shared/types/domain.d.ts +20 -0
  148. package/dist/shared/types/domain.d.ts.map +1 -1
  149. package/dist/shared/types/federation.d.ts +60 -0
  150. package/dist/shared/types/federation.d.ts.map +1 -0
  151. package/dist/shared/types/federation.js +12 -0
  152. package/dist/shared/types/federation.js.map +1 -0
  153. package/package.json +6 -3
  154. package/tools/dkk/claude/agents/dkk-domain-reviewer.md +69 -0
  155. package/tools/dkk/claude/commands/dkk-adr.md +11 -0
  156. package/tools/dkk/claude/commands/dkk-impact.md +34 -0
  157. package/tools/dkk/claude/commands/dkk-implement.md +12 -0
  158. package/tools/dkk/claude/commands/dkk-prime.md +6 -0
  159. package/tools/dkk/claude/commands/dkk-review.md +12 -0
  160. package/tools/dkk/claude/commands/dkk-story.md +12 -0
  161. package/tools/dkk/claude/hooks/post-edit-validate.mjs +51 -0
  162. package/tools/dkk/claude/hooks/pre-edit-block-generated.mjs +39 -0
  163. package/tools/dkk/claude/hooks/session-start-prime.mjs +33 -0
  164. package/tools/dkk/claude/hooks/stop-validate.mjs +48 -0
  165. package/tools/dkk/claude/settings.json +62 -0
  166. package/tools/dkk/claude/skills/dkk-adr-author/SKILL.md +54 -0
  167. package/tools/dkk/claude/skills/dkk-flow-implementer/SKILL.md +51 -0
  168. package/tools/dkk/claude/skills/dkk-story-analyst/SKILL.md +108 -0
  169. package/tools/dkk/schema/actors.schema.json +11 -1
  170. package/tools/dkk/schema/adr-frontmatter.schema.json +4 -4
  171. package/tools/dkk/schema/aggregate.schema.json +1 -1
  172. package/tools/dkk/schema/command.schema.json +1 -1
  173. package/tools/dkk/schema/event.schema.json +1 -1
  174. package/tools/dkk/schema/federation.schema.json +71 -0
  175. package/tools/dkk/schema/glossary.schema.json +1 -1
  176. package/tools/dkk/schema/index.schema.json +2 -2
  177. package/tools/dkk/schema/policy.schema.json +1 -1
  178. package/tools/dkk/schema/read-model.schema.json +15 -1
  179. package/tools/dkk/schema/service.schema.json +30 -0
  180. package/.github/skills/domain-knowledge/skill.md +0 -93
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Walk through framework-agnostic implementation of a DKK flow using the dkk-flow-implementer skill.
3
+ argument-hint: <flow-id-or-feature-name>
4
+ ---
5
+
6
+ Invoke the `dkk-flow-implementer` skill. The user's target is `$ARGUMENTS`.
7
+
8
+ - If `$ARGUMENTS` is empty, ask the user which flow to implement, or list available flows via `mcp__dkk__list` (filter `type: flow`).
9
+ - If `$ARGUMENTS` looks like a flow id (`flow.<Name>` or bare `<Name>`), pass it through to `mcp__dkk__story`.
10
+ - Otherwise, run `mcp__dkk__search` with `$ARGUMENTS` first to identify the matching flow or root command, then proceed.
11
+
12
+ Follow the skill's workflow: retrieve story, ask clarifying questions, present ADR constraints, generate the framework-agnostic checklist, and walk the user through items interactively.
@@ -0,0 +1,6 @@
1
+ ---
2
+ description: Re-inject DKK agent context (domain principles, item types, CLI reference, current model summary). Use after compaction or topic drift.
3
+ allowed-tools: mcp__dkk__prime
4
+ ---
5
+
6
+ Call `mcp__dkk__prime` with default arguments and read the response. After loading, briefly confirm the number of contexts, items, and ADRs currently in the model. Do not summarize the prime content itself — the user just needs the agent to be re-primed.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Review the current change for DKK domain impact. Delegates to the dkk-domain-reviewer subagent in an isolated context.
3
+ argument-hint: [pr-number | git-range]
4
+ ---
5
+
6
+ Invoke the `dkk-domain-reviewer` subagent. Pass through `$ARGUMENTS` as the input scope:
7
+
8
+ - If `$ARGUMENTS` is empty, instruct the subagent to review the working-tree diff (`git status` + `git diff`).
9
+ - If `$ARGUMENTS` looks like a number or `#NNN`, instruct it to run `gh pr diff <number>` and review that PR.
10
+ - Otherwise, treat `$ARGUMENTS` as a git range (e.g. `origin/main...HEAD`) and pass it through.
11
+
12
+ Wait for the subagent's report. Display it verbatim to the user. Do not perform the review yourself.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Generate a user story or epic from a DKK flow using the dkk-story-analyst skill.
3
+ argument-hint: <flow-id-or-feature-name>
4
+ ---
5
+
6
+ Invoke the `dkk-story-analyst` skill. The user's target is `$ARGUMENTS`.
7
+
8
+ - If `$ARGUMENTS` is empty, ask the user which flow to draft a story for, or list available flows via `mcp__dkk__list` (filter `type: flow`).
9
+ - If `$ARGUMENTS` looks like a flow id (`flow.<Name>` or bare `<Name>`), pass it through to `mcp__dkk__story`.
10
+ - Otherwise, run `mcp__dkk__search` with `$ARGUMENTS` first to identify the matching flow or root command, then proceed.
11
+
12
+ Follow the skill's workflow end to end, including clarifying questions and acceptance-criteria mapping.
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * PostToolUse hook — auto-validate after edits to domain YAML.
4
+ *
5
+ * When Claude Code edits or writes a file under `.dkk/domain/`, run
6
+ * `dkk validate` so any broken cross-references or schema violations
7
+ * surface back into the agent loop immediately, before the next step.
8
+ *
9
+ * Stays silent for unrelated edits (no-op, exit 0).
10
+ */
11
+ import { spawnSync } from "node:child_process";
12
+ import { existsSync } from "node:fs";
13
+ import { resolve } from "node:path";
14
+
15
+ let raw = "";
16
+ process.stdin.on("data", (d) => (raw += d));
17
+ process.stdin.on("end", () => {
18
+ let payload;
19
+ try {
20
+ payload = JSON.parse(raw || "{}");
21
+ } catch {
22
+ process.exit(0);
23
+ }
24
+
25
+ const filePath =
26
+ payload?.tool_input?.file_path ??
27
+ payload?.tool_input?.notebook_path ??
28
+ "";
29
+
30
+ // Only act on domain YAML edits.
31
+ const isDomainYaml = /\.dkk\/domain\/.*\.ya?ml$/.test(filePath);
32
+ if (!isDomainYaml) process.exit(0);
33
+
34
+ const repoRoot = process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
35
+ const cliEntry = resolve(repoRoot, "src/cli.ts");
36
+
37
+ const [cmd, args] = existsSync(cliEntry)
38
+ ? ["npx", ["tsx", cliEntry, "validate", "--json", "--minify"]]
39
+ : ["dkk", ["validate", "--json", "--minify"]];
40
+
41
+ const res = spawnSync(cmd, args, { cwd: repoRoot, encoding: "utf8" });
42
+ // If validate fails, surface the JSON output to the model via stderr (exit 2
43
+ // makes Claude Code feed stderr back as a tool-result correction signal).
44
+ if (res.status !== 0) {
45
+ process.stderr.write(
46
+ `dkk validate failed after edit to ${filePath}:\n${res.stdout || res.stderr || ""}\n`,
47
+ );
48
+ process.exit(2);
49
+ }
50
+ process.exit(0);
51
+ });
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * PreToolUse hook — block writes to generated/derived directories.
4
+ *
5
+ * `.dkk/docs/` is regenerated from YAML by `dkk render`. Edits there are
6
+ * always lost on the next render, so we block the tool call up-front and
7
+ * tell the agent to edit the source YAML instead.
8
+ *
9
+ * Same treatment for `dist/` (TypeScript build output).
10
+ */
11
+ let raw = "";
12
+ process.stdin.on("data", (d) => (raw += d));
13
+ process.stdin.on("end", () => {
14
+ let payload;
15
+ try {
16
+ payload = JSON.parse(raw || "{}");
17
+ } catch {
18
+ process.exit(0);
19
+ }
20
+
21
+ const filePath = payload?.tool_input?.file_path ?? "";
22
+ if (!filePath) process.exit(0);
23
+
24
+ if (/\.dkk\/docs\//.test(filePath)) {
25
+ process.stderr.write(
26
+ `Blocked: ${filePath} is generated by \`dkk render\`. Edit the YAML under .dkk/domain/ and re-render instead.\n`,
27
+ );
28
+ process.exit(2);
29
+ }
30
+
31
+ if (/\/dist\//.test(filePath)) {
32
+ process.stderr.write(
33
+ `Blocked: ${filePath} is build output. Edit the source under src/ and run \`npm run build\`.\n`,
34
+ );
35
+ process.exit(2);
36
+ }
37
+
38
+ process.exit(0);
39
+ });
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * SessionStart hook — pipe `dkk prime` output into Claude Code's context.
4
+ *
5
+ * The hook prints the agent context document (item types, retrieval/update
6
+ * workflows, current domain summary) to stdout, which Claude Code surfaces
7
+ * as additional context for the session. Any errors fall through silently
8
+ * so a missing domain model never blocks session start.
9
+ */
10
+ import { spawnSync } from "node:child_process";
11
+ import { existsSync } from "node:fs";
12
+ import { resolve } from "node:path";
13
+
14
+ const repoRoot = process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
15
+ const cliEntry = resolve(repoRoot, "src/cli.ts");
16
+
17
+ let cmd, args;
18
+ if (existsSync(cliEntry)) {
19
+ // Local DKK development: run via tsx.
20
+ cmd = "npx";
21
+ args = ["tsx", cliEntry, "prime"];
22
+ } else {
23
+ // Downstream consumer: rely on the published `dkk` binary.
24
+ cmd = "dkk";
25
+ args = ["prime"];
26
+ }
27
+
28
+ const res = spawnSync(cmd, args, { cwd: repoRoot, encoding: "utf8" });
29
+ if (res.status === 0 && res.stdout) {
30
+ process.stdout.write(res.stdout);
31
+ }
32
+ // Always exit 0 — never block session start over a missing/empty model.
33
+ process.exit(0);
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Stop hook — final validation gate before the agent ends a turn.
4
+ *
5
+ * Runs `dkk validate`. If the domain model is invalid, returns exit code 2
6
+ * with the JSON error report on stderr. Claude Code feeds that back so the
7
+ * agent must fix the broken model before declaring the work complete.
8
+ *
9
+ * `stop_hook_active` is honoured to prevent infinite loops if Claude tries
10
+ * to stop again after the hook already fired once.
11
+ */
12
+ import { spawnSync } from "node:child_process";
13
+ import { existsSync } from "node:fs";
14
+ import { resolve } from "node:path";
15
+
16
+ let raw = "";
17
+ process.stdin.on("data", (d) => (raw += d));
18
+ process.stdin.on("end", () => {
19
+ let payload;
20
+ try {
21
+ payload = JSON.parse(raw || "{}");
22
+ } catch {
23
+ process.exit(0);
24
+ }
25
+
26
+ if (payload?.stop_hook_active) {
27
+ process.exit(0);
28
+ }
29
+
30
+ const repoRoot = process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
31
+ const cliEntry = resolve(repoRoot, "src/cli.ts");
32
+
33
+ // No domain model? Nothing to gate on.
34
+ if (!existsSync(resolve(repoRoot, ".dkk/domain"))) process.exit(0);
35
+
36
+ const [cmd, args] = existsSync(cliEntry)
37
+ ? ["npx", ["tsx", cliEntry, "validate", "--json", "--minify"]]
38
+ : ["dkk", ["validate", "--json", "--minify"]];
39
+
40
+ const res = spawnSync(cmd, args, { cwd: repoRoot, encoding: "utf8" });
41
+ if (res.status !== 0) {
42
+ process.stderr.write(
43
+ `Domain validation failed — fix these before ending the turn:\n${res.stdout || res.stderr || ""}\n`,
44
+ );
45
+ process.exit(2);
46
+ }
47
+ process.exit(0);
48
+ });
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/claude-code-settings.json",
3
+ "permissions": {
4
+ "allow": [
5
+ "Bash(dkk list:*)",
6
+ "Bash(dkk show:*)",
7
+ "Bash(dkk summary:*)",
8
+ "Bash(dkk search:*)",
9
+ "Bash(dkk related:*)",
10
+ "Bash(dkk graph:*)",
11
+ "Bash(dkk locate:*)",
12
+ "Bash(dkk story:*)",
13
+ "Bash(dkk validate:*)",
14
+ "Bash(dkk stats:*)",
15
+ "Bash(dkk prime:*)"
16
+ ]
17
+ },
18
+ "hooks": {
19
+ "SessionStart": [
20
+ {
21
+ "hooks": [
22
+ {
23
+ "type": "command",
24
+ "command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/session-start-prime.mjs\""
25
+ }
26
+ ]
27
+ }
28
+ ],
29
+ "PreToolUse": [
30
+ {
31
+ "matcher": "Edit|Write|MultiEdit|NotebookEdit",
32
+ "hooks": [
33
+ {
34
+ "type": "command",
35
+ "command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/pre-edit-block-generated.mjs\""
36
+ }
37
+ ]
38
+ }
39
+ ],
40
+ "PostToolUse": [
41
+ {
42
+ "matcher": "Edit|Write|MultiEdit",
43
+ "hooks": [
44
+ {
45
+ "type": "command",
46
+ "command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/post-edit-validate.mjs\""
47
+ }
48
+ ]
49
+ }
50
+ ],
51
+ "Stop": [
52
+ {
53
+ "hooks": [
54
+ {
55
+ "type": "command",
56
+ "command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/stop-validate.mjs\""
57
+ }
58
+ ]
59
+ }
60
+ ]
61
+ }
62
+ }
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: dkk-adr-author
3
+ description: Draft a new Architecture Decision Record grounded in the local Domain Knowledge Pack. Use when the user wants to record an architectural decision, capture a trade-off, document a tech choice, or formalize a discussion as an ADR.
4
+ ---
5
+
6
+ # ADR Author
7
+
8
+ Use this skill whenever the user wants to **record an architectural decision, draft an ADR, or capture a trade-off** in a project that has a Domain Knowledge Pack (`.dkk/`).
9
+
10
+ > **The DKK model is the single source of truth.** Every ADR must link to the domain items it constrains, bidirectionally. Skipping that link is the most common failure mode this skill prevents.
11
+
12
+ ## Preferred tools
13
+
14
+ 1. `mcp__dkk__search` (with `type: adr`) — find related existing ADRs
15
+ 2. `mcp__dkk__show` — read those ADRs in full
16
+ 3. `mcp__dkk__search` and `mcp__dkk__related` — identify which domain items the decision affects
17
+ 4. `mcp__dkk__locate` — get absolute paths to edit the linked items
18
+ 5. `mcp__dkk__validate` — final correctness check
19
+ 6. `dkk new adr "<title>"` (Bash) — scaffold the file with the right number and frontmatter
20
+ 7. `dkk render` (Bash) — refresh docs and search index after the ADR is finished
21
+
22
+ Use the equivalent `dkk` shell commands only if the MCP server is unavailable.
23
+
24
+ ## Workflow
25
+
26
+ 1. **Search prior ADRs first.** Call `mcp__dkk__search` with the topic and `type: adr`. Read every related ADR via `mcp__dkk__show`. If a *current* ADR already covers the decision, do not create a new one — update the existing record (with `superseded_by` if direction has changed). If a *deprecated* ADR is relevant, surface its rationale to the user; do not relitigate without acknowledging it.
27
+ 2. **Identify affected domain items.** From the user's description, search the model and use `mcp__dkk__related` to find aggregates, events, commands, policies, and read models the decision constrains. Confirm the list with the user.
28
+ 3. **Clarify the decision.** Ask **2–5 targeted questions** before drafting. Derive each question and its options from the search results and the user's stated motivation. Skip questions only when the decision is fully specified and uncontroversial. Examples (only if relevant):
29
+ - What problem prompted the decision? (constraint / incident / new requirement / cleanup)
30
+ - What alternatives were considered, and why were they rejected?
31
+ - Which domain items are constrained by this decision?
32
+ - What is the status — Proposed (needs review), Accepted (in effect), or Deprecated (recording history)?
33
+ - Does this supersede a prior ADR? If yes, which one?
34
+ 4. **Scaffold via the CLI.** Run `dkk new adr "<title>"` — this auto-increments the number and creates the file with valid frontmatter and the canonical section structure. Do not hand-create the file.
35
+ 5. **Fill the body.** The canonical sections are *Context*, *Decision*, *Consequences*, and *Alternatives Considered*. Use precise domain terminology — match every name to the items returned by `mcp__dkk__search` and `mcp__dkk__show`.
36
+ 6. **Set the bidirectional links.** Both sides must agree:
37
+ - In the ADR frontmatter, set `domain_refs:` to the list of affected item ids (e.g. `ordering.OrderPlaced`, `actor.Customer`).
38
+ - On every linked domain item's YAML, append the new ADR id to its `adr_refs:` list. Use `mcp__dkk__locate` to find each file.
39
+ 7. **Run quality gates.** The post-edit hook runs `mcp__dkk__validate` automatically; before declaring the work done, also run `dkk render` to refresh `.dkk/docs/` and rebuild the search index.
40
+
41
+ ## Status discipline
42
+
43
+ - **Proposed** — newly drafted, awaiting team review. The decision is not in effect yet.
44
+ - **Accepted** — the decision is in effect; new code must comply.
45
+ - **Deprecated** — no longer in effect, but kept as project memory. If a successor exists, set `superseded_by: adr-NNNN` in the frontmatter.
46
+
47
+ Never delete an ADR. Even superseded ones are institutional memory.
48
+
49
+ ## Don'ts
50
+
51
+ - Don't draft an ADR that doesn't reference at least one domain item (the bidirectional link is what makes ADRs queryable).
52
+ - Don't invent domain terms in the ADR body — every name must exist in the model.
53
+ - Don't hand-edit the ADR filename or number; let `dkk new adr` assign it.
54
+ - Don't skip searching for prior ADRs — relitigating a decided question without referencing the prior ADR is the worst failure mode.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: dkk-flow-implementer
3
+ description: Guide a developer through framework-agnostic implementation of a DKK flow. Use when the user asks to implement, build, or code a flow or feature that maps to a flow in the local Domain Knowledge Pack.
4
+ ---
5
+
6
+ # Flow Implementer
7
+
8
+ Use this skill whenever the user asks to **implement, build, or code a flow / feature** in a project that has a Domain Knowledge Pack (`.dkk/`).
9
+
10
+ > **Source of truth is local.** Do not look for or reference external trackers (Jira, GitHub Issues, Linear, Trello, etc.) for requirements. The local DKK model — accessed through the MCP `dkk` server or the `dkk` CLI — is authoritative.
11
+
12
+ ## Preferred tools
13
+
14
+ Call MCP tools rather than shelling out, in this order of preference:
15
+
16
+ 1. `mcp__dkk__story` — full flow context (actors, ordered steps, policies, BDD examples, ADRs, downstream effects) in one call
17
+ 2. `mcp__dkk__list` — to discover available flows when the user hasn't named one
18
+ 3. `mcp__dkk__search` — to locate a flow when the user gives a feature name instead of an id
19
+ 4. `mcp__dkk__related` — to extend blast radius beyond the immediate flow
20
+ 5. `mcp__dkk__show` — to read the full definition of a specific item
21
+ 6. `mcp__dkk__validate` — final correctness check after edits
22
+
23
+ Fall back to the equivalent `dkk` shell commands only if the MCP server is unavailable.
24
+
25
+ ## Workflow
26
+
27
+ 1. **Identify the flow.** If the user gave an id, normalize it (`flow.<Name>` or bare `<Name>`). Otherwise call `mcp__dkk__list` filtered by `type: flow`, or `mcp__dkk__search` on the feature name to find a candidate flow or root command.
28
+ 2. **Retrieve full context.** Call `mcp__dkk__story` with the flow id. Read the actors, ordered steps, triggered policies, BDD examples, ADRs, and downstream effects.
29
+ 3. **Clarify scope.** Ask **1–7 clarifying questions** before generating any checklist. Derive every question, its options, and your recommended default from the actual story output and the project's conventions — never use a fixed list. Each question must offer concrete options with one marked as recommended. **Skip the questions entirely** for trivial flows (≤2 steps, no cross-context effects, no ambiguity). Questions should target implementation behavior and UX, e.g.:
30
+ - What should the user see immediately after this command succeeds?
31
+ - How should validation errors surface (inline / toast / page-level)?
32
+ - Optimistic UI or wait-for-confirmation?
33
+ - Concurrency: can two users trigger this simultaneously?
34
+ - Is there an undo path, or one-way?
35
+ 4. **Present architectural constraints.** List every ADR returned in the story output (`adr-NNNN — title — status`). Ask the user to acknowledge these before implementation begins. If the agent identifies any ADR conflict with the user's stated approach, surface it before proceeding.
36
+ 5. **Generate a framework-agnostic checklist.** Group by domain role:
37
+ - **Aggregates** — entities, state transitions, invariants
38
+ - **Commands** — handlers, preconditions, validations
39
+ - **Events** — what to publish on success
40
+ - **Policies** — reactive logic triggered by events
41
+ - **Read models** — projections to update on events
42
+ 6. **Walk through interactively.** Ask the user which checklist item they want to tackle first. Guide on the **domain logic** — invariants, policies, transitions — not framework boilerplate. Only emit framework-specific code if the user explicitly asks or `AGENTS.md` / `CLAUDE.md` directs otherwise.
43
+ 7. **Use the canonical nouns.** Whatever names appear in the `mcp__dkk__story` output are the only allowed names. Do not rename `OrderBasket` to `ShoppingCart`.
44
+ 8. **Validate and render after structural changes.** When the user's implementation requires new or modified domain items, use the DKK CLI commands (`dkk add`, `dkk rename`, `dkk rm`) for structural changes and edit YAML directly only for content. The post-edit hook will run `mcp__dkk__validate` automatically; before declaring the work done, also run `dkk render` to refresh docs and the search index.
45
+
46
+ ## Interaction rules
47
+
48
+ - Do not generate full boilerplate up front. Wait for the user to request code for a specific checklist item.
49
+ - Confirm with the user before moving to the next checklist item.
50
+ - If the user asks for a framework-specific implementation, defer to `AGENTS.md` or `CLAUDE.md` conventions.
51
+ - Never invent domain terms. If a needed concept is missing from the model, surface it as a gap and propose adding it via `dkk add` rather than coding around it.
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: dkk-story-analyst
3
+ description: Generate, split, or reshape user stories and epics from the local Domain Knowledge Pack. Use when the user asks to write, draft, refine, or split a user story or epic for a feature that maps to a DKK flow or command.
4
+ ---
5
+
6
+ # Story Analyst
7
+
8
+ Use this skill whenever the user asks to **write, draft, generate, refine, or split a user story or epic** in a project that has a Domain Knowledge Pack (`.dkk/`).
9
+
10
+ > **"User stories" and "epics" here are behavioral requirements derived from the local DDD/Event-Storming model in `.dkk/`.** Do not consult external trackers (Jira, GitHub Issues, Linear, Trello, etc.). The MCP `dkk` server (or the `dkk` CLI as fallback) is the only source of truth.
11
+
12
+ ## Preferred tools
13
+
14
+ 1. `mcp__dkk__story` — aggregate a flow's full context (actors, steps, policies, BDD examples, ADRs, downstream effects) in one call
15
+ 2. `mcp__dkk__list` filtered by `type: flow` — discover available flows
16
+ 3. `mcp__dkk__search` — locate a flow or command from a feature name
17
+ 4. `mcp__dkk__show` — fall back when no flow exists, to read a command directly
18
+ 5. `mcp__dkk__related` — to gather neighbours when working from a command instead of a flow
19
+
20
+ Use the corresponding `dkk` shell commands only if the MCP server is unavailable.
21
+
22
+ ## Workflow
23
+
24
+ 1. **Identify the flow.** Normalize the id (`flow.<Name>` or bare `<Name>`). If the user gave a feature name instead, call `mcp__dkk__search` to locate a matching flow or root command.
25
+ 2. **Retrieve context.** Call `mcp__dkk__story` with the flow id. The response contains actors, ordered steps, triggered policies, BDD examples, ADRs, and downstream effects.
26
+ 3. **Clarify scope.** Ask **1–7 clarifying questions** before drafting. Derive every question, its options, and your recommended default from the actual story output and the project's conventions — never use a fixed list. Each question must offer concrete options with one marked as recommended. **Skip the questions entirely** for trivial flows (≤2 steps, 1 actor, no ambiguity). Target product behavior and story scope, e.g.:
27
+ - Which user-facing outcome matters most?
28
+ - Confirmation/feedback on success — how should it surface?
29
+ - On failure or rejection, what does the user experience?
30
+ - Optional steps that can be skipped, or strictly linear?
31
+ - Happy path only, or include edge cases?
32
+ 4. **Map to story format.**
33
+ - **As a** `<Actor from "Actors" section>`
34
+ - **I want to** `<Command description from Steps>`
35
+ - **So that** `<Flow description>`
36
+ 5. **Write acceptance criteria** from the policies and BDD examples in the output:
37
+ - Policies → Given/When/Then: *When [triggering event] → Then [consequent command]*
38
+ - BDD examples on commands and events are pre-written scenarios — use them directly or expand
39
+ 6. **Add an Architectural Constraints section** listing every ADR (`adr-NNNN — title — status`). Developers must respect these.
40
+ 7. **Add an Implementation Notes section** from the downstream effects: read models to update, secondary policies that fire.
41
+
42
+ ## Noun enforcement (mandatory)
43
+
44
+ Use only the terminology in the `mcp__dkk__story` output. Do not:
45
+
46
+ - Invent entity, command, or event names not present
47
+ - Rename domain terms (if DKK says `OrderBasket`, the story says `OrderBasket`)
48
+ - Reference bounded contexts not mentioned in the step refs
49
+ - Pull names from external APIs or trackers
50
+
51
+ If unsure whether a term is canonical, run `mcp__dkk__search` to verify.
52
+
53
+ ## Epic vs. story decision rules
54
+
55
+ After retrieving the flow context:
56
+
57
+ - **Single story** when the flow has ≤3 command steps and spans ≤1 bounded context.
58
+ - **Epic with story slices** when the flow has >3 command steps **or** spans >1 bounded context. Slice by:
59
+ 1. Group consecutive steps that share the same context prefix (all `ordering.*` steps → Story 1)
60
+ 2. Each policy trigger becomes its own story ("As a system, when X happens, I want Y to be triggered, so that Z")
61
+ 3. Each slice that produces an event consumed by a read model must include updating that read model in its scope or acceptance criteria
62
+
63
+ When recommending an epic breakdown, present the slice boundaries and explain which downstream effects belong to each slice based on the model.
64
+
65
+ ## Story reshaping
66
+
67
+ When asked to refine, split, or revise an existing story:
68
+
69
+ 1. Call `mcp__dkk__story` for the relevant flow to get current domain truth
70
+ 2. Compare the story's terminology to the output
71
+ 3. Flag mismatches: invented terms, missing actors, acceptance criteria that contradict policies
72
+ 4. Suggest corrections using exact DKK terminology
73
+ 5. Ensure the reshaped story still covers all downstream effects
74
+
75
+ ## Fallback: no flow exists
76
+
77
+ If no flow has been modeled for the requested feature:
78
+
79
+ 1. Locate the most relevant command: `mcp__dkk__search` with `type: command`
80
+ 2. Get its full definition: `mcp__dkk__show`
81
+ 3. Get its neighbours: `mcp__dkk__related` with `depth: 2`
82
+ 4. Assemble the story from:
83
+ - Command `actor` → "As a..."
84
+ - Command `description` → "I want to..."
85
+ - Command `preconditions`, `rejections`, `examples` → acceptance criteria
86
+ - Neighbouring policies and read models → downstream effects
87
+ 5. Note in the story that no formal flow has been modeled, and recommend the team define one.
88
+
89
+ ## Output format
90
+
91
+ ```markdown
92
+ ## [Story Title]
93
+
94
+ **As a** [Actor], **I want to** [action], **so that** [business value].
95
+
96
+ ### Acceptance Criteria
97
+
98
+ - **Given** [precondition], **When** [command/event], **Then** [outcome]
99
+ - (repeat for each policy rule and BDD example)
100
+
101
+ ### Architectural Constraints
102
+
103
+ - [adr-NNNN]: [title] ([status])
104
+
105
+ ### Implementation Notes
106
+
107
+ - [Downstream read models, secondary policy triggers, cross-context effects]
108
+ ```
@@ -25,9 +25,19 @@
25
25
  "minLength": 1,
26
26
  "description": "What role this actor plays in the domain"
27
27
  },
28
+ "capabilities": {
29
+ "type": "array",
30
+ "items": { "type": "string", "minLength": 1 },
31
+ "description": "What this actor can do, expressed in domain language"
32
+ },
33
+ "failure_modes": {
34
+ "type": "array",
35
+ "items": { "type": "string", "minLength": 1 },
36
+ "description": "How this actor can fail, expressed in domain language"
37
+ },
28
38
  "adr_refs": {
29
39
  "type": "array",
30
- "items": { "type": "string", "pattern": "^adr-\\d{4}$" },
40
+ "items": { "type": "string", "pattern": "^([a-z][a-z0-9-]*:)?adr-\\d{4}$" },
31
41
  "uniqueItems": true,
32
42
  "description": "Related ADR identifiers"
33
43
  }
@@ -34,16 +34,16 @@
34
34
  "type": "array",
35
35
  "items": {
36
36
  "type": "string",
37
- "pattern": "^[a-z][a-z0-9-]*\\.[A-Za-z][A-Za-z0-9]*$",
38
- "description": "Domain item reference in context.Name format (e.g. ordering.OrderPlaced)"
37
+ "pattern": "^([a-z][a-z0-9-]*:)?[a-z][a-z0-9-]*\\.[A-Za-z][A-Za-z0-9]*$",
38
+ "description": "Domain item reference in context.Name format (e.g. ordering.OrderPlaced, or service:context.Name for federated refs)"
39
39
  },
40
40
  "uniqueItems": true,
41
41
  "description": "Domain items related to this decision"
42
42
  },
43
43
  "superseded_by": {
44
44
  "type": "string",
45
- "pattern": "^adr-\\d{4}$",
46
- "description": "ID of the ADR that supersedes this one"
45
+ "pattern": "^([a-z][a-z0-9-]*:)?adr-\\d{4}$",
46
+ "description": "ID of the ADR that supersedes this one (optionally service-qualified for peer ADRs)"
47
47
  }
48
48
  },
49
49
  "required": ["id", "title", "status", "date"],
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "adr_refs": {
50
50
  "type": "array",
51
- "items": { "type": "string", "pattern": "^adr-\\d{4}$" },
51
+ "items": { "type": "string", "pattern": "^([a-z][a-z0-9-]*:)?adr-\\d{4}$" },
52
52
  "uniqueItems": true,
53
53
  "description": "Related ADR identifiers"
54
54
  }
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "adr_refs": {
68
68
  "type": "array",
69
- "items": { "type": "string", "pattern": "^adr-\\d{4}$" },
69
+ "items": { "type": "string", "pattern": "^([a-z][a-z0-9-]*:)?adr-\\d{4}$" },
70
70
  "uniqueItems": true,
71
71
  "description": "Related ADR identifiers"
72
72
  }
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "adr_refs": {
58
58
  "type": "array",
59
- "items": { "type": "string", "pattern": "^adr-\\d{4}$" },
59
+ "items": { "type": "string", "pattern": "^([a-z][a-z0-9-]*:)?adr-\\d{4}$" },
60
60
  "uniqueItems": true,
61
61
  "description": "Related ADR identifiers"
62
62
  }
@@ -0,0 +1,71 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "federation.schema.json",
4
+ "title": "Federation Manifest",
5
+ "description": "Peer service manifest for multi-repo federation (.dkk/federation.yml). Each peer points at a filesystem path or a git URL+branch; the peer's `.dkk/` directory is loaded read-only alongside the local model.",
6
+ "type": "object",
7
+ "properties": {
8
+ "peers": {
9
+ "type": "array",
10
+ "items": { "$ref": "#/definitions/peer" },
11
+ "description": "Peer services whose .dkk/ should be loaded alongside the local model."
12
+ }
13
+ },
14
+ "required": ["peers"],
15
+ "additionalProperties": false,
16
+ "definitions": {
17
+ "peer": {
18
+ "type": "object",
19
+ "properties": {
20
+ "name": {
21
+ "type": "string",
22
+ "pattern": "^[a-z][a-z0-9-]*$",
23
+ "description": "Kebab-case peer service name (must match the peer's own service.yml)."
24
+ },
25
+ "source": {
26
+ "oneOf": [
27
+ { "$ref": "#/definitions/localSource" },
28
+ { "$ref": "#/definitions/gitSource" }
29
+ ]
30
+ }
31
+ },
32
+ "required": ["name", "source"],
33
+ "additionalProperties": false
34
+ },
35
+ "localSource": {
36
+ "type": "object",
37
+ "properties": {
38
+ "type": { "const": "local" },
39
+ "path": {
40
+ "type": "string",
41
+ "minLength": 1,
42
+ "description": "Absolute or repo-root-relative path to the peer's repository root."
43
+ }
44
+ },
45
+ "required": ["type", "path"],
46
+ "additionalProperties": false
47
+ },
48
+ "gitSource": {
49
+ "type": "object",
50
+ "properties": {
51
+ "type": { "const": "git" },
52
+ "url": {
53
+ "type": "string",
54
+ "minLength": 1,
55
+ "description": "Git URL (https or ssh)."
56
+ },
57
+ "branch": {
58
+ "type": "string",
59
+ "minLength": 1,
60
+ "description": "Branch to track."
61
+ },
62
+ "path": {
63
+ "type": "string",
64
+ "description": "Optional sub-path inside the peer repo where .dkk/ lives (default: repo root)."
65
+ }
66
+ },
67
+ "required": ["type", "url", "branch"],
68
+ "additionalProperties": false
69
+ }
70
+ }
71
+ }