@ryuenn3123/agentic-senior-core 3.0.19 → 3.0.20

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 (77) hide show
  1. package/.agent-context/prompts/bootstrap-design.md +84 -103
  2. package/.agent-context/prompts/init-project.md +32 -100
  3. package/.agent-context/prompts/refactor.md +22 -44
  4. package/.agent-context/prompts/review-code.md +28 -52
  5. package/.agent-context/review-checklists/architecture-review.md +31 -62
  6. package/.agent-context/review-checklists/pr-checklist.md +74 -108
  7. package/.agent-context/rules/api-docs.md +18 -206
  8. package/.agent-context/rules/architecture.md +40 -207
  9. package/.agent-context/rules/database-design.md +10 -199
  10. package/.agent-context/rules/docker-runtime.md +5 -5
  11. package/.agent-context/rules/efficiency-vs-hype.md +11 -149
  12. package/.agent-context/rules/error-handling.md +9 -231
  13. package/.agent-context/rules/event-driven.md +17 -221
  14. package/.agent-context/rules/frontend-architecture.md +66 -119
  15. package/.agent-context/rules/git-workflow.md +1 -1
  16. package/.agent-context/rules/microservices.md +28 -161
  17. package/.agent-context/rules/naming-conv.md +8 -138
  18. package/.agent-context/rules/performance.md +9 -175
  19. package/.agent-context/rules/realtime.md +11 -44
  20. package/.agent-context/rules/security.md +11 -295
  21. package/.agent-context/rules/testing.md +9 -174
  22. package/.agent-context/state/benchmark-analysis.json +3 -3
  23. package/.agent-context/state/memory-continuity-benchmark.json +1 -1
  24. package/.agent-context/state/onboarding-report.json +71 -11
  25. package/.agents/workflows/init-project.md +7 -24
  26. package/.agents/workflows/refactor.md +7 -24
  27. package/.agents/workflows/review-code.md +7 -24
  28. package/.cursorrules +22 -21
  29. package/.gemini/instructions.md +2 -2
  30. package/.github/copilot-instructions.md +2 -2
  31. package/.instructions.md +112 -213
  32. package/.windsurfrules +22 -21
  33. package/AGENTS.md +4 -4
  34. package/CONTRIBUTING.md +13 -22
  35. package/README.md +6 -20
  36. package/lib/cli/commands/init.mjs +102 -148
  37. package/lib/cli/commands/launch.mjs +3 -3
  38. package/lib/cli/commands/optimize.mjs +14 -4
  39. package/lib/cli/commands/upgrade.mjs +25 -23
  40. package/lib/cli/compiler.mjs +96 -62
  41. package/lib/cli/constants.mjs +28 -136
  42. package/lib/cli/detector/design-evidence.mjs +189 -6
  43. package/lib/cli/detector.mjs +6 -7
  44. package/lib/cli/init-detection-flow.mjs +10 -93
  45. package/lib/cli/init-selection.mjs +2 -68
  46. package/lib/cli/project-scaffolder/constants.mjs +1 -1
  47. package/lib/cli/project-scaffolder/design-contract.mjs +162 -108
  48. package/lib/cli/project-scaffolder/discovery.mjs +36 -82
  49. package/lib/cli/project-scaffolder/prompt-builders.mjs +41 -55
  50. package/lib/cli/project-scaffolder/storage.mjs +0 -2
  51. package/lib/cli/token-optimization.mjs +1 -1
  52. package/lib/cli/utils.mjs +75 -9
  53. package/package.json +2 -2
  54. package/scripts/detection-benchmark.mjs +4 -15
  55. package/scripts/documentation-boundary-audit.mjs +9 -9
  56. package/scripts/explain-on-demand-audit.mjs +11 -11
  57. package/scripts/forbidden-content-check.mjs +9 -9
  58. package/scripts/frontend-usability-audit.mjs +45 -35
  59. package/scripts/llm-judge.mjs +1 -1
  60. package/scripts/mcp-server/constants.mjs +2 -2
  61. package/scripts/mcp-server/tool-registry.mjs +1 -1
  62. package/scripts/release-gate/audit-checks.mjs +4 -4
  63. package/scripts/release-gate/static-checks.mjs +5 -5
  64. package/scripts/release-gate.mjs +1 -1
  65. package/scripts/rules-guardian-audit.mjs +14 -13
  66. package/scripts/single-source-lazy-loading-audit.mjs +3 -3
  67. package/scripts/sync-thin-adapters.mjs +5 -5
  68. package/scripts/ui-design-judge/design-execution-summary.mjs +27 -1
  69. package/scripts/ui-design-judge/prompting.mjs +4 -4
  70. package/scripts/ui-design-judge/reporting.mjs +2 -1
  71. package/scripts/ui-design-judge/rubric-calibration.mjs +8 -5
  72. package/scripts/ui-design-judge/rubric-goldset.json +2 -2
  73. package/scripts/ui-design-judge.mjs +70 -6
  74. package/scripts/validate/config.mjs +138 -48
  75. package/scripts/validate/coverage-checks.mjs +32 -7
  76. package/scripts/validate.mjs +8 -4
  77. package/lib/cli/architect.mjs +0 -431
