@ryuenn3123/agentic-senior-core 3.0.17 → 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 (85) hide show
  1. package/.agent-context/prompts/bootstrap-design.md +84 -94
  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 +438 -335
  48. package/lib/cli/project-scaffolder/discovery.mjs +36 -82
  49. package/lib/cli/project-scaffolder/prompt-builders.mjs +55 -63
  50. package/lib/cli/project-scaffolder/storage.mjs +0 -4
  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 +57 -36
  59. package/scripts/llm-judge.mjs +1 -1
  60. package/scripts/mcp-server/constants.mjs +60 -0
  61. package/scripts/mcp-server/tool-registry.mjs +149 -0
  62. package/scripts/mcp-server/tools.mjs +446 -0
  63. package/scripts/mcp-server.mjs +23 -661
  64. package/scripts/release-gate/audit-checks.mjs +426 -0
  65. package/scripts/release-gate/constants.mjs +53 -0
  66. package/scripts/release-gate/runtime.mjs +63 -0
  67. package/scripts/release-gate/static-checks.mjs +182 -0
  68. package/scripts/release-gate.mjs +13 -794
  69. package/scripts/rules-guardian-audit.mjs +14 -13
  70. package/scripts/single-source-lazy-loading-audit.mjs +3 -3
  71. package/scripts/sync-thin-adapters.mjs +5 -5
  72. package/scripts/ui-design-judge/constants.mjs +24 -0
  73. package/scripts/ui-design-judge/design-execution-summary.mjs +259 -0
  74. package/scripts/ui-design-judge/git-input.mjs +131 -0
  75. package/scripts/ui-design-judge/prompting.mjs +73 -0
  76. package/scripts/ui-design-judge/providers.mjs +102 -0
  77. package/scripts/ui-design-judge/reporting.mjs +182 -0
  78. package/scripts/ui-design-judge/rubric-calibration.mjs +214 -0
  79. package/scripts/ui-design-judge/rubric-goldset.json +188 -0
  80. package/scripts/ui-design-judge.mjs +166 -771
  81. package/scripts/ui-rubric-calibration.mjs +35 -0
  82. package/scripts/validate/config.mjs +198 -55
  83. package/scripts/validate/coverage-checks.mjs +32 -7
  84. package/scripts/validate.mjs +8 -4
  85. package/lib/cli/architect.mjs +0 -431
