@bonesofspring/ai-rules 0.2.6 → 0.2.7

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 (188) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +9 -3
  3. package/bin/cli.js +28 -1
  4. package/package.json +3 -2
  5. package/presets/_shared/core/agent-team/agent-team-intake.md +1 -1
  6. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +1 -1
  7. package/presets/_shared/core/architecture/reference-features.template.md +12 -0
  8. package/presets/_shared/core/quality/code-quality-and-refactoring.md +11 -0
  9. package/presets/_shared/core/review/code-review-mr.md +9 -0
  10. package/presets/claude/go/CLAUDE.md +5 -1
  11. package/presets/claude/go/README.md +5 -1
  12. package/presets/claude/go/REPO_AGENTS.md +48 -0
  13. package/presets/claude/go/agents/README.md +19 -2
  14. package/presets/claude/go/agents/build-verifier.md +5 -0
  15. package/presets/claude/go/agents/codebase-analyzer.md +28 -0
  16. package/presets/claude/go/agents/feature-developer.md +13 -0
  17. package/presets/claude/go/hooks/README.md +6 -0
  18. package/presets/claude/go/hooks/examples/README.md +18 -0
  19. package/presets/claude/go/hooks/examples/format-edited.example.sh +9 -0
  20. package/presets/claude/go/hooks/examples/secret-guard.example.sh +10 -0
  21. package/presets/claude/go/hooks/examples/test-on-save.example.sh +11 -0
  22. package/presets/claude/go/rules/api-and-data/api-http.md +10 -3
  23. package/presets/claude/go/rules/architecture/reference-features.md +4 -0
  24. package/presets/claude/go/rules/stack/go-conventions.md +30 -3
  25. package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +1 -1
  26. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  27. package/presets/claude/go/rules/tooling-and-review/code-quality.md +12 -1
  28. package/presets/claude/go/rules/tooling-and-review/code-review.md +9 -0
  29. package/presets/claude/go/skills/README.md +2 -2
  30. package/presets/claude/go/skills/code-review/SKILL.md +11 -2
  31. package/presets/claude/go/skills/feature-delivery/SKILL.md +4 -0
  32. package/presets/claude/go/skills/technical-retro/SKILL.md +46 -2
  33. package/presets/claude/go/skills/write-adr/SKILL.md +41 -0
  34. package/presets/claude/go/team/conventions.md +21 -0
  35. package/presets/claude/ios-swift/CLAUDE.md +4 -1
  36. package/presets/claude/ios-swift/README.md +5 -1
  37. package/presets/claude/ios-swift/REPO_AGENTS.md +46 -0
  38. package/presets/claude/ios-swift/agents/README.md +3 -2
  39. package/presets/claude/ios-swift/agents/build-verifier.md +6 -0
  40. package/presets/claude/ios-swift/agents/codebase-analyzer.md +28 -0
  41. package/presets/claude/ios-swift/agents/feature-developer.md +13 -0
  42. package/presets/claude/ios-swift/hooks/README.md +6 -0
  43. package/presets/claude/ios-swift/hooks/examples/README.md +18 -0
  44. package/presets/claude/ios-swift/hooks/examples/format-edited.example.sh +13 -0
  45. package/presets/claude/ios-swift/hooks/examples/secret-guard.example.sh +10 -0
  46. package/presets/claude/ios-swift/hooks/examples/test-on-save.example.sh +8 -0
  47. package/presets/claude/ios-swift/rules/architecture/reference-features.md +4 -0
  48. package/presets/claude/ios-swift/rules/stack/swift-conventions.md +12 -2
  49. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +1 -1
  50. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  51. package/presets/claude/ios-swift/rules/tooling-and-review/code-quality.md +12 -1
  52. package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +47 -0
  53. package/presets/claude/ios-swift/rules/ui-and-accessibility/swiftui.md +8 -0
  54. package/presets/claude/ios-swift/skills/README.md +1 -0
  55. package/presets/claude/ios-swift/skills/code-review/SKILL.md +10 -2
  56. package/presets/claude/ios-swift/skills/feature-delivery/SKILL.md +4 -0
  57. package/presets/claude/ios-swift/skills/technical-retro/SKILL.md +46 -2
  58. package/presets/claude/ios-swift/skills/write-adr/SKILL.md +41 -0
  59. package/presets/claude/ios-swift/team/conventions.md +21 -0
  60. package/presets/claude/next/CLAUDE.md +5 -1
  61. package/presets/claude/next/README.md +6 -1
  62. package/presets/claude/next/REPO_AGENTS.md +48 -0
  63. package/presets/claude/next/agents/README.md +7 -1
  64. package/presets/claude/next/agents/build-verifier.md +5 -0
  65. package/presets/claude/next/agents/codebase-analyzer.md +28 -0
  66. package/presets/claude/next/agents/feature-developer.md +13 -0
  67. package/presets/claude/next/agents/security-reviewer.md +4 -2
  68. package/presets/claude/next/hooks/README.md +6 -0
  69. package/presets/claude/next/hooks/examples/README.md +18 -0
  70. package/presets/claude/next/hooks/examples/format-edited.example.sh +11 -0
  71. package/presets/claude/next/hooks/examples/secret-guard.example.sh +10 -0
  72. package/presets/claude/next/hooks/examples/test-on-save.example.sh +8 -0
  73. package/presets/claude/next/rules/README.md +2 -1
  74. package/presets/claude/next/rules/api-and-data/api-services.md +22 -0
  75. package/presets/claude/next/rules/api-and-data/http-client.md +21 -0
  76. package/presets/claude/next/rules/api-and-data/store-rtk.md +20 -0
  77. package/presets/claude/next/rules/architecture/architecture-boundaries.md +28 -0
  78. package/presets/claude/next/rules/architecture/layer-barrel-exports.md +15 -0
  79. package/presets/claude/next/rules/architecture/public-imports.md +14 -0
  80. package/presets/claude/next/rules/architecture/reference-features.md +4 -0
  81. package/presets/claude/next/rules/stack/arrow-functions.md +13 -28
  82. package/presets/claude/next/rules/stack/next-app-router.md +13 -1
  83. package/presets/claude/next/rules/testing/tests-unit.md +13 -0
  84. package/presets/claude/next/rules/tooling-and-review/README.md +2 -1
  85. package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +1 -1
  86. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
  87. package/presets/claude/next/rules/tooling-and-review/code-quality.md +12 -2
  88. package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +22 -0
  89. package/presets/claude/next/rules/tooling-and-review/security-next.md +57 -0
  90. package/presets/claude/next/rules/ui-and-accessibility/react-ui.md +21 -0
  91. package/presets/claude/next/skills/README.md +2 -0
  92. package/presets/claude/next/skills/code-review/SKILL.md +10 -2
  93. package/presets/claude/next/skills/feature-delivery/SKILL.md +4 -0
  94. package/presets/claude/next/skills/react-performance/SKILL.md +44 -0
  95. package/presets/claude/next/skills/technical-retro/SKILL.md +19 -5
  96. package/presets/claude/next/skills/write-adr/SKILL.md +41 -0
  97. package/presets/claude/next/team/conventions.md +21 -0
  98. package/presets/cursor/go/AGENTS.md +6 -0
  99. package/presets/cursor/go/README.md +6 -5
  100. package/presets/cursor/go/REPO_AGENTS.md +48 -0
  101. package/presets/cursor/go/agents/README.md +23 -2
  102. package/presets/cursor/go/agents/build-verifier.md +5 -0
  103. package/presets/cursor/go/agents/codebase-analyzer.md +28 -0
  104. package/presets/cursor/go/agents/feature-developer.md +13 -0
  105. package/presets/cursor/go/commands/README.md +1 -1
  106. package/presets/cursor/go/hooks/README.md +4 -0
  107. package/presets/cursor/go/hooks/examples/README.md +18 -0
  108. package/presets/cursor/go/hooks/examples/format-edited.example.sh +9 -0
  109. package/presets/cursor/go/hooks/examples/secret-guard.example.sh +10 -0
  110. package/presets/cursor/go/hooks/examples/test-on-save.example.sh +11 -0
  111. package/presets/cursor/go/rules/README.md +2 -2
  112. package/presets/cursor/go/rules/agent-team-intake.mdc +1 -1
  113. package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
  114. package/presets/cursor/go/rules/api-http.mdc +10 -3
  115. package/presets/cursor/go/rules/code-quality-and-refactoring.mdc +12 -1
  116. package/presets/cursor/go/rules/code-review-mr.mdc +9 -0
  117. package/presets/cursor/go/rules/go-conventions.mdc +30 -3
  118. package/presets/cursor/go/rules/reference-features.mdc +4 -0
  119. package/presets/cursor/go/skills/README.md +2 -2
  120. package/presets/cursor/go/skills/code-review/SKILL.md +10 -1
  121. package/presets/cursor/go/skills/feature-delivery/SKILL.md +4 -0
  122. package/presets/cursor/go/skills/technical-retro/SKILL.md +46 -2
  123. package/presets/cursor/go/skills/write-adr/SKILL.md +41 -0
  124. package/presets/cursor/go/team/conventions.md +21 -0
  125. package/presets/cursor/ios-swift/AGENTS.md +5 -2
  126. package/presets/cursor/ios-swift/README.md +6 -5
  127. package/presets/cursor/ios-swift/REPO_AGENTS.md +46 -0
  128. package/presets/cursor/ios-swift/agents/README.md +3 -2
  129. package/presets/cursor/ios-swift/agents/build-verifier.md +6 -0
  130. package/presets/cursor/ios-swift/agents/codebase-analyzer.md +28 -0
  131. package/presets/cursor/ios-swift/agents/feature-developer.md +13 -0
  132. package/presets/cursor/ios-swift/commands/README.md +1 -1
  133. package/presets/cursor/ios-swift/hooks/README.md +4 -0
  134. package/presets/cursor/ios-swift/hooks/examples/README.md +18 -0
  135. package/presets/cursor/ios-swift/hooks/examples/format-edited.example.sh +13 -0
  136. package/presets/cursor/ios-swift/hooks/examples/secret-guard.example.sh +10 -0
  137. package/presets/cursor/ios-swift/hooks/examples/test-on-save.example.sh +8 -0
  138. package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +1 -1
  139. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
  140. package/presets/cursor/ios-swift/rules/code-quality-and-refactoring.mdc +12 -1
  141. package/presets/cursor/ios-swift/rules/code-review-mr.mdc +9 -0
  142. package/presets/cursor/ios-swift/rules/reference-features.mdc +4 -0
  143. package/presets/cursor/ios-swift/rules/swift-conventions.mdc +12 -2
  144. package/presets/cursor/ios-swift/rules/swiftui-ui.mdc +8 -0
  145. package/presets/cursor/ios-swift/skills/README.md +1 -0
  146. package/presets/cursor/ios-swift/skills/code-review/SKILL.md +10 -2
  147. package/presets/cursor/ios-swift/skills/feature-delivery/SKILL.md +4 -0
  148. package/presets/cursor/ios-swift/skills/technical-retro/SKILL.md +46 -2
  149. package/presets/cursor/ios-swift/skills/write-adr/SKILL.md +41 -0
  150. package/presets/cursor/ios-swift/team/conventions.md +21 -0
  151. package/presets/cursor/next/AGENTS.md +5 -2
  152. package/presets/cursor/next/README.md +7 -6
  153. package/presets/cursor/next/REPO_AGENTS.md +48 -0
  154. package/presets/cursor/next/agents/README.md +7 -1
  155. package/presets/cursor/next/agents/build-verifier.md +5 -0
  156. package/presets/cursor/next/agents/codebase-analyzer.md +28 -0
  157. package/presets/cursor/next/agents/feature-developer.md +13 -0
  158. package/presets/cursor/next/agents/security-reviewer.md +4 -2
  159. package/presets/cursor/next/commands/README.md +1 -1
  160. package/presets/cursor/next/hooks/README.md +4 -0
  161. package/presets/cursor/next/hooks/examples/README.md +18 -0
  162. package/presets/cursor/next/hooks/examples/format-edited.example.sh +11 -0
  163. package/presets/cursor/next/hooks/examples/secret-guard.example.sh +10 -0
  164. package/presets/cursor/next/hooks/examples/test-on-save.example.sh +8 -0
  165. package/presets/cursor/next/rules/README.md +4 -3
  166. package/presets/cursor/next/rules/agent-team-intake.mdc +1 -1
  167. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
  168. package/presets/cursor/next/rules/api-services.mdc +21 -0
  169. package/presets/cursor/next/rules/architecture-boundaries.mdc +27 -0
  170. package/presets/cursor/next/rules/arrow-functions.mdc +13 -28
  171. package/presets/cursor/next/rules/code-quality-and-refactoring.mdc +12 -2
  172. package/presets/cursor/next/rules/code-review-mr.mdc +11 -13
  173. package/presets/cursor/next/rules/http-client.mdc +21 -0
  174. package/presets/cursor/next/rules/layer-barrel-exports.mdc +15 -0
  175. package/presets/cursor/next/rules/next-app-router.mdc +13 -1
  176. package/presets/cursor/next/rules/public-imports.mdc +14 -0
  177. package/presets/cursor/next/rules/react-ui.mdc +20 -0
  178. package/presets/cursor/next/rules/reference-features.mdc +4 -0
  179. package/presets/cursor/next/rules/security-next.mdc +57 -0
  180. package/presets/cursor/next/rules/store-rtk.mdc +19 -0
  181. package/presets/cursor/next/rules/tests-unit.mdc +12 -0
  182. package/presets/cursor/next/skills/README.md +2 -0
  183. package/presets/cursor/next/skills/code-review/SKILL.md +10 -2
  184. package/presets/cursor/next/skills/feature-delivery/SKILL.md +4 -0
  185. package/presets/cursor/next/skills/react-performance/SKILL.md +44 -0
  186. package/presets/cursor/next/skills/technical-retro/SKILL.md +19 -5
  187. package/presets/cursor/next/skills/write-adr/SKILL.md +41 -0
  188. package/presets/cursor/next/team/conventions.md +21 -0
