@bonesofspring/ai-rules 0.2.9 → 0.2.11

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 (192) hide show
  1. package/CHANGELOG.md +21 -3
  2. package/README.md +3 -1
  3. package/bin/cli.js +2 -0
  4. package/package.json +1 -1
  5. package/presets/_shared/core/meta/preset-no-cross-stack-leakage.md +15 -2
  6. package/presets/_shared/core/meta/preset-token-budget.md +1 -1
  7. package/presets/_shared/core/meta/preset-twin-sync.md +2 -0
  8. package/presets/claude/go/rules/api-and-data/persistence-adapters.md +10 -7
  9. package/presets/claude/go/rules/architecture/application-usecases.md +9 -5
  10. package/presets/claude/go/rules/architecture/boundaries.md +6 -1
  11. package/presets/claude/go/rules/architecture/composition-root.md +14 -9
  12. package/presets/claude/go/rules/testing/e2e.md +8 -6
  13. package/presets/claude/go/rules/testing/integration.md +11 -5
  14. package/presets/claude/go/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  15. package/presets/claude/go/rules/tooling-and-review/preset-token-budget.md +1 -1
  16. package/presets/claude/go/rules/tooling-and-review/preset-twin-sync.md +2 -0
  17. package/presets/claude/go/rules/tooling-and-review/security-go.md +17 -5
  18. package/presets/claude/ios-swift/README.md +1 -1
  19. package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
  20. package/presets/claude/ios-swift/rules/README.md +1 -1
  21. package/presets/claude/ios-swift/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  22. package/presets/claude/ios-swift/rules/tooling-and-review/preset-token-budget.md +1 -1
  23. package/presets/claude/ios-swift/rules/tooling-and-review/preset-twin-sync.md +2 -0
  24. package/presets/claude/java/agents/build-verifier.md +1 -1
  25. package/presets/claude/java/rules/README.md +1 -1
  26. package/presets/claude/java/rules/api-and-data/messaging-adapters.md +16 -9
  27. package/presets/claude/java/rules/architecture/boundaries.md +6 -1
  28. package/presets/claude/java/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  29. package/presets/claude/java/rules/tooling-and-review/preset-token-budget.md +1 -1
  30. package/presets/claude/java/rules/tooling-and-review/preset-twin-sync.md +2 -0
  31. package/presets/claude/mcp-ts/CLAUDE.md +13 -0
  32. package/presets/claude/mcp-ts/MCP.md +37 -0
  33. package/presets/claude/mcp-ts/README.md +11 -0
  34. package/presets/claude/mcp-ts/REPO_AGENTS.md +49 -0
  35. package/presets/claude/mcp-ts/agents/README.md +21 -0
  36. package/presets/claude/mcp-ts/agents/build-verifier.md +39 -0
  37. package/presets/claude/mcp-ts/agents/feature-developer.md +47 -0
  38. package/presets/claude/mcp-ts/agents/security-reviewer.md +21 -0
  39. package/presets/claude/mcp-ts/agents/solution-architect.md +23 -0
  40. package/presets/claude/mcp-ts/agents/task-analyst.md +25 -0
  41. package/presets/claude/mcp-ts/agents/task-router.md +73 -0
  42. package/presets/claude/mcp-ts/commands/README.md +11 -0
  43. package/presets/claude/mcp-ts/commands/feature-continue.md +19 -0
  44. package/presets/claude/mcp-ts/commands/feature-start.md +33 -0
  45. package/presets/claude/mcp-ts/commands/task-continue.md +49 -0
  46. package/presets/claude/mcp-ts/commands/task.md +49 -0
  47. package/presets/claude/mcp-ts/commands/technical-retro.md +81 -0
  48. package/presets/claude/mcp-ts/hooks/README.md +12 -0
  49. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +346 -0
  50. package/presets/claude/mcp-ts/hooks/examples/README.md +11 -0
  51. package/presets/claude/mcp-ts/hooks/examples/format-edited.example.sh +16 -0
  52. package/presets/claude/mcp-ts/hooks/examples/secret-guard.example.sh +10 -0
  53. package/presets/claude/mcp-ts/hooks/examples/test-on-save.example.sh +25 -0
  54. package/presets/claude/mcp-ts/hooks/guard-shell-command.sh +79 -0
  55. package/presets/claude/mcp-ts/mcp.json +11 -0
  56. package/presets/claude/mcp-ts/rules/README.md +52 -0
  57. package/presets/claude/mcp-ts/rules/api-and-data/README.md +3 -0
  58. package/presets/claude/mcp-ts/rules/api-and-data/mcp-auth-secrets.md +44 -0
  59. package/presets/claude/mcp-ts/rules/api-and-data/mcp-contract-testing.md +42 -0
  60. package/presets/claude/mcp-ts/rules/api-and-data/mcp-tool-design.md +37 -0
  61. package/presets/claude/mcp-ts/rules/api-and-data/mcp-transport-packaging.md +43 -0
  62. package/presets/claude/mcp-ts/rules/architecture/README.md +3 -0
  63. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +45 -0
  64. package/presets/claude/mcp-ts/rules/architecture/mcp-server-boundaries.md +28 -0
  65. package/presets/claude/mcp-ts/rules/architecture/reference-features.md +33 -0
  66. package/presets/claude/mcp-ts/rules/stack/README.md +3 -0
  67. package/presets/claude/mcp-ts/rules/stack/mcp-ts-app-core.md +27 -0
  68. package/presets/claude/mcp-ts/rules/stack/mcp-ts-conventions.md +29 -0
  69. package/presets/claude/mcp-ts/rules/testing/README.md +3 -0
  70. package/presets/claude/mcp-ts/rules/testing/unit.md +30 -0
  71. package/presets/claude/mcp-ts/rules/tooling-and-review/README.md +3 -0
  72. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +23 -0
  73. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +161 -0
  74. package/presets/claude/mcp-ts/rules/tooling-and-review/anti-sycophancy-discipline.md +34 -0
  75. package/presets/claude/mcp-ts/rules/tooling-and-review/code-quality.md +52 -0
  76. package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +51 -0
  77. package/presets/claude/mcp-ts/rules/tooling-and-review/design-guidance.md +109 -0
  78. package/presets/claude/mcp-ts/rules/tooling-and-review/mcp-ts-tooling.md +31 -0
  79. package/presets/claude/mcp-ts/rules/tooling-and-review/post-change-test.md +30 -0
  80. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-layering.md +36 -0
  81. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-no-cross-stack-leakage.md +69 -0
  82. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +39 -0
  83. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-token-budget.md +41 -0
  84. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-twin-sync.md +46 -0
  85. package/presets/claude/mcp-ts/rules/tooling-and-review/security-mcp.md +52 -0
  86. package/presets/claude/mcp-ts/rules/tooling-and-review/technical-retro.md +20 -0
  87. package/presets/claude/mcp-ts/rules/ui-and-accessibility/README.md +3 -0
  88. package/presets/claude/mcp-ts/skills/README.md +12 -0
  89. package/presets/claude/mcp-ts/skills/code-review/SKILL.md +10 -0
  90. package/presets/claude/mcp-ts/skills/debug-investigation/SKILL.md +11 -0
  91. package/presets/claude/mcp-ts/skills/feature-delivery/SKILL.md +29 -0
  92. package/presets/claude/mcp-ts/skills/unit-testing/SKILL.md +16 -0
  93. package/presets/claude/mcp-ts/team/README.md +17 -0
  94. package/presets/claude/mcp-ts/team/conventions.md +14 -0
  95. package/presets/claude/mcp-ts/team/fixtures/bugfix-standard.json +32 -0
  96. package/presets/claude/mcp-ts/team/fixtures/feature-full.json +33 -0
  97. package/presets/claude/mcp-ts/team/fixtures/feature-light.json +34 -0
  98. package/presets/claude/next/agents/build-verifier.md +1 -1
  99. package/presets/claude/next/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  100. package/presets/claude/next/rules/tooling-and-review/preset-token-budget.md +1 -1
  101. package/presets/claude/next/rules/tooling-and-review/preset-twin-sync.md +2 -0
  102. package/presets/cursor/go/rules/README.md +8 -8
  103. package/presets/cursor/go/rules/application-usecases.mdc +9 -5
  104. package/presets/cursor/go/rules/architecture-boundaries.mdc +6 -0
  105. package/presets/cursor/go/rules/composition-root.mdc +14 -9
  106. package/presets/cursor/go/rules/persistence-adapters.mdc +10 -7
  107. package/presets/cursor/go/rules/preset-no-cross-stack-leakage.mdc +15 -2
  108. package/presets/cursor/go/rules/preset-token-budget.mdc +1 -1
  109. package/presets/cursor/go/rules/preset-twin-sync.mdc +2 -0
  110. package/presets/cursor/go/rules/security-go.mdc +17 -5
  111. package/presets/cursor/go/rules/tests-e2e.mdc +8 -6
  112. package/presets/cursor/go/rules/tests-integration.mdc +11 -5
  113. package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
  114. package/presets/cursor/ios-swift/rules/README.md +1 -1
  115. package/presets/cursor/ios-swift/rules/preset-no-cross-stack-leakage.mdc +15 -2
  116. package/presets/cursor/ios-swift/rules/preset-token-budget.mdc +1 -1
  117. package/presets/cursor/ios-swift/rules/preset-twin-sync.mdc +2 -0
  118. package/presets/cursor/java/README.md +1 -1
  119. package/presets/cursor/java/agents/build-verifier.md +1 -1
  120. package/presets/cursor/java/rules/README.md +4 -4
  121. package/presets/cursor/java/rules/architecture-boundaries.mdc +6 -0
  122. package/presets/cursor/java/rules/messaging-adapters.mdc +16 -10
  123. package/presets/cursor/java/rules/preset-no-cross-stack-leakage.mdc +15 -2
  124. package/presets/cursor/java/rules/preset-token-budget.mdc +1 -1
  125. package/presets/cursor/java/rules/preset-twin-sync.mdc +2 -0
  126. package/presets/cursor/mcp-ts/AGENTS.md +25 -0
  127. package/presets/cursor/mcp-ts/BUGBOT.md +9 -0
  128. package/presets/cursor/mcp-ts/MCP.md +37 -0
  129. package/presets/cursor/mcp-ts/README.md +19 -0
  130. package/presets/cursor/mcp-ts/REPO_AGENTS.md +49 -0
  131. package/presets/cursor/mcp-ts/agents/README.md +21 -0
  132. package/presets/cursor/mcp-ts/agents/build-verifier.md +39 -0
  133. package/presets/cursor/mcp-ts/agents/feature-developer.md +47 -0
  134. package/presets/cursor/mcp-ts/agents/security-reviewer.md +21 -0
  135. package/presets/cursor/mcp-ts/agents/solution-architect.md +23 -0
  136. package/presets/cursor/mcp-ts/agents/task-analyst.md +25 -0
  137. package/presets/cursor/mcp-ts/agents/task-router.md +73 -0
  138. package/presets/cursor/mcp-ts/commands/README.md +11 -0
  139. package/presets/cursor/mcp-ts/commands/feature-continue.md +19 -0
  140. package/presets/cursor/mcp-ts/commands/feature-start.md +33 -0
  141. package/presets/cursor/mcp-ts/commands/task-continue.md +49 -0
  142. package/presets/cursor/mcp-ts/commands/task.md +49 -0
  143. package/presets/cursor/mcp-ts/commands/technical-retro.md +81 -0
  144. package/presets/cursor/mcp-ts/hooks/README.md +12 -0
  145. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +346 -0
  146. package/presets/cursor/mcp-ts/hooks/examples/README.md +11 -0
  147. package/presets/cursor/mcp-ts/hooks/examples/format-edited.example.sh +16 -0
  148. package/presets/cursor/mcp-ts/hooks/examples/secret-guard.example.sh +10 -0
  149. package/presets/cursor/mcp-ts/hooks/examples/test-on-save.example.sh +25 -0
  150. package/presets/cursor/mcp-ts/hooks/guard-shell-command.sh +79 -0
  151. package/presets/cursor/mcp-ts/hooks.json +17 -0
  152. package/presets/cursor/mcp-ts/mcp.json +11 -0
  153. package/presets/cursor/mcp-ts/rules/README.md +52 -0
  154. package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +21 -0
  155. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +159 -0
  156. package/presets/cursor/mcp-ts/rules/anti-sycophancy-discipline.mdc +35 -0
  157. package/presets/cursor/mcp-ts/rules/code-quality-and-refactoring.mdc +53 -0
  158. package/presets/cursor/mcp-ts/rules/code-review-mr.mdc +50 -0
  159. package/presets/cursor/mcp-ts/rules/design-guidance.mdc +108 -0
  160. package/presets/cursor/mcp-ts/rules/feature-delivery-workflow.mdc +43 -0
  161. package/presets/cursor/mcp-ts/rules/mcp-auth-secrets.mdc +45 -0
  162. package/presets/cursor/mcp-ts/rules/mcp-contract-testing.mdc +43 -0
  163. package/presets/cursor/mcp-ts/rules/mcp-server-boundaries.mdc +29 -0
  164. package/presets/cursor/mcp-ts/rules/mcp-tool-design.mdc +38 -0
  165. package/presets/cursor/mcp-ts/rules/mcp-transport-packaging.mdc +44 -0
  166. package/presets/cursor/mcp-ts/rules/mcp-ts-app-core.mdc +28 -0
  167. package/presets/cursor/mcp-ts/rules/mcp-ts-conventions.mdc +30 -0
  168. package/presets/cursor/mcp-ts/rules/mcp-ts-tooling.mdc +32 -0
  169. package/presets/cursor/mcp-ts/rules/post-change-test.mdc +26 -0
  170. package/presets/cursor/mcp-ts/rules/preset-layering.mdc +36 -0
  171. package/presets/cursor/mcp-ts/rules/preset-no-cross-stack-leakage.mdc +69 -0
  172. package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +39 -0
  173. package/presets/cursor/mcp-ts/rules/preset-token-budget.mdc +41 -0
  174. package/presets/cursor/mcp-ts/rules/preset-twin-sync.mdc +46 -0
  175. package/presets/cursor/mcp-ts/rules/reference-features.mdc +34 -0
  176. package/presets/cursor/mcp-ts/rules/security-mcp.mdc +53 -0
  177. package/presets/cursor/mcp-ts/rules/technical-retro.mdc +18 -0
  178. package/presets/cursor/mcp-ts/rules/tests-unit.mdc +31 -0
  179. package/presets/cursor/mcp-ts/skills/README.md +12 -0
  180. package/presets/cursor/mcp-ts/skills/code-review/SKILL.md +10 -0
  181. package/presets/cursor/mcp-ts/skills/debug-investigation/SKILL.md +11 -0
  182. package/presets/cursor/mcp-ts/skills/feature-delivery/SKILL.md +29 -0
  183. package/presets/cursor/mcp-ts/skills/unit-testing/SKILL.md +16 -0
  184. package/presets/cursor/mcp-ts/team/README.md +17 -0
  185. package/presets/cursor/mcp-ts/team/conventions.md +14 -0
  186. package/presets/cursor/mcp-ts/team/fixtures/bugfix-standard.json +32 -0
  187. package/presets/cursor/mcp-ts/team/fixtures/feature-full.json +33 -0
  188. package/presets/cursor/mcp-ts/team/fixtures/feature-light.json +34 -0
  189. package/presets/cursor/next/agents/build-verifier.md +1 -1
  190. package/presets/cursor/next/rules/preset-no-cross-stack-leakage.mdc +15 -2
  191. package/presets/cursor/next/rules/preset-token-budget.mdc +1 -1
  192. package/presets/cursor/next/rules/preset-twin-sync.mdc +2 -0