@@ -1,76 +1,45 @@
1
1
  # Architecture Review Checklist
2
2
 
3
- > Run this when reviewing module structure, new feature design, or refactoring.
4
- > Bad architecture is invisible until it becomes unmaintainable.
3
+ Use this when module structure, feature shape, public contracts, topology, or refactoring are in scope.
5
4
 
6
- ## Instructions for Agent
5
+ ## Boundary Review
7
6
 
8
- Evaluate every item against the current project structure. For each violation, explain:
9
- 1. What layer or boundary is broken
10
- 2. Why it leads to maintenance or scalability problems
11
- 3. The correct architectural pattern to apply
7
+ - [ ] The changed code has clear transport, application, domain, and infrastructure boundaries where those layers exist.
8
+ - [ ] Business policy is not hidden in transport handlers, UI adapters, database queries, framework glue, or generated code.
9
+ - [ ] Internal models do not leak across public API, event, CLI, library, or UI contracts without a deliberate mapping.
10
+ - [ ] Modules import through public entrypoints instead of deep internal paths.
11
+ - [ ] Circular dependencies are absent or explicitly removed.
12
12
 
13
- ---
14
-
15
- ## Layer Separation
16
-
17
- - [ ] **Controllers/Handlers contain NO business logic** — Only parsing input, calling service, formatting response
18
- - [ ] **Services contain NO HTTP concepts** — No `Request`, `Response`, `HttpStatus` imports
19
- - [ ] **Services contain NO raw SQL or direct DB access** — Use repository/DAO layer
20
- - [ ] **Repositories contain NO business rules** — Only CRUD and query operations
21
- - [ ] **Domain entities have NO framework dependencies** — Pure language types only
22
- - [ ] **Dependencies flow inward** — Transport → Service → Repository → Domain (never reverse)
23
-
24
- ## Module Boundaries
25
-
26
- - [ ] **Modules don't import from each other's internal files** — Only public exports
27
- - [ ] **No circular dependencies between modules** — A → B → A is forbidden
28
- - [ ] **Each module has a clear single responsibility** — Not a "kitchen sink" module
29
- - [ ] **Shared code is genuinely shared** — Not domain-specific code disguised as "common"
30
- - [ ] **Module size is reasonable** — If a module has 20+ files, consider splitting
13
+ ## Structure Review
31
14
 
32
15
  ## Backend Universal Principles
33
16
 
34
- - [ ] **No clever hacks in backend and shared core modules** — Prefer explicit flow over language tricks that hide intent
35
- - [ ] **No premature abstraction** Introduce shared abstractions only after repeated, stable patterns emerge
36
- - [ ] **Readability over brevity** Prefer clear multi-line logic over compressed one-liners
37
-
38
- ## Dependency Management
39
-
40
- - [ ] **No God classes** No class/file with 500+ lines or 10+ dependencies
41
- - [ ] **Constructor injection only** — No service locator, no field injection, no global state
42
- - [ ] **Interfaces defined where consumed** — Not in the implementation module
43
- - [ ] **External services abstracted behind interfaces** — Swappable, testable
44
- - [ ] **Configuration injected, not hardcoded** — No magic strings for URLs, ports, keys
45
-
46
- ## Data Flow
47
-
48
- - [ ] **DTOs at boundaries** — Internal models don't leak to external interfaces
49
- - [ ] **Validation at entry points** — Zod / Pydantic / Bean Validation at transport layer
50
- - [ ] **No raw request objects passed deep** — Transform to domain types ASAP
51
- - [ ] **Response transformation explicit** — Dedicated serializers / resources / mappers
52
- - [ ] **Sensitive data excluded from responses** — Passwords, tokens, internal IDs
17
+ - [ ] No clever hacks in backend and shared core modules
18
+ - [ ] No premature abstraction (base classes/util layers created only after repeated stable patterns)
19
+ - [ ] Readability over brevity for maintainability
20
+ - [ ] The project structure follows existing repo conventions unless a change was approved.
21
+ - [ ] New structure is feature/domain-oriented when that improves discoverability.
22
+ - [ ] Large files or modules are split around real responsibilities, not arbitrary layers.
23
+ - [ ] Shared code is genuinely shared and not domain-specific behavior disguised as utility.
24
+ - [ ] Names describe product meaning, not generic plumbing.
53
25
 
