@bonesofspring/ai-rules 0.2.10 → 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 (152) hide show
  1. package/CHANGELOG.md +10 -0
  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-twin-sync.md +2 -0
  7. package/presets/claude/go/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  8. package/presets/claude/go/rules/tooling-and-review/preset-twin-sync.md +2 -0
  9. package/presets/claude/ios-swift/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  10. package/presets/claude/ios-swift/rules/tooling-and-review/preset-twin-sync.md +2 -0
  11. package/presets/claude/java/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  12. package/presets/claude/java/rules/tooling-and-review/preset-twin-sync.md +2 -0
  13. package/presets/claude/mcp-ts/CLAUDE.md +13 -0
  14. package/presets/claude/mcp-ts/MCP.md +37 -0
  15. package/presets/claude/mcp-ts/README.md +11 -0
  16. package/presets/claude/mcp-ts/REPO_AGENTS.md +49 -0
  17. package/presets/claude/mcp-ts/agents/README.md +21 -0
  18. package/presets/claude/mcp-ts/agents/build-verifier.md +39 -0
  19. package/presets/claude/mcp-ts/agents/feature-developer.md +47 -0
  20. package/presets/claude/mcp-ts/agents/security-reviewer.md +21 -0
  21. package/presets/claude/mcp-ts/agents/solution-architect.md +23 -0
  22. package/presets/claude/mcp-ts/agents/task-analyst.md +25 -0
  23. package/presets/claude/mcp-ts/agents/task-router.md +73 -0
  24. package/presets/claude/mcp-ts/commands/README.md +11 -0
  25. package/presets/claude/mcp-ts/commands/feature-continue.md +19 -0
  26. package/presets/claude/mcp-ts/commands/feature-start.md +33 -0
  27. package/presets/claude/mcp-ts/commands/task-continue.md +49 -0
  28. package/presets/claude/mcp-ts/commands/task.md +49 -0
  29. package/presets/claude/mcp-ts/commands/technical-retro.md +81 -0
  30. package/presets/claude/mcp-ts/hooks/README.md +12 -0
  31. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +346 -0
  32. package/presets/claude/mcp-ts/hooks/examples/README.md +11 -0
  33. package/presets/claude/mcp-ts/hooks/examples/format-edited.example.sh +16 -0
  34. package/presets/claude/mcp-ts/hooks/examples/secret-guard.example.sh +10 -0
  35. package/presets/claude/mcp-ts/hooks/examples/test-on-save.example.sh +25 -0
  36. package/presets/claude/mcp-ts/hooks/guard-shell-command.sh +79 -0
  37. package/presets/claude/mcp-ts/mcp.json +11 -0
  38. package/presets/claude/mcp-ts/rules/README.md +52 -0
  39. package/presets/claude/mcp-ts/rules/api-and-data/README.md +3 -0
  40. package/presets/claude/mcp-ts/rules/api-and-data/mcp-auth-secrets.md +44 -0
  41. package/presets/claude/mcp-ts/rules/api-and-data/mcp-contract-testing.md +42 -0
  42. package/presets/claude/mcp-ts/rules/api-and-data/mcp-tool-design.md +37 -0
  43. package/presets/claude/mcp-ts/rules/api-and-data/mcp-transport-packaging.md +43 -0
  44. package/presets/claude/mcp-ts/rules/architecture/README.md +3 -0
  45. package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +45 -0
  46. package/presets/claude/mcp-ts/rules/architecture/mcp-server-boundaries.md +28 -0
  47. package/presets/claude/mcp-ts/rules/architecture/reference-features.md +33 -0
  48. package/presets/claude/mcp-ts/rules/stack/README.md +3 -0
  49. package/presets/claude/mcp-ts/rules/stack/mcp-ts-app-core.md +27 -0
  50. package/presets/claude/mcp-ts/rules/stack/mcp-ts-conventions.md +29 -0
  51. package/presets/claude/mcp-ts/rules/testing/README.md +3 -0
  52. package/presets/claude/mcp-ts/rules/testing/unit.md +30 -0
  53. package/presets/claude/mcp-ts/rules/tooling-and-review/README.md +3 -0
  54. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +23 -0
  55. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +161 -0
  56. package/presets/claude/mcp-ts/rules/tooling-and-review/anti-sycophancy-discipline.md +34 -0
  57. package/presets/claude/mcp-ts/rules/tooling-and-review/code-quality.md +52 -0
  58. package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +51 -0
  59. package/presets/claude/mcp-ts/rules/tooling-and-review/design-guidance.md +109 -0
  60. package/presets/claude/mcp-ts/rules/tooling-and-review/mcp-ts-tooling.md +31 -0
  61. package/presets/claude/mcp-ts/rules/tooling-and-review/post-change-test.md +30 -0
  62. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-layering.md +36 -0
  63. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-no-cross-stack-leakage.md +69 -0
  64. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +39 -0
  65. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-token-budget.md +41 -0
  66. package/presets/claude/mcp-ts/rules/tooling-and-review/preset-twin-sync.md +46 -0
  67. package/presets/claude/mcp-ts/rules/tooling-and-review/security-mcp.md +52 -0
  68. package/presets/claude/mcp-ts/rules/tooling-and-review/technical-retro.md +20 -0
  69. package/presets/claude/mcp-ts/rules/ui-and-accessibility/README.md +3 -0
  70. package/presets/claude/mcp-ts/skills/README.md +12 -0
  71. package/presets/claude/mcp-ts/skills/code-review/SKILL.md +10 -0
  72. package/presets/claude/mcp-ts/skills/debug-investigation/SKILL.md +11 -0
  73. package/presets/claude/mcp-ts/skills/feature-delivery/SKILL.md +29 -0
  74. package/presets/claude/mcp-ts/skills/unit-testing/SKILL.md +16 -0
  75. package/presets/claude/mcp-ts/team/README.md +17 -0
  76. package/presets/claude/mcp-ts/team/conventions.md +14 -0
  77. package/presets/claude/mcp-ts/team/fixtures/bugfix-standard.json +32 -0
  78. package/presets/claude/mcp-ts/team/fixtures/feature-full.json +33 -0
  79. package/presets/claude/mcp-ts/team/fixtures/feature-light.json +34 -0
  80. package/presets/claude/next/rules/tooling-and-review/preset-no-cross-stack-leakage.md +15 -2
  81. package/presets/claude/next/rules/tooling-and-review/preset-twin-sync.md +2 -0
  82. package/presets/cursor/go/rules/preset-no-cross-stack-leakage.mdc +15 -2
  83. package/presets/cursor/go/rules/preset-twin-sync.mdc +2 -0
  84. package/presets/cursor/ios-swift/rules/preset-no-cross-stack-leakage.mdc +15 -2
  85. package/presets/cursor/ios-swift/rules/preset-twin-sync.mdc +2 -0
  86. package/presets/cursor/java/rules/preset-no-cross-stack-leakage.mdc +15 -2
  87. package/presets/cursor/java/rules/preset-twin-sync.mdc +2 -0
  88. package/presets/cursor/mcp-ts/AGENTS.md +25 -0
  89. package/presets/cursor/mcp-ts/BUGBOT.md +9 -0
  90. package/presets/cursor/mcp-ts/MCP.md +37 -0
  91. package/presets/cursor/mcp-ts/README.md +19 -0
  92. package/presets/cursor/mcp-ts/REPO_AGENTS.md +49 -0
  93. package/presets/cursor/mcp-ts/agents/README.md +21 -0
  94. package/presets/cursor/mcp-ts/agents/build-verifier.md +39 -0
  95. package/presets/cursor/mcp-ts/agents/feature-developer.md +47 -0
  96. package/presets/cursor/mcp-ts/agents/security-reviewer.md +21 -0
  97. package/presets/cursor/mcp-ts/agents/solution-architect.md +23 -0
  98. package/presets/cursor/mcp-ts/agents/task-analyst.md +25 -0
  99. package/presets/cursor/mcp-ts/agents/task-router.md +73 -0
  100. package/presets/cursor/mcp-ts/commands/README.md +11 -0
  101. package/presets/cursor/mcp-ts/commands/feature-continue.md +19 -0
  102. package/presets/cursor/mcp-ts/commands/feature-start.md +33 -0
  103. package/presets/cursor/mcp-ts/commands/task-continue.md +49 -0
  104. package/presets/cursor/mcp-ts/commands/task.md +49 -0
  105. package/presets/cursor/mcp-ts/commands/technical-retro.md +81 -0
  106. package/presets/cursor/mcp-ts/hooks/README.md +12 -0
  107. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +346 -0
  108. package/presets/cursor/mcp-ts/hooks/examples/README.md +11 -0
  109. package/presets/cursor/mcp-ts/hooks/examples/format-edited.example.sh +16 -0
  110. package/presets/cursor/mcp-ts/hooks/examples/secret-guard.example.sh +10 -0
  111. package/presets/cursor/mcp-ts/hooks/examples/test-on-save.example.sh +25 -0
  112. package/presets/cursor/mcp-ts/hooks/guard-shell-command.sh +79 -0
  113. package/presets/cursor/mcp-ts/hooks.json +17 -0
  114. package/presets/cursor/mcp-ts/mcp.json +11 -0
  115. package/presets/cursor/mcp-ts/rules/README.md +52 -0
  116. package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +21 -0
  117. package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +159 -0
  118. package/presets/cursor/mcp-ts/rules/anti-sycophancy-discipline.mdc +35 -0
  119. package/presets/cursor/mcp-ts/rules/code-quality-and-refactoring.mdc +53 -0
  120. package/presets/cursor/mcp-ts/rules/code-review-mr.mdc +50 -0
  121. package/presets/cursor/mcp-ts/rules/design-guidance.mdc +108 -0
  122. package/presets/cursor/mcp-ts/rules/feature-delivery-workflow.mdc +43 -0
  123. package/presets/cursor/mcp-ts/rules/mcp-auth-secrets.mdc +45 -0
  124. package/presets/cursor/mcp-ts/rules/mcp-contract-testing.mdc +43 -0
  125. package/presets/cursor/mcp-ts/rules/mcp-server-boundaries.mdc +29 -0
  126. package/presets/cursor/mcp-ts/rules/mcp-tool-design.mdc +38 -0
  127. package/presets/cursor/mcp-ts/rules/mcp-transport-packaging.mdc +44 -0
  128. package/presets/cursor/mcp-ts/rules/mcp-ts-app-core.mdc +28 -0
  129. package/presets/cursor/mcp-ts/rules/mcp-ts-conventions.mdc +30 -0
  130. package/presets/cursor/mcp-ts/rules/mcp-ts-tooling.mdc +32 -0
  131. package/presets/cursor/mcp-ts/rules/post-change-test.mdc +26 -0
  132. package/presets/cursor/mcp-ts/rules/preset-layering.mdc +36 -0
  133. package/presets/cursor/mcp-ts/rules/preset-no-cross-stack-leakage.mdc +69 -0
  134. package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +39 -0
  135. package/presets/cursor/mcp-ts/rules/preset-token-budget.mdc +41 -0
  136. package/presets/cursor/mcp-ts/rules/preset-twin-sync.mdc +46 -0
  137. package/presets/cursor/mcp-ts/rules/reference-features.mdc +34 -0
  138. package/presets/cursor/mcp-ts/rules/security-mcp.mdc +53 -0
  139. package/presets/cursor/mcp-ts/rules/technical-retro.mdc +18 -0
  140. package/presets/cursor/mcp-ts/rules/tests-unit.mdc +31 -0
  141. package/presets/cursor/mcp-ts/skills/README.md +12 -0
  142. package/presets/cursor/mcp-ts/skills/code-review/SKILL.md +10 -0
  143. package/presets/cursor/mcp-ts/skills/debug-investigation/SKILL.md +11 -0
  144. package/presets/cursor/mcp-ts/skills/feature-delivery/SKILL.md +29 -0
  145. package/presets/cursor/mcp-ts/skills/unit-testing/SKILL.md +16 -0
  146. package/presets/cursor/mcp-ts/team/README.md +17 -0
  147. package/presets/cursor/mcp-ts/team/conventions.md +14 -0
  148. package/presets/cursor/mcp-ts/team/fixtures/bugfix-standard.json +32 -0
  149. package/presets/cursor/mcp-ts/team/fixtures/feature-full.json +33 -0
  150. package/presets/cursor/mcp-ts/team/fixtures/feature-light.json +34 -0
  151. package/presets/cursor/next/rules/preset-no-cross-stack-leakage.mdc +15 -2
  152. package/presets/cursor/next/rules/preset-twin-sync.mdc +2 -0
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env bash
2
+ # Lightweight shell guard for Claude Code projects using this preset.
3
+ # TypeScript MCP: allow npm/npx/node/tsc/vitest/jest; package-manager mismatch checks when lockfile exists.
4
+ # Package-manager mismatch checks apply only when a JS lockfile/package.json exists.
5
+
6
+ set -euo pipefail
7
+
8
+ input=$(cat)
9
+
10
+ INPUT="$input" node <<'NODE'
11
+ const fs = require('fs');
12
+
13
+ const raw = process.env.INPUT || '';
14
+ let event;
15
+ try {
16
+ event = JSON.parse(raw);
17
+ } catch {
18
+ process.stdout.write('{ "permission": "allow" }');
19
+ process.exit(0);
20
+ }
21
+
22
+ const command = String(event.command || event.input?.command || '');
23
+ if (!command.trim()) {
24
+ process.stdout.write('{ "permission": "allow" }');
25
+ process.exit(0);
26
+ }
27
+
28
+ function out(permission, userMessage, agentMessage) {
29
+ process.stdout.write(JSON.stringify({
30
+ permission,
31
+ user_message: userMessage,
32
+ agent_message: agentMessage || userMessage,
33
+ }));
34
+ }
35
+
36
+ const dangerousGit = /\bgit\s+(reset\s+--hard|clean\s+-[^\n]*f|push\s+--force|push\s+-f|checkout\s+--\s+)/;
37
+ if (dangerousGit.test(command)) {
38
+ out(
39
+ 'ask',
40
+ 'This command looks destructive for git state. Review it before continuing.',
41
+ 'A project hook flagged a destructive git command. Ask the user before running it.',
42
+ );
43
+ process.exit(0);
44
+ }
45
+
46
+ const managerByFile = [
47
+ ['yarn.lock', 'yarn'],
48
+ ['pnpm-lock.yaml', 'pnpm'],
49
+ ['package-lock.json', 'npm'],
50
+ ].find(([file]) => fs.existsSync(file));
51
+
52
+ let expected = managerByFile?.[1];
53
+ if (!expected && fs.existsSync('package.json')) {
54
+ try {
55
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
56
+ const pm = typeof pkg.packageManager === 'string' ? pkg.packageManager : '';
57
+ expected = pm.split('@')[0] || undefined;
58
+ } catch {
59
+ // Ignore invalid package.json in the hook; the agent can diagnose it later.
60
+ }
61
+ }
62
+
63
+ if (!expected) {
64
+ process.stdout.write('{ "permission": "allow" }');
65
+ process.exit(0);
66
+ }
67
+
68
+ const used = command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2];
69
+ if (used && used !== expected) {
70
+ out(
71
+ 'ask',
72
+ `This repository appears to use ${expected}, but the command uses ${used}. Confirm before continuing.`,
73
+ `Use ${expected} for package scripts and installs unless the user explicitly approves ${used}.`,
74
+ );
75
+ process.exit(0);
76
+ }
77
+
78
+ process.stdout.write('{ "permission": "allow" }');
79
+ NODE
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": {
3
+ "context7": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@upstash/context7-mcp@3.2.5"
8
+ ]
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,52 @@
1
+ # `.claude/rules` (preset mcp-ts)
2
+
3
+ Claude topic `.md` files are **derived** from Cursor SoT `presets/cursor/mcp-ts/rules/*.mdc`.
4
+
5
+ ## SoT sync
6
+
7
+ | Principle | Detail |
8
+ |-----------|--------|
9
+ | **SoT** | `presets/cursor/mcp-ts/rules/*.mdc` |
10
+ | **Derive** | Claude topic `.md` + `paths:` (drop `alwaysApply`) |
11
+ | **Checklist** | change Cursor → update Claude twin **same PR** (**FAIL** if missing — see `preset-twin-sync` / build-verifier) |
12
+
13
+ ## Loading budget
14
+
15
+ - **Session-start (no `paths:`):** exactly **3** — `mcp-ts-app-core`, `mcp-server-boundaries`, `code-quality`
16
+ - All others — with `paths:`
17
+ - **Twin depth:** domain rules target ≥15 body lines; thin aliases: `agent-team-intake`, `technical-retro`
18
+
19
+ ## Cursor → Claude mapping
20
+
21
+ | Cursor `.mdc` (SoT) | Claude topic |
22
+ |---------------------|--------------|
23
+ | `agent-team-intake.mdc` | `tooling-and-review/agent-team-intake.md` |
24
+ | `agent-team-orchestrator.mdc` | `tooling-and-review/agent-team-orchestrator.md` |
25
+ | `anti-sycophancy-discipline.mdc` | `tooling-and-review/anti-sycophancy-discipline.md` |
26
+ | `code-quality-and-refactoring.mdc` | `tooling-and-review/code-quality.md` |
27
+ | `code-review-mr.mdc` | `tooling-and-review/code-review.md` |
28
+ | `design-guidance.mdc` | `tooling-and-review/design-guidance.md` |
29
+ | `feature-delivery-workflow.mdc` | `architecture/feature-delivery.md` |
30
+ | `mcp-auth-secrets.mdc` | `api-and-data/mcp-auth-secrets.md` |
31
+ | `mcp-contract-testing.mdc` | `api-and-data/mcp-contract-testing.md` |
32
+ | `mcp-server-boundaries.mdc` | `architecture/mcp-server-boundaries.md` |
33
+ | `mcp-tool-design.mdc` | `api-and-data/mcp-tool-design.md` |
34
+ | `mcp-transport-packaging.mdc` | `api-and-data/mcp-transport-packaging.md` |
35
+ | `mcp-ts-app-core.mdc` | `stack/mcp-ts-app-core.md` |
36
+ | `mcp-ts-conventions.mdc` | `stack/mcp-ts-conventions.md` |
37
+ | `mcp-ts-tooling.mdc` | `tooling-and-review/mcp-ts-tooling.md` |
38
+ | `post-change-test.mdc` | `tooling-and-review/post-change-test.md` |
39
+ | `preset-layering.mdc` | `tooling-and-review/preset-layering.md` |
40
+ | `preset-no-cross-stack-leakage.mdc` | `tooling-and-review/preset-no-cross-stack-leakage.md` |
41
+ | `preset-pr-checklist.mdc` | `tooling-and-review/preset-pr-checklist.md` |
42
+ | `preset-token-budget.mdc` | `tooling-and-review/preset-token-budget.md` |
43
+ | `preset-twin-sync.mdc` | `tooling-and-review/preset-twin-sync.md` |
44
+ | `reference-features.mdc` | `architecture/reference-features.md` |
45
+ | `security-mcp.mdc` | `tooling-and-review/security-mcp.md` |
46
+ | `technical-retro.mdc` | `tooling-and-review/technical-retro.md` |
47
+ | `tests-unit.mdc` | `testing/unit.md` |
48
+
49
+ ## Topics
50
+
51
+ `architecture/`, `stack/`, `api-and-data/`, `testing/`, `tooling-and-review/`.
52
+ `ui-and-accessibility/` — README stub only (N/A for MCP server authoring).
@@ -0,0 +1,3 @@
1
+ # api-and-data
2
+
3
+ MCP tool design, transport, auth, contract testing.
@@ -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.