package/CHANGELOG.md CHANGED
@@ -2,8 +2,53 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Claude Code handbook agent discipline
6
+
7
+ Borrowed workflow patterns from [claude-code-rules](https://github.com/nikiforovall/claude-code-rules) (methodology marketplace — not coding standards). Additive on top of structure-change / preset-rules-improvements work.
8
+
9
+ - **`feature-developer` ×6:** Zero improvisation + Will / Will not (scope discipline; clarify before guessing).
10
+ - **`feature-delivery` skill ×6:** short Scope discipline pointer.
11
+ - **`codebase-analyzer` agent ×6:** explain-as-is only; AGENTS/CLAUDE + agents README pointers; roster next/ios **22**, go **21**.
12
+ - **`code-review` skill ×6:** Reuse + Efficiency lenses.
13
+ - **`technical-retro` skill ×6:** wrong-turn taxonomy + conventions.md feedback (Rule of Three); full skill body on next/go/ios (not alias-only); no auto-apply.
14
+ - **`agent-team-intake` / `agent-team-orchestrator`:** pure questions → prefer **`codebase-analyzer`** (aligned with AGENTS/CLAUDE maps).
15
+ - **`docs/PRESET-CONTRIBUTION.md`:** Building blocks matrix (rule / command / skill / agent / conventions / hook).
16
+
17
+ ### Awesome-cursorrules borrow backlog
18
+
19
+ - **`security-next`** (cursor + claude next): coding-time secrets/auth/XSS/Server Actions rule; wired into `security-reviewer`, catalogs, AGENTS/CLAUDE quick start.
20
+ - **Anti-hallucination banlists:** `next-app-router`, `go-conventions`, `swift-conventions` (❌/✅ tables).
21
+ - **Review output contract** in shared `review/code-review-mr` (+6 adapters) and all 6 `code-review` skills: `path:line`, severity `blocker|important|nit`, verdict line.
22
+ - **Go:** expanded `go-conventions` (errors/interfaces/concurrency); `api-http` resilience (idempotency, bulkheads, thin handlers) — catalog depth stub→full.
23
+ - **iOS:** `swiftui-ui` lifecycle/ownership (`.task`, DI vs `@StateObject`, hit testing).
24
+ - **Shared quality:** Agent discipline (anti-sycophancy) section in `quality/code-quality-and-refactoring` (+6 adapters).
25
+
26
+ ### Preset rules improvements (9 items)
27
+
28
+ Cross-cutting preset packaging work (all six presets unless noted **next-only**). Hard gates unchanged: twin sync, ≤3 always-on, no cross-stack leakage.
29
+
30
+ | # | Item | Unreleased note |
31
+ |---|------|-----------------|
32
+ | 1 | Root `AGENTS.md` + **CLI** | `repoRootFiles`: `REPO_AGENTS.md` → `<cwd>/AGENTS.md` on cursor **and** claude `init` (overwrite policy A); removed on `clean` either tool |
33
+ | 2 | Incorrect/Correct samples | **next only** — 9 domain rules with emedcard-grounded pairs |
34
+ | 3 | Impact tags | `impact: CRITICAL\|HIGH\|MEDIUM\|LOW` frontmatter; documented in PRESET-CONTRIBUTION |
35
+ | 4 | Eval harness (opt-in) | `eval/next/manifest.json`, `check-rule-eval.mjs`, `yarn check:rule-eval`, workflow `rule-eval.yml` |
36
+ | 5 | Living conventions | `reference-features` lineage + `team/conventions.md` ×6 |
37
+ | 6 | Hooks cookbook | `hooks/examples/` (secret-guard, format-edited, test-on-save); default `hooks.json` unchanged |
38
+ | 7 | Skill `write-adr` | ×6 presets (on-demand) |
39
+ | 8 | Skill `react-performance` | **next only** (cursor + claude) |
40
+ | 9 | Linter-delegated style | Stack notes in code-quality adapters; `arrow-functions` trimmed → ESLint/Stylelint + `post-change-lint` |
41
+
5
42
  ### Added
6
43
 
44
+ - **CLI `repoRootFiles` + root `AGENTS.md` (all stacks):** preset source `REPO_AGENTS.md` → `<cwd>/AGENTS.md` on cursor **and** claude `init` (overwrite); removed on `clean`. Lean cross-tool sections + pointer to `team/conventions.md`.
45
+ - **Impact frontmatter:** `impact: CRITICAL|HIGH|MEDIUM|LOW` documented in `docs/PRESET-CONTRIBUTION.md`; applied on next golden domain rules with Incorrect/Correct samples.
46
+ - **Next Incorrect/Correct samples** on 9 domain rules (architecture-boundaries, public-imports, api-services, store-rtk, react-ui, tests-unit, http-client, layer-barrel-exports, arrow-functions) + Claude twins.
47
+ - **Opt-in eval:** `eval/next/manifest.json`, `scripts/check-rule-eval.mjs`, `yarn check:rule-eval`, workflow `.github/workflows/rule-eval.yml` (not in `check:preset-structure`).
48
+ - **Living conventions:** lineage section in `reference-features.template.md` + 6 adapters; `team/conventions.md` template ×6.
49
+ - **Skills:** `write-adr` ×6; `react-performance` ×2 (next cursor+claude only).
50
+ - **Hooks cookbook:** `hooks/examples/` (secret-guard, format-edited, test-on-save) ×3 stacks ×2 platforms; default `hooks.json` unchanged.
51
+ - **Dogfood:** `sync-dogfood-cursor.sh` copies root `AGENTS.md` from `REPO_AGENTS.md`; seeds `team/conventions.md` if absent.
7
52
  - **Always-on Principles** in shared `quality/code-quality-and-refactoring` (+6 adapters): compact § **Принципы** — KISS, DRY + Rule of Three, YAGNI, SOLID, CUPID, composition over inheritance, Law of Demeter hint. No smell/GoF catalogs in always-on.
8
53
  - **Requestable `quality/design-guidance`** (+6 adapters, Cursor/Claude × next/ios-swift/go): curated Fowler smells (≤12) + GoF (≤8) + skip/avoid; globs `app/src/**/*.{ts,tsx}` / `**/*.swift` / `**/*.go`. Cross-refs in `feature-delivery-workflow` (ubiquitous language) and `code-review-mr` checklist. One-liner wiring in feature-developer / code-review / debugger (+ recommended roles).
9
54
  - **Go hexagonal preset (`go`):** Cursor + Claude twins — 32 rules (always-on: `go-app-core`, `architecture-boundaries`, `code-quality-and-refactoring`), 20 agents (`integration-test-*`, no a11y/Playwright/XCUITest), 7 skills (+ `integration-testing`), hooks/commands/team/MCP. Structure scripts `STACKS` include `go`; leakage `GO_FORBIDDEN_*` + pairwise chain forks. Install: `init cursor|claude --preset go`. Lineage markers on go `feature-delivery-workflow` / `reference-features`; go team fixtures / commands READMEs use Go gates (not xcodebuild/XCUITest copy-paste).
@@ -19,6 +64,8 @@
19
64
 
20
65
  ### Changed
21
66
 
67
+ - **Style delegate:** next `arrow-functions` trimmed → ESLint/Stylelint + `post-change-lint`; ios/go Stack notes point to SwiftLint / golangci; abstract style sentence in shared code-quality core (no tool names in core body).
68
+ - **Leakage scan:** `hooks/**/*.sh` recursive (includes cookbook examples).
22
69
  - **Meta twin policy (three stacks):** `preset-twin-sync` / `preset-pr-checklist` / `preset-layering` core + embeds name **next, ios-swift, and go**; twin FAIL applies to all three (`check-preset-twin-map.sh`).
23
70
  - **PRESET-CONTRIBUTION:** shared-core sync step says **all six adapters** (3 stacks × 2 platforms), not «four presets».
24
71
  - **Claude session-start count (Option A):** when counting rules without `paths:`, **exclude `**/README.md`**; intended trio remains **exactly 3**; body budget sums only those 3 (`preset-token-budget`, PRESET-CONTRIBUTION, build-verifier ×4).
package/README.md CHANGED
@@ -32,6 +32,7 @@ If `.cursor` does not appear, check the command output for errors and confirm yo
32
32
  - optional dirs when present: `agents/`, `hooks/`, `skills/`, `team/`
33
33
  - Cursor root files: `hooks.json`, `BUGBOT.md`, `AGENTS.md`, `MCP.md`, `mcp.json`
34
34
  - Claude: `CLAUDE.md`, `MCP.md` under `.claude/`; project `.mcp.json` at repo root
35
+ - **Both tools:** repo-root `AGENTS.md` (from preset `REPO_AGENTS.md`)
35
36
 
36
37
  Any other files you added under `.cursor/` or `.claude/` (notes, local overrides, IDE state) are **left intact**. Older releases that deleted the whole tool directory are no longer the behavior.
37
38
 
@@ -43,10 +44,14 @@ Where things go on `init`:
43
44
  | commands | `.cursor/commands` | `.claude/commands` |
44
45
  | agents | `.cursor/agents` | `.claude/agents` |
45
46
  | hooks | `.cursor/hooks`, `.cursor/hooks.json` | `.claude/hooks` |
47
+ | hooks cookbook | `.cursor/hooks/examples/` (not in default `hooks.json`) | `.claude/hooks/examples/` |
46
48
  | skills | `.cursor/skills` | `.claude/skills` |
47
- | team artifacts template | `.cursor/team` | `.claude/team` |
49
+ | team artifacts template | `.cursor/team` (incl. `conventions.md`) | `.claude/team` |
48
50
  | MCP | `mcp.json` → `.cursor/mcp.json`, `MCP.md` → `.cursor/` | `mcp.json` → **`.mcp.json`** (project root), `MCP.md` → `.claude/` |
49
- | other | `BUGBOT.md`, `AGENTS.md` → `.cursor/` | `CLAUDE.md` → `.claude/CLAUDE.md` |
51
+ | tool map | `AGENTS.md` → `.cursor/AGENTS.md`, `BUGBOT.md` | `CLAUDE.md` → `.claude/CLAUDE.md` |
52
+ | **repo-root agents** | `REPO_AGENTS.md` → **`<cwd>/AGENTS.md`** | same |
53
+
54
+ Skills of note: `write-adr` (all stacks); `react-performance` (**next only**). Living gotchas: `team/conventions.md`. Opt-in rule samples eval: `yarn check:rule-eval` (workflow `rule-eval.yml`; not part of `check:preset-structure`).
50
55
 
51
56
  The package ships presets including **`next`** (Next.js stack), **`ios-swift`** (iOS apps on Swift / SwiftUI), and **`go`** (Go backends with hexagonal architecture). Other preset names: see `presets/` in the [repo](https://github.com/bonesofspring/ai-rules). Name is a single path segment, no `/` or `..`.
52
57
 
@@ -65,8 +70,9 @@ Presets are developed in this monorepo under `presets/`. If you add or change ru
65
70
 
66
71
  - **Taxonomy & layers:** [`presets/_shared/README.md`](presets/_shared/README.md) — shared core (`_shared/core`), stack adapters, platform packaging
67
72
  - **Contribution guide:** [`docs/PRESET-CONTRIBUTION.md`](docs/PRESET-CONTRIBUTION.md) — SoT, twin sync, embed vs lineage, token budget (≤3 always-on), PR checklist, new stack preset, platform-only files (`BUGBOT.md`, `CLAUDE.md`)
68
- - **Dogfood / drift scripts:** [`scripts/sync-dogfood-cursor.sh`](scripts/sync-dogfood-cursor.sh), [`scripts/check-shared-core-drift.sh`](scripts/check-shared-core-drift.sh)
73
+ - **Dogfood / drift scripts:** [`scripts/sync-dogfood-cursor.sh`](scripts/sync-dogfood-cursor.sh) (also syncs root `AGENTS.md` from `REPO_AGENTS.md`; seeds `team/conventions.md` if absent), [`scripts/check-shared-core-drift.sh`](scripts/check-shared-core-drift.sh)
69
74
  - **Preset structure CI gates** (exit non-zero on FAIL): `yarn check:preset-structure` (or `bash scripts/check-preset-structure.sh`) — twin map, session-start budget (Option A), leakage; soft drift included without `AI_RULES_DRIFT_FAIL`
75
+ - **Opt-in rule eval:** `yarn check:rule-eval` + `.github/workflows/rule-eval.yml` (`workflow_dispatch` + paths-scoped PR) — **not** wired into `check:preset-structure`
70
76
  - **CLI note:** `_shared` is not an installable `--preset`; `init` copies only `presets/cursor/<name>/` or `presets/claude/<name>/`
71
77
 
72
78
  MIT.
package/bin/cli.js CHANGED
@@ -21,6 +21,8 @@ const PRESETS = {
21
21
  mcpJsonSrc: 'mcp.json',
22
22
  mcpJsonDest: '.cursor/mcp.json',
23
23
  toolRootFiles: ['BUGBOT.md', 'AGENTS.md', 'MCP.md'],
24
+ /** Preset-root basename → path relative to cwd (not under .cursor/). */
25
+ repoRootFiles: { 'REPO_AGENTS.md': 'AGENTS.md' },
24
26
  },
25
27
  claude: {
26
28
  rulesDir: '.claude/rules',
@@ -32,6 +34,8 @@ const PRESETS = {
32
34
  mcpJsonSrc: 'mcp.json',
33
35
  mcpJsonDest: '.mcp.json',
34
36
  toolRootFiles: ['MCP.md'],
37
+ /** Same cross-tool root AGENTS.md as cursor (overwrite on init). */
38
+ repoRootFiles: { 'REPO_AGENTS.md': 'AGENTS.md' },
35
39
  },
36
40
  };
37
41
 
@@ -57,8 +61,10 @@ Options:
57
61
 
58
62
  Notes:
59
63
  init merges into the target directory; same-named files are overwritten.
60
- Cursor init copies rules, commands, agents, hooks, skills, team, hooks.json, BUGBOT.md, AGENTS.md, MCP.md, mcp.json → .cursor/mcp.json.
64
+ Cursor init copies rules, commands, agents, hooks, skills, team, hooks.json, BUGBOT.md, AGENTS.md → .cursor/AGENTS.md, MCP.md, mcp.json → .cursor/mcp.json.
61
65
  Claude init copies rules, commands, skills, agents, hooks, team, CLAUDE.md, MCP.md, and mcp.json → .mcp.json (project root).
66
+ Both tools also copy REPO_AGENTS.md → <cwd>/AGENTS.md (repo-root cross-tool agents file; overwrite).
67
+ clean removes tool dirs/files and <cwd>/AGENTS.md (shared across tools — re-init the other tool to restore).
62
68
  Command forms: "init cursor --preset next", "init cursor next", "--preset next init cursor", "cursor init --preset next".
63
69
 
64
70
  Examples:
@@ -255,6 +261,11 @@ function presetHasAnySource(base, cfg) {
255
261
  return true;
256
262
  }
257
263
  }
264
+ for (const srcName of Object.keys(cfg.repoRootFiles || {})) {
265
+ if (fs.existsSync(path.join(base, srcName))) {
266
+ return true;
267
+ }
268
+ }
258
269
  return false;
259
270
  }
