@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.
- package/.agent-context/prompts/bootstrap-design.md +84 -103
- package/.agent-context/prompts/init-project.md +32 -100
- package/.agent-context/prompts/refactor.md +22 -44
- package/.agent-context/prompts/review-code.md +28 -52
- package/.agent-context/review-checklists/architecture-review.md +31 -62
- package/.agent-context/review-checklists/pr-checklist.md +74 -108
- package/.agent-context/rules/api-docs.md +18 -206
- package/.agent-context/rules/architecture.md +40 -207
- package/.agent-context/rules/database-design.md +10 -199
- package/.agent-context/rules/docker-runtime.md +5 -5
- package/.agent-context/rules/efficiency-vs-hype.md +11 -149
- package/.agent-context/rules/error-handling.md +9 -231
- package/.agent-context/rules/event-driven.md +17 -221
- package/.agent-context/rules/frontend-architecture.md +66 -119
- package/.agent-context/rules/git-workflow.md +1 -1
- package/.agent-context/rules/microservices.md +28 -161
- package/.agent-context/rules/naming-conv.md +8 -138
- package/.agent-context/rules/performance.md +9 -175
- package/.agent-context/rules/realtime.md +11 -44
- package/.agent-context/rules/security.md +11 -295
- package/.agent-context/rules/testing.md +9 -174
- package/.agent-context/state/benchmark-analysis.json +3 -3
- package/.agent-context/state/memory-continuity-benchmark.json +1 -1
- package/.agent-context/state/onboarding-report.json +71 -11
- package/.agents/workflows/init-project.md +7 -24
- package/.agents/workflows/refactor.md +7 -24
- package/.agents/workflows/review-code.md +7 -24
- package/.cursorrules +22 -21
- package/.gemini/instructions.md +2 -2
- package/.github/copilot-instructions.md +2 -2
- package/.instructions.md +112 -213
- package/.windsurfrules +22 -21
- package/AGENTS.md +4 -4
- package/CONTRIBUTING.md +13 -22
- package/README.md +6 -20
- package/lib/cli/commands/init.mjs +102 -148
- package/lib/cli/commands/launch.mjs +3 -3
- package/lib/cli/commands/optimize.mjs +14 -4
- package/lib/cli/commands/upgrade.mjs +25 -23
- package/lib/cli/compiler.mjs +96 -62
- package/lib/cli/constants.mjs +28 -136
- package/lib/cli/detector/design-evidence.mjs +189 -6
- package/lib/cli/detector.mjs +6 -7
- package/lib/cli/init-detection-flow.mjs +10 -93
- package/lib/cli/init-selection.mjs +2 -68
- package/lib/cli/project-scaffolder/constants.mjs +1 -1
- package/lib/cli/project-scaffolder/design-contract.mjs +162 -108
- package/lib/cli/project-scaffolder/discovery.mjs +36 -82
- package/lib/cli/project-scaffolder/prompt-builders.mjs +41 -55
- package/lib/cli/project-scaffolder/storage.mjs +0 -2
- package/lib/cli/token-optimization.mjs +1 -1
- package/lib/cli/utils.mjs +75 -9
- package/package.json +2 -2
- package/scripts/detection-benchmark.mjs +4 -15
- package/scripts/documentation-boundary-audit.mjs +9 -9
- package/scripts/explain-on-demand-audit.mjs +11 -11
- package/scripts/forbidden-content-check.mjs +9 -9
- package/scripts/frontend-usability-audit.mjs +45 -35
- package/scripts/llm-judge.mjs +1 -1
- package/scripts/mcp-server/constants.mjs +2 -2
- package/scripts/mcp-server/tool-registry.mjs +1 -1
- package/scripts/release-gate/audit-checks.mjs +4 -4
- package/scripts/release-gate/static-checks.mjs +5 -5
- package/scripts/release-gate.mjs +1 -1
- package/scripts/rules-guardian-audit.mjs +14 -13
- package/scripts/single-source-lazy-loading-audit.mjs +3 -3
- package/scripts/sync-thin-adapters.mjs +5 -5
- package/scripts/ui-design-judge/design-execution-summary.mjs +27 -1
- package/scripts/ui-design-judge/prompting.mjs +4 -4
- package/scripts/ui-design-judge/reporting.mjs +2 -1
- package/scripts/ui-design-judge/rubric-calibration.mjs +8 -5
- package/scripts/ui-design-judge/rubric-goldset.json +2 -2
- package/scripts/ui-design-judge.mjs +70 -6
- package/scripts/validate/config.mjs +138 -48
- package/scripts/validate/coverage-checks.mjs +32 -7
- package/scripts/validate.mjs +8 -4
- package/lib/cli/architect.mjs +0 -431
|
@@ -1,119 +1,66 @@
|
|
|
1
|
-
# Frontend
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
When the
|
|
7
|
-
|
|
8
|
-
UI scope
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
- Do not
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
##
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
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
|
-
#
|
|
1
|
+
# Service Boundary Rule
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
5
|
+
## Monolith Boundary
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Use a single deployable system when:
|
|
9
8
|
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
+
## Service Split Boundary
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
Split a service only when current evidence justifies the operational cost.
|
|
19
24
|
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33
|
+
Hard rules:
|
|
28
34
|
|
|
29
|
-
|
|
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
|
-
|
|
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
|
|
1
|
+
# Naming Boundary
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use the target language and framework conventions. Do not invent a naming style from this repo.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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.
|