54
- ## Database Design
26
+ ## Topology Review
55
27
 
56
- - [ ] **Migrations are incremental** No destructive changes without migration plan
57
- - [ ] **Foreign keys for data integrity** Relations enforced at DB level
58
- - [ ] **Indexes for query patterns** Not just primary keys
59
- - [ ] **No business logic in DB** Triggers and stored procs used sparingly
60
- - [ ] **Soft delete considered** — For audit-sensitive entities
28
+ - [ ] Monolith remains acceptable when boundaries, team size, consistency needs, and operations favor one deployable.
29
+ - [ ] Service extraction is backed by current evidence: ownership, scaling, compliance, fault isolation, or deploy cadence.
30
+ - [ ] Service boundaries define ownership, contract, data boundary, observability, timeouts, retry, and recovery behavior.
31
+ - [ ] Event or realtime architecture is justified by product need, not trend pressure.
61
32
 
62
- ## Error Architecture
33
+ ## Contract Review
63
34
 
64
- - [ ] **Error hierarchy defined** Base error class with domain-specific subtypes
65
- - [ ] **Global error handler exists** Catches unhandled errors, returns safe responses
66
- - [ ] **Error codes are typed** Enum or const, not arbitrary strings
67
- - [ ] **Client errors vs server errors distinguished** 4xx vs 5xx with different handling
68
- - [ ] **Errors don't leak internals** — No stack traces, SQL errors, or file paths to client
35
+ - [ ] API, event, CLI, library, data, and UI contracts are documented before or alongside implementation.
36
+ - [ ] Schema and validation strategy matches the project’s chosen runtime and official docs.
37
+ - [ ] Error contracts are safe, stable, and do not leak internals.
38
+ - [ ] Migration and rollback plans exist for risky data or public contract changes.
69
39
 
70
- ## Scalability Readiness
40
+ ## Operational Review
71
41
 
72
- - [ ] **Stateless services** No in-memory session or request state across requests
73
- - [ ] **Background jobs for heavy work** Long operations don't block HTTP responses
74
- - [ ] **Idempotent endpoints where needed** POST with idempotency keys for payment/creation
75
- - [ ] **Feature flags for gradual rollout** New features can be toggled without deploy
76
- - [ ] **Health check endpoint exists** — `/health` returning service status
42
+ - [ ] Critical flows have tests at the right level.
43
+ - [ ] Observability, logging, and health checks match the project’s runtime and risk level.
44
+ - [ ] Security assumptions are documented and enforced at trust boundaries.
45
+ - [ ] Performance-sensitive paths avoid avoidable repeated work, unbounded lists, and hidden blocking operations.
@@ -1,138 +1,104 @@
1
- # PR Checklist The Quality Gate
1
+ # PR Checklist - Quality Gate
2
2
 
3
- > Run this before declaring any task "done."
4
- > If ANY item fails, the task is NOT complete.
3
+ Run this before declaring a task done. Apply only the sections relevant to the changed scope, but do not skip correctness, security, testing, or docs checks when the change touches them.
5
4
 
6
- ## Instructions for Agent
5
+ ## 1. Repo Context
7
6
 
8
- When asked to review code using this checklist, evaluate EVERY item below.
9
- For each failed item, provide a Reasoning Chain (see `.cursorrules` Reasoning Clause).
10
- Output format:
7
+ - [ ] The agent read `AGENTS.md` and the smallest relevant rule set.
8
+ - [ ] Existing project context came from real files, docs, package metadata, and changed code, not folder name alone.
9
+ - [ ] Runtime, framework, library, topology, and design choices are explicit user constraints or agent recommendations from current evidence.
10
+ - [ ] No offline default stack, blueprint, vendor, or visual style was treated as authoritative.
11
11
 
12
- ```
13
- ## PR REVIEW RESULTS
14
- ━━━━━━━━━━━━━━━━━━━
12
+ ## 2. Correctness
15
13
 
16
- PASS [Item]
17
- FAIL [Item]
18
- Rule: [rule file + section]
19
- Problem: [specific issue found]
20
- Fix: [what to change]
14
+ - [ ] The changed behavior matches the user request.
15
+ - [ ] Existing behavior is preserved unless the user approved a behavior change.
16
+ - [ ] Edge cases, empty states, error paths, and rollback/recovery paths are handled.
17
+ - [ ] Public contracts remain stable or are versioned and documented.
21
18
 
22
- VERDICT: PASS / FAIL (X/Y items passed)
23
- ```
19
+ ## 3. Architecture
24
20
 