260
271
 
@@ -386,6 +397,17 @@ function cmdInit(tool, preset, cwdOption) {
386
397
  copiedSteps++;
387
398
  }
388
399
  }
400
+
401
+ for (const [srcName, destRel] of Object.entries(cfg.repoRootFiles || {})) {
402
+ const from = path.join(base, srcName);
403
+ if (fs.existsSync(from)) {
404
+ const destAbs = path.join(cwd, destRel);
405
+ fs.mkdirSync(path.dirname(destAbs), { recursive: true });
406
+ fs.copyFileSync(from, destAbs);
407
+ console.log(`Copied ${srcName} → ${destRel}`);
408
+ copiedSteps++;
409
+ }
410
+ }
389
411
  } catch (err) {
390
412
  const msg = err instanceof Error ? err.message : String(err);
391
413
  console.error(`init failed: ${msg}`);
@@ -444,6 +466,11 @@ function cmdClean(tool, cwdOption) {
444
466
  removedParts.push(`${toolRoot}/${name}`);
445
467
  }
446
468
 
469
+ for (const destRel of Object.values(cfg.repoRootFiles || {})) {
470
+ removeFileIfExists(path.join(cwd, destRel));
471
+ removedParts.push(destRel);
472
+ }
473
+
447
474
  console.log(`Removed ${removedParts.join(', ')} (if present)`);
448
475
  }