@@ -1,119 +1,66 @@
1
- # Frontend Architecture & Composition Patterns
2
-
3
- > A complex UI is built from simple, mathematically robust functions. State is dangerous; isolate it.
4
-
5
- ## 0. Frontend Designer Mode (Auto Activation)
6
- When the user request is UI-facing, frontend design governance activates automatically. No manual mode toggle is required.
7
-
8
- UI scope trigger signals (any one is enough):
9
- - keywords such as: ui, ux, page, screen, component, layout, landing, dashboard, form, onboarding, animation, interaction
10
- - explicit requests to improve visual quality, conversion clarity, or interaction behavior
11
- - feature requests that include frontend deliverables even when backend changes are also included
12
-
13
- Mandatory behavior when triggered:
14
- - apply consolidated review checks from `.agent-context/review-checklists/pr-checklist.md`
15
- - apply structural checks from `.agent-context/review-checklists/architecture-review.md`
16
- - score and review generated UI work against visual intent, interaction quality, and conversion clarity
17
- - reject template-only repetitive outputs and force a distinct layout direction
18
- - treat prior website memory or old-project visual carryover as invalid evidence unless the user explicitly requests continuity with that exact system
19
- - do not flatten ambitious visual or motion ideas by default; keep them when they are optimized, intentional, and accessible
20
- - let current repo evidence, the active brief, current project docs, and explicitly approved reference systems outrank remembered style residue every time
21
-
22
- ## Context Hygiene and Reference Boundaries (Mandatory)
23
-
24
- - Valid visual-context sources are limited to the current repo evidence, the current user brief, current project docs, and explicitly approved reference systems.
25
- - Design continuity is opt-in. If the user does not request continuity with a prior visual system, synthesize from the current project context instead.
26
- - Old project screenshots, remembered website styles, and cross-chat visual residue are tainted context unless the user explicitly authorizes them.
27
- - When repo evidence and memory residue conflict, repo evidence wins.
28
- - If a reference system is approved, adapt its reasoning and constraints. Do not copy its surface 1:1.
29
-
30
- ## Accessibility Split (Mandatory)
31
-
32
- - Treat WCAG 2.2 AA as the hard compliance floor for release-blocking accessibility issues.
33
- - Treat APCA as an advisory readability model for perceptual tuning, especially for typography, dark mode, and nuanced contrast review.
34
- - Advisory APCA findings must never waive a WCAG hard failure.
35
- - Hard accessibility checks must cover more than contrast alone. They must include focus visibility, focus appearance, target size, keyboard access, use-of-color-only failures, accessible authentication, and status or dynamic state access.
36
- - Keep accessibility compatible with expressive design. Fix the violation without flattening the interface into generic low-risk layouts unless that is the only safe option.
37
-
38
- ## Hybrid Visual QA Boundaries (Mandatory)
39
-
40
- - Visual QA must be deterministic-first. Run screenshot or pixel-diff style checks before escalating to any semantic judge.
41
- - Treat dynamic masking as explicit policy, not ad hoc cleanup. Time, randomized content, live counters, streaming media, and other unstable regions must be masked deliberately and documented.
42
- - Define stability thresholds so the system can separate tiny rendering noise from meaningful layout or styling drift.
43
- - Required visual coverage must include mobile, tablet, and desktop unless the product scope explicitly excludes one of those surfaces.
44
- - Escalate to semantic review only when deterministic evidence shows meaningful drift, missing required viewport coverage, or another contract-critical visual failure.
45
- - Do not use semantic review to invent aesthetic problems when deterministic evidence says the surface is stable.
46
-
47
- ## UI Consistency Guardrails (Mandatory)
48
-
49
- - Content language must stay consistent per screen and flow unless user requests multilingual output.
50
- - Text color must remain contrast-safe against its background; no color collisions.
51
- - Layout must avoid overlap, clipped text, and misaligned key actions across breakpoints.
52
- - Responsive quality requires layout mutation and task reprioritization across breakpoints. Shrinking the desktop layout is not enough.
53
- - Keep spacing and positioning token-driven so repeated outputs stay stable.
54
- - Distinctive visual direction is allowed. Originality is a quality signal when hierarchy, task clarity, and accessibility still hold.
55
- - Motion is allowed to be expressive. Judge it by clarity, reduced-motion safety, and rendering cost, not by how restrained it looks.
56
- - Prefer transform and opacity for rich motion. Treat layout-thrashing animation, uncontrolled autoplay, and heavy continuous effects as optimization problems to solve, not reasons to remove personality from the UI entirely.
57
-
58
- ## 1. File Structure (Feature-Driven Design)
59
- Organize your application by feature domain, not by file type.
60
- - **BANNED:** Monolithic directories like `/components` (with 500 files), `/hooks`, `/api`.
61
- - **REQUIRED (Feature Sliced):**
62
- ```
63
- src/
64
- features/
65
- authentication/
66
- api/ #(login, logout fetchers)
67
- components/ #(LoginForm, ProfileView)
68
- hooks/ #(useAuth, useSession)
69
- store.ts #(Zustand slice)
70
- types.ts #(Zod schemas)
71
- components/ #(Global shared UI like Button, Modal)
72
- lib/ #(Axios instance, utility wrappers)
73
- ```
74
-
75
- ## 2. Separation of State and UI (Smart vs. Dumb)
76
- - **Dumb Components (Presentational):** Receive data via `props`, emit events via callbacks (`onAction`). They do not know about the network, global context, or databases.
77
- - **Smart Components (Containers):** Connect to global state (Redux/Zustand), fetch data (React Query), and pass it down.
78
- - **Rule:** An intricate UI layout component should NEVER contain a `fetch` or `useQuery` call.
79
-
80
- ## 3. Server State vs. Client State
81
- Modern frontend frameworks differentiate between remote and local data.
82
- - **Server State (Async, Cached):** Data belonging to the database. MUST be managed by tools like `TanStack Query` (React Query) or `SWR`.
83
- - **Client State (Sync, Ephemeral):** UI toggles, modal states, form drafts. Manage via `useState`, `useContext`, or `Zustand`.
84
- - **BANNED:** Storing API responses in a global Redux/Zustand store (e.g., `dispatch(setUsers(data))`). Use React Query instead.
85
-
86
- ## 4. The Composition Pattern (Avoiding Prop Drilling)
87
- If a component takes more than 5 props, or if props are passed down through 3+ intermediate components, the architecture is broken.
88
- - **BANNED:** `<Layout user={user} theme={theme} onLogout={handleLogout} />`
89
- - **REQUIRED:** Use React's `children` prop and composition.
90
- ```tsx
91
- // ✅ Clean composition
92
- <Layout>
93
- <Sidebar user={user} />
94
- <Content onLogout={handleLogout} />
95
- </Layout>
96
- ```
97
-
98
- ## 5. Explicit Component Contracts (Typing)
99
- Every component **MUST** have an explicit, exported interface for its props.
100
- - **BANNED:** `const Button = (props: any) => ...`
101
- - **REQUIRED:** Prefix handlers with `on` and booleans with `is/has`.
102
- ```typescript
103
- export interface ButtonProps {
104
- variant: 'primary' | 'secondary';
105
- isLoading?: boolean;
106
- onClick: () => void;
107
- children: React.ReactNode;
108
- }
109
- ```
110
-
111
- ## 6. Form Handling & Validation
112
- Never write manual state bindings for complex forms.
113
- - **Rule:** All forms MUST use a robust library (`react-hook-form` is the standard) combined with a schema validator (`Zod`).
114
- - **BANNED:** Creating 5 `useState` variables for 5 input fields.
115
-
116
- ## 7. Performance & Re-renders
117
- React is fast until you break it.
118
- - **Rule:** Do not pass newly instantiated objects or arrow functions directly into dependency arrays (`useEffect`) or memoized components (`React.memo`) unless wrapped in `useMemo`/`useCallback`.
119
- - **Rule:** Never execute expensive mapping/filtering inside the render path blindly without memoization.
1
+ # Frontend Design and Interaction Boundaries
2
+
3
+ UI work must load the smallest relevant surface, not the entire engineering handbook.
4
+
5
+ ## Auto Activation
6
+ When the request is UI-facing, this rule activates automatically.
7
+
8
+ UI scope triggers:
9
+ - ui, ux, page, screen, component, layout, landing, dashboard, form, onboarding, animation, interaction
10
+ - redesign, reskin, visual refresh, responsive fix, hierarchy fix
11
+ - frontend deliverables even when the task also touches backend code
12
+
13
+ ## What This Rule Is For
14
+ Use this file to enforce:
15
+ - anti-generic layout and morphology boundaries
16
+ - responsive mutation requirements
17
+ - accessibility floor for expressive UI
18
+ - source hygiene for visual decisions
19
+ - lightweight implementation boundaries that keep UI code from collapsing into framework defaults
20
+
21
+ Do not use this file to teach generic frontend basics the model already knows.
22
+
23
+ ## Source Hygiene and Source Boundaries
24
+
25
+ - Valid style context is limited to current repo evidence, the active brief, and current project docs.
26
+ - This rule guides the LLM; it must not choose the final style, framework, palette, typography, layout paradigm, or animation library offline.
27
+ - Design continuity is opt-in. If the user does not request continuity, synthesize from the current product context instead of remembered layouts.
28
+ - Repo evidence outranks memory residue every time.
29
+ - External references are tainted by default. If the user supplies one, convert only explicit constraints into the current contract and do not compare against or imitate the source surface.
30
+ - If a new UI, animation, styling, or component library is needed, research current official docs and choose the latest stable compatible option for the project.
31
+
32
+ ## Accessibility Split
33
+
34
+ - Treat WCAG 2.2 AA as the hard compliance floor.
35
+ - Treat APCA as advisory perceptual tuning only.
36
+ - Hard checks must include focus visibility, focus appearance, target size, keyboard access, accessible authentication, use-of-color-only failures, and dynamic status/state access.
37
+ - Fix the violation without flattening the interface into generic safe chrome unless that is the only safe option.
38
+
39
+ ## Anti-Generic UI Boundaries
40
+
41
+ - Do not default to interchangeable dashboard chrome, balanced card grids, centered marketing shells, or generic component-kit surfaces unless the product explicitly needs them.
42
+ - Do not let repeated surfaces share the same visual treatment by habit. Repetition is allowed only when the contract explains the product reason.
43
+ - Do not use default framework button and input treatment as the final UI language.
44
+ - Do not let heading, body, and data/meta roles collapse into one safe typographic family without explicit rationale.
45
+ - At least one visual, interaction, content, motion, or state behavior must read as project-specific at a glance.
46
+
47
+ ## Responsive Mutation Requirements
48
+
49
+ - Responsive quality is not allowed to be scale-only. At least one surface must materially change position, grouping, priority, or disclosure strategy between mobile and desktop.
50
+ - Mobile must prioritize the first decisive action, not preserve desktop balance out of habit.
51
+ - Tablet must simplify simultaneous surfaces without becoming a shrunken desktop.
52
+ - Desktop may expose more context, but it must not become an interchangeable admin shell by default.
53
+
54
+ ## Surface and Morphology Requirements
55
+
56
+ - Define the primary user task or reading path from current evidence before arranging surfaces.
57
+ - Supporting surfaces must earn their placement through role, priority, or behavior. They must not feel like cloned modules.
58
+ - Component states must preserve identity under hover, focus, loading, success, empty, and error. Do not let everything collapse into anonymous rounded panels.
59
+ - Motion may be expressive, but it must strengthen hierarchy, feedback, or memorability while staying reduced-motion-safe and performant.
60
+
61
+ ## Implementation Boundaries
62
+
63
+ - Follow the shipped project stack and current repo patterns before inventing state-management or data-fetching rules.
64
+ - Do not hardcode Zustand, React Query, smart/dumb component doctrine, or any framework-specific architecture as universal frontend law in baseline design governance.
65
+ - If the repo already uses a runtime pattern, stay consistent with it. If it does not, choose the lightest modern fit for the task and document why.
66
+ - Keep structure feature-oriented and avoid giant catch-all UI buckets when the repo does not explicitly require them.
@@ -26,7 +26,7 @@
26
26
 