25
- ---
21
+ ### 2. Architecture (→ rules/architecture.md)
26
22
 
27
- ## The Checklist
23
+ - [ ] Layer and module boundaries are clear for the project’s chosen structure.
24
+ - [ ] No clever hacks in backend and shared core modules
25
+ - [ ] No premature abstraction (base classes/util layers created only after repeated stable patterns)
26
+ - [ ] Readability over brevity for maintainability
27
+ - [ ] Code is grouped by feature/domain where that improves maintainability.
28
+ - [ ] Cross-module access uses public contracts instead of internal file reach-through.
29
+ - [ ] Files above roughly 1000 lines were split or explicitly justified.
30
+ - [ ] Monolith/service split decisions are evidence-backed, not fashion-driven.
28
31
 
29
- ### 1. Naming (→ rules/naming-conv.md)
30
- - [ ] All variables are descriptive nouns (no `data`, `temp`, `val`, `x`)
31
- - [ ] All functions start with a verb (no `userData()`, `orderLogic()`)
32
- - [ ] All booleans use `is/has/can/should` prefix
33
- - [ ] Constants use SCREAMING_SNAKE_CASE with unit suffix
34
- - [ ] No single-letter variables (except `i` in classic for-loops)
35
- - [ ] File names follow the project's chosen convention consistently
32
+ ## 4. Security And Privacy
36
33
 