449
476
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonesofspring/ai-rules",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Presets of Cursor and Claude rules/commands for Revy Ross personal use",
5
5
  "license": "MIT",
6
6
  "author": "Revy Ross",
@@ -29,7 +29,8 @@
29
29
  "check:preset-twin-map": "bash scripts/check-preset-twin-map.sh",
30
30
  "check:preset-token-budget": "bash scripts/check-preset-token-budget.sh",
31
31
  "check:preset-leakage": "bash scripts/check-preset-leakage.sh",
32
- "check:shared-core-drift": "bash scripts/check-shared-core-drift.sh"
32
+ "check:shared-core-drift": "bash scripts/check-shared-core-drift.sh",
33
+ "check:rule-eval": "node scripts/check-rule-eval.mjs"
33
34
  },
34
35
  "engines": {
35
36
  "node": ">=18"
@@ -4,6 +4,6 @@ When the user message looks like a **work request** (implement, add, fix, refact
4
4
 
5
5
  1. Prefer **`/task <their request>`** or invoke **task-router** first.
6
6
  2. Do not jump straight to coding without router + pipeline when scope is non-trivial.
7
- 3. Pure questions («как работает X», «объясни») — answer normally, no `/task`.
7
+ 3. Pure questions («как работает X», «объясни») — prefer agent **`codebase-analyzer`** (explain-as-is); trivial one-liners may be answered inline. Do not open `/task`.
8
8
 
9
9
  Exceptions: user explicitly says «без pipeline», «просто сделай», or continues an active slug.
@@ -126,7 +126,7 @@ If `pipeline.json` is missing (old `/feature-start` tasks), fall back to fixed p
126
126
 
127
127
  Do **not** run `/task` + router for:
128
128
 
129
- - Pure questions («как работает X», «объясни»).
129
+ - Pure questions («как работает X», «объясни») — prefer agent **`codebase-analyzer`** for deep traces; inline OK for trivial one-liners.
130
130
  - Typo / one-file fix / trivial config with no architecture risk.
131
131
  - User explicitly says «без pipeline», «просто сделай», or continues an active slug.
132
132
  - Single-line `docs-only` with no code impact.
@@ -22,6 +22,18 @@
22
22
  3. Зеркаль именование, порядок файлов, паттерны импортов и тестов.
23
23
  4. Если эталона нет — выбери **самую близкую** существующую фичу того же слоя и зафиксируй выбор в handoff.
24
24
 
25
+ ## Living conventions
26
+
27
+ После init команда ведёт **локальные** gotchas, patterns и decisions в consumer-owned store (не в shared core и не только в корневом `AGENTS.md`):
28
+
29
+ | Раздел | Что фиксировать |
30
+ |--------|-----------------|
31
+ | Gotchas | Повторяющиеся ловушки, хрупкие места, «не делай X в этом репо» |
32
+ | Patterns | Локальные паттерны сверх эталонной таблицы |
33
+ | Decisions | Краткие ADR-ссылки / продуктовые решения, влияющие на код |
34
+
35
+ Указатель пути к файлу и stack-таблицы — в адаптере пресета (`team/conventions.md`). Файл **не** always-on.
36
+
25
37
  ## Связанные правила
26
38
 
27
39
  - `code-quality-and-refactoring` — повторять паттерны, не deep-import.
@@ -55,4 +55,15 @@
55
55
  - **Boy scout rule:** оставлять модуль немного лучше, чем до изменения (простые, безопасные улучшения).
56
56
  - Не жертвовать архитектурой и слоями ради краткости реализации.
57
57
 
58
+ ## Agent discipline (anti-sycophancy)
59
+
60
+ - Unverifiable third-party API → mark `// VERIFY: lib.symbol @ version` (or stack equivalent) and surface uncertainty; never invent signatures.
61
+ - Before «is this correct?» — list ≥3 failure modes (empty, boundary, concurrency/state) or name what you could not check.
62
+ - Refactor without tests → propose a characterization test first; if declined, label `UNTESTED`.
63
+ - Comments = WHY only when non-obvious; ban self-referential «added for issue Y» comments.
64
+ - Urgency/authority pressure: name the technical trade-off once, then comply — no apology loops.
65
+ - Match verification depth to risk; report status by what was **verified**, not attempted.
66
+
67
+ Style enforcement (formatter / linter / post-change gate) lives in the **stack toolchain** — see each adapter’s **Stack notes**; do not invent a parallel style bible in this core body.
68
+
58
69
  > Stack-specific lint gates, примеры и toolchain — в секции **Stack notes** адаптера пресета.
@@ -27,3 +27,12 @@ Concrete rule stems — in **Stack notes**.
27
27
  - Use local `git diff` — do not invent hosting metadata.
28
28
  - Boy scout rule: suggest fixes feasible within the MR scope.
29
29
  - No «большие рефакторинги» without an explicit request (`code-quality-and-refactoring`).
30
+
31
+ ## Output contract
32
+
33
+ Procedure details live in skill `code-review`. Required shape:
34
+
35
+ - Each finding cites **`path:line`**, the problem, impact, and a concrete fix direction.
36
+ - Rank by severity: **`blocker` | `important` | `nit`** (list blocker → nit).
37
+ - Vague («looks risky») is not a finding — cite evidence or ask for surrounding file context.
38
+ - End with a verdict on its own line: **`Safe to merge | needs changes | reject`**.
@@ -2,9 +2,13 @@
2
2
 
3
3
  Preset for Go backends using ports & adapters.
4
4
 
5
+ **Repo-root agents:** see [`AGENTS.md`](../../AGENTS.md) at the project root.
6
+
5
7
  - Session-start: `go-app-core`, `architecture/boundaries`, `code-quality` (exactly 3).
6
8
  - Delivery: `architecture/feature-delivery.md` + skill `feature-delivery`.
7
9
  - After Go edits: `tooling-and-review/post-change-test.md`.
8
10
  - Integration tests: agents `integration-test-*` (never Playwright/XCUITest).
11
+ - ADR: skill `write-adr` (on-demand).
12
+ - How does X work: agent `codebase-analyzer` (explain-as-is; no `/task`).
9
13
 
10
- Init: `npx @bonesofspring/ai-rules init claude --preset go`
14
+ Init: `npx @bonesofspring/ai-rules init claude --preset go` (also copies `REPO_AGENTS.md` → root `AGENTS.md`).
@@ -12,7 +12,7 @@ npx @bonesofspring/ai-rules init claude --preset go
12
12
  |------|------------|
13
13
  | `CLAUDE.md` | Thin session entry |
14
14
  | `rules/**` | Topic `.md` + `paths:` (session-start = 3) |
15
- | `agents/**` | **20** ролей |
15
+ | `agents/**` | **21** ролей (+ `codebase-analyzer`) |
16
16
  | `skills/**` | **7** skills (в т.ч. `integration-testing`) |
17
17
  | `commands/**` | task, task-continue, feature-start/continue, technical-retro |
18
18
  | `hooks/**` | guard-shell + chain-team-phases |
@@ -32,3 +32,7 @@ npx @bonesofspring/ai-rules init claude --preset go
32
32
  ## Sync with Cursor
33
33
 
34
34
  SoT = `presets/cursor/go/`. Update this twin **in the same PR** when Cursor changes.
35
+
36
+ ## Cross-tool root AGENTS
37
+
38
+ `REPO_AGENTS.md` → project-root `AGENTS.md` on init. Living conventions: `team/conventions.md`. Skill `write-adr` on-demand.
@@ -0,0 +1,48 @@
1
+ # Go — agent instructions
2
+
3
+ Cross-tool repo-root guide. Tool-specific maps stay under `.cursor/AGENTS.md` and `.claude/CLAUDE.md`.
4
+
5
+ ## Cross-tool setup
6
+
7
+ - Treat this file as the **shared** entry for any agent (Cursor, Claude Code, or other).
8
+ - Tool maps live in `.cursor/AGENTS.md` / `.claude/CLAUDE.md` when that tool is installed.
9
+ - Install:
10
+
11
+ ```bash
12
+ npx @bonesofspring/ai-rules init cursor --preset go
13
+ npx @bonesofspring/ai-rules init claude --preset go
14
+ ```
15
+
16
+ `init` overwrites this file from the preset (`REPO_AGENTS.md` → `AGENTS.md`). Living gotchas belong in `team/conventions.md`, not here.
17
+
18
+ ## Commands (test / lint / build)
19
+
20
+ Prefer hexagonal / ports-and-adapters layout from stack rules (`go-app-core`, `architecture-boundaries`).
21
+
22
+ | Gate | Typical command |
23
+ |------|-----------------|
24
+ | Test | `go test ./...` (or package-scoped) |
25
+ | Vet | `go vet ./...` |
26
+ | Lint | **golangci-lint** when configured |
27
+ | Format | `gofmt` / `goimports` |
28
+
29
+ After code edits: invoke **`post-change-test`** (requestable). Full gate: agent `build-verifier`.
30
+
31
+ ## Security basics
32
+
33
+ - Do not commit secrets (tokens, `.env`, private keys).
34
+ - Review destructive git before running; respect shell hooks.
35
+ - Do not weaken CI or skip hooks unless the user explicitly asks.
36
+
37
+ ## Tool entry points
38
+
39
+ | Tool | Map |
40
+ |------|-----|
41
+ | Cursor | `.cursor/AGENTS.md` (optional if Cursor not installed) |
42
+ | Claude Code | `.claude/CLAUDE.md` (optional if Claude not installed) |
43
+
44
+ Rules: `.cursor/rules/` or `.claude/rules/`. Skills: `.cursor/skills/` or `.claude/skills/`.
45
+
46
+ ## Living conventions
47
+
48
+ Gotchas, local patterns, and team decisions: **`.cursor/team/conventions.md`** and/or **`.claude/team/conventions.md`** (fill after init).
@@ -1,8 +1,19 @@
1
1
  # `.claude/agents` (preset go)
2
2
 
3
+ Ролевые subagents для командного пайплайна Claude Code (Go hexagonal).
4
+
5
+ ## Analysis (on-demand)
6
+
7
+ | Agent | Файл | Production-код |
8
+ |-------|------|----------------|
9
+ | Codebase analyzer | `codebase-analyzer.md` | no (explain-as-is only) |
10
+
11
+ ## Roster (21)
12
+
3
13
  | Agent | Production writes |
4
14
  |-------|-------------------|
5
15
  | task-router, task-analyst, solution-architect | team only |
16
+ | codebase-analyzer | no (explain-as-is only) |
6
17
  | feature-developer | yes (Go sources) |
7
18
  | build-verifier | no (report only) |
8
19
  | debugger, ci-investigator | minimal |
@@ -10,6 +21,12 @@
10
21
  | migration-specialist, api-contract-reviewer, tech-writer | team / docs |
11
22
  | qa-tester, unit-test-*, integration-test-* | tests |
12
23
 
13
- **Roster:** 20 agents. **No** `accessibility-reviewer`, Playwright, or XCUITest stems.
24
+ **No** `accessibility-reviewer`, Playwright, or XCUITest stems. Replace those intents with **`integration-test-*`**.
25
+
26
+ ## Model matrix
14
27
 
15
- Replace Playwright/XCUITest intents with **`integration-test-*`**.
28
+ | Tier | Agents |
29
+ |------|--------|
30
+ | **cheap** | router, analyst, build-verifier, code-reviewer, tech-writer, codebase-analyzer |
31
+ | **standard** | developer, debugger, ci-investigator, api-contract, qa, unit-*, integration-* |
32
+ | **strong** | solution-architect, migration-specialist, security-reviewer, performance-auditor |
@@ -28,3 +28,8 @@ yarn check:preset-structure
28
28
  Hard gates: twin-map (stacks include **go**), token-budget (alwaysApply/session-start = 3), leakage (`GO_FORBIDDEN_*`, chain forks go≠next≠ios-swift).
29
29
 
30
30
  Document PASS/FAIL in `validation-report.md`.
31
+
32
+ 9. **Root AGENTS template:** each installable preset (`cursor|claude` × `next|ios-swift|go`) must ship `REPO_AGENTS.md` when validating preset packaging → **FAIL** if missing.
33
+ 10. **Hooks cookbook:** default `hooks.json` must **not** reference `hooks/examples/` → **FAIL** if it does.
34
+ 11. **No react-performance on ios/go:** skill directory / required handoff must be absent under ios-swift and go → **FAIL** (leakage). Prefer `check:preset-leakage`.
35
+ 12. **Rule eval (WARN):** `scripts/check-rule-eval.mjs` / `yarn check:rule-eval` should exist for maintainers; smoke optional. Hard fail only when the opt-in eval job runs — not part of default `check:preset-structure`.
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: codebase-analyzer
3
+ description: Explains HOW existing Go code works as-is. Use when the user asks how something works, to trace ports/adapters, or document architecture — without suggesting changes. Prefer over /task for pure questions.
4
+ readonly: false
5
+ model: fast
6
+ ---
7
+
8
+ You are a specialist at understanding HOW this Go hexagonal service works. Document implementation details with precise `path:line` references.
9
+
10
+ ## CRITICAL — explain as-is only
11
+
12
+ - DO NOT suggest improvements, refactors, or "better approaches" unless the user explicitly asks.
13
+ - DO NOT perform root-cause analysis or bug hunts unless asked.
14
+ - DO NOT critique quality, performance, or security unless asked.
15
+ - ONLY describe what exists, how it works, and how components interact.
16
+
17
+ ## Workflow
18
+
19
+ 1. Start from entry points the user named (`cmd/`, handlers, use cases, ports).
20
+ 2. Trace domain → application/ports → adapters → composition root as applicable.
21
+ 3. Summarize: purpose, flow, port contracts, adapter placement, conventions observed.
22
+ 4. End with open questions only if facts are missing — not with a wishlist of changes.
23
+
24
+ ## Will / Will not
25
+
26
+ **Will:** map packages, call chains, ports/adapters as they exist today.
27
+
28
+ **Will not:** edit production code; open `/task` pipelines; propose PRs or refactors unprompted; require Next/iOS gates.
@@ -19,6 +19,19 @@ Implement Go features following hexagonal boundaries.
19
19
  - **Don't** import frameworks into domain; don't use SQL in use cases.
20
20
  - **Don't** require Playwright, XCUITest, or yarn lint gates.
21
21
 
22
+ ## Zero improvisation
23
+
24
+ - Implement **only** what the brief / AC / current decomposition task require.
25
+ - If requirements are ambiguous, conflicting, or multi-way — **ask** before coding; do not guess extras as "best practices".
26
+ - Forbidden without explicit AC/task: unrelated security hardening, extra validation, observability, drive-by refactors, new config/env.
27
+ - Boy scout / `design-guidance` improvements stay **within** touched files and must not expand task scope.
28
+
29
+ ## Will / Will not
30
+
31
+ **Will:** follow hexagonal order; add required tests; run `post-change-test` (+ `go-tooling`); update task artifacts.
32
+
33
+ **Will not:** formal code review; invent AC; pull Next/iOS gates; auto-continue the next WP when the pipeline expects a human gate or handoff.
34
+
22
35
  ## Preset packaging
23
36
 
24
37
  When editing ai-rules `presets/**/go/**`, keep Cursor/Claude twins in sync and preserve chain fork ≠ next/ios-swift.
@@ -8,3 +8,9 @@
8
8
  Claude Code may not use Cursor `hooks.json`. Wire scripts per project docs when enabling agent-team auto-chain.
9
9
 
10
10
  **No `hooks.json` in Claude preset** (platform limit — same as next Claude).
11
+
12
+ ## Optional cookbook
13
+
14
+ Example scripts live in `hooks/examples/` (secret-guard, format-edited, test-on-save). They are **not** auto-enabled.
15
+
16
+ To wire in Claude Code: copy an `.example.sh` into `hooks/`, make executable, and register per [Claude Code hooks](https://code.claude.com/docs/en/hooks) for your project. Keep stack-safe recipes (this preset: **go**). Cursor twin examples under `presets/cursor/go/hooks/examples/` are the same allowlist forks.
@@ -0,0 +1,18 @@
1
+ # Hooks cookbook (examples)
2
+
3
+ Optional scripts under `hooks/examples/`. **Not** referenced from default `hooks.json` (only `guard-shell-command.sh` + `chain-team-phases.sh`).
4
+
5
+ | Script | Purpose |
6
+ |--------|---------|
7
+ | `secret-guard.example.sh` | Fail if staged diff looks like secrets |
8
+ | `format-edited.example.sh` | Stack formatter / linter on edited files |
9
+ | `test-on-save.example.sh` | Scoped tests for the stack |
10
+
11
+ ## Wiring (Cursor)
12
+
13
+ 1. Copy an example into `hooks/` (drop `.example` suffix), e.g. `cp hooks/examples/secret-guard.example.sh hooks/secret-guard.sh`.
14
+ 2. `chmod +x hooks/secret-guard.sh`.
15
+ 3. Add a hook entry in `.cursor/hooks.json` (e.g. `beforeShellExecution` or `afterFileEdit` — see Cursor hooks docs).
16
+ 4. Keep cookbook scripts **out** of the default preset `hooks.json` when contributing back upstream.
17
+
18
+ Stack: **go** — recipes must stay stack-safe (no cross-stack lint/test commands).
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ # Optional: gofmt / golangci-lint on edited packages.
3
+ # NOT in default hooks.json.
4
+ set -euo pipefail
5
+ gofmt -w $(git diff --name-only --diff-filter=ACMR HEAD 2>/dev/null | grep '\.go$' || true) 2>/dev/null || true
6
+ if command -v golangci-lint >/dev/null 2>&1; then
7
+ golangci-lint run ./... 2>/dev/null || true
8
+ fi
9
+ exit 0
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # Optional cookbook: block committing likely secrets in staged diffs.
3
+ # NOT wired in default hooks.json — copy to hooks/ and register manually.
4
+ set -euo pipefail
5
+ PATTERN='(AKIA[0-9A-Z]{16}|-----BEGIN (RSA |OPENSSH )?PRIVATE KEY-----|api[_-]?key\s*[:=]\s*['\''\"][^'\''\"]{12,})'
6
+ if git diff --cached -U0 2>/dev/null | grep -Eiq "$PATTERN"; then
7
+ echo "secret-guard: possible secret in staged diff — review before commit" >&2
8
+ exit 1
9
+ fi
10
+ exit 0
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+ # Optional: package-scoped go test for changed packages.
3
+ # NOT in default hooks.json.
4
+ set -euo pipefail
5
+ pkgs=$(git diff --name-only --diff-filter=ACMR HEAD 2>/dev/null | grep '\.go$' | xargs -n1 dirname 2>/dev/null | sort -u | sed 's|^|./|' || true)
6
+ if [[ -n "${pkgs:-}" ]]; then
7
+ go test $pkgs 2>/dev/null || true
8
+ else
9
+ go test ./... 2>/dev/null || true
10
+ fi
11
+ exit 0
@@ -6,15 +6,21 @@ paths:
6
6
  - **/*router*.go
7
7
  ---
8
8
 
9
-
10
9
  # HTTP API adapters
11
10
 
12
- - Handlers call inbound ports / use cases; return mapped status + body.
13
- - Use consistent error envelope; map domain errors centrally.
11
+ - Handlers are **thin**: parse input, call one inbound port / use case, map status + body.
12
+ - Use consistent error envelope; map **domain exceptions** centrally — do not leak transport types into use cases.
14
13
  - Version routes if the repo already versions (`/v1/...`).
15
14
  - Prefer `net/http` interfaces so tests can use `httptest` without a full framework.
16
15
  - Timeouts: set server read/write timeouts; propagate request context.
17
16
 
17
+ ## Resilience
18
+
19
+ - Side-effect endpoints (charge, create, enqueue): accept/propagate an **idempotency key** when the domain already uses one; document if intentionally omitted.
20
+ - Outbound HTTP to third parties: prefer **per-provider clients** (separate timeouts/pools) — bulkhead isolation, not one shared client for everything.
21
+ - Provider/ACL adapters return typed results or errors — never raw `map[string]any` / untyped JSON blobs into the domain.
22
+ - Soft file-size hint: plan a split when a handler/router file grows past ~400 LOC; prefer package + re-export over god-files.
23
+
18
24
  ## Testing
19
25
 
20
26
  - Prefer `httptest` against handler/router with mocked use cases (unit of adapter).
@@ -24,3 +30,4 @@ paths:
24
30
 
25
31
  - Business rules or SQL in handlers.
26
32
  - Ignoring `ctx` cancelation from `r.Context()`.
33
+ - Raising transport-only errors from use cases (keep HTTP mapping at the adapter edge).
@@ -21,6 +21,10 @@ Fill TBD paths after adopting this preset in a real service repo.
21
21
  | Unit tests | `*_test.go` beside packages | `**/*_test.go` |
22
22
  | Integration | `**/integration/` | `**/*_integration_test.go` |
23
23
 
24
+ ## Living conventions
25
+
26
+ Post-init gotchas / patterns / decisions: **`.claude/team/conventions.md`** (and the twin tool path if both Cursor and Claude are installed). Consumer-owned; not always-on. See root `AGENTS.md` § Living conventions.
27
+
24
28
  ## Dogfood scenarios
25
29
 
26
30
  1. `/task` new use case — domain → ports → adapters → wire → `post-change-test`.
@@ -4,21 +4,48 @@ paths:
4
4
  - **/*.go
5
5
  ---
6
6
 
7
-
8
7
  # Go conventions
9
8
 
10
9
  - Follow [Effective Go](https://go.dev/doc/effective_go) and repo `golangci-lint` / `staticcheck` when present.
11
10
  - Accept `context.Context` as first param on I/O and use-case methods.
12
- - Wrap errors: `fmt.Errorf("…: %w", err)`; avoid panics in library/service code.
13
11
  - Prefer `camelCase` unexported, `PascalCase` exported; package names short and lowercase.
14
12
  - Do not expose `internal/` outside the module.
15
13
  - Prefer table-driven tests; use `t.Parallel` only when safe.
16
14
 
15
+ ## Errors
16
+
17
+ - Always handle errors — never `_ = err`.
18
+ - Wrap with `fmt.Errorf("…: %w", err)`; check with `errors.Is` / `errors.As`.
19
+ - Prefer domain/custom error types for structured cases; avoid panics in library/service code.
20
+
21
+ ## Interfaces
22
+
23
+ - Accept interfaces, return concrete types.
24
+ - Define interfaces at the **call site** (ports / consumers), not on every implementation.
25
+ - Prefer small, single-method interfaces when they match the use.
26
+
17
27
  ## Packages
18
28
 
19
29
  - Avoid `util`/`common` dumping grounds — name by domain capability.
20
30
  - Keep `main` packages thin (see composition-root).
31
+ - No `init()` for business logic; no package-level mutable state for request data.
21
32
 
22
33
  ## Concurrency
23
34
 
24
- - Document cancelation; do not start unbounded goroutines from handlers without supervision.
35
+ - Document cancelation; `defer cancel()` after creating a derived context.
36
+ - Do not start unbounded goroutines from handlers without a termination condition / supervision (`WaitGroup`, errgroup, or context cancel).
37
+ - Channels for communication, mutexes for shared state — match existing package patterns.
38
+
39
+ ## Anti-hallucination
40
+
41
+ | ❌ Avoid | ✅ Prefer |
42
+ |---------|----------|
43
+ | `_ = err` / ignored errors | Handle or wrap with `%w` |
44
+ | Interfaces on every struct «just in case» | Ports at consumer / call site |
45
+ | Invented modules not in `go.mod` | Add dependency explicitly or copy existing import |
46
+ | `interface{}` where generics or a concrete type fit | Generics / concrete types used by the repo |
47
+ | Business logic in `init()` | Wire in composition root / `main` |
48
+
49
+ ## Agent requirement
50
+
51
+ New Go code must stay idiomatic and verifiable against `go.mod` and neighboring packages. Less guessed code is better than more.
@@ -16,7 +16,7 @@ When the user message looks like a **work request** (implement, add, fix, refact
16
16
 
17
17
  1. Prefer **`/task <their request>`** or invoke **task-router** first.
18
18
  2. Do not jump straight to coding without router + pipeline when scope is non-trivial.
19
- 3. Pure questions («как работает X», «объясни») — answer normally, no `/task`.
19
+ 3. Pure questions («как работает X», «объясни») — prefer agent **`codebase-analyzer`** (explain-as-is); trivial one-liners may be answered inline. Do not open `/task`.
20
20
 
21
21
  Exceptions: user explicitly says «без pipeline», «просто сделай», or continues an active slug.
22
22
 
@@ -138,7 +138,7 @@ If `pipeline.json` is missing (old `/feature-start` tasks), fall back to fixed p
138
138
 
139
139
  Do **not** run `/task` + router for:
140
140
 
141
- - Pure questions («как работает X», «объясни»).
141
+ - Pure questions («как работает X», «объясни») — prefer agent **`codebase-analyzer`** for deep traces; inline OK for trivial one-liners.
142
142
  - Typo / one-file fix / trivial config with no architecture risk.
143
143
  - User explicitly says «без pipeline», «просто сделай», or continues an active slug.
144
144
  - Single-line `docs-only` with no code impact.