27
27
  ### Rules
28
28
  1. **Type is mandatory.** No commits without a type prefix.
29
- 2. **Scope is recommended.** Use the module/feature name.
29
+ 2. **Scope is required for module or feature changes.** Use the module/feature name.
30
30
  3. **Description is imperative mood.** "add", not "added" or "adds".
31
31
  4. **Max 72 characters** for the subject line.
32
32
  5. **Body explains WHY,** not what. The diff shows what.
@@ -1,174 +1,41 @@
1
- # Microservices When to Split, How to Split
1
+ # Service Boundary Rule
2
2
 
3
- > Don't start with microservices. Earn them through pain.
4
- > A bad monolith becomes a distributed bad monolith faster than you think.
3
+ Do not ask for or force "monolith vs microservices" as an init default. Do not start with microservices by fashion, fear, or habit. The agent must infer the right topology from the user brief, repo evidence, team/runtime constraints, and live official docs when technology choices matter.
5
4
 
6
- ## The Default: Modular Monolith
5
+ ## Monolith Boundary
7
6
 
8
- **Start with a modular monolith. Always.** Microservices are a scaling strategy, not a design philosophy.
7
+ Use a single deployable system when:
9
8
 
10
- A well-structured modular monolith can handle most applications indefinitely. Splitting prematurely creates distributed complexity without distributed benefits.
9
+ - one team or one delivery stream owns most changes
10
+ - feature boundaries can stay clear inside one repo/process
11
+ - synchronous data consistency is more valuable than distributed autonomy
12
+ - observability, CI/CD, and operational maturity are still forming
11
13
 
