create-rigel 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +156 -0
  3. package/cli.js +122 -0
  4. package/package.json +47 -0
  5. package/templates/express/.claude/CLAUDE.md +114 -0
  6. package/templates/express/.claude/agents/arch-validator.md +85 -0
  7. package/templates/express/.claude/agents/db-optimizer.md +72 -0
  8. package/templates/express/.claude/agents/doc-gardener.md +67 -0
  9. package/templates/express/.claude/agents/garbage-collector.md +94 -0
  10. package/templates/express/.claude/agents/gate-checker.md +176 -0
  11. package/templates/express/.claude/agents/reviewer.md +84 -0
  12. package/templates/express/.claude/agents/security-auditor.md +82 -0
  13. package/templates/express/.claude/hooks/post-write.sh +93 -0
  14. package/templates/express/.claude/rules/api.md +149 -0
  15. package/templates/express/.claude/rules/architecture.md +78 -0
  16. package/templates/express/.claude/rules/database.md +104 -0
  17. package/templates/express/.claude/rules/jobs.md +81 -0
  18. package/templates/express/.claude/rules/security.md +92 -0
  19. package/templates/express/.claude/rules/testing.md +97 -0
  20. package/templates/express/.claude/settings.json +35 -0
  21. package/templates/express/.claude/skills/00-infra-setup/SKILL.md +479 -0
  22. package/templates/express/.claude/skills/01-write-roadmap/SKILL.md +72 -0
  23. package/templates/express/.claude/skills/02-write-spec/SKILL.md +119 -0
  24. package/templates/express/.claude/skills/03-write-plan/SKILL.md +124 -0
  25. package/templates/express/.claude/skills/04-build-layer/SKILL.md +216 -0
  26. package/templates/express/.claude/skills/05-validate-layer/SKILL.md +43 -0
  27. package/templates/express/.claude/skills/06-push-layer/SKILL.md +59 -0
  28. package/templates/express/.claude/skills/07-layer-check/SKILL.md +62 -0
  29. package/templates/express/.claude/skills/08-garbage-collect/SKILL.md +86 -0
  30. package/templates/express/.claude/skills/09-doc-garden/SKILL.md +64 -0
  31. package/templates/express/.claude/skills/10-db-optimize/SKILL.md +96 -0
  32. package/templates/express/.claude/skills/11-load-test/SKILL.md +77 -0
  33. package/templates/express/.dockerignore +43 -0
  34. package/templates/express/.env.example +42 -0
  35. package/templates/express/.github/CODEOWNERS +22 -0
  36. package/templates/express/.github/dependabot.yml +48 -0
  37. package/templates/express/.github/pull_request_template.md +58 -0
  38. package/templates/express/.github/workflows/ci.yml +278 -0
  39. package/templates/express/.github/workflows/load-test.yml +41 -0
  40. package/templates/express/.gitleaks.toml +18 -0
  41. package/templates/express/.lintstagedrc.json +3 -0
  42. package/templates/express/.nvmrc +1 -0
  43. package/templates/express/.prettierrc +8 -0
  44. package/templates/express/.sequelizerc +8 -0
  45. package/templates/express/AGENTS.md +94 -0
  46. package/templates/express/ARCHITECTURE.md +161 -0
  47. package/templates/express/Dockerfile +40 -0
  48. package/templates/express/Makefile +79 -0
  49. package/templates/express/QUICKSTART.md +131 -0
  50. package/templates/express/docker-compose.yml +114 -0
  51. package/templates/express/docs/PLANS.md +111 -0
  52. package/templates/express/docs/QUALITY_SCORE.md +66 -0
  53. package/templates/express/docs/design-docs/core-beliefs.md +89 -0
  54. package/templates/express/docs/design-docs/decisions/ADR-000-infrastructure.md +70 -0
  55. package/templates/express/docs/design-docs/decisions/ADR-001-observability.md +82 -0
  56. package/templates/express/docs/design-docs/decisions/index.md +23 -0
  57. package/templates/express/docs/design-docs/index.md +11 -0
  58. package/templates/express/docs/design-docs/observability.md +194 -0
  59. package/templates/express/docs/design-docs/team-workflow.md +64 -0
  60. package/templates/express/docs/exec-plans/active/.gitkeep +0 -0
  61. package/templates/express/docs/exec-plans/completed/.gitkeep +0 -0
  62. package/templates/express/docs/exec-plans/tech-debt-tracker.md +31 -0
  63. package/templates/express/docs/generated/.gitkeep +0 -0
  64. package/templates/express/docs/product-specs/ROADMAP.md +49 -0
  65. package/templates/express/docs/product-specs/draft/.gitkeep +0 -0
  66. package/templates/express/docs/product-specs/index.md +21 -0
  67. package/templates/express/docs/product-specs/ready/.gitkeep +0 -0
  68. package/templates/express/eslint.config.mjs +94 -0
  69. package/templates/express/gitignore +36 -0
  70. package/templates/express/infra/monitoring/alloy/config.alloy +59 -0
  71. package/templates/express/jest.config.ts +61 -0
  72. package/templates/express/package.json +45 -0
  73. package/templates/express/scripts/openapi.export.ts +77 -0
  74. package/templates/express/tests/architecture/isolation.test.ts +51 -0
  75. package/templates/express/tests/architecture/layers.test.ts +83 -0
  76. package/templates/express/tests/integration/health.test.ts +40 -0
  77. package/templates/express/tests/integration/isolation.test.template.ts +88 -0
  78. package/templates/express/tests/load/smoke.js +46 -0
  79. package/templates/express/tests/load/soak.js +45 -0
  80. package/templates/express/tests/load/stress.js +44 -0
  81. package/templates/express/tests/unit/utils/response.util.test.ts +53 -0
  82. package/templates/express/tsconfig.build.json +8 -0
  83. package/templates/express/tsconfig.json +20 -0
  84. package/templates/fastapi/.claude/CLAUDE.md +122 -0
  85. package/templates/fastapi/.claude/agents/arch-validator.md +64 -0
  86. package/templates/fastapi/.claude/agents/db-optimizer.md +59 -0
  87. package/templates/fastapi/.claude/agents/doc-gardener.md +55 -0
  88. package/templates/fastapi/.claude/agents/garbage-collector.md +74 -0
  89. package/templates/fastapi/.claude/agents/gate-checker.md +133 -0
  90. package/templates/fastapi/.claude/agents/reviewer.md +74 -0
  91. package/templates/fastapi/.claude/agents/security-auditor.md +69 -0
  92. package/templates/fastapi/.claude/hooks/post-write.sh +65 -0
  93. package/templates/fastapi/.claude/rules/api.md +119 -0
  94. package/templates/fastapi/.claude/rules/architecture.md +84 -0
  95. package/templates/fastapi/.claude/rules/database.md +153 -0
  96. package/templates/fastapi/.claude/rules/jobs.md +85 -0
  97. package/templates/fastapi/.claude/rules/security.md +102 -0
  98. package/templates/fastapi/.claude/rules/testing.md +207 -0
  99. package/templates/fastapi/.claude/settings.json +50 -0
  100. package/templates/fastapi/.claude/skills/00-infra-setup/SKILL.md +311 -0
  101. package/templates/fastapi/.claude/skills/01-write-roadmap/SKILL.md +61 -0
  102. package/templates/fastapi/.claude/skills/02-write-spec/SKILL.md +82 -0
  103. package/templates/fastapi/.claude/skills/03-write-plan/SKILL.md +83 -0
  104. package/templates/fastapi/.claude/skills/04-build-layer/SKILL.md +170 -0
  105. package/templates/fastapi/.claude/skills/05-validate-layer/SKILL.md +20 -0
  106. package/templates/fastapi/.claude/skills/06-push-layer/SKILL.md +31 -0
  107. package/templates/fastapi/.claude/skills/07-layer-check/SKILL.md +51 -0
  108. package/templates/fastapi/.claude/skills/08-garbage-collect/SKILL.md +47 -0
  109. package/templates/fastapi/.claude/skills/09-doc-garden/SKILL.md +9 -0
  110. package/templates/fastapi/.claude/skills/10-db-optimize/SKILL.md +53 -0
  111. package/templates/fastapi/.claude/skills/11-load-test/SKILL.md +81 -0
  112. package/templates/fastapi/.dockerignore +30 -0
  113. package/templates/fastapi/.github/dependabot.yml +24 -0
  114. package/templates/fastapi/AGENTS.md +87 -0
  115. package/templates/fastapi/ARCHITECTURE.md +141 -0
  116. package/templates/fastapi/Makefile +42 -0
  117. package/templates/fastapi/README.md +179 -0
  118. package/templates/fastapi/docs/PLANS.md +26 -0
  119. package/templates/fastapi/docs/QUALITY_SCORE.md +26 -0
  120. package/templates/fastapi/docs/design-docs/core-beliefs.md +46 -0
  121. package/templates/fastapi/docs/design-docs/decisions/ADR-000-infrastructure.md +79 -0
  122. package/templates/fastapi/docs/design-docs/decisions/index.md +7 -0
  123. package/templates/fastapi/docs/design-docs/index.md +9 -0
  124. package/templates/fastapi/docs/exec-plans/active/.gitkeep +0 -0
  125. package/templates/fastapi/docs/exec-plans/completed/.gitkeep +0 -0
  126. package/templates/fastapi/docs/exec-plans/tech-debt-tracker.md +19 -0
  127. package/templates/fastapi/docs/generated/.gitkeep +0 -0
  128. package/templates/fastapi/docs/product-specs/ROADMAP.md +49 -0
  129. package/templates/fastapi/docs/product-specs/draft/.gitkeep +0 -0
  130. package/templates/fastapi/docs/product-specs/index.md +18 -0
  131. package/templates/fastapi/docs/product-specs/ready/.gitkeep +0 -0
  132. package/templates/fastapi/gitignore +46 -0
  133. package/templates/fastapi/scripts/gate.sh +68 -0
  134. package/templates/nestjs/.claude/CLAUDE.md +121 -0
  135. package/templates/nestjs/.claude/agents/db-optimizer.md +51 -0
  136. package/templates/nestjs/.claude/agents/doc-gardener.md +45 -0
  137. package/templates/nestjs/.claude/agents/garbage-collector.md +50 -0
  138. package/templates/nestjs/.claude/agents/gate-checker.md +127 -0
  139. package/templates/nestjs/.claude/agents/reviewer.md +68 -0
  140. package/templates/nestjs/.claude/agents/security-auditor.md +72 -0
  141. package/templates/nestjs/.claude/hooks/post-write.sh +91 -0
  142. package/templates/nestjs/.claude/rules/api.md +87 -0
  143. package/templates/nestjs/.claude/rules/architecture.md +104 -0
  144. package/templates/nestjs/.claude/rules/database.md +111 -0
  145. package/templates/nestjs/.claude/rules/security.md +110 -0
  146. package/templates/nestjs/.claude/rules/testing.md +145 -0
  147. package/templates/nestjs/.claude/settings.json +33 -0
  148. package/templates/nestjs/.claude/skills/00-infra-setup/SKILL.md +222 -0
  149. package/templates/nestjs/.claude/skills/01-write-spec/SKILL.md +25 -0
  150. package/templates/nestjs/.claude/skills/02-write-plan/SKILL.md +18 -0
  151. package/templates/nestjs/.claude/skills/03-build-layer/SKILL.md +242 -0
  152. package/templates/nestjs/.claude/skills/04-validate-layer/SKILL.md +4 -0
  153. package/templates/nestjs/.claude/skills/05-push-layer/SKILL.md +6 -0
  154. package/templates/nestjs/.claude/skills/06-layer-check/SKILL.md +12 -0
  155. package/templates/nestjs/.claude/skills/07-garbage-collect/SKILL.md +2 -0
  156. package/templates/nestjs/.claude/skills/08-doc-garden/SKILL.md +4 -0
  157. package/templates/nestjs/.claude/skills/09-api-sync/SKILL.md +36 -0
  158. package/templates/nestjs/.claude/skills/10-load-test/SKILL.md +29 -0
  159. package/templates/nestjs/.env.example +11 -0
  160. package/templates/nestjs/AGENTS.md +88 -0
  161. package/templates/nestjs/ARCHITECTURE.md +192 -0
  162. package/templates/nestjs/docs/PLANS.md +22 -0
  163. package/templates/nestjs/docs/QUALITY_SCORE.md +27 -0
  164. package/templates/nestjs/docs/design-docs/core-beliefs.md +18 -0
  165. package/templates/nestjs/docs/design-docs/decisions/ADR-000-infrastructure.md +58 -0
  166. package/templates/nestjs/docs/design-docs/decisions/index.md +7 -0
  167. package/templates/nestjs/docs/design-docs/index.md +7 -0
  168. package/templates/nestjs/docs/exec-plans/active/.gitkeep +0 -0
  169. package/templates/nestjs/docs/exec-plans/completed/.gitkeep +0 -0
  170. package/templates/nestjs/docs/exec-plans/tech-debt-tracker.md +16 -0
  171. package/templates/nestjs/docs/generated/.gitkeep +0 -0
  172. package/templates/nestjs/docs/product-specs/draft/.gitkeep +0 -0
  173. package/templates/nestjs/docs/product-specs/index.md +7 -0
  174. package/templates/nestjs/docs/product-specs/ready/.gitkeep +0 -0
  175. package/templates/nestjs/gitignore +8 -0
  176. package/templates/nextjs/.claude/CLAUDE.md +139 -0
  177. package/templates/nextjs/.claude/agents/arch-validator.md +66 -0
  178. package/templates/nextjs/.claude/agents/contract-checker.md +78 -0
  179. package/templates/nextjs/.claude/agents/doc-gardener.md +52 -0
  180. package/templates/nextjs/.claude/agents/garbage-collector.md +61 -0
  181. package/templates/nextjs/.claude/agents/gate-checker.md +129 -0
  182. package/templates/nextjs/.claude/agents/perf-auditor.md +109 -0
  183. package/templates/nextjs/.claude/agents/reviewer.md +79 -0
  184. package/templates/nextjs/.claude/agents/security-auditor.md +50 -0
  185. package/templates/nextjs/.claude/hooks/post-write.sh +121 -0
  186. package/templates/nextjs/.claude/rules/api-contract.md +166 -0
  187. package/templates/nextjs/.claude/rules/architecture.md +99 -0
  188. package/templates/nextjs/.claude/rules/components.md +122 -0
  189. package/templates/nextjs/.claude/rules/security.md +122 -0
  190. package/templates/nextjs/.claude/rules/testing.md +187 -0
  191. package/templates/nextjs/.claude/scripts/infra-setup.sh +550 -0
  192. package/templates/nextjs/.claude/settings.json +33 -0
  193. package/templates/nextjs/.claude/skills/00-infra-setup/SKILL.md +471 -0
  194. package/templates/nextjs/.claude/skills/01-write-roadmap/SKILL.md +77 -0
  195. package/templates/nextjs/.claude/skills/02-write-spec/SKILL.md +78 -0
  196. package/templates/nextjs/.claude/skills/03-write-plan/SKILL.md +91 -0
  197. package/templates/nextjs/.claude/skills/04-build-layer/SKILL.md +141 -0
  198. package/templates/nextjs/.claude/skills/05-validate-layer/SKILL.md +13 -0
  199. package/templates/nextjs/.claude/skills/06-push-layer/SKILL.md +20 -0
  200. package/templates/nextjs/.claude/skills/07-layer-check/SKILL.md +28 -0
  201. package/templates/nextjs/.claude/skills/08-garbage-collect/SKILL.md +14 -0
  202. package/templates/nextjs/.claude/skills/09-doc-garden/SKILL.md +12 -0
  203. package/templates/nextjs/.claude/skills/10-api-sync/SKILL.md +50 -0
  204. package/templates/nextjs/.claude/skills/11-perf-budget/SKILL.md +51 -0
  205. package/templates/nextjs/.dockerignore +25 -0
  206. package/templates/nextjs/.gitattributes +10 -0
  207. package/templates/nextjs/.github/CODEOWNERS +24 -0
  208. package/templates/nextjs/.github/dependabot.yml +31 -0
  209. package/templates/nextjs/.github/pull_request_template.md +59 -0
  210. package/templates/nextjs/.github/workflows/ci.yml +143 -0
  211. package/templates/nextjs/.github/workflows/lighthouse.yml +54 -0
  212. package/templates/nextjs/.github/workflows/load-test.yml +54 -0
  213. package/templates/nextjs/.husky/pre-commit +1 -0
  214. package/templates/nextjs/.lintstagedrc.json +4 -0
  215. package/templates/nextjs/.mcp.json +8 -0
  216. package/templates/nextjs/.prettierignore +13 -0
  217. package/templates/nextjs/.prettierrc +9 -0
  218. package/templates/nextjs/AGENTS.md +88 -0
  219. package/templates/nextjs/ARCHITECTURE.md +165 -0
  220. package/templates/nextjs/Dockerfile +38 -0
  221. package/templates/nextjs/Makefile +50 -0
  222. package/templates/nextjs/QUICKSTART.md +128 -0
  223. package/templates/nextjs/docs/PLANS.md +23 -0
  224. package/templates/nextjs/docs/QUALITY_SCORE.md +27 -0
  225. package/templates/nextjs/docs/design-docs/core-beliefs.md +43 -0
  226. package/templates/nextjs/docs/design-docs/decisions/ADR-000-infrastructure.md +72 -0
  227. package/templates/nextjs/docs/design-docs/decisions/index.md +7 -0
  228. package/templates/nextjs/docs/design-docs/index.md +7 -0
  229. package/templates/nextjs/docs/design-docs/team-workflow.md +66 -0
  230. package/templates/nextjs/docs/exec-plans/active/.gitkeep +0 -0
  231. package/templates/nextjs/docs/exec-plans/completed/.gitkeep +0 -0
  232. package/templates/nextjs/docs/exec-plans/tech-debt-tracker.md +19 -0
  233. package/templates/nextjs/docs/generated/.gitkeep +0 -0
  234. package/templates/nextjs/docs/product-specs/ROADMAP.md +59 -0
  235. package/templates/nextjs/docs/product-specs/draft/.gitkeep +0 -0
  236. package/templates/nextjs/docs/product-specs/index.md +18 -0
  237. package/templates/nextjs/docs/product-specs/ready/.gitkeep +0 -0
  238. package/templates/nextjs/eslint.config.mjs +150 -0
  239. package/templates/nextjs/gitignore +35 -0
  240. package/templates/nextjs/lighthouserc.js +37 -0