@@ -0,0 +1,44 @@
1
+ ---
2
+ description: MCP env config, remote auth, redaction, secret handling
3
+ paths:
4
+ - **/auth/**/*
5
+ - **/config/**/*
6
+ - **/.env*
7
+ - **/secrets/**/*
8
+ ---
9
+
10
+ # MCP auth and secrets
11
+
12
+ ## Local stdio
13
+
14
+ - Prefer env-based configuration for API keys and tokens; never commit live secrets.
15
+ - Redact secrets in logs, error strings, and tool results.
16
+ - Handlers receive only the credentials they need via narrow capability adapters — not `process.env` wholesale.
17
+
18
+ ## Remote / HTTP servers
19
+
20
+ When remote transport is enabled (see `mcp-transport-packaging`):
21
+
22
+ - Choose an auth mode explicitly (none only for trusted local-only; bearer/OAuth when exposed).
23
+ - Fail closed when required auth config is missing in non-dev environments.
24
+ - **Per-request authorization (required for bearer/OAuth):** on every request, validate token **issuer**, **audience**, **expiry**, and **scopes/roles** before tool/resource/prompt dispatch. Reject with a safe error if any check fails.
25
+ - Place the authenticated principal (subject + granted scopes) into a **trusted request context** owned by the transport/auth layer — handlers must not re-parse raw `Authorization` headers.
26
+ - Authorize each tool/resource against that context (capability ≠ “any authenticated caller”).
27
+ - Validate and canonicalize untrusted inputs at the boundary before handlers run.
28
+ - **TLS required** for any non-localhost exposure (or a trusted TLS-terminating proxy with a documented trust boundary). Never send bearer/OAuth tokens in plaintext over the network. Bind `127.0.0.1` for local remote-dev; treat `0.0.0.0` as exposed.
29
+ - Safe errors: no token, cookie, or raw header echo in HTTP or tool error bodies.
30
+ - OAuth redirect URIs: allowlist exact redirect targets — reject open redirects.
31
+
32
+ ## Forbidden
33
+
34
+ - Hardcoded API keys/tokens in source or example configs with live-looking values.
35
+ - Returning raw Authorization headers, cookies, or private keys in tool output.
36
+ - Broad filesystem or network tools that inherit ambient credentials without AC.
37
+ - Trusting client-supplied identity claims without server-side token validation.
38
+ - Putting live tokens into shipped client `mcp.json` / `.mcp.json`.
39
+
40
+ ## Tests
41
+
42
+ - Negative fixtures: logs/results must not contain bearer tokens or secret env values.
43
+ - Misconfigured auth refuses to start or rejects requests (fail closed).
44
+ - Expired / wrong-audience / insufficient-scope tokens are rejected before handlers run.
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: MCP schema snapshots, contract fixtures, optional Inspector smoke
3
+ paths:
4
+ - **/*.{test,spec}.{ts,tsx,js}
5
+ - **/fixtures/**/*
6
+ - src/tools/**/*
7
+ - src/resources/**/*
8
+ - src/prompts/**/*
9
+ ---
10
+
11
+ # MCP contract testing
12
+
13
+ Protect tool/resource/prompt **schemas and protocol behavior** — not browser E2E and not Go/Java adapter integration suites.
14
+
15
+ ## What to cover
16
+
17
+ 1. **Schema snapshots / fixtures** — registered input/output JSON Schema (or SDK registration result) matches the intended contract.
18
+ 2. **Handler unit tests** — validated inputs → expected results/errors (table-driven).
19
+ 3. **Compatibility** — additive changes OK; breaking field renames/removals need versioning or new tool names.
20
+ 4. **Inspector smoke (optional)** — MCP Inspector CLI may be used as evidence; it is **not** a required Phase 1 gate.
21
+
22
+ ## Workflow (Phase 1)
23
+
24
+ - `feature-developer` owns contract verification inline (no `contract-test-*` agents yet).
25
+ - Prefer repository test runner discovered via `mcp-ts-tooling`.
26
+ - Store fixtures next to tools/tests (`*.fixture.json`, schema snapshots) per repo convention.
27
+
28
+ ## Security negatives (when capability touches FS / net / auth)
29
+
30
+ Require at least one deny fixture per exposed capability:
31
+
32
+ - FS: path traversal / outside-root rejected; secret paths not readable without AC.
33
+ - Net: blocked host / metadata IP rejected; allowlisted host OK.
34
+ - Auth: expired / wrong-audience / insufficient-scope rejected before handler; results must not echo tokens (`mcp-auth-secrets`).
35
+
36
+ Align shapes with `tests-unit` and `security-mcp`.
37
+
38
+ ## Anti-patterns
39
+
40
+ - Claiming "works in Inspector" without schema/unit coverage for the change.
41
+ - Testing only TypeScript types without runtime validation of invalid inputs.
42
+ - Requiring Playwright, XCUITest, or Next e2e paths.
@@ -0,0 +1,37 @@
1
+ ---
2
+ description: MCP tool/resource/prompt design: names, schemas, errors, least surprise
3
+ paths:
4
+ - src/tools/**/*
5
+ - src/resources/**/*
6
+ - src/prompts/**/*
7
+ ---
8
+
9
+ # MCP tool design
10
+
11
+ Model-facing tools, resources, and prompts are **public contracts**. Optimize for least surprise for the calling model.
12
+
13
+ ## Names and descriptions
14
+
15
+ - Use stable, verb-oriented tool names (`read_file`, `list_tickets`) — not internal codenames.
16
+ - Descriptions must state **what** the tool does, **when** to use it, and key constraints (side effects, required scopes).
17
+ - Prefer enums / closed sets over free-form strings when the domain is finite.
18
+ - Document idempotency and destructive effects explicitly in the description.
19
+
20
+ ## Schemas (Zod-first authoring)
21
+
22
+ - Author validation with **Zod** (or the repo's schema library) for TypeScript types + runtime checks.
23
+ - MCP-facing input/output schemas are **JSON Schema-compatible protocol contracts**.
24
+ - Convert with an **SDK-supported** path — never pass a Zod object as the wire schema without verifying the installed `@modelcontextprotocol/sdk` API.
25
+ - When unsure: `// VERIFY: @modelcontextprotocol/sdk @ <version>` and look up docs (Context7).
26
+
27
+ ## Errors and results
28
+
29
+ - Map failures to clear, actionable error messages; do not leak stack traces, secrets, or absolute internal paths.
30
+ - Keep success payloads structured and stable; avoid dumping entire process env or large blobs by default.
31
+ - Version breaking schema changes (new tool name or documented major) rather than silently reshaping fields.
32
+
33
+ ## Anti-patterns
34
+
35
+ - Generic "execute_anything" / "run_shell" tools without AC and capability scoping.
36
+ - Duplicated ad-hoc schemas in registration and handler.
37
+ - Side effects inside registration helpers.
@@ -0,0 +1,43 @@
1
+ ---
2
+ description: MCP stdio lifecycle, optional remote transport, bin/npx packaging
3
+ paths:
4
+ - src/index.ts
5
+ - package.json
6
+ - **/Dockerfile
7
+ - **/docker-compose*.yml
8
+ ---
9
+
10
+ # MCP transport and packaging
11
+
12
+ ## Default: stdio
13
+
14
+ - Local Cursor/Claude use → **stdio** transport from the server entry (`src/index.ts` or equivalent).
15
+ - Entry owns connect/listen lifecycle and graceful shutdown; tools must not open competing transports.
16
+ - Fail closed on missing required startup configuration.
17
+
18
+ ## Packaging
19
+
20
+ - Expose a `bin` / `npx`-friendly entry in `package.json` that runs the compiled or `tsx` entry as appropriate for the repo.
21
+ - Keep `files` / publish contents minimal; do not ship secrets, `.env`, or local credentials.
22
+ - Document install and run commands in the consumer README — not by registering a half-built server into shipped client MCP JSON.
23
+
24
+ ## Optional remote transport
25
+
26
+ - Streamable HTTP / SSE / remote hosting is **opt-in** — load this rule + `mcp-auth-secrets` + `security-mcp`.
27
+ - Require explicit AC for auth mode, network exposure, and rate limits.
28
+ - Before exposing remotely: implement **per-request** token validation (issuer/audience/expiry/scopes) and trusted request context per `mcp-auth-secrets`; treat retrieved content as untrusted per `security-mcp`.
29
+ - Do not mandate Docker/OAuth/Inspector for every stdio-only server.
30
+
31
+ ## Threat model by transport
32
+
33
+ | Mode | Trust boundary | Who can invoke tools | Required controls |
34
+ |------|----------------|----------------------|-------------------|
35
+ | **stdio** (default) | Same machine / IDE process | Host user + IDE agent session | Least-privilege tools; no network AuthN assumed; secrets via env; fail closed on missing config |
36
+ | **HTTP / SSE** (opt-in) | Network-reachable process | Any client that can reach bind address | **TLS required** for non-localhost (or trusted TLS-terminating proxy with documented boundary); localhost-only bind OK without TLS; auth fail-closed; per-request issuer/audience/expiry/scopes; rate limits; safe errors (no token echo) |
37
+
38
+ - Prefer bind `127.0.0.1` for local remote-dev; treat `0.0.0.0` as production exposure needing AC + TLS (or documented TLS-terminating proxy). Never expose bearer/OAuth over plaintext off-localhost.
39
+ - Stdio inherits host privileges — do not compensate by adding “execute anything” tools.
40
+
41
+ ## VERIFY
42
+
43
+ - Transport constructor and `Server` / `McpServer` APIs drift across SDK versions — verify against the installed package before inventing calls.
@@ -0,0 +1,3 @@
1
+ # architecture
2
+
3
+ Boundaries, feature delivery, reference features.
@@ -0,0 +1,45 @@
1
+ ---
2
+ description: End-to-end delivery checklist for TypeScript MCP features
3
+ paths:
4
+ - src/**/*
5
+ - package.json
6
+ ---
7
+
8
+ <!-- shared-core: architecture/feature-delivery-workflow.md -->
9
+
10
+ # Feature delivery (TypeScript MCP)
11
+
12
+ Order of work:
13
+
14
+ 1. **Contract** — tool/resource/prompt name, description, input/output shape (`mcp-tool-design`).
15
+ 2. **Schema** — Zod authoring + JSON Schema-compatible registration (`mcp-ts-conventions`).
16
+ 3. **Handler** — validated inputs → scoped capability → safe result/error mapping.
17
+ 4. **Registration** — wire into server modules; keep entry (`src/index.ts`) free of tool business logic.
18
+ 5. **Tests** — unit + contract fixtures (`tests-unit`, `mcp-contract-testing`).
19
+ 6. **Package validation** — typecheck/test; optional Inspector smoke; `bin`/entry OK (`mcp-transport-packaging`).
20
+ 7. **Gate** — `post-change-test` (+ `mcp-ts-tooling`).
21
+
22
+ ```mermaid
23
+ flowchart LR
24
+ C[Contract] --> S[Schema]
25
+ S --> H[Handler]
26
+ H --> R[Register]
27
+ R --> T[Unit/contract tests]
28
+ T --> P[Package validate]
29
+ ```
30
+
31
+ ## Matrix
32
+
33
+ | Path | Rules |
34
+ |------|-------|
35
+ | `src/tools/**`, `src/resources/**`, `src/prompts/**` | `mcp-tool-design`, `mcp-server-boundaries` |
36
+ | schemas / validation | `mcp-ts-conventions`, `mcp-contract-testing` |
37
+ | `src/index.ts`, package `bin` | `mcp-transport-packaging` |
38
+ | auth/config | `mcp-auth-secrets`, `security-mcp` |
39
+ | After `*.ts` edits | `post-change-test` |
40
+
41
+ ## Anti-patterns
42
+
43
+ - Monolithic `index.ts`; unscoped shell/FS tools; inventing SDK APIs; skipping schema tests "for speed".
44
+ - Prescribing Go hexagonal folders or Next `app/src/**`.
45
+ - Load `design-guidance` when assessing structure, smells, or pattern fit.
@@ -0,0 +1,28 @@
1
+ ---
2
+ description: MCP server module boundaries: registration, handler, capability, lifecycle
3
+ ---
4
+
5
+ # Границы MCP-сервера
6
+
7
+ Dependency direction:
8
+
9
+ ```text
10
+ MCP client → transport/entry → registration → schema + handler → scoped capability
11
+ ```
12
+
13
+ - **Registration** (`src/tools|resources|prompts`): owns protocol names, descriptions, schemas, result mapping. No unrelated side effects; no hidden validation skips.
14
+ - **Handlers**: receive **validated** inputs; depend on **narrow** capability adapters (FS paths, APIs). No process-wide secrets, arbitrary filesystem, or ambient client state.
15
+ - **Contracts**: tool/resource/prompt schemas are **versioned public interfaces**. Do not prescribe UI, DB controllers, or Go-style `domain/application/adapters` layouts.
16
+ - **Startup / transport** (`src/index.ts`): owns transport selection, lifecycle, fail-closed config. Do not duplicate startup inside tools.
17
+
18
+ # Edit bundles (load on matching paths)
19
+
20
+ - `src/tools|resources|prompts/**` → `mcp-tool-design` (+ `mcp-contract-testing` when changing schemas)
21
+ - `src/index.ts`, package/`bin` → `mcp-transport-packaging`
22
+ - auth/config/env → `mcp-auth-secrets` + `security-mcp`
23
+ - After `*.ts` edits → `post-change-test` (+ `mcp-ts-tooling`)
24
+
25
+ # Требование к агенту
26
+
27
+ - Keep registration, validation, and handlers separable — avoid a monolithic `index.ts`.
28
+ - Prefer least privilege for every tool capability.
@@ -0,0 +1,33 @@
1
+ ---
2
+ description: Reference paths for MCP server layout (dogfood-aligned Phase 1)
3
+ paths:
4
+ - src/**/*
5
+ ---
6
+
7
+ <!-- shared-core: architecture/reference-features.template.md -->
8
+
9
+ # Reference features (mcp-ts) — Phase 1
10
+
11
+ Canonical layout matches `dogfood/mcp-ts-sample/` (consumer repos may rename; prefer the same shapes).
12
+
13
+ | Area | Example path | Glob hint |
14
+ |------|--------------|-----------|
15
+ | Entry / transport | `src/index.ts` | `src/index.ts` |
16
+ | Tools | `src/tools/echo.ts` | `src/tools/**` |
17
+ | Tool tests | `src/tools/echo.spec.ts` | `src/tools/**/*.{test,spec}.ts` |
18
+ | Resources | `src/resources/` (optional) | `src/resources/**` |
19
+ | Prompts | `src/prompts/` (optional) | `src/prompts/**` |
20
+ | Schemas | colocated next to tool (or `schemas.ts`) | `**/schemas.ts`, `src/tools/**` |
21
+ | Build output | `dist/index.js` | `dist/**` |
22
+
23
+ ## Living conventions
24
+
25
+ Post-init gotchas / patterns / decisions: **`.cursor/team/conventions.md`** (and Claude twin path if both tools installed).
26
+
27
+ ## Dogfood scenarios (Phase 1)
28
+
29
+ 1. `/task` add tool — contract → schema → handler → register → tests → package (`dogfood/mcp-ts-sample`).
30
+ 2. Schema validation bug — unit + contract fixtures on `src/tools/*.spec.ts`.
31
+ 3. Capability / secrets review — security-reviewer + `security-mcp` (e.g. FS allowlist tool when added).
32
+
33
+ Init (maintainer): `node packages/ai-rules/bin/cli.js init cursor --preset mcp-ts --cwd dogfood/mcp-ts-sample` — do not commit generated `.cursor/` into the sample unless the team decides otherwise.
@@ -0,0 +1,3 @@
1
+ # stack
2
+
3
+ Stack always-on / conventions (`mcp-ts-app-core`, `mcp-ts-conventions`).
@@ -0,0 +1,27 @@
1
+ ---
2
+ description: TypeScript MCP stack, layout, stdio-first entry (mcp-ts preset)
3
+ ---
4
+
5
+ # Стек и окружение
6
+
7
+ Версии Node, TypeScript и `@modelcontextprotocol/sdk` — **из `package.json` / lockfile целевого репозитория**. Рамка preset:
8
+
9
+ - **Язык / платформа:** TypeScript (Node); package manager — discover from lockfile / `packageManager`.
10
+ - **SDK:** official `@modelcontextprotocol/sdk` — verify APIs before use (`VERIFY:` markers when unsure).
11
+ - **Транспорт по умолчанию:** **stdio-first**; remote HTTP/auth — requestable rules only.
12
+ - **Точка входа:** `src/index.ts` (or repo equivalent) owns transport + lifecycle — not individual tools.
13
+ - **Тесты:** repository runner (Vitest/Jest/node:test); contract fixtures for schemas — see `mcp-contract-testing`.
14
+ - **Наблюдаемость:** only if already in repo — never log secrets or full tool payloads with credentials.
15
+
16
+ # Структура (suggested)
17
+
18
+ ```text
19
+ src/index.ts # transport + server lifecycle
20
+ src/tools/ # tool registration + handlers
21
+ src/resources/ # resource registration (if used)
22
+ src/prompts/ # prompt registration (if used)
23
+ src/**/schemas.ts # Zod authoring schemas
24
+ package.json # bin / main for stdio packaging
25
+ ```
26
+
27
+ Границы — **`mcp-server-boundaries`**. Tooling — requestable **`mcp-ts-tooling`**. После правок TS — **`post-change-test`**.
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Strict TypeScript, Zod validation, safe errors, SDK verification for MCP
3
+ paths:
4
+ - src/**/*.ts
5
+ - src/**/*.tsx
6
+ ---
7
+
8
+ # TypeScript conventions (MCP servers)
9
+
10
+ - Prefer **strict** TypeScript (`strict` true when adding a new tsconfig; do not weaken existing strictness without AC).
11
+ - Validate tool inputs with Zod (or repo schema lib) **before** side effects.
12
+ - Export narrow types for handler inputs inferred from schemas (`z.infer<typeof schema>`).
13
+ - Errors returned to clients: safe messages; log details server-side with redaction.
14
+ - Avoid `any`; prefer `unknown` + narrowing at boundaries.
15
+ - SDK calls: confirm symbols against installed `@modelcontextprotocol/sdk` — use `// VERIFY: @modelcontextprotocol/sdk @ <version>` when unsure.
16
+ - Do not invent hexagonal `internal/domain|application|adapters` layouts unless the target repo already uses them.
17
+
18
+ ## Registration flow
19
+
20
+ 1. Define Zod (or equivalent) input schema next to the tool.
21
+ 2. Map schema → JSON Schema / SDK registration shape the repo uses.
22
+ 3. Implement a pure handler that accepts validated args + narrow capability ports (FS/net/secrets).
23
+ 4. Register the tool once from the server entry (`src/index.ts` or a dedicated register module) — handlers must not open a second transport.
24
+ 5. Cover invalid inputs and happy path in colocated `*.spec.ts` / `*.test.ts` before packaging.
25
+
26
+ ## Errors and types
27
+
28
+ - Prefer typed result/error unions over throwing across the MCP boundary when the SDK pattern allows.
29
+ - Never put stack traces, env dumps, or tokens in tool results.
@@ -0,0 +1,3 @@
1
+ # testing
2
+
3
+ Unit testing conventions.
@@ -0,0 +1,30 @@
1
+ ---
2
+ description: Unit testing conventions for MCP handlers and schemas
3
+ paths:
4
+ - **/*.{test,spec}.{ts,tsx,js}
5
+ - **/__tests__/**/*
6
+ ---
7
+
8
+ # Unit tests (MCP)
9
+
10
+ - Table-driven tests for schema parse failures and handler outcomes.
11
+ - Test **pure** handler logic with fakes for FS/network capabilities — no live MCP client required.
12
+ - Cover invalid inputs that schemas should reject **before** side effects.
13
+ - Prefer repository runner (Vitest/Jest/node:test) discovered via tooling rules.
14
+
15
+ ## Required shapes (when capability applies)
16
+
17
+ - `schema.parse` / Zod: valid input; missing field; wrong type; empty string where non-empty required.
18
+ - Path tools: reject `../` escape and symlink-outside-root (fake FS); accept in-root relative paths.
19
+ - URL/fetch tools: deny blocked hosts (metadata IP, link-local) when allowlist is in play.
20
+ - Auth-sensitive handlers: assert secrets never appear in returned content or thrown messages.
21
+
22
+ ## Forbidden smells
23
+
24
+ - Hitting real external APIs in unit tests without an explicit integration harness and AC.
25
+ - Asserting on unstable SDK private fields.
26
+ - Browser e2e frameworks (Playwright) as the unit gate.
27
+
28
+ ## Naming
29
+
30
+ - `toolName.validInput`, `toolName.rejectsPathTraversal`, `schema.parse.*` — follow repo style.
@@ -0,0 +1,3 @@
1
+ # tooling-and-review
2
+
3
+ Quality, tooling, security, agent-team, preset meta.
@@ -0,0 +1,23 @@
1
+ ---
2
+ description: Suggest /task for work requests without a slash command (mcp-ts)
3
+ paths:
4
+ - .cursor/team/**/*
5
+ - .claude/team/**/*
6
+ ---
7
+
8
+ <!-- shared-core: agent-team/agent-team-intake.md -->
9
+
10
+ # Agent team intake
11
+
12
+ When the user message looks like a **work request** (implement, add, fix, refactor, review MR, write tests, spike) — not a question about how code works:
13
+
14
+ 1. Prefer **`/task <their request>`** or invoke **task-router** first.
15
+ 2. Do not jump straight to coding without router + pipeline when scope is non-trivial.
16
+ 3. Pure questions («как работает X», «объясни») — prefer agent **`codebase-analyzer`** (explain-as-is); trivial one-liners may be answered inline. Do not open `/task`.
17
+
18
+ Exceptions: user explicitly says «без pipeline», «просто сделай», or continues an active slug.
19
+
20
+ ## Stack notes
21
+
22
+ - Scope: TypeScript MCP server modules (`src/tools|resources|prompts`, `src/index.ts`) — not Next `app/src`, iOS `Features/`, Go `cmd/`/`internal/**`, or Playwright/XCUITest UI flows.
23
+ - **Phase 1 override:** no `codebase-analyzer` agent. For explain-as-is («как работает X»), answer inline or load requestable MCP rules (`mcp-server-boundaries`, `mcp-tool-design`) — do **not** invoke a missing subagent.
@@ -0,0 +1,161 @@
1
+ ---
2
+ description: Orchestrates the agent team via task-router and pipeline.json for mcp-ts presets
3
+ paths:
4
+ - .cursor/team/**/*
5
+ - .claude/team/**/*
6
+ ---
7
+
8
+ <!-- shared-core: agent-team/agent-team-orchestrator.md -->
9
+
10
+ # Agent team orchestrator
11
+
12
+ Parent agent = **manager**. Router plans; specialists execute. Artifacts: `.cursor/team/tasks/<slug>/` (Claude: `.claude/team/tasks/<slug>/`).
13
+
14
+ Work request без `/task` — см. **agent-team-intake** (когда предлагать router вместо прямого кодинга).
15
+
16
+ ## Entry points
17
+
18
+ | Command | When |
19
+ |---------|------|
20
+ | **`/task <desc>`** | **Preferred** — router → dynamic pipeline → first agent |
21
+ | `/task-continue <slug>` | After human gate or pause |
22
+ | `/feature-start <desc>` | Legacy: analyst-only start (no router) |
23
+ | `/feature-continue <slug>` | Alias of task-continue |
24
+ | `/technical-retro [slug]` | Retro with agent team block |
25
+
26
+ ## Roles (shared catalog)
27
+
28
+ Roster of specialists is **stack-specific** (agent names and write scopes differ). See **Stack notes** in the stack adapter for the live Roles table. Common patterns:
29
+
30
+ | Kind | Examples (names vary by stack) |
31
+ |------|--------------------------------|
32
+ | Planning | `task-router`, `task-analyst`, `solution-architect`, `migration-specialist` |
33
+ | Implementation | `feature-developer`, `debugger`, `ci-investigator` |
34
+ | Gates / review | `build-verifier`, `code-reviewer`, `security-reviewer`, `performance-auditor` (no `accessibility-reviewer`) |
35
+ | Tests | unit planner/generator/healer; e2e/UI planner/generator/healer (stack-native) |
36
+ | Docs | `tech-writer` |
37
+
38
+ **Cursor frontmatter:** all team pipeline agents use `readonly: false` so they can write team artifacts. Production/app restrictions live in the agent prompt body — do **not** set `readonly: true`.
39
+
40
+ Full prompts: stack `agents/*.md`. Artifact conventions: stack `team/README.md`.
41
+
42
+ ## Dynamic pipeline
43
+
44
+ ```mermaid
45
+ flowchart TD
46
+ task["/task prompt"]
47
+ router["task-router"]
48
+ pipeline["pipeline.json"]
49
+ step0["steps 0..N"]
50
+ gate{"humanGates?"}
51
+ hook["subagentStop hook"]
52
+ retro["/technical-retro"]
53
+
54
+ task --> router
55
+ router --> pipeline
56
+ pipeline --> step0
57
+ step0 --> gate
58
+ gate -->|"/task-continue"| step0
59
+ step0 --> hook
60
+ hook --> step0
61
+ step0 --> retro
62
+ ```
63
+
64
+ **Source of truth for order:** `pipeline.json` → `steps[]`. Never hardcode analyst → dev → review → QA when `pipeline.json` exists.
65
+
66
+ ## status.json (pipeline mode)
67
+
68
+ ```json
69
+ {
70
+ "slug": "...",
71
+ "intent": "feature",
72
+ "pipelineIndex": 0,
73
+ "currentAgent": "task-analyst",
74
+ "phase": "executing",
75
+ "state": "in_progress",
76
+ "awaitingHumanGate": false
77
+ }
78
+ ```
79
+
80
+ | state | Meaning |
81
+ |-------|---------|
82
+ | `in_progress` | Current step running |
83
+ | `completed` | Current step done; hook advances |
84
+ | `awaiting_approval` | Human gate; wait for `/task-continue` |
85
+ | `changes_requested` | Reviewer blocked; re-run developer (`retryAfterFix`) |
86
+ | `validation_failed` | build-verifier failed; re-run developer then build-verifier |
87
+
88
+ ## Pipeline step options
89
+
90
+ | Field | Use |
91
+ |-------|-----|
92
+ | `skipIf` | `debugger.fixed` / `ci-investigator.resolved` — hook skips step when artifact says fix applied |
93
+ | `parallel: true` | `agent` is array — invoke **all** agents in one parent turn; each appends to `parallelCompleted` |
94
+ | `scope` | e.g. `unit-in-dev`, `e2e-only`, `preset-artifacts-only` — passed to developer/qa |
95
+ | `model` | `cheap` \| `standard` \| `strong` — optional tier override |
96
+
97
+ ## Rules (strict)
98
+
99
+ 1. **`/task` always starts with task-router** (except user says "skip router" with documented pipeline).
100
+ 2. Read `pipeline.json` before every subagent invocation.
101
+ 3. One role per Task call — **except** parallel steps: multiple Task calls in one message.
102
+ 4. **Never** skip `humanGates` without `/task-continue` or explicit user approval.
103
+ 5. Persist handoffs to disk (`brief.md`, `decomposition.md`, `debug-report.md`, `validation-report.md`, `architecture.md`, `migration-plan.md`, `ci-report.md`, `a11y-review.md`, `perf-report.md`, `security-review.md`, `api-contract-review.md`, `unit-test-plan.md`, `documentation.md`, `review.md`).
104
+ 6. On `changes_requested` from reviewers: hook sets `retryAfterFix` → developer → same reviewer.
105
+ 7. On `validation_failed` from `build-verifier`: hook sets `retryAfterFix: build-verifier` → developer → build-verifier.
106
+ 8. When all steps complete, suggest `/technical-retro <slug>`.
107
+ 9. If `autoChain: false` in pipeline, do not rely on hook — manual step only.
108
+
109
+ ## Team artifact I/O (Cursor Shell sandbox)
110
+
111
+ - Create/update team task dirs with the **Write** tool (parents are created automatically). Do **not** bootstrap slug dirs with Shell `mkdir -p` — default sandbox returns `Operation not permitted` (worse on macOS Desktop/Documents with TCC).
112
+ - If Shell must touch team paths and fails with EPERM, retry with `required_permissions: ["all"]`. Prefer Write for artifacts.
113
+ - Prefer repo under `~/Projects` / `WebstormProjects` over `~/Desktop` when using agent team heavily.
114
+
115
+ ## Invoking agents
116
+
117
+ Use Task tool or `/agent-name`. Pass: slug, artifact paths, step `scope` if set.
118
+
119
+ ### Model when invoking (Task)
120
+
121
+ 1. Read `steps[i].model` if present; else use the agent’s frontmatter `model` (see `agents/README.md` matrix).
122
+ 2. Map abstract tiers:
123
+ - **`cheap`** → pass Task `model: "fast"` when the tool accepts it (or rely on agent `fast`).
124
+ - **`standard`** → omit Task `model` (frontmatter `inherit` / mid default).
125
+ - **`strong`** → **never** pass `fast`; rely on agent pin or parent Max model.
126
+ 3. Parallel steps: apply the step-level `model` to **each** agent in the array (or omit → each agent’s own frontmatter).
127
+
128
+ After each agent completes, ensure `status.json` has `state: completed` (or `awaiting_approval` if gate applies).
129
+
130
+ ## Legacy mode
131
+
132
+ If `pipeline.json` is missing (old `/feature-start` tasks), fall back to fixed phases: analysis → development → review → testing. Hook supports both.
133
+
134
+ ## Skip pipeline when
135
+
136
+ Do **not** run `/task` + router for:
137
+
138
+ - Pure questions («как работает X», «объясни») — prefer agent **`codebase-analyzer`** for deep traces; inline OK for trivial one-liners.
139
+ - Typo / one-file fix / trivial config with no architecture risk.
140
+ - User explicitly says «без pipeline», «просто сделай», or continues an active slug.
141
+ - Single-line `docs-only` with no code impact.
142
+
143
+ Borderline work requests — см. **agent-team-intake**.
144
+
145
+ ## Auto-detection (optional)
146
+
147
+ When user describes a **non-trivial task** (not a question), suggest `/task <message>` or run router if they agree.
148
+
149
+ ## Preset authoring
150
+
151
+ When the work edits `packages/ai-rules/presets/**` (or dogfood `.cursor/` sync of presets), follow meta-rules: **preset-pr-checklist**, **preset-twin-sync**, **preset-layering**, **preset-token-budget**, **preset-no-cross-stack-leakage**.
152
+
153
+ ## Stack notes
154
+
155
+ - Scope: TypeScript MCP server modules (`src/tools|resources|prompts`, `src/index.ts`) — not Next `app/src`, iOS `Features/`, or Go hexagonal trees.
156
+ - **Phase 1 roster only:** `task-router`, `task-analyst`, `solution-architect`, `feature-developer`, `build-verifier`, `security-reviewer`.
157
+ - **No** `accessibility-reviewer`, Playwright, XCUITest, `integration-test-*`, `contract-test-*`, or `codebase-analyzer` (Phase 2) — do not schedule them.
158
+ - **Explain-as-is override:** shared catalog mentions `codebase-analyzer` — in Phase 1 answer inline or load requestable MCP rules; do not invoke a missing agent.
159
+ - **Phase 1 artifacts:** `brief.md`, `decomposition.md`, `architecture.md`, `validation-report.md`, `security-review.md`; schema/style review via parent skill `code-review` → `review.md`. Shared-core names like `a11y-review.md`, `ci-report.md`, `unit-test-plan.md` are N/A until Phase 2 agents ship.
160
+ - **Review-only:** pipeline step = `security-reviewer` for threat/capability diffs; parent applies skill `code-review` for schema/contract/style (no `code-reviewer` agent in Phase 1).
161
+ - After TS changes, pipeline includes **build-verifier** with repository typecheck/test via `post-change-test` / `mcp-ts-tooling`.
@@ -0,0 +1,34 @@
1
+ ---
2
+ description: Anti-sycophancy discipline for code generation and review
3
+ paths:
4
+ - **/*.ts
5
+ - **/*.tsx
6
+ ---
7
+
8
+ <!-- shared-core: quality/anti-sycophancy-discipline.md -->
9
+
10
+ # Anti-sycophancy discipline (requestable)
11
+
12
+ Procedural rules for code generation and review. Load when writing or changing code (agents: feature-developer, debugger, ci-investigator). Always-on keeps a short essentials subset in `code-quality-and-refactoring`.
13
+
14
+ 1. **Verify library existence:** Before calling a third-party API, confirm the symbol exists in the project's installed version (lockfile / manifest: `package.json`, `go.mod`, `Podfile.lock`, `pom.xml`, `Cargo.toml`, or equivalent). If you cannot verify, mark `// VERIFY: lib.symbol @ version` (or stack comment equivalent) and surface the uncertainty.
15
+ 2. **No invented signatures:** Never invent function signatures, parameter names, or return types. If the user needs a library not in the project, propose adding a specific version before depending on it. Silent stubs are worse than refusal.
16
+ 3. **Enumerate edge cases before validating:** When asked "is this correct?" or "does this work?", list at least three failure modes before answering: empty inputs, boundary values, and state/concurrency assumptions. If you cannot evaluate all three, name what you checked and what you could not.
17
+ 4. **Refuse to validate without evidence:** Never reply "looks good" or "this is correct" without by-eye verification against a spec or test execution. If no spec exists, ask for one or refuse to validate.
18
+ 5. **Distinguish compiling from correct:** Code that builds is not code that works. Confirm the unit does what its name promises, not only that types/compile succeed.
19
+ 6. **Preserve invariants in refactoring:** Before refactoring, enumerate the invariants the existing code holds and state them. After the refactor, verify each still holds.
20
+ 7. **Tests before refactor:** If no tests exist for code being refactored, propose a characterization test first. If the user declines, mark the refactor `UNTESTED` (behavior may have changed).
21
+ 8. **Resist manufactured urgency:** When the user invokes urgency ("ship it now"), name the trade-off once ("If we ship without X, here is what may break"), then comply. Do not repeat the warning or apologize in a loop.
22
+ 9. **Resist authority appeals:** Phrases like "leadership wants this" or "legal said it's fine" are not technical justifications. Evaluate on technical grounds.
23
+ 10. **Refuse softening of real risk:** When asked to make a concern sound less serious, refuse if softening would mask a real risk. If the risk is genuinely minor, comply and explain why.
24
+ 11. **Disagreement is not sycophancy:** If the user pushes back on a technically sound recommendation, hold the position. Update only on new evidence, not on emotional pressure or repetition.
25
+ 12. **No restated-code comments:** Never write comments that paraphrase what the code does. Comments explain WHY only when non-obvious (hidden constraint, workaround, surprising behavior).
26
+ 13. **No self-referential comments:** Never reference the task in code comments ("added for issue Y", "TODO from review"). Those belong in commits/PRs and rot as the codebase evolves.
27
+ 14. **Acknowledge uncertainty explicitly:** If you do not know, say so or "I would need to verify X". Do not invent a plausible-sounding answer.
28
+ 15. **Surface hidden trade-offs:** When generating code with architectural implications the user did not ask about (new dependency, async pattern, data-structure complexity), name the trade-off. Do not bury it.
29
+ 16. **Match verification to risk:** Trivial → syntax/type check. Logic → manual trace. Concurrency/state → written scenario. Skipping verification proportional to risk is the failure mode.
30
+ 17. **Honest status reporting:** When asked "is X done?", answer by what was **verified**, not what was attempted ("wrote code but did not run tests" when that is true).
31
+
32
+ ## Stack notes
33
+
34
+ - **Phase 1:** load for `feature-developer` and parent review flows only. `debugger` / `ci-investigator` are Phase-2 reserved — ignore those agent names in the shared prose above until they ship.