12
- ---
14
+ Hard rules:
13
15
 
14
- ## The Split Decision Framework
16
+ - Keep feature/domain boundaries explicit.
17
+ - Do not let one giant shared module become the real architecture.
18
+ - Keep contracts clear between modules.
19
+ - Refactor toward cleaner seams before extracting services.
15
20
 
16
- ### Prerequisites (ALL Must Be True)
21
+ ## Service Split Boundary
17
22
 
18
- Before even considering microservices, these must exist:
23
+ Split a service only when current evidence justifies the operational cost.
19
24
 
20
- 1. **Mature CI/CD pipeline** — automated testing, deployment, rollback
21
- 2. **Observability in place** — distributed tracing, centralized logging, metrics
22
- 3. **Team maturity** — team understands distributed systems failure modes
23
- 4. **Clear module boundaries** — modules already communicate through interfaces, not internals
25
+ Valid split signals:
24
26
 
25
- If any prerequisite is missing, **stop.** Fix the monolith first.
27
+ - independent deploy cadence is already painful
28
+ - one domain has materially different scale, latency, security, or compliance needs
29
+ - ownership boundaries are stable and repeated coupling is causing delivery risk
30
+ - failure isolation is a real product or business requirement
31
+ - the service contract and data ownership can be documented before extraction
26
32
 
27
- ### Trigger Conditions (2+ Required)
33
+ Hard rules:
28
34
 
29
- Split a module into a service ONLY when **2 or more** of these triggers exist:
35
+ - Each service owns its data boundary.
36
+ - Public service contracts must be documented before implementation or extraction.
37
+ - Cross-service calls need timeout, retry, idempotency, observability, and recovery behavior.
38
+ - Avoid synchronous call chains that turn services into a distributed monolith.
39
+ - Prefer incremental extraction over rewrites.
30
40
 
31
- | # | Trigger | Evidence |
32
- |---|---------|----------|
33
- | 1 | **Deploy conflicts** | Teams block each other on releases; merge queues exceed 24h |
34
- | 2 | **Scale mismatch** | One module needs 50-100x resources of another |
35
- | 3 | **Team ownership collision** | Multiple teams edit the same module weekly |
36
- | 4 | **Fault isolation** | One module crashing must not kill the entire system |
37
- | 5 | **Technology divergence** | Module genuinely requires a different runtime/language |
38
- | 6 | **Compliance boundary** | Regulatory requirement to isolate data processing (PCI, HIPAA) |
39
-
40
- ```
41
- BANNED: "Let's use microservices because Netflix does"
42
- BANNED: "We might need to scale later"
43
- BANNED: "It's more modern"
44
- BANNED: "Each developer gets their own service"
45
- ```
46
-
47
- ---
48
-
49
- ## How to Split (The Extraction Protocol)
50
-
51
- ### Step 1: Identify the Seam
52
-
53
- Find the natural boundary in your modular monolith:
54
- ```
55
- GOOD seams:
56
- - Module communicates with others through a defined interface/API
57
- - Module has its own database tables with no foreign keys to other modules
58
- - Module can be deployed independently without breaking others
59
-
60
- BAD seams:
61
- - Two modules share a database table
62
- - Extracting requires duplicating business logic
63
- - Module makes 10+ synchronous calls to other modules per request
64
- ```
65
-
66
- ### Step 2: Strangle, Don't Rewrite
67
-
68
- ```
69
- ❌ BANNED: "Let's rewrite everything as microservices"
70
-
71
- ✅ REQUIRED: The Strangler Fig Pattern
72
- 1. Build the new service alongside the monolith
73
- 2. Route traffic to the new service gradually (feature flags, proxy rules)
74
- 3. Verify the new service handles all cases correctly
75
- 4. Remove the old code from the monolith
76
- 5. Repeat for the next service, ONE AT A TIME
77
- ```
78
-
79
- ### Step 3: Define the Contract
80
-
81
- Before extracting, define the communication contract:
82
-
83
- ```
84
- REQUIRED for every service boundary:
85
- - API contract (OpenAPI 3.1, Protobuf, or AsyncAPI for events)
86
- - Versioning strategy (URL versioning, header versioning)
87
- - Error contract (standardized error response format)
88
- - SLA definition (latency, availability, throughput)
89
- - Ownership (which team owns this service)
90
- ```
91
-
92
- ---
93
-
94
- ## Communication Patterns
95
-
96
- ### Synchronous (Request-Response)
97
-
98
- | Pattern | When | Watch Out |
99
- |---------|------|-----------|
100
- | REST/HTTP | Standard CRUD operations | Cascading failures, tight coupling |
101
- | gRPC | High-performance, internal services | Schema evolution, debugging complexity |
102
-
103
- **Rules:**
104
- - Always set timeouts (connection: 1s, request: 5s default)
105
- - Implement circuit breakers (fail-fast after N failures)
106
- - Never chain more than 3 synchronous calls
107
- - Implement retries with exponential backoff (transient errors only)
108
-
109
- ### Asynchronous (Events)
110
-
111
- | Pattern | When | Watch Out |
112
- |---------|------|-----------|
113
- | Pub/Sub | One event, multiple consumers | Message ordering, at-least-once delivery |
114
- | Command Queue | Exactly-once processing needed | Dead letter queues, poison messages |
115
- | Event Sourcing | Full audit trail required | Complexity, event schema evolution |
116
-
117
- **Rules:**
118
- - Prefer async communication over sync between services
119
- - Events are facts (past tense): `OrderPlaced`, `PaymentProcessed`
120
- - Commands are requests (imperative): `ProcessPayment`, `ShipOrder`
121
- - Always handle duplicate messages (idempotency)
122
-
123
- ---
124
-
125
- ## Data Ownership
126
-
127
- ### The Database-Per-Service Rule
128
-
129
- ```
130
- ❌ DEATH PENALTY: Shared databases between services
131
- Service A → Database ← Service B
132
- // One schema change breaks both services
133
-
134
- ✅ REQUIRED: Each service owns its data
135
- Service A → Database A
136
- Service B → Database B
137
- // Services communicate through APIs or events
138
- ```
139
-
140
- ### Data Consistency
141
-
142
- - **Accept eventual consistency** — strong consistency across services is extremely expensive
143
- - **Use the Saga pattern** for distributed transactions (choreography or orchestration)
144
- - **Never use distributed 2PC (two-phase commit)** in production — it doesn't scale
145
-
146
- ---
147
-
148
- ## Anti-Patterns (Instant Rejection)
149
-
150
- | Anti-Pattern | Why It's Dangerous |
151
- |-------------|-------------------|
152
- | **Distributed Monolith** | Services that must be deployed together defeat the purpose |
153
- | **Nano-services** | One function per service creates operational nightmare |
154
- | **Shared libraries with logic** | Tight coupling through shared code |
155
- | **Synchronous chains** | A→B→C→D means one failure kills everything |
156
- | **Shared database** | Schema changes break multiple services |
157
- | **"We'll figure out observability later"** | You won't find bugs without tracing. Ever. |
158
-
159
- ---
160
-
161
- ## The Microservices Readiness Checklist
162
-
163
- Before splitting ANY module:
164
-
165
- - [ ] 2+ trigger conditions met (documented with evidence)
166
- - [ ] All prerequisites in place (CI/CD, observability, team maturity)
167
- - [ ] Service boundary defined with clear ownership
168
- - [ ] API contract defined (OpenAPI, Protobuf, AsyncAPI)
169
- - [ ] Data ownership clear — no shared tables
170
- - [ ] Communication pattern chosen (sync vs async)
171
- - [ ] Failure handling designed (timeouts, circuit breakers, retries)
172
- - [ ] Monitoring and alerting planned
173
- - [ ] Rollback strategy defined
174
- - [ ] Team agrees this is the right decision (not just the architect)
41
+ If the evidence is unclear, document the uncertainty and keep the topology agent-recommended instead of pretending an offline default is correct.
@@ -1,141 +1,11 @@
1
- # Naming Conventions — The "No Lazy Names" Standard
1
+ # Naming Boundary
2
2
 