37
- ### 2. Architecture (→ rules/architecture.md)
38
- - [ ] No layer leaks (controllers don't query DB, services don't return HTTP responses)
39
- - [ ] Feature-based file organization (not technical grouping)
40
- - [ ] Dependencies flow inward (transport service repository)
41
- - [ ] Module boundaries respected (no reaching into another module's internals)
42
- - [ ] Domain layer has zero external dependencies
43
- - [ ] No clever hacks in backend and shared core modules (prefer explicit control flow)
44
- - [ ] No premature abstraction (base classes/util layers created only after repeated stable patterns)
45
- - [ ] Readability over brevity for maintainability (no compressed one-liners that hide intent)
46
-
47
- ### 3. Type Safety (→ dynamic TypeScript stack guidance)
48
- - [ ] No `any` type anywhere (use `unknown` + narrowing)
49
- - [ ] No `// @ts-ignore` (use `@ts-expect-error` with justification comment)
50
- - [ ] All function return types are explicit
51
- - [ ] Zod schemas validate ALL external input at boundaries
52
- - [ ] Types derived from Zod schemas (single source of truth)
53
-
54
- ### 4. Error Handling (→ rules/error-handling.md)
55
- - [ ] No empty catch blocks
56
- - [ ] No `catch(e) { console.log(e) }` without re-throw or recovery
57
- - [ ] Typed error classes used (not generic `new Error('...')`)
58
- - [ ] Error responses don't leak internal details to clients
59
- - [ ] Structured logging with context (traceId, userId, action)
60
-
61
- ### 5. Security (→ rules/security.md)
62
- - [ ] All user input validated at boundaries (Zod/schema)
63
- - [ ] No SQL/command string concatenation with user input
64
- - [ ] No secrets hardcoded in source code
65
- - [ ] Auth checked server-side (not client-side only)
66
- - [ ] Error messages don't reveal internal system details
67
- - [ ] CORS configured (not `*` in production)
68
-
69
- ### 6. Performance (→ rules/performance.md)
70
- - [ ] No N+1 queries (no queries inside loops)
71
- - [ ] All list queries have LIMIT/pagination
72
- - [ ] No `SELECT *` (only needed columns)
73
- - [ ] No synchronous I/O in async context
74
- - [ ] Cache has documented invalidation strategy (if caching used)
75
-
76
- ### 7. Testing (→ rules/testing.md)
77
- - [ ] Business logic has unit tests
78
- - [ ] Test names follow `should [behavior] when [condition]`
79
- - [ ] Tests follow AAA pattern (Arrange → Act → Assert)
80
- - [ ] No implementation detail testing (test behavior, not structure)
81
- - [ ] Test data uses factories (no copy-pasted objects)
82
-
83
- ### 8. Dependencies (→ rules/efficiency-vs-hype.md)
84
- - [ ] No new dependencies added without justification
85
- - [ ] No dependency that replaces < 20 lines of code
86
- - [ ] New packages checked for maintenance health
87
- - [ ] Bundle impact considered (frontend)
88
-
89
- ### 9. Git (→ rules/git-workflow.md)
90
- - [ ] Commit messages follow Conventional Commits
91
- - [ ] No `console.log` debugging statements
92
- - [ ] No `// TODO` without a linked issue
93
- - [ ] No commented-out code blocks
94
- - [ ] `.env` not committed
34
+ - [ ] External input is validated at trust boundaries using the project’s chosen validation approach.
35
+ - [ ] Secrets, tokens, credentials, and private data are not committed or logged.
36
+ - [ ] Authorization is enforced at a trusted boundary.
37
+ - [ ] Error responses and logs do not leak internals.
38
+ - [ ] Dependency or platform security claims are based on current official docs or repo evidence.
39
+
40
+ ## 5. Testing
41
+
42
+ - [ ] Changed behavior has appropriate tests at the smallest useful level.
43
+ - [ ] Tests assert behavior and contracts, not implementation trivia.
44
+ - [ ] Critical flows include failure-path coverage.
45
+ - [ ] Test fixtures are readable and do not hide the behavior under test.
46
+
47
+ ## 6. Docs And Contracts
95
48
 
96
49
  ### 10. Documentation
50
+
97
51
  - [ ] Scope applied: This applies to documentation, release notes, onboarding text, review summaries, and agent-facing explanations
98
52
  - [ ] Style scope review is advisory and does not block merge when API docs are synced in the same commit and contract details are correct
53
+ - [ ] Required docs exist before implementation: project brief, architecture decision, flow overview, API/public contract when relevant, data model when relevant, and UI design contract when relevant.
54
+ - [ ] Docs cover feature plan, architecture rationale, public contracts, data model, UI/design, security assumptions, testing strategy, delivery flow, and next validation actions where relevant.
55
+ - [ ] API, event, CLI, library, data, and UI contract changes update docs in the same scope.
99
56
  - [ ] Public surface changes fail review if documentation updates are missing or stale in the same scope
100
- - [ ] API endpoint/contract changes include synchronized API/OpenAPI documentation updates
101
- - [ ] Database structure changes include synchronized schema or migration documentation updates
102
57
  - [ ] Documentation checks stay boundary-aware and only enforce touched scopes
103
- - [ ] API endpoints have OpenAPI/Swagger documentation
104
- - [ ] Complex business logic has comments explaining WHY
105
- - [ ] Public functions/methods have JSDoc/docstrings
106
- - [ ] README updated if new setup steps required
58
+ - [ ] Facts, assumptions, and next actions are separated when context is incomplete.
107
59
  - [ ] No emoji in formal documentation or review summaries
108
60
  - [ ] Documentation uses plain English and avoids AI cliches
109
- - [ ] Performance/quality claims include source and timestamp
110
- - [ ] Acronyms are expanded on first use
111
- - [ ] Facts and assumptions are explicitly separated
61
+
62
+ ## 7. UI And Accessibility
63
+
64
+ - [ ] UI work follows `docs/DESIGN.md` and `docs/design-intent.json`.
65
+ - [ ] Visual direction is project-specific and not a template/default component-kit habit.
66
+ - [ ] Responsive behavior recomposes content and priority, not only shrinking desktop layout.
67
+ - [ ] Accessibility hard requirements are preserved: keyboard access, focus visibility, contrast, target size, status feedback, and no color-only meaning.
68
+ - [ ] Motion is purposeful, reduced-motion-safe, and justified by product value.
69
+
70
+ ## 8. Dependencies And Runtime
71
+
72
+ - [ ] New dependencies are justified by capability, maintenance health, bundle/runtime cost, and current official docs.
73
+ - [ ] Official setup flows are preferred when they produce better-supported current defaults.
74
+ - [ ] Docker, framework, package, and ecosystem claims were checked live when they could be stale.
75
+ - [ ] Token optimization and memory continuity defaults remain enabled unless the user explicitly opts out.
76
+
77
+ ## 9. State And Governance
112
78
 
113
79
  ### 11. Context-Triggered Audit Mode
80
+
114
81
  - [ ] Strict audit mode activates automatically on review and PR-intent workflows
115
82
  - [ ] Small edits avoid heavy checks by default unless strict mode is explicitly requested
116
83
  - [ ] User can always force strict audit mode manually
117
-
118
- ### 12. Rules as Guardian (Cross-Session Consistency)
119
- - [ ] Session handoff includes active architecture contract summary
120
- - [ ] Drift detection warns before direction changes
121
- - [ ] Direction changes require explicit user confirmation
122
-
123
- ### 13. Invisible State Management (Explain-on-Demand)
124
- - [ ] Default responses avoid unnecessary state-file internals
125
- - [ ] State internals are exposed only on explicit request
126
- - [ ] Diagnostic mode can explain relevant state decisions when needed
127
-
128
- ### 14. Single Source and Lazy Rule Loading
84
+ - [ ] Session handoff includes active architecture contract summary.
85
+ - [ ] Drift detection warns before direction changes.
86
+ - [ ] Direction changes require explicit user confirmation.
87
+ - [ ] Default responses avoid unnecessary state-file internals.
88
+ - [ ] State internals are exposed only on explicit request.
89
+ - [ ] Diagnostic mode can explain relevant state decisions when needed.
129
90
  - [ ] Canonical rule source is explicitly defined and enforced
130
91
  - [ ] Language-specific guidance is loaded lazily based on detected scope
131
92
  - [ ] No conflicting duplicate rule instructions during normal flow
93
+ - [ ] Canonical rule source is explicit and duplicate/conflicting instructions are avoided.
132
94
 
133
95
  ### 15. Universal SOP Consolidation
134
- - [ ] `.agent-context/rules/` remains the default guidance source for implementation and review
135
- - [ ] Backend and frontend mindset checks are both applied when scope spans API and UI boundaries
136
- - [ ] Security and testing requirements remain mandatory after static template purge
96
+
97
+ - [ ] `.agent-context/rules/` remains the default guidance source for implementation and review.
98
+ - [ ] Security and testing requirements remain mandatory after static template purge.
137
99
  - [ ] Coding flow is blocked if `docs/architecture-decision-record.md` (or `docs/Architecture-Decision-Record.md`) is missing
138
100
  - [ ] UI implementation flow is blocked if `docs/DESIGN.md` or `docs/design-intent.json` is missing
101
+
102
+ ## Verdict
103
+
104
+ Report findings first, ordered by severity, with file/line references and concrete fixes. If no findings exist, say that explicitly and name any residual risk.
@@ -1,29 +1,19 @@
1
- # API Documentation The "Invisible API" Rule
1
+ # API and Public Contract Boundary
2
2
 
3
- > An undocumented API is an unusable API.
4
- > If it's not in the spec, it doesn't exist.
5
-
6
- ## The Zero-Doc Death Penalty
7
-
8
- Every API endpoint MUST have machine-readable documentation that covers:
9
- 1. HTTP method + path
10
- 2. Request body schema with field descriptions and examples
11
- 3. All response codes with typed schemas
12
- 4. Authentication requirements
13
- 5. Rate limiting (if applicable)
3
+ ## Documentation as Hard Rule (Boundary-Aware)
14
4
 
15
- ```
16
- BANNED: An endpoint without a defined Request/Response schema.
17
- BANNED: Using generic `object` or `any` in documentation types.
18
- BANNED: "See code for details" as documentation.
19
- BANNED: Swagger UI with auto-generated summaries only (no descriptions, no examples).
5
+ If a change affects an API, CLI command, exported library behavior, schema, event, or integration contract, update the matching docs in the same change.
20
6
 
21
- REQUIRED: Every field MUST have a `description` and an `example` value.
22
- REQUIRED: Every error response MUST be documented (400, 401, 403, 404, 409, 500).
23
- REQUIRED: Documentation MUST be updated in the SAME commit as the endpoint change.
24
- ```
7
+ ## Contract Rules
25
8
 
26
- ---
9
+ - Document the public surface before or alongside implementation.
10
+ - Machine-readable API contracts should use the current project standard. If unresolved, the LLM must recommend a current maintained option from official docs.
11
+ - HTTP APIs should prefer OpenAPI 3.1 when no stronger project standard exists.
12
+ - Event APIs should define producer, consumer, payload, versioning, retry, and failure behavior.
13
+ - CLI/library public behavior must update README, help text, changelog, or docs as appropriate.
14
+ - Do not write "see code" as the contract.
15
+ - Do not expose generic `object` or `any` contract shapes when the boundary can be typed.
16
+ - Public error shapes must be safe, stable, and documented.
27
17
 
28
18
  ## Human Writing Standard (Mandatory)
29
19
 
@@ -31,6 +21,7 @@ This applies to documentation, release notes, onboarding text, review summaries,
31
21
  API docs and README updates are included in this scope.
32
22
 
33
23
  ### Style Baseline
24
+
34
25
  1. Write for native English speakers.
35
26
  2. Target an 8th-grade reading level.
36
27
  3. Use clear, direct, plain language.
@@ -39,6 +30,7 @@ API docs and README updates are included in this scope.
39
30
  6. State the main point first, then supporting detail.
40
31
 
41
32
  ### Required Behavior
33
+
42
34
  1. Explain decisions the way a competent coworker would explain them out loud.
43
35
  2. Cut unnecessary words and remove filler.
44
36
  3. Use concrete verbs and everyday phrasing.
@@ -46,206 +38,26 @@ API docs and README updates are included in this scope.
46
38
  5. Keep explanations short by default; expand only when complexity requires it.
47
39
 
48
40
  ### Scope Severity and Merge Behavior
41
+
49
42
  1. Scope style guidance controls readability and consistency.
50
43
  2. Style baseline findings are advisory by default and must not block endpoint-change commits that already include accurate docs/spec updates.
51
44
  3. Hard blockers remain contract failures: missing same-commit docs sync, incorrect schema, missing required responses, or factual inaccuracies.
52
45
  4. If style polish is still needed, open a follow-up task instead of delaying the contract update.
53
46
 
54
47
  ### Non-Negotiables
48
+
55
49
  1. No emoji in formal artifacts.
56
50
  2. Avoid AI cliches and buzzwords: delve, leverage, robust, utilize, seamless.
57
51
  3. Avoid inflated, academic, or performative language.
58
52
  4. Avoid padding, hedging, and redundant phrasing.
59
53
 
60
54
  ### Critical Controls
55
+
61
56
  1. Any claim about quality, performance, or reliability must include a measurable source and timestamp.
62
57
  2. Expand acronyms on first use, then use terms consistently.
63
58
  3. Separate facts from assumptions explicitly.
64
59
  4. End major explanations with a clear next action.
65
60
 
66
61
  ### Final Check
67
- Read the text out loud before shipping. If it sounds robotic, rewrite it.
68
62
 
69
- ---
70
-
71
- ## Documentation Format: OpenAPI 3.1 (Non-Negotiable)
72
-
73
- All APIs produce an OpenAPI 3.1 specification. Not 3.0, not proprietary formats, not "we'll add Swagger later."
74
-
75
- ### Why OpenAPI
76
- - Machine-readable: clients, tests, and mocks can be generated from the spec
77
- - Full JSON Schema Draft 2020-12 compatibility (3.1+ only)
78
- - Vendor-neutral: works with Scalar, Swagger UI, Redoc, Postman, Stoplight
79
- - Version-controllable: the spec is a file you can diff and review
80
-
81
- ---
82
-
83
- ## Tooling by Framework
84
-
85
- ### NestJS
86
- Use `@nestjs/swagger` with Scalar UI (not default Swagger UI — Scalar is faster and more readable).
87
-
88
- ```typescript
89
- // main.ts — Setup
90
- import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
91
- import { apiReference } from '@scalar/nestjs-api-reference';
92
-
93
- const config = new DocumentBuilder()
94
- .setTitle('Service Name')
95
- .setDescription('Brief service purpose')
96
- .setVersion('1.0')
97
- .addBearerAuth()
98
- .build();
99
-
100
- const document = SwaggerModule.createDocument(app, config);
101
-
102
- // Scalar UI at /docs
103
- app.use('/docs', apiReference({ spec: { content: document } }));
104
-
105
- // Raw spec at /api-json
106
- SwaggerModule.setup('api', app, document);
107
- ```
108
-
109
- Every controller method requires these decorators at minimum:
110
- ```typescript
111
- @ApiOperation({ summary: 'Create a user account' })
112
- @ApiBody({ type: CreateUserDto, description: 'User registration data' })
113
- @ApiResponse({ status: 201, type: UserResponseDto, description: 'User created successfully' })
114
- @ApiResponse({ status: 400, description: 'Validation error — invalid input fields' })
115
- @ApiResponse({ status: 409, description: 'Conflict — email already registered' })
116
- @Post()
117
- ```
118
-
119
- Every DTO property requires `@ApiProperty`:
120
- ```typescript
121
- export class CreateUserDto {
122
- @ApiProperty({
123
- description: 'User email address, must be unique across the system',
124
- example: 'jane.doe@example.com',
125
- })
126
- email: string;
127
-
128
- @ApiProperty({
129
- description: 'Display name shown in the UI',
130
- example: 'Jane Doe',
131
- minLength: 1,
132
- maxLength: 100,
133
- })
134
- name: string;
135
- }
136
- ```
137
-
138
- ### Next.js (App Router)
139
- Use `zod-to-openapi` or `next-swagger-doc` to generate OpenAPI from Zod schemas.
140
-
141
- ```typescript
142
- import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
143
- import { z } from 'zod';
144
-
145
- extendZodWithOpenApi(z);
146
-
147
- export const CreateUserSchema = z.object({
148
- email: z.string().email().openapi({
149
- description: 'User email address, must be unique',
150
- example: 'jane.doe@example.com',
151
- }),
152
- name: z.string().min(1).max(100).openapi({
153
- description: 'Display name shown in the UI',
154
- example: 'Jane Doe',
155
- }),
156
- }).openapi('CreateUserRequest');
157
- ```
158
-
159
- Expose the spec at `/api/docs` or `/api/openapi.json`.
160
-
161
- ### Other Frameworks (Express, Fastify, Hono)
162
- Use `swagger-jsdoc` + TSDoc comments, or `@asteasolutions/zod-to-openapi`.
163
- The output MUST be a valid OpenAPI 3.1 JSON/YAML file served at a known endpoint.
164
-
165
- ---
166
-
167
- ## Response Documentation Standard
168
-
169
- Every endpoint MUST document these response scenarios:
170
-
171
- | Status | When | Schema Required |
172
- |--------|------|----------------|
173
- | `200` | Successful retrieval or update | Yes — typed response body |
174
- | `201` | Successful creation | Yes — the created resource |
175
- | `204` | Successful deletion | No body |
176
- | `400` | Validation error | Yes — field-level error details |
177
- | `401` | Missing or invalid authentication | Fixed message, no details |
178
- | `403` | Authenticated but insufficient permissions | Fixed message |
179
- | `404` | Resource not found | Fixed message |
180
- | `409` | Conflict (duplicate resource) | Description of conflict |
181
- | `429` | Rate limit exceeded | Retry-After header |
182
- | `500` | Internal error | `{ traceId }` only — NO stack traces |
183
-
184
- ### Error Response Schema (Standardized)
185
- ```json
186
- {
187
- "error": {
188
- "code": "VALIDATION_ERROR",
189
- "message": "One or more fields are invalid",
190
- "details": [
191
- { "field": "email", "message": "Invalid email format" }
192
- ],
193
- "traceId": "req-abc-123"
194
- }
195
- }
196
- ```
197
-
198
- This schema MUST be documented in OpenAPI as a reusable component (`#/components/schemas/ErrorResponse`).
199
-
200
- ---
201
-
202
- ## Documentation Sync Rule
203
-
204
- ```
205
- Endpoint changed + docs NOT updated = PR REJECTED.
206
-
207
- This sync rule has higher priority than style polish timing.
208
- Do not delay same-commit documentation sync only to iterate writing tone.
209
-
210
- The spec is a contract. If the contract is wrong, consumers will break.
211
- "I'll update the docs later" means "the docs will never be updated."
212
- ```
213
-
214
- ## Documentation as Hard Rule (Boundary-Aware)
215
-
216
- Documentation checks are hard-blocking for contract accuracy, but scope-aware to avoid unnecessary overhead.
217
-
218
- ### Boundary Triggers
219
- 1. Public surface boundary: exported/public behavior changes in CLI, library, or runtime scripts.
220
- 2. API contract boundary: endpoint, route, controller, or OpenAPI contract changes.
221
- 3. Database structure boundary: schema, migration, repository contract, or persistence model changes.
222
-
223
- ### Boundary-Aware Enforcement
224
- 1. Only triggered boundaries require synchronized documentation updates.
225
- 2. Untouched boundaries are ignored during the same review run.
226
- 3. Missing docs for a triggered boundary is a blocking failure.
227
-
228
- ### Required Same-Scope Sync
229
- 1. Public surface changes must update user-facing docs (`README.md`, `CHANGELOG.md`, or `docs/*`).
230
- 2. API contract changes must update API/OpenAPI docs in the same scope.
231
- 3. Database structure changes must update schema/migration documentation in the same scope.
232
-
233
- ### Enforcement
234
- 1. API docs live next to the code (same module, same directory)
235
- 2. Docs update in the SAME commit as the endpoint change
236
- 3. CI can validate the spec: `openapi-generator validate -i openapi.json`
237
- 4. Generated clients (if any) must be regenerated after spec changes
238
-
239
- ---
240
-
241
- ## The Documentation Quality Test
242
-
243
- Open your API docs URL (`/docs`). For a randomly chosen endpoint, verify:
244
-
245
- 1. Can a developer who has never seen the codebase call this endpoint correctly? (Must be YES)
246
- 2. Are all required fields clearly marked? (Must be YES)
247
- 3. Does every field have a realistic example value? (Must be YES)
248
- 4. Are all error responses documented with their conditions? (Must be YES)
249
- 5. Can you copy the example request and it works? (Must be YES)
250
-
251
- If any answer is "no", the documentation is incomplete.
63
+ Read the text out loud before shipping. If it sounds robotic, rewrite it.