@@ -0,0 +1,114 @@
1
+ # The top-level `version:` key is obsolete in Compose v2 and emits a warning — omitted.
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ ports:
9
+ - '3000:3000'
10
+ environment:
11
+ NODE_ENV: development
12
+ PORT: 3000
13
+ DATABASE_URL: postgresql://postgres:postgres@postgres:5432/myapp
14
+ REDIS_URL: redis://redis:6379
15
+ # Dev-only placeholder (≥32 chars to satisfy env validation). NEVER use in prod.
16
+ JWT_SECRET: dev-only-secret-change-me-min-32-characters
17
+ CORS_ORIGINS: http://localhost:3000
18
+ LOG_LEVEL: debug
19
+ SERVICE_NAME: myapp
20
+ # Traces + metrics → otel-lgtm collector (OTLP/HTTP). Defaults to the lgtm service;
21
+ # export an empty OTEL_EXPORTER_OTLP_ENDPOINT to disable (e.g. CI runs the app without LGTM).
22
+ OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT-http://lgtm:4318}
23
+ OTEL_SERVICE_NAME: myapp
24
+ depends_on:
25
+ postgres:
26
+ condition: service_healthy
27
+ redis:
28
+ condition: service_healthy
29
+ lgtm:
30
+ condition: service_started # don't block app boot; OTLP exporter retries until collector is up
31
+ networks:
32
+ - app-network
33
+ restart: unless-stopped
34
+
35
+ postgres:
36
+ image: postgres:16-alpine
37
+ ports:
38
+ - '5432:5432'
39
+ environment:
40
+ POSTGRES_USER: postgres
41
+ POSTGRES_PASSWORD: postgres
42
+ POSTGRES_DB: myapp
43
+ volumes:
44
+ - postgres-data:/var/lib/postgresql/data
45
+ healthcheck:
46
+ test: ['CMD-SHELL', 'pg_isready -U postgres']
47
+ interval: 10s
48
+ timeout: 5s
49
+ retries: 5
50
+ networks:
51
+ - app-network
52
+ restart: unless-stopped
53
+
54
+ redis:
55
+ image: redis:7-alpine
56
+ ports:
57
+ - '6379:6379'
58
+ volumes:
59
+ - redis-data:/data
60
+ healthcheck:
61
+ test: ['CMD', 'redis-cli', 'ping']
62
+ interval: 10s
63
+ timeout: 3s
64
+ retries: 5
65
+ networks:
66
+ - app-network
67
+ restart: unless-stopped
68
+
69
+ # All-in-one OpenTelemetry backend: Collector + Prometheus (metrics) + Tempo (traces)
70
+ # + Loki (logs) + Grafana UI. Receives OTLP on 4317 (gRPC) / 4318 (HTTP).
71
+ lgtm:
72
+ image: grafana/otel-lgtm:latest
73
+ ports:
74
+ - '3001:3000' # Grafana UI (remapped off 3000 to avoid clashing with the app)
75
+ - '4317:4317' # OTLP gRPC
76
+ - '4318:4318' # OTLP HTTP
77
+ volumes:
78
+ - lgtm-data:/data
79
+ healthcheck:
80
+ # otel-lgtm writes this readiness marker once all bundled services are up.
81
+ test: ['CMD-SHELL', 'test -f /tmp/ready || exit 1']
82
+ interval: 10s
83
+ timeout: 5s
84
+ retries: 12
85
+ networks:
86
+ - app-network
87
+ restart: unless-stopped
88
+
89
+ # Log shipper: tails container stdout JSON and pushes to Loki inside otel-lgtm.
90
+ # (Traces + metrics go straight to the collector via OTLP; only logs use Alloy.)
91
+ alloy:
92
+ image: grafana/alloy:latest
93
+ command:
94
+ - run
95
+ - /etc/alloy/config.alloy
96
+ - --storage.path=/var/lib/alloy/data
97
+ volumes:
98
+ - ./infra/monitoring/alloy/config.alloy:/etc/alloy/config.alloy:ro
99
+ - /var/run/docker.sock:/var/run/docker.sock:ro
100
+ depends_on:
101
+ lgtm:
102
+ condition: service_healthy
103
+ networks:
104
+ - app-network
105
+ restart: unless-stopped
106
+
107
+ volumes:
108
+ postgres-data:
109
+ redis-data:
110
+ lgtm-data:
111
+
112
+ networks:
113
+ app-network:
114
+ driver: bridge
@@ -0,0 +1,111 @@
1
+ # PLANS.md — Execution Plan Format & Lifecycle
2
+
3
+ ---
4
+
5
+ ## Roadmap → Specs (the altitude above plans)
6
+
7
+ `/write-roadmap` creates → `docs/product-specs/ROADMAP.md` (epics → dependency-ordered specs).
8
+ The roadmap plans the SET of specs for a whole product; `/write-spec` then authors each one.
9
+ A single spec may span MULTIPLE plans — slice a big spec into shippable milestones, each its own
10
+ `PLAN-XXX`. The spec's `**Plan:**` field then lists them all (e.g. `PLAN-003, PLAN-007`).
11
+
12
+ ---
13
+
14
+ ## Lifecycle
15
+
16
+ ```
17
+ /write-plan creates → docs/exec-plans/active/PLAN-XXX.md [IN_PROGRESS]
18
+ → layers built one by one, checkboxes ticked
19
+ → /garbage-collect closes → docs/exec-plans/completed/ [COMPLETE]
20
+ ```
21
+
22
+ Plans are **never deleted.** They are the project's memory.
23
+
24
+ ---
25
+
26
+ ## Plan Template
27
+
28
+ ```markdown
29
+ # PLAN-XXX — {Feature Name}
30
+
31
+ **Status:** IN_PROGRESS
32
+ **Spec:** docs/product-specs/ready/SPEC-XXX-{slug}.md
33
+ **Created:** YYYY-MM-DD
34
+ **Completed:** —
35
+
36
+ ---
37
+
38
+ ## Goal
39
+ One sentence.
40
+
41
+ ---
42
+
43
+ ## Layer Build Order
44
+
45
+ | # | Layer | Files | Gate Focuses On |
46
+ |---|---|---|---|
47
+ | 1 | Types | `src/types/...` | Zero imports, zero logic |
48
+ | 2 | Config | `src/config/...` | process.env only in env.ts |
49
+ | 3 | Models | `src/models/...` | paranoid, UUIDv7, indexes |
50
+ | 4 | Migrations | `db/migrations/...` | Runs clean, has down() |
51
+ | 5 | Repo | `src/repo/...` | Zod parse, cursor, ownership, no N+1 |
52
+ | 6 | Service | `src/services/...` | No express, ≥90% coverage |
53
+ | 7 | Runtime | `src/runtime/routes/v1/...` | Auth first, envelope |
54
+ | 8 | Workers | `src/runtime/workers/...` | Zod payload, retry, logs |
55
+ | 9 | Tests | `tests/...` | Coverage gates |
56
+
57
+ ---
58
+
59
+ ## Acceptance Criteria
60
+ - [ ] criterion (from spec)
61
+
62
+ ---
63
+
64
+ ## Progress Log
65
+
66
+ ### YYYY-MM-DD — Plan created
67
+ - notes
68
+
69
+ ---
70
+
71
+ ## Decision Log
72
+
73
+ ### Decision: {title}
74
+ **Date:** YYYY-MM-DD
75
+ **Context:** why this decision was needed
76
+ **Chosen:** what was decided
77
+ **Alternatives:** what else was considered
78
+ **Trade-offs:** what this costs
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Small Task Alternative (< 2 hours)
84
+
85
+ Use a PR description instead of a full plan:
86
+
87
+ ```markdown
88
+ ## What
89
+ [1-2 sentences]
90
+
91
+ ## Why
92
+ [1 sentence]
93
+
94
+ ## Checklist
95
+ - [ ] Types updated
96
+ - [ ] Tests pass
97
+ - [ ] ESLint clean
98
+ - [ ] QUALITY_SCORE.md updated
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Escalation Rule
104
+
105
+ Escalate to human only when judgment is required:
106
+ - Ambiguous acceptance criteria
107
+ - Conflicting requirements
108
+ - Security decision with no established pattern
109
+ - Performance budget impossible without architecture change
110
+
111
+ Never escalate for: technical unknowns, linter failures, test failures — fix those.
@@ -0,0 +1,66 @@
1
+ # QUALITY_SCORE.md — Domain Health Grades
2
+
3
+ Updated by `/garbage-collect` after every feature.
4
+
5
+ ---
6
+
7
+ ## Grading Rubric
8
+
9
+ Coverage is judged **per layer** against the thresholds in `jest.config.ts`
10
+ (utils 100% · services 90% · repo 80% · routes 75% · providers 70%), never as a single
11
+ global number — that is what CI enforces.
12
+
13
+ | Grade | Meaning |
14
+ |---|---|
15
+ | A | All invariants met, **every per-layer coverage threshold met**, zero known debt |
16
+ | B | Minor issues, per-layer thresholds met with little margin, low-priority debt logged |
17
+ | C | Layer violation OR any per-layer threshold breached OR unresolved medium debt |
18
+ | D | Multiple violations, coverage well under thresholds, active bugs |
19
+ | F | Blocking issues, data integrity risk, security concern |
20
+
21
+ ---
22
+
23
+ ## Architecture Health
24
+
25
+ | Check | Status |
26
+ |---|---|
27
+ | No cross-layer imports (eslint boundaries) | — |
28
+ | Cross-user isolation test per owned resource | — |
29
+ | No circular imports (madge) | — |
30
+ | No files > 400 lines | — |
31
+ | No process.env outside Config | — |
32
+ | No console.log in src/ | — |
33
+ | OpenAPI contract in sync (openapi:export clean) | — |
34
+ | Utils: 100% test coverage | — |
35
+
36
+ Run `/layer-check` to update this table.
37
+
38
+ ---
39
+
40
+ ## Domain Grades
41
+
42
+ | Domain | Grade | Coverage | Last Updated | Notes |
43
+ |---|---|---|---|---|
44
+ | *(no domains yet — add after first feature)* | — | — | — | — |
45
+
46
+ ---
47
+
48
+ ## Domain Grade Template
49
+
50
+ Copy this block for each new domain:
51
+
52
+ ```
53
+ ### {Domain Name}
54
+ **Grade:** —
55
+ **Coverage:** —%
56
+ **Last Updated:** YYYY-MM-DD (PLAN-XXX)
57
+
58
+ Passing:
59
+ - [ ] No layer violations
60
+ - [ ] Zod parse on all repo boundaries
61
+ - [ ] Structured logging on all service methods
62
+ - [ ] OTel spans on all service boundaries
63
+
64
+ Issues:
65
+ - none
66
+ ```
@@ -0,0 +1,89 @@
1
+ # Core Beliefs — The Engineering Constitution
2
+
3
+ Rules without reasons get bent under pressure.
4
+ This document explains the WHY behind every constraint in this harness.
5
+
6
+ ---
7
+
8
+ ## 1. The Repo Is Reality
9
+
10
+ If a decision isn't written in this repository, it doesn't exist.
11
+ Slack messages, verbal agreements, and meeting notes are invisible to agents and to future engineers.
12
+
13
+ **Consequence:** Every architectural decision → ADR. Every product → `ROADMAP.md`. Every feature intent → spec. Every execution plan → PLAN-XXX.md.
14
+
15
+ ---
16
+
17
+ ## 2. Enforce Mechanically, Not Aspirationally
18
+
19
+ A linter rule that blocks CI is worth ten documentation paragraphs.
20
+ Agents respond to feedback in their context window — linter errors are that feedback.
21
+
22
+ **Consequence:** Every constraint that matters is encoded as an ESLint rule, a structural test, or a hook. Not just a doc.
23
+
24
+ ---
25
+
26
+ ## 3. Agents Execute. Humans Steer.
27
+
28
+ Human attention is the scarcest resource. Every minute spent writing boilerplate is a minute not spent on product quality.
29
+
30
+ **Consequence:** The harness is optimised for maximum agent autonomy. Escalations happen only when judgment is required — not when tasks are hard.
31
+
32
+ ---
33
+
34
+ ## 4. Layers Protect Business Logic
35
+
36
+ The layer architecture isn't aesthetic. It exists so business logic can be tested, ported, and reasoned about in isolation — without spinning up HTTP, a database, or any external dependency.
37
+
38
+ **Consequence:** Service methods take domain types and return domain types. No `Request`, no `Response`, no HTTP concepts.
39
+
40
+ ---
41
+
42
+ ## 5. External Data Is Adversarial Until Proven Otherwise
43
+
44
+ TypeScript's type system tells you what you expect — not what you got.
45
+ APIs change. DB schemas get migrated. Payloads get spoofed.
46
+
47
+ **Consequence:** `Schema.parse(raw.toJSON())` at every external data boundary. `as SomeType` is forbidden on external data.
48
+
49
+ ---
50
+
51
+ ## 6. Observability Is Not Optional
52
+
53
+ When something breaks in production, structured logs + traces are the only way to reproduce it without live debugging. Agents can query logs to fix bugs autonomously — but only if the logs exist.
54
+
55
+ **Consequence:** Structured JSON logging and OTel spans on every service boundary. No silent operations.
56
+
57
+ ---
58
+
59
+ ## 7. Gate Before Commit — Always
60
+
61
+ Shipping code that violates the harness compounds over time. Every violation makes the next one cheaper to introduce.
62
+
63
+ **Consequence:** The gate-checker runs after every layer. It must PASS before any commit is made. Auto-fix is enabled — there's no reason to leave violations unfixed.
64
+
65
+ ---
66
+
67
+ ## 8. Small, Boring, Legible
68
+
69
+ Agents reason best about code they can fully read in a single context window.
70
+ 400 lines is the cognitive limit. Boring technology has more training data and fewer surprises.
71
+
72
+ **Consequence:** 400-line hard limit. Prefer well-known libraries. No premature abstraction.
73
+
74
+ ---
75
+
76
+ ## 9. Technical Debt Is a High-Interest Loan
77
+
78
+ Every shortcut taken today costs more to fix when built upon.
79
+ Log debt immediately. Pay it in small amounts daily.
80
+
81
+ **Consequence:** `tech-debt-tracker.md` is updated after every feature. Garbage collection runs after every plan completes.
82
+
83
+ ---
84
+
85
+ ## 10. The Fix Is Never "Try Harder"
86
+
87
+ Repeated failures indicate a missing capability — a missing tool, constraint, or abstraction.
88
+
89
+ **Consequence:** When the same problem recurs: diagnose the missing capability → build it → solve it permanently. Build the abstraction before writing the third hand-rolled copy.
@@ -0,0 +1,70 @@
1
+ # ADR-000 — Infrastructure & Stack Choices
2
+
3
+ **Status:** ACCEPTED
4
+ **Date:** *(fill when /infra-setup is run)*
5
+ **Plan:** Phase 0
6
+
7
+ ---
8
+
9
+ ## Context
10
+
11
+ Starting a new TypeScript backend project. Need to select the foundational stack for the long term.
12
+ Choices made here are expensive to change later.
13
+
14
+ ---
15
+
16
+ ## Decisions
17
+
18
+ ### Runtime: Node 24 LTS + TypeScript 5
19
+ - Node 24 is the current LTS — stable, long support window
20
+ - TypeScript 5 with `strict: true` — `exactOptionalPropertyTypes` and `noUncheckedIndexedAccess` catch a class of bugs TypeScript 4 missed
21
+
22
+ ### Framework: Express 5
23
+ - Express 5 is finally stable — async error propagation built-in (no need for `express-async-errors` wrapper in future)
24
+ - Widest ecosystem, most agent training data, most Stack Overflow coverage
25
+ - Alternatives considered: Fastify (better performance, less ecosystem), Hono (newer, less mature)
26
+
27
+ ### ORM: Sequelize 6 + sequelize-typescript
28
+ - Team already familiar
29
+ - `paranoid: true` soft deletes built-in
30
+ - sequelize-cli provides robust migration tooling
31
+ - Stable v6 release with proven production track record
32
+ - Alternatives considered: Prisma (better DX, but generates its own runtime, less control), Drizzle (very new)
33
+
34
+ ### Auth: jose 5 (JWT)
35
+ - Zero CVE history (unlike `jsonwebtoken`)
36
+ - Web Crypto API — runs in any JS runtime
37
+ - Alternatives rejected: `jsonwebtoken` — has had multiple CVEs
38
+
39
+ ### Password Hashing: argon2
40
+ - Winner of the Password Hashing Competition (2015)
41
+ - Resistant to GPU/ASIC attacks
42
+ - Alternatives rejected: bcrypt — vulnerable to GPU attacks at high parallelism
43
+
44
+ ### Queue: BullMQ 5 + Redis
45
+ - Most mature Redis-backed queue in Node ecosystem
46
+ - Built-in retry, backoff, rate limiting, delayed jobs
47
+ - Alternatives considered: `pg-boss` (Postgres-backed, fewer deps), SQS (infrastructure dependency)
48
+
49
+ ### Logging: pino 9
50
+ - Fastest structured JSON logger in Node ecosystem (~5x faster than winston)
51
+ - Built-in redaction
52
+ - Alternatives rejected: winston — slow, complex config
53
+
54
+ ### Validation: Zod 3
55
+ - TypeScript-first, infers types from schemas
56
+ - Used at every external data boundary
57
+ - Alternatives considered: Yup (less TypeScript-native), io-ts (too verbose)
58
+
59
+ ### Caching/Sessions: ioredis 5
60
+ - Most stable Redis client for Node
61
+ - Used for: rate limiting, token revocation, job queues, application cache
62
+
63
+ ---
64
+
65
+ ## Consequences
66
+
67
+ - Express 5 async errors: built-in async error propagation to `errorHandler` middleware
68
+ - Sequelize + `paranoid: true`: never hard-delete unless explicitly using `{ force: true }`
69
+ - jose: tokens are stateless — revocation requires Redis check on every verify
70
+ - argon2: slower than bcrypt on CPU (that's a feature, not a bug — harder to brute-force)
@@ -0,0 +1,82 @@
1
+ # ADR-001 — Observability (Traces, Metrics, Logs)
2
+
3
+ **Status:** ACCEPTED
4
+ **Date:** *(fill when /infra-setup is run)*
5
+ **Plan:** Phase 0
6
+ **See also:** `docs/design-docs/observability.md` (the see-it/debug-it walkthrough)
7
+
8
+ ---
9
+
10
+ ## Context
11
+
12
+ Core belief #6 ("observability is not optional") and `QUALITY_SCORE.md` require structured logging
13
+ and OTel spans on every service boundary, so that production issues can be reproduced — and fixed by
14
+ agents — from telemetry alone. We need a concrete, low-friction implementation that works in dev,
15
+ no-ops cleanly in tests/CI, and respects the layered-architecture import rules. This ADR records the
16
+ non-obvious choices; the mechanics live in `observability.md`.
17
+
18
+ ---
19
+
20
+ ## Decisions
21
+
22
+ ### Signals: OpenTelemetry SDK (`@opentelemetry/sdk-node`), one release line
23
+ - Traces + metrics exported via OTLP/HTTP (`exporter-trace-otlp-http`, `exporter-metrics-otlp-http`)
24
+ with `getNodeAutoInstrumentations()` (http/express/pg/ioredis patched for free).
25
+ - All `@opentelemetry/*` packages pinned to the same release line; `@opentelemetry/api` is kept
26
+ within the SDK's peer range. Version skew here is the most common source of silent breakage.
27
+
28
+ ### Local backend: `grafana/otel-lgtm` (all-in-one)
29
+ - A single container bundles the OTel Collector + Prometheus (metrics) + Tempo (traces) + Loki
30
+ (logs) + Grafana. Zero config, OTLP defaults, one `docker compose up`.
31
+ - Alternatives rejected: wiring discrete collector + Prometheus + Tempo + Loki + Grafana services —
32
+ far more YAML and moving parts for a template, with no dev-time benefit.
33
+ - Grafana is published on host **3001** (its in-container default is 3000) to avoid clashing with
34
+ the app/frontend.
35
+ - **Not for production** — prod points `OTEL_EXPORTER_OTLP_ENDPOINT` at a real collector / Grafana
36
+ Cloud; app code is unchanged.
37
+
38
+ ### Logs: pino JSON → Alloy → Loki (not OTLP from the app)
39
+ - Under ESM, `@opentelemetry/instrumentation-pino`'s OTLP log-sending does not reliably emit, so we
40
+ do not depend on it. Instead:
41
+ 1. **Correlation** is deterministic — a pino `mixin` reads `trace.getActiveSpan()` and stamps
42
+ `trace_id`/`span_id` on every line, independent of auto-instrumentation patching.
43
+ 2. **Shipping** is decoupled — Grafana Alloy tails container stdout JSON and pushes to Loki.
44
+ - Consequence: we **do not install** `@opentelemetry/exporter-logs-otlp-http` or
45
+ `@opentelemetry/sdk-logs`; the `NodeSDK` carries only `traceExporter` + `metricReaders`. Fewer
46
+ packages, no ESM log-export bug to fight.
47
+
48
+ ### Helpers live in Config, the SDK lives in Providers
49
+ - The layer rules let every domain layer import `config/` but forbid Service/Repo from importing
50
+ `providers/` (enforced by madge). So `logger`, `withSpan` (tracing), and `metrics` live in
51
+ `src/config/` and use only the `@opentelemetry/api` global (a safe no-op until an SDK starts).
52
+ - The `NodeSDK` itself lives only in `src/providers/telemetry.ts`, boot-only.
53
+
54
+ ### Boot order: start the SDK before importing the app (ESM)
55
+ - Auto-instrumentation can only patch a library loaded *after* `sdk.start()`. `src/runtime/server.ts`
56
+ statically imports only telemetry, calls `await startTelemetry()`, then `await import('./app.js')`.
57
+ - The instrumented libs (express/pg/ioredis) are CommonJS, so the SDK's require-hook patches them
58
+ with no ESM loader hook needed — provided the start runs before the first `require`. This pattern
59
+ is identical under `tsx` (dev) and `node dist/...` (prod), so there is no start-command divergence
60
+ and no `NODE_OPTIONS`/`--import` flag to maintain.
61
+
62
+ ### Off by default in tests/CI
63
+ - Gate on `OTEL_EXPORTER_OTLP_ENDPOINT`: blank ⇒ `startTelemetry()` returns early and all helpers
64
+ no-op. `npm test`/CI run with it unset and never start the LGTM stack.
65
+ - `providers/telemetry.ts` is boot-only and excluded from coverage (like `server.ts`); the `config/`
66
+ helpers are unit-tested against the no-op API.
67
+
68
+ ### Env booleans: `z.stringbool()`, never `z.coerce.boolean()`
69
+ - `z.coerce.boolean('false')` is `true` (any non-empty string is truthy). Boolean `OTEL_*` flags use
70
+ zod 4's `z.stringbool()`.
71
+
72
+ ---
73
+
74
+ ## Consequences
75
+
76
+ - One `docker compose up` gives a full local trace/metric/log stack with log↔trace correlation.
77
+ - Services stay clean: `withSpan(...)` + the existing `logger.info({ event, durationMs })`, no
78
+ Provider imports, no manual trace-context threading.
79
+ - Logging is resilient to OTel/ESM churn because correlation and shipping don't depend on the pino
80
+ auto-instrumentation.
81
+ - Adding OTLP log export later (if the ESM gap closes) is additive: install `sdk-logs` +
82
+ `exporter-logs-otlp-http`, add `logRecordProcessors` to the SDK, drop Alloy. No app-code change.
@@ -0,0 +1,23 @@
1
+ # Architectural Decision Records (ADRs)
2
+
3
+ All significant decisions are recorded here. Never deleted — mark as SUPERSEDED if replaced.
4
+
5
+ ---
6
+
7
+ ## Index
8
+
9
+ | ID | Title | Status | Date | Plan |
10
+ |---|---|---|---|---|
11
+ | ADR-000 | Infrastructure & Stack Choices | ACCEPTED | *(fill on /infra-setup)* | — |
12
+
13
+ ---
14
+
15
+ ## ADR Statuses
16
+
17
+ | Status | Meaning |
18
+ |---|---|
19
+ | PROPOSED | Under discussion |
20
+ | ACCEPTED | Adopted — in effect |
21
+ | REJECTED | Considered but not adopted |
22
+ | SUPERSEDED | Replaced by a newer ADR |
23
+ | DEPRECATED | No longer relevant |
@@ -0,0 +1,11 @@
1
+ # Design Docs Index
2
+
3
+ | Document | Purpose |
4
+ | ------------------------------------- | ---------------------------------------------------- |
5
+ | `core-beliefs.md` | The engineering constitution — WHY every rule exists |
6
+ | `decisions/index.md` | ADR registry — all architectural decisions |
7
+ | `decisions/ADR-000-infrastructure.md` | Stack choices and rationale |
8
+
9
+ ---
10
+
11
+ Add a row here when creating a new design doc or ADR.