3
- > If your variable name needs a comment to explain it, the name is wrong.
3
+ Use the target language and framework conventions. Do not invent a naming style from this repo.
4
4
 
5
- ## Universal Rules (All Languages)
5
+ Reject only these common LLM bad habits:
6
+ - vague names that hide meaning, such as `data`, `result`, `item`, `thing`, `temp`, `handle`, or `process` when a precise domain name exists
7
+ - names that require reading the implementation to understand the value
8
+ - mixed file or directory naming styles inside the same feature without a framework reason
9
+ - booleans, units, and side-effect functions whose names hide what they represent or change
6
10
 
7
- ### Variables: Nouns That Tell a Story
8
- ```
9
- ❌ BANNED ✅ REQUIRED
10
- ─────────────────────────────────────────────
11
- d durationInSeconds
12
- data userProfilePayload
13
- res httpResponse
14
- temp unsortedItems
15
- val discountPercentage
16
- info orderSummary
17
- item cartLineItem
18
- list activeSubscriptions
19
- obj paymentConfiguration
20
- ```
21
-
22
- **Rule:** A variable name must answer "WHAT is this?" without reading surrounding code.
23
-
24
- ### Functions: Verbs That Declare Intent
25
- ```
26
- ❌ BANNED ✅ REQUIRED
27
- ─────────────────────────────────────────────
28
- process() validatePaymentDetails()
29
- handle() routeIncomingWebhook()
30
- doStuff() calculateShippingCost()
31
- run() executeScheduledCleanup()
32
- getData() fetchActiveUsersByRegion()
33
- check() isEligibleForDiscount()
34
- ```
35
-
36
- **Rule:** A function name must answer "WHAT does this do?" as a verb phrase. Generic verbs like `process`, `handle`, `manage` are BANNED unless suffixed with a specific noun (e.g., `handlePaymentFailure`).
37
-
38
- ### Booleans: is/has/can/should Prefix
39
- ```
40
- ❌ BANNED ✅ REQUIRED
41
- ─────────────────────────────────────────────
42
- active isActive
43
- logged isLoggedIn
44
- admin hasAdminRole
45
- edit canEditDocument
46
- visible shouldRenderSidebar
47
- ```
48
-
49
- **Rule:** Boolean variables MUST use `is`, `has`, `can`, or `should` prefix. No exceptions.
50
-
51
- ### Constants: SCREAMING_SNAKE for True Constants
52
- ```
53
- ❌ BANNED ✅ REQUIRED
54
- ─────────────────────────────────────────────
55
- maxRetries = 3 MAX_RETRY_COUNT = 3
56
- timeout = 5000 REQUEST_TIMEOUT_MS = 5000
57
- apiUrl = "..." API_BASE_URL = "..."
58
- ```
59
-
60
- **Rule:** Use SCREAMING_SNAKE_CASE for compile-time constants and config values. Include the unit in the name when applicable (`_MS`, `_BYTES`, `_COUNT`).
61
-
62
- ### Single-Letter Variables
63
- **BANNED.** With exactly ONE exception:
64
-
65
- ```
66
- // ALLOWED: Classic loop counter in simple iterations
67
- for (let i = 0; i < items.length; i++) { ... }
68
-
69
- // BANNED: Everything else
70
- const x = getPrice(); // ❌ What is x?
71
- const n = users.length; // ❌ Use userCount
72
- arr.map(v => v.id); // ❌ Use user => user.id
73
- ```
74
-
75
- ---
76
-
77
- ## File & Directory Naming
78
-
79
- ### Files
80
- | Type | Convention | Example |
81
- |------|-----------|---------|
82
- | Component (React/Vue) | PascalCase | `PaymentForm.tsx` |
83
- | Module/Service | camelCase or kebab-case | `paymentService.ts` or `payment-service.ts` |
84
- | Utility | camelCase or kebab-case | `formatCurrency.ts` or `format-currency.ts` |
85
- | Test | Same as source + `.test`/`.spec` | `paymentService.test.ts` |
86
- | Type/Interface | PascalCase | `PaymentTypes.ts` |
87
- | Constant file | SCREAMING_SNAKE or kebab-case | `constants.ts` or `api-endpoints.ts` |
88
- | Config | kebab-case | `database-config.ts` |
89
-
90
- **Rule:** Pick ONE convention per project and enforce it everywhere. Mixing `camelCase` and `kebab-case` in the same project is a code smell.
91
-
92
- ### Directories
93
- - Always `kebab-case`: `user-management/`, `payment-processing/`
94
- - Never PascalCase for directories (except component folders in React convention)
95
- - No abbreviations: `auth/` → `authentication/` (unless universally understood like `api/`, `db/`)
96
-
97
- ---
98
-
99
- ## Abbreviation Policy
100
-
101
- ### Allowed (Universal)
102
- `id`, `url`, `api`, `db`, `http`, `io`, `ui`, `dto`, `config`, `env`, `auth`, `admin`, `src`, `lib`, `pkg`, `cmd`, `ctx`, `err`, `req`, `res` (in HTTP handler context only)
103
-
104
- ### Banned
105
- Everything else. Spell it out:
106
- ```
107
- ❌ usr → ✅ user
108
- ❌ cnt → ✅ count
109
- ❌ mgr → ✅ manager
110
- ❌ btn → ✅ button
111
- ❌ msg → ✅ message
112
- ❌ impl → ✅ implementation
113
- ❌ calc → ✅ calculate
114
- ❌ proc → ✅ process
115
- ```
116
-
117
- ---
118
-
119
- ## The Naming Decision Tree
120
-
121
- ```
122
- Is it a boolean?
123
- → Yes → Add is/has/can/should prefix
124
- → No ↓
125
-
126
- Is it a function?
127
- → Yes → Start with a verb (fetch, create, validate, calculate, is, has)
128
- → No ↓
129
-
130
- Is it a constant?
131
- → Yes → SCREAMING_SNAKE_CASE with unit suffix
132
- → No ↓
133
-
134
- Is it a class/type/interface?
135
- → Yes → PascalCase, noun, no prefix (not IUser, not UserInterface)
136
- → No ↓
137
-
138
- It's a variable
139
- → Descriptive noun, camelCase
140
- → Must be understandable without context
141
- ```
11
+ Prefer names that explain domain intent, user action, state, and boundary responsibility.