prizmkit 1.1.54 → 1.1.55
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.
- package/bundled/VERSION.json +3 -3
- package/bundled/rules/_rules-metadata.json +6 -1
- package/bundled/rules/general/cohesive-modeling.md +27 -0
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/app-planner/SKILL.md +114 -4
- package/bundled/skills/app-planner/references/rules/backend/derivation-rules.md +609 -0
- package/bundled/skills/app-planner/references/rules/backend/fixed-rules.md +285 -0
- package/bundled/skills/app-planner/references/rules/backend/question-bank.md +249 -0
- package/bundled/skills/app-planner/references/rules/backend/template.md +173 -0
- package/bundled/skills/app-planner/references/rules/database/derivation-rules.md +373 -0
- package/bundled/skills/app-planner/references/rules/database/fixed-rules.md +211 -0
- package/bundled/skills/app-planner/references/rules/database/question-bank.md +184 -0
- package/bundled/skills/app-planner/references/rules/database/template.md +158 -0
- package/bundled/skills/app-planner/references/rules/frontend/derivation-rules.md +810 -0
- package/bundled/skills/app-planner/references/rules/frontend/fixed-rules.md +188 -0
- package/bundled/skills/app-planner/references/rules/frontend/question-bank.md +302 -0
- package/bundled/skills/app-planner/references/rules/frontend/template.md +320 -0
- package/bundled/skills/app-planner/references/rules/mobile/derivation-rules.md +639 -0
- package/bundled/skills/app-planner/references/rules/mobile/fixed-rules.md +290 -0
- package/bundled/skills/app-planner/references/rules/mobile/question-bank.md +232 -0
- package/bundled/skills/app-planner/references/rules/mobile/template.md +175 -0
- package/bundled/skills/prizm-kit/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/SKILL.md +47 -6
- package/bundled/skills/prizmkit-init/references/config-schema.md +7 -3
- package/bundled/skills/prizmkit-init/references/rules/layer-detection.md +41 -0
- package/package.json +1 -1
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Fixed Rules — Complete Backend Fixed Rules
|
|
2
|
+
|
|
3
|
+
> This file is read by the `backend-rules` skill in Phase 1 and injected directly into `backend-rules.md`.
|
|
4
|
+
> These rules are industry consensus / best practices — **do not ask the user**.
|
|
5
|
+
> Every rule includes RATIONALE so the AI understands intent, not just constraints.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## F1. Project Structure
|
|
10
|
+
|
|
11
|
+
### F1.1 Layered Architecture (Mandatory)
|
|
12
|
+
|
|
13
|
+
- **Rule**: Must use one of the following layering patterns, and be consistent across the project:
|
|
14
|
+
- Classic three-tier: `controller → service → repository`
|
|
15
|
+
- DDD-style: `handler → usecase → repository` (Go) / `router → service → dao` (Node)
|
|
16
|
+
- **Rule**: Upper layers must not bypass lower layers (controller must not call repository directly).
|
|
17
|
+
- **Rule**: Each layer does only its own job — controller handles request validation and response formatting, service handles business logic, repository handles data access.
|
|
18
|
+
- **RATIONALE**: Mixed layer boundaries are the #1 cause of backend code rot. When AI can't tell which layer does what, business logic scatters into controllers.
|
|
19
|
+
|
|
20
|
+
### F1.2 Directory Conventions
|
|
21
|
+
|
|
22
|
+
- **Rule**: The project root structure must clearly reflect the layering.
|
|
23
|
+
- **Rule**: Shared utilities (utils) must be isolated from business code.
|
|
24
|
+
- **Rule**: Config, constants, and type definitions are centrally managed.
|
|
25
|
+
- **Forbidden**: Turning `utils/` into a dumping ground for anything without a clear home.
|
|
26
|
+
- **RATIONALE**: The directory structure is the project's first piece of documentation. A new developer (including AI) should know where a function belongs just by reading it.
|
|
27
|
+
|
|
28
|
+
### F1.3 Module Boundaries
|
|
29
|
+
|
|
30
|
+
- **Rule**: Organize by business domain, not by technical layer (types/services/models cross-domain).
|
|
31
|
+
- **Rule**: Modules communicate through explicit interfaces. Do not access another module's internal implementation directly.
|
|
32
|
+
- **Forbidden**: Circular dependencies (module A imports B, B imports A).
|
|
33
|
+
- **RATIONALE**: Technical-layer organization scatters code for a single feature across 4–5 directories. Changing one feature requires jumping across directories.
|
|
34
|
+
- **Note on layering interaction with F1.1**: Organize by business domain at the top level. Within each domain directory, enforce the layering from F1.1 (e.g., user/controller/, user/service/, user/repository/). Do NOT create top-level controllers/, services/, repositories/ directories that span all domains.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## F2. API Design
|
|
39
|
+
|
|
40
|
+
### F2.1 REST Contract
|
|
41
|
+
|
|
42
|
+
- **Rule**: URLs use plural nouns (`/users`, `/orders`), never verbs (forbid `/getUser`, `/createOrder`).
|
|
43
|
+
- **Rule**: HTTP method semantics must be correct:
|
|
44
|
+
- `GET` — query, must not modify data
|
|
45
|
+
- `POST` — create
|
|
46
|
+
- `PUT` — full update
|
|
47
|
+
- `PATCH` — partial update
|
|
48
|
+
- `DELETE` — remove
|
|
49
|
+
- **Rule**: Standard pagination params: `page` (1-based), `pageSize` (default 20, max 100).
|
|
50
|
+
- **Rule**: Standard sorting params: `sortBy=field&sortOrder=asc|desc`.
|
|
51
|
+
- **RATIONALE**: The API is a contract between frontend and backend. Inconsistent naming and parameter formats cause bugs in consumers.
|
|
52
|
+
|
|
53
|
+
### F2.2 Status Codes
|
|
54
|
+
|
|
55
|
+
- **Rule**: Use HTTP status codes strictly by semantics:
|
|
56
|
+
- `200` — query success
|
|
57
|
+
- `201` — create success
|
|
58
|
+
- `204` — delete success (no body)
|
|
59
|
+
- `400` — validation failure
|
|
60
|
+
- `401` — not authenticated
|
|
61
|
+
- `403` — forbidden
|
|
62
|
+
- `404` — resource not found
|
|
63
|
+
- `409` — resource conflict
|
|
64
|
+
- `422` — valid request format but business logic rejection
|
|
65
|
+
- `500` — unknown server error
|
|
66
|
+
- **Forbidden**: Returning `200` for all errors with an error code in the body.
|
|
67
|
+
- **RATIONALE**: HTTP status codes are standard signals for infrastructure (load balancers, monitoring, gateways). Bypassing them makes all observability useless.
|
|
68
|
+
|
|
69
|
+
### F2.3 Error Response Format
|
|
70
|
+
|
|
71
|
+
- **Rule**: All errors return a unified structure:
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"error": {
|
|
75
|
+
"code": "USER_NOT_FOUND",
|
|
76
|
+
"message": "User not found",
|
|
77
|
+
"details": [],
|
|
78
|
+
"traceId": "abc-123"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
- **Rule**: `code` uses UPPER_SNAKE_CASE with business semantics (`USER_NOT_FOUND`, not `ERR_001`).
|
|
83
|
+
- **Rule**: `traceId` is generated at request entry and propagated through the entire call chain.
|
|
84
|
+
- **RATIONALE**: A unified error format lets frontends and gateways write one error handler instead of per-endpoint if/else chains.
|
|
85
|
+
|
|
86
|
+
### F2.4 API Versioning
|
|
87
|
+
|
|
88
|
+
- **Rule**: APIs must indicate version in URL or Header (`/api/v1/users` or `Accept: application/vnd.api.v1+json`).
|
|
89
|
+
- **Rule**: Breaking changes require a new version. Old versions must be maintained for at least one release cycle.
|
|
90
|
+
- **RATIONALE**: Unversioned APIs cause widespread mobile/third-party client crashes on release.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## F3. Error Handling
|
|
95
|
+
|
|
96
|
+
- **Rule**: All exceptions must be caught by a global exception filter and return a unified error response.
|
|
97
|
+
- **Rule**: Business exceptions vs. system exceptions are separated — business exceptions return 4xx, system exceptions return 500.
|
|
98
|
+
- **Forbidden**: Empty `catch(e) {}` blocks. If ignoring is truly necessary, comment why.
|
|
99
|
+
- **Forbidden**: `catch(e) { throw new Error('something went wrong') }` that swallows the original stack trace.
|
|
100
|
+
- **Rule**: Error logs must include traceId, user identifier, request method, and path.
|
|
101
|
+
- **RATIONALE**: The biggest backend failure isn't "an error occurred" — it's "an error occurred and nobody knows".
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## F4. Security
|
|
106
|
+
|
|
107
|
+
### F4.1 Input Validation (Mandatory)
|
|
108
|
+
|
|
109
|
+
- **Rule**: All external inputs must be validated (body, query params, path params, headers, cookies).
|
|
110
|
+
- **Rule**: Use a validation framework (Joi/Zod/Pydantic/validator), not hand-written if/else.
|
|
111
|
+
- **Rule**: Validation failures return 400 with field-level error details.
|
|
112
|
+
- **Forbidden**: Trusting data from the frontend to be directly stored or executed.
|
|
113
|
+
- **RATIONALE**: Input validation is the first line of defense and the root cause mitigation for multiple OWASP Top 10 attacks.
|
|
114
|
+
|
|
115
|
+
### F4.2 Authentication & Authorization
|
|
116
|
+
|
|
117
|
+
- **Rule**: AuthN and AuthZ must be separated — middleware handles authentication, business logic handles authorization.
|
|
118
|
+
- **Rule**: JWT tokens must have expiration (access token ≤ 15min, refresh token ≤ 7d).
|
|
119
|
+
- **Rule**: Sensitive operations (delete, transfer, permission changes) require secondary confirmation.
|
|
120
|
+
- **Forbidden**: Hardcoding tokens/secrets in source code.
|
|
121
|
+
- **RATIONALE**: Separating AuthN and AuthZ allows independent security audits at each layer.
|
|
122
|
+
|
|
123
|
+
### F4.3 General Protections
|
|
124
|
+
|
|
125
|
+
- **Rule**: All external links/callback URLs must be validated against a whitelist to prevent Open Redirect.
|
|
126
|
+
- **Rule**: File uploads must validate type (whitelist), size, and content magic bytes.
|
|
127
|
+
- **Rule**: Passwords must use bcrypt/argon2 hashing. Forbid plaintext, MD5, or SHA1.
|
|
128
|
+
- **Forbidden**: Exposing secrets, tokens, or passwords in error messages or logs.
|
|
129
|
+
- **Forbidden**: Returning internal implementation details in responses (stack traces, SQL statements, framework versions).
|
|
130
|
+
- **RATIONALE**: These are the most common security vulnerabilities. Not a question of "should we" — it's "you will be breached if you don't."
|
|
131
|
+
|
|
132
|
+
### F4.4 Rate Limiting
|
|
133
|
+
|
|
134
|
+
- **Rule**: All public API endpoints must have rate limiting. Forbid unlimited request rates.
|
|
135
|
+
- **Rule**: Rate limit tiers: authentication endpoints (5 req/min), general API (100 req/min per user/IP), internal/admin endpoints (higher limits).
|
|
136
|
+
- **Rule**: Rate limit headers: include X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset in responses.
|
|
137
|
+
- **Rule**: Rate limit exceeded returns 429 Too Many Requests with Retry-After header.
|
|
138
|
+
- **RATIONALE**: Without rate limiting, a single misbehaving client or a simple script-kiddie attack can take down your entire API.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## F5. Database
|
|
143
|
+
|
|
144
|
+
**Note**: These rules assume a relational database (PostgreSQL/MySQL). If the project uses MongoDB (selected in Q8), some rules (migration files, SELECT syntax) do not apply. Document-specific rules are in the derived rules section.
|
|
145
|
+
|
|
146
|
+
- **Rule**: Connection pool must be reasonably sized (default ≤ CPU cores × 2). Connections must have timeouts.
|
|
147
|
+
- **Rule**: All migration files must be versioned, reversible, and committed to the repository.
|
|
148
|
+
- **Rule**: Queries must use parameterized queries or ORM-provided safe methods. Forbid string-concatenated SQL.
|
|
149
|
+
- **Rule**: Bulk operations (>1000 rows) must be batched.
|
|
150
|
+
- **Forbidden**: Executing single-row SQL inside loops (use batch insert/update instead).
|
|
151
|
+
- **Forbidden**: SELECT without LIMIT.
|
|
152
|
+
- **Forbidden**: `SELECT *` (specify columns explicitly).
|
|
153
|
+
- **RATIONALE**: The database is the component where a single failure has the largest blast radius in a backend system. One bad query can bring down the entire service.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## F6. Observability
|
|
158
|
+
|
|
159
|
+
- **Rule**: Logs must be structured (JSON format), containing: `timestamp`, `level`, `message`, `traceId`, `userId`, `path`, `method`.
|
|
160
|
+
- **Rule**: Expose at least two endpoints: `GET /health` (liveness) and `GET /health/ready` (readiness).
|
|
161
|
+
- **Rule**: Key business operations must be instrumented (registration, login, payment, order creation, etc.).
|
|
162
|
+
- **Forbidden**: Using `console.log` as a substitute for structured logging.
|
|
163
|
+
- **RATIONALE**: A microservice without structured logging is a black box. Troubleshooting goes from minutes to hours.
|
|
164
|
+
|
|
165
|
+
### F6.2 Distributed Tracing
|
|
166
|
+
|
|
167
|
+
- **Rule**: Every incoming request must generate or propagate a traceId. traceId is passed in X-Trace-Id header.
|
|
168
|
+
- **Rule**: All downstream calls (database, cache, message queue, external APIs) must carry the traceId.
|
|
169
|
+
- **Rule**: Use W3C Trace Context standard (traceparent header) for cross-service propagation.
|
|
170
|
+
- **Forbidden**: Generating a new traceId mid-request chain (breaks distributed traces).
|
|
171
|
+
- **RATIONALE**: traceId is the thread that ties together every log line and span for a single request across microservices. Without it, troubleshooting distributed systems is guesswork.
|
|
172
|
+
|
|
173
|
+
### F6.3 Health Check Endpoints
|
|
174
|
+
|
|
175
|
+
- **Rule**: GET /health (liveness) — returns 200 if the process is alive. No dependency checks.
|
|
176
|
+
- **Rule**: GET /health/ready (readiness) — returns 200 if all critical dependencies are available (database, cache, message queue). Returns 503 if any critical dependency is unreachable.
|
|
177
|
+
- **Rule**: Health checks must be lightweight (< 50ms). Forbid running expensive queries or external API calls.
|
|
178
|
+
- **RATIONALE**: Kubernetes and load balancers use these endpoints to decide whether to route traffic or restart the pod. A slow /health creates cascading failures.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## F7. Configuration Management
|
|
183
|
+
|
|
184
|
+
- **Rule**: Configuration has three tiers — code defaults < environment variables < config files (by priority).
|
|
185
|
+
- **Forbidden**: Committing any secrets, tokens, or passwords to Git.
|
|
186
|
+
- **Rule**: All environment-specific config (database connections, Redis addresses, third-party API keys) injected via environment variables.
|
|
187
|
+
- **Rule**: Must have a `.env.example` file listing all required environment variables with descriptions (use placeholders for values).
|
|
188
|
+
- **RATIONALE**: Separating config from code is a 12-Factor App principle and a security baseline.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## F8. Async & Message Queues
|
|
193
|
+
|
|
194
|
+
- **Rule**: Message handlers must be idempotent — replaying the same message produces no side effects.
|
|
195
|
+
- **Rule**: Async tasks must have timeout handling, retry strategy (exponential backoff), and dead letter queues.
|
|
196
|
+
- **Rule**: Message bodies must contain a unique id (for deduplication) and traceId (for tracing).
|
|
197
|
+
- **Rule**: Retry count and interval must have upper limits (e.g., max 3 retries, intervals 1s/5s/15s).
|
|
198
|
+
- **RATIONALE**: The biggest async system problem isn't "messages got lost" — it's "messages got processed twice and double-charged the customer."
|
|
199
|
+
|
|
200
|
+
### F8.4 Message Delivery Semantics
|
|
201
|
+
|
|
202
|
+
- **Rule**: Explicitly document the delivery guarantee for each queue/topic: at-most-once, at-least-once, or exactly-once.
|
|
203
|
+
- **Rule**: At-least-once (default for most systems): consumers must be idempotent.
|
|
204
|
+
- **Rule**: Dead letter queues (DLQ) must be configured. Failed messages route to DLQ after max retries.
|
|
205
|
+
- **Rule**: DLQ messages must have a replay/inspect mechanism. Forbid silently discarding failed messages.
|
|
206
|
+
- **RATIONALE**: The difference between at-least-once and exactly-once is the difference between "customer charged once" and "customer charged twice."
|
|
207
|
+
|
|
208
|
+
### F8.5 Graceful Shutdown
|
|
209
|
+
|
|
210
|
+
- **Rule**: Application must handle SIGTERM gracefully: stop accepting new requests, finish in-progress requests (with timeout), close database connections, flush logs.
|
|
211
|
+
- **Rule**: Shutdown timeout must be configured (default 30s). Kubernetes terminationGracePeriodSeconds must exceed this.
|
|
212
|
+
- **Rule**: In-flight async tasks must complete or be re-queued before shutdown.
|
|
213
|
+
- **Forbidden**: Hard-exit on SIGTERM (SIGKILL should be the fallback, not the default).
|
|
214
|
+
- **RATIONALE**: Deployments and pod restarts should not cause failed requests or lost data. Graceful shutdown is a basic operational requirement.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## F9. Testing
|
|
219
|
+
|
|
220
|
+
- **Rule**: Testing has three tiers — unit tests (service layer), integration tests (API endpoints + database), E2E (critical business flows).
|
|
221
|
+
- **Rule**: External dependencies (database, Redis, third-party APIs) must be mocked in unit tests.
|
|
222
|
+
- **Rule**: Integration tests use a test database or testcontainers. Test data is cleaned before and after each run.
|
|
223
|
+
- **Rule**: Coverage baseline: service layer ≥ 80%, controller layer ≥ 60%.
|
|
224
|
+
- **Forbidden**: Tests sharing mutable state (global variables / shared database rows).
|
|
225
|
+
- **RATIONALE**: Backend regression risk is far higher than frontend (one data corruption is irreversible). Tests are the only safety net.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## F10. AI Vibecoding Baseline Constraints (project-agnostic, always active)
|
|
230
|
+
|
|
231
|
+
### F10.1 Search First
|
|
232
|
+
- **Rule**: Before generating a new module, AI must search existing code to check for similar functionality.
|
|
233
|
+
- **Rule**: Before writing SQL/migrations, AI must read existing migration files and schema.
|
|
234
|
+
|
|
235
|
+
### F10.2 Dependency Control
|
|
236
|
+
- **Rule**: AI must not modify `package.json` / `requirements.txt` / `go.mod` / `Cargo.toml` on its own.
|
|
237
|
+
- **Rule**: If a new dependency is truly needed, AI must list: package name, version, reason, alternative comparison.
|
|
238
|
+
|
|
239
|
+
### F10.3 Breaking Changes
|
|
240
|
+
- **Rule**: Before modifying a shared module/utility/API contract, AI must list all callers.
|
|
241
|
+
- **Rule**: Changing API response field names or types requires assessing frontend impact first.
|
|
242
|
+
|
|
243
|
+
### F10.4 Config Immutability
|
|
244
|
+
- **Rule**: AI must not modify environment variables, database connection config, docker-compose, or CI/CD configuration on its own.
|
|
245
|
+
- **Rule**: Adding a new environment variable in code must be accompanied by an update to `.env.example`.
|
|
246
|
+
|
|
247
|
+
### F10.5 SQL Safety
|
|
248
|
+
- **Rule**: All AI-written SQL must be parameterized queries.
|
|
249
|
+
- **Forbidden**: AI generating string-concatenated SQL code.
|
|
250
|
+
|
|
251
|
+
### F10.6 Migration Files
|
|
252
|
+
- **Rule**: AI generating a new migration must also produce the corresponding rollback migration.
|
|
253
|
+
- **Forbidden**: Dropping columns or changing types in migrations (add-only, unless a rollback plan exists).
|
|
254
|
+
|
|
255
|
+
### F10.7 Context Honesty
|
|
256
|
+
- **Rule**: When uncertain, AI must explicitly say "I'm not sure." Forbid inventing API paths, library versions, or database field names.
|
|
257
|
+
- **Rule**: AI must read the latest file contents before modifying. Forbid generating diffs based on guesswork.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Injection Instructions (for the AI executing this skill)
|
|
262
|
+
|
|
263
|
+
Each chapter in this file corresponds to a `{{ FIXED_RULES_* }}` placeholder in the template:
|
|
264
|
+
|
|
265
|
+
| Chapter | Inject Into Placeholder | Template Section |
|
|
266
|
+
|---------|------------------------|-------------------|
|
|
267
|
+
| F1 Project Structure | `{{ FIXED_RULES_STRUCTURE }}` | §1 Project Structure |
|
|
268
|
+
| F2 API Design | `{{ FIXED_RULES_API }}` | §2 API Design |
|
|
269
|
+
| F3 Error Handling | `{{ FIXED_RULES_ERROR }}` | §3 Error Handling |
|
|
270
|
+
| F4 Security | `{{ FIXED_RULES_SECURITY }}` | §4 Security (F4.1-F4.3 only; stop before F4.4) |
|
|
271
|
+
| F4.4 Rate Limiting | `{{ FIXED_RULES_RATE_LIMITING }}` | §4 Security (F4.4 only, injected separately) |
|
|
272
|
+
| F5 Database | `{{ FIXED_RULES_DATABASE }}` | §5 Database |
|
|
273
|
+
| F6 Observability | `{{ FIXED_RULES_OBSERVABILITY }}` | §6 Observability (F6 + F6.3 only; stop before F6.2) |
|
|
274
|
+
| F6.2 Distributed Tracing | `{{ FIXED_RULES_TRACING }}` | §6 Observability (F6.2 only, injected separately) |
|
|
275
|
+
| F7 Configuration | `{{ FIXED_RULES_CONFIG }}` | §7 Configuration |
|
|
276
|
+
| F8 Async & Queues | `{{ FIXED_RULES_ASYNC }}` | §8 Async & Queues |
|
|
277
|
+
| F8.4 Message Delivery | `{{ FIXED_RULES_MESSAGE_DELIVERY }}` | §8 Async & Queues |
|
|
278
|
+
| F8.5 Graceful Shutdown | `{{ FIXED_RULES_GRACEFUL_SHUTDOWN }}` | §8 Async & Queues |
|
|
279
|
+
| F9 Testing | `{{ FIXED_RULES_TEST }}` | §9 Testing |
|
|
280
|
+
| F10 AI Constraints | `{{ FIXED_RULES_AI_BASE }}` | §10 AI Behavior Constraints |
|
|
281
|
+
|
|
282
|
+
**Rendering rules**:
|
|
283
|
+
1. Copy each chapter's full body (including RATIONALE) directly into the corresponding placeholder.
|
|
284
|
+
2. RATIONALE must be preserved — it lets AI understand intent rather than follow mechanically.
|
|
285
|
+
3. Keep the original markdown list structure. Do not rewrite as prose paragraphs.
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Question Bank — Backend Interactive Question Bank
|
|
2
|
+
|
|
3
|
+
> This file is read on demand by SKILL.md in Phase 2. The AI must strictly follow the group order defined in this file, asking **one group at a time (1–3 questions)**, never dumping all questions at once.
|
|
4
|
+
> For every question, show the user: question number, question text, options, **recommended choice (marked "Recommended")**, and a one-line description.
|
|
5
|
+
> After each user response, immediately record the choice to internal state `answers[Qx] = ...` and proceed to the next group.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Asking Rules
|
|
10
|
+
|
|
11
|
+
1. **Group order**: G1 → G2 → G3 → G4 → G5 → G6 → G7 → G8 → G9. Do not skip.
|
|
12
|
+
2. **Shortcut commands** (respond immediately when user types these at any point):
|
|
13
|
+
- `recommended` / `default` → skip current group, adopt all recommended options
|
|
14
|
+
- `all recommended` / `one-click` → skip all remaining groups, adopt all recommended options
|
|
15
|
+
- `strict` / `strictest` → adopt the strictest option for the current group
|
|
16
|
+
- `skip` / `don't need this` → mark current group as N/A, note in output that "project does not require this yet"
|
|
17
|
+
- `custom: xxx` → record user's custom content, do not match against options
|
|
18
|
+
3. **Abbreviation recognition**: `A` / `a` / `1` all mean option A. `A,C` means multi-select (only for multi-select questions).
|
|
19
|
+
4. **Follow-up rule**: If the user gives an answer outside the options (e.g., "I use Astro"), first confirm whether to classify as an "other" branch of an existing option before continuing.
|
|
20
|
+
5. **Forbidden behaviors**:
|
|
21
|
+
- Must not make choices for the user before they explicitly answer.
|
|
22
|
+
- Must not fabricate user preferences to complete the answer set.
|
|
23
|
+
- Must not output more than 3 questions in a single message.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Group Overview
|
|
28
|
+
|
|
29
|
+
| Group | Topic | Questions | Count |
|
|
30
|
+
|-------|-------|-----------|-------|
|
|
31
|
+
| G1 | Language & Runtime | Q1–Q2 | 2 |
|
|
32
|
+
| G2 | Framework & Architecture | Q3–Q4 | 2 |
|
|
33
|
+
| G3 | API Style | Q5–Q6 | 2 |
|
|
34
|
+
| G4 | Data Layer | Q7–Q8 | 2 |
|
|
35
|
+
| G5 | Auth | Q9 | 1 |
|
|
36
|
+
| G6 | Infrastructure | Q10–Q12 | 3 |
|
|
37
|
+
| G7 | Testing & Quality | Q13–Q15 | 3 |
|
|
38
|
+
| G8 | Observability | Q16–Q17 | 2 |
|
|
39
|
+
| G9 | AI Constraints | Q18–Q20 | 3 |
|
|
40
|
+
|
|
41
|
+
Total: 20 questions.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## G1 — Language & Runtime
|
|
46
|
+
|
|
47
|
+
### Q1. Programming Language
|
|
48
|
+
- **Options**:
|
|
49
|
+
- A) TypeScript/Node.js **【Recommended: full-stack consistency】**
|
|
50
|
+
- B) Python
|
|
51
|
+
- C) Go
|
|
52
|
+
- D) Java
|
|
53
|
+
- E) Rust
|
|
54
|
+
- F) Custom
|
|
55
|
+
- **Note**: Determines subsequent framework recommendations, ORM choices, and code style rules. If Q1=Custom (option F), Q3 (Framework) and Q7 (ORM) are language-dependent sub-lists with no predefined options. For Custom, ask Q3 and Q7 as open-ended questions (user types framework/ORM name), or skip with user consent. Q14 (Test Framework) should also be asked as an open-ended question.
|
|
56
|
+
- **Maps to**: `{{ language }}` + `{{ tech_stack_rules }}`
|
|
57
|
+
|
|
58
|
+
### Q2. Runtime Version
|
|
59
|
+
- **Options**:
|
|
60
|
+
- A) Latest LTS **【Recommended】**
|
|
61
|
+
- B) Latest stable
|
|
62
|
+
- C) Specific version (please specify)
|
|
63
|
+
- **Note**: Locks the runtime version to avoid environment divergence issues.
|
|
64
|
+
- **Maps to**: `{{ runtime_version }}`
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## G2 — Framework & Architecture
|
|
69
|
+
|
|
70
|
+
### Q3. Web Framework
|
|
71
|
+
- **Options (varies by Q1)**:
|
|
72
|
+
- For Node.js: A) Express **【Recommended】** — B) Nest.js — C) Fastify — D) Hono — E) Koa
|
|
73
|
+
- For Python: A) FastAPI **【Recommended】** — B) Django + DRF — C) Flask — D) Litestar
|
|
74
|
+
- For Go: A) Gin **【Recommended】** — B) Echo — C) Chi — D) Fiber — E) Standard library net/http
|
|
75
|
+
- For Java: A) Spring Boot **【Recommended】** — B) Quarkus — C) Micronaut
|
|
76
|
+
- For Rust: A) Actix Web — B) Axum **【Recommended】** — C) Rocket
|
|
77
|
+
- **Note**: Determines routing registration, middleware mechanism, and DI conventions.
|
|
78
|
+
- **Maps to**: `{{ framework }}` + `{{ tech_stack_rules }}`
|
|
79
|
+
|
|
80
|
+
### Q4. Architecture Pattern
|
|
81
|
+
- **Options**:
|
|
82
|
+
- A) Classic three-tier (Controller → Service → Repository) **【Recommended】**
|
|
83
|
+
- B) Domain-Driven Design (Handler → Usecase → Repository)
|
|
84
|
+
- C) Clean Architecture (Ports & Adapters)
|
|
85
|
+
- D) Simple MVC (no over-engineering, small projects)
|
|
86
|
+
- **Note**: Determines directory structure and module boundary rules. Small projects don't need DDD.
|
|
87
|
+
- **Maps to**: `{{ architecture }}` + `{{ arch_rules }}`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## G3 — API Style
|
|
92
|
+
|
|
93
|
+
### Q5. API Style
|
|
94
|
+
- **Options**:
|
|
95
|
+
- A) RESTful **【Recommended】**
|
|
96
|
+
- B) GraphQL
|
|
97
|
+
- C) gRPC (microservice-to-microservice)
|
|
98
|
+
- D) REST + gRPC hybrid
|
|
99
|
+
- **Note**: Determines which API design rules are injected.
|
|
100
|
+
- **Maps to**: `{{ api_style }}` + `{{ api_rules }}`
|
|
101
|
+
|
|
102
|
+
### Q6. API Documentation
|
|
103
|
+
- **Conditional logic**: If Q5 = GraphQL, auto-select B and skip Q6. If Q5 = gRPC, auto-select C and skip Q6. If Q5 = REST + gRPC hybrid, ask but note that REST endpoints default to A. Only ask Q6 directly when Q5 = RESTful.
|
|
104
|
+
- **Options**:
|
|
105
|
+
- A) OpenAPI/Swagger auto-generated **【Recommended for REST projects】**
|
|
106
|
+
- B) GraphQL Schema (self-documenting) — auto-selected when Q5 = GraphQL
|
|
107
|
+
- C) Protobuf (self-documenting) — auto-selected when Q5 = gRPC
|
|
108
|
+
- D) Hand-written Markdown
|
|
109
|
+
- **Note**: Choosing A auto-injects "forbid hand-written API docs" rule.
|
|
110
|
+
- **Maps to**: `{{ api_docs }}`
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## G4 — Data Layer
|
|
115
|
+
|
|
116
|
+
### Q7. ORM / Data Access
|
|
117
|
+
- **Options (varies by Q1)**:
|
|
118
|
+
- For Node.js: A) Prisma **【Recommended】** — B) TypeORM — C) Drizzle ORM — D) Knex — E) Raw SQL
|
|
119
|
+
- For Python: A) SQLAlchemy **【Recommended】** — B) Django ORM — C) Prisma Client Python — D) Raw SQL
|
|
120
|
+
- For Go: A) GORM — B) sqlc **【Recommended】** — C) sqlx — D) Raw SQL
|
|
121
|
+
- For Java: A) JPA/Hibernate — B) MyBatis — C) jOOQ **【Recommended】**
|
|
122
|
+
- For Rust: A) Diesel — B) sqlx **【Recommended】** — C) SeaORM
|
|
123
|
+
- **Note**: Determines N+1 prevention, query standards, and migration strategy rules.
|
|
124
|
+
- **Maps to**: `{{ orm }}` + `{{ data_rules }}`
|
|
125
|
+
|
|
126
|
+
### Q8. Database
|
|
127
|
+
- **Options**:
|
|
128
|
+
- A) PostgreSQL **【Recommended】**
|
|
129
|
+
- B) MySQL
|
|
130
|
+
- C) MongoDB
|
|
131
|
+
- D) SQLite (development/small projects only)
|
|
132
|
+
- **Note**: Determines database-specific rules (column types, index syntax, migration tools).
|
|
133
|
+
- **Maps to**: `{{ database }}`
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## G5 — Auth
|
|
138
|
+
|
|
139
|
+
### Q9. Authentication Scheme
|
|
140
|
+
- **Options**:
|
|
141
|
+
- A) JWT (stateless, suitable for APIs/microservices) **【Recommended】**
|
|
142
|
+
- B) OAuth2 + OIDC (third-party login/SSO)
|
|
143
|
+
- C) Session + Cookie (traditional web apps)
|
|
144
|
+
- D) API Key (service-to-service)
|
|
145
|
+
- **Note**: Determines middleware selection and token management rules.
|
|
146
|
+
- **Maps to**: `{{ auth_scheme }}` + `{{ auth_rules }}`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## G6 — Infrastructure
|
|
151
|
+
|
|
152
|
+
### Q10. Caching
|
|
153
|
+
- **Options**:
|
|
154
|
+
- A) Redis **【Recommended】**
|
|
155
|
+
- B) Memcached
|
|
156
|
+
- C) In-memory cache (single instance only)
|
|
157
|
+
- D) No caching needed
|
|
158
|
+
- **Note**: Determines cache key conventions, expiry strategy, and penetration/avalanche protection rules.
|
|
159
|
+
- **Maps to**: `{{ cache }}` + `{{ cache_rules }}`
|
|
160
|
+
|
|
161
|
+
### Q11. Message Queue
|
|
162
|
+
- **Options**:
|
|
163
|
+
- A) RabbitMQ
|
|
164
|
+
- B) Kafka **【Recommended: high-throughput/event sourcing】**
|
|
165
|
+
- C) Redis Stream/BullMQ (lightweight task queues)
|
|
166
|
+
- D) No message queue needed
|
|
167
|
+
- **Note**: Determines async processing, idempotency, and retry strategy rules. B is the default recommendation for most projects. Choose C only for lightweight task needs.
|
|
168
|
+
- **Maps to**: `{{ mq }}` + `{{ mq_rules }}`
|
|
169
|
+
|
|
170
|
+
### Q12. Containerization & Deployment
|
|
171
|
+
- **Options**:
|
|
172
|
+
- A) Docker + Docker Compose **【Recommended】**
|
|
173
|
+
- B) Kubernetes
|
|
174
|
+
- C) No containerization (direct deployment)
|
|
175
|
+
- **Note**: Determines Dockerfile standards, health check, and environment variable management rules.
|
|
176
|
+
- **Maps to**: `{{ container }}` + `{{ deploy_rules }}`
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## G7 — Testing & Quality
|
|
181
|
+
|
|
182
|
+
### Q13. Test Coverage Requirements
|
|
183
|
+
- **Options**:
|
|
184
|
+
- A) Unit tests + Integration tests **【Recommended】**
|
|
185
|
+
- B) Unit tests only
|
|
186
|
+
- C) Critical path integration tests only
|
|
187
|
+
- D) Not required yet
|
|
188
|
+
- **Note**: Determines test tier rules and coverage thresholds.
|
|
189
|
+
- **Maps to**: `{{ test_requirement }}` + `{{ test_rules }}`
|
|
190
|
+
|
|
191
|
+
### Q14. Test Framework (only ask if Q13 ≠ D)
|
|
192
|
+
- **Options (varies by Q1)**:
|
|
193
|
+
- For Node.js: A) Vitest — B) Jest **【Recommended】**
|
|
194
|
+
- For Python: A) pytest **【Recommended】** — B) unittest
|
|
195
|
+
- For Go: A) Standard library testing **【Recommended】** — B) testify
|
|
196
|
+
- For Java: A) JUnit 5 + Mockito **【Recommended】** — B) TestNG
|
|
197
|
+
- For Rust: A) Built-in test **【Recommended】** — B) proptest
|
|
198
|
+
- **Maps to**: `{{ test_framework }}`
|
|
199
|
+
|
|
200
|
+
### Q15. Mock Strategy
|
|
201
|
+
- **Options**:
|
|
202
|
+
- A) Mock all external deps, use testcontainers or in-memory DB for database **【Recommended】**
|
|
203
|
+
- B) Mock all external deps including database
|
|
204
|
+
- C) Use real environments as much as possible, minimal mocking
|
|
205
|
+
- **Note**: Determines test isolation level and CI dependencies.
|
|
206
|
+
- **Maps to**: `{{ mock_strategy }}` + `{{ test_rules }}`
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## G8 — Observability
|
|
211
|
+
|
|
212
|
+
### Q16. Logging
|
|
213
|
+
- **Options**:
|
|
214
|
+
- A) Structured JSON logging + centralized collection (ELK/Loki) **【Recommended】**
|
|
215
|
+
- B) Structured logging + local files
|
|
216
|
+
- C) Simple text logs, good enough
|
|
217
|
+
- **Note**: Determines log format and field specifications.
|
|
218
|
+
- **Maps to**: `{{ logging }}` + `{{ observability_rules }}`
|
|
219
|
+
|
|
220
|
+
### Q17. Monitoring & Tracing
|
|
221
|
+
- **Options**:
|
|
222
|
+
- A) OpenTelemetry + Prometheus + Grafana **【Recommended】**
|
|
223
|
+
- B) Health check endpoints + system monitoring only
|
|
224
|
+
- C) Not needed yet
|
|
225
|
+
- **Note**: Determines instrumentation and alerting rules.
|
|
226
|
+
- **Maps to**: `{{ monitoring }}` + `{{ observability_rules }}`
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## G9 — AI Constraints
|
|
231
|
+
|
|
232
|
+
### Q18. AI Permission to Add Dependencies
|
|
233
|
+
- **Options**:
|
|
234
|
+
- A) Forbid AI from adding dependencies on its own; must undergo human review **【Recommended】**
|
|
235
|
+
- B) Allowed, but must declare reason in PR description
|
|
236
|
+
- C) Fully allowed
|
|
237
|
+
- **Maps to**: `{{ ai_dependency_rule }}`
|
|
238
|
+
|
|
239
|
+
### Q19. AI Modifying Shared Modules
|
|
240
|
+
- **Options**:
|
|
241
|
+
- A) Must list all callers and impact analysis first **【Recommended】**
|
|
242
|
+
- B) Not required
|
|
243
|
+
- **Maps to**: `{{ ai_breaking_change_rule }}`
|
|
244
|
+
|
|
245
|
+
### Q20. AI Modifying Configuration & Environment Variables
|
|
246
|
+
- **Options**:
|
|
247
|
+
- A) Forbid modification; must be done manually **【Recommended】**
|
|
248
|
+
- B) Allowed to modify, but must sync `.env.example`
|
|
249
|
+
- **Maps to**: `{{ ai_config_rule }}`
|