@ryuenn3123/agentic-senior-core 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/.agent-context/blueprints/api-nextjs.md +184 -0
  2. package/.agent-context/blueprints/aspnet-api.md +247 -0
  3. package/.agent-context/blueprints/ci-github-actions.md +226 -0
  4. package/.agent-context/blueprints/ci-gitlab.md +200 -0
  5. package/.agent-context/blueprints/fastapi-service.md +210 -0
  6. package/.agent-context/blueprints/go-service.md +217 -0
  7. package/.agent-context/blueprints/graphql-grpc-api.md +51 -0
  8. package/.agent-context/blueprints/infrastructure-as-code.md +62 -0
  9. package/.agent-context/blueprints/kubernetes-manifests.md +76 -0
  10. package/.agent-context/blueprints/laravel-api.md +223 -0
  11. package/.agent-context/blueprints/nestjs-logic.md +247 -0
  12. package/.agent-context/blueprints/observability.md +227 -0
  13. package/.agent-context/blueprints/spring-boot-api.md +218 -0
  14. package/.agent-context/policies/llm-judge-threshold.json +20 -0
  15. package/.agent-context/profiles/platform.md +13 -0
  16. package/.agent-context/profiles/regulated.md +13 -0
  17. package/.agent-context/profiles/startup.md +13 -0
  18. package/.agent-context/prompts/init-project.md +86 -0
  19. package/.agent-context/prompts/refactor.md +45 -0
  20. package/.agent-context/prompts/review-code.md +47 -0
  21. package/.agent-context/review-checklists/architecture-review.md +70 -0
  22. package/.agent-context/review-checklists/frontend-usability.md +33 -0
  23. package/.agent-context/review-checklists/performance-audit.md +65 -0
  24. package/.agent-context/review-checklists/pr-checklist.md +97 -0
  25. package/.agent-context/review-checklists/release-operations.md +29 -0
  26. package/.agent-context/review-checklists/security-audit.md +113 -0
  27. package/.agent-context/rules/api-docs.md +186 -0
  28. package/.agent-context/rules/architecture.md +198 -0
  29. package/.agent-context/rules/database-design.md +202 -0
  30. package/.agent-context/rules/efficiency-vs-hype.md +143 -0
  31. package/.agent-context/rules/error-handling.md +234 -0
  32. package/.agent-context/rules/event-driven.md +226 -0
  33. package/.agent-context/rules/frontend-architecture.md +66 -0
  34. package/.agent-context/rules/git-workflow.md +200 -0
  35. package/.agent-context/rules/microservices.md +174 -0
  36. package/.agent-context/rules/naming-conv.md +141 -0
  37. package/.agent-context/rules/performance.md +168 -0
  38. package/.agent-context/rules/realtime.md +47 -0
  39. package/.agent-context/rules/security.md +195 -0
  40. package/.agent-context/rules/testing.md +178 -0
  41. package/.agent-context/stacks/csharp.md +149 -0
  42. package/.agent-context/stacks/go.md +181 -0
  43. package/.agent-context/stacks/java.md +135 -0
  44. package/.agent-context/stacks/php.md +178 -0
  45. package/.agent-context/stacks/python.md +153 -0
  46. package/.agent-context/stacks/ruby.md +80 -0
  47. package/.agent-context/stacks/rust.md +86 -0
  48. package/.agent-context/stacks/typescript.md +317 -0
  49. package/.agent-context/state/architecture-map.md +25 -0
  50. package/.agent-context/state/dependency-map.md +32 -0
  51. package/.agent-override.md +36 -0
  52. package/.agents/workflows/init-project.md +29 -0
  53. package/.agents/workflows/refactor.md +29 -0
  54. package/.agents/workflows/review-code.md +29 -0
  55. package/.cursorrules +140 -0
  56. package/.gemini/instructions.md +97 -0
  57. package/.github/ISSUE_TEMPLATE/v1.7-frontend-work-item.yml +54 -0
  58. package/.github/copilot-instructions.md +104 -0
  59. package/.github/workflows/benchmark-detection.yml +38 -0
  60. package/.github/workflows/frontend-usability-gate.yml +36 -0
  61. package/.github/workflows/release-gate.yml +32 -0
  62. package/.github/workflows/sbom-compliance.yml +32 -0
  63. package/.windsurfrules +106 -0
  64. package/AGENTS.md +131 -0
  65. package/CONTRIBUTING.md +136 -0
  66. package/LICENSE +21 -0
  67. package/README.md +239 -0
  68. package/bin/agentic-senior-core.js +1147 -0
  69. package/mcp.json +29 -0
  70. package/package.json +50 -0
  71. package/scripts/detection-benchmark.mjs +138 -0
  72. package/scripts/frontend-usability-audit.mjs +87 -0
  73. package/scripts/generate-sbom.mjs +61 -0
  74. package/scripts/init-project.ps1 +105 -0
  75. package/scripts/init-project.sh +131 -0
  76. package/scripts/llm-judge.mjs +664 -0
  77. package/scripts/release-gate.mjs +116 -0
  78. package/scripts/validate.mjs +554 -0
@@ -0,0 +1,80 @@
1
+ # Ruby on Rails Engineering Standards
2
+
3
+ > Rails provides "Convention over Configuration," but convention does not mean "put all your business logic in ActiveRecord callbacks."
4
+
5
+ ## Core Tenets
6
+ 1. **Skinny Models, Skinny Controllers, Fat Services:** The default Rails MVC is insufficient for complex domains. Extract business logic into Service Objects (Interactors).
7
+ 2. **Death to N+1 Queries:** The `bullet` gem is mandatory in development and test environments. Any N+1 query is a blocker.
8
+ 3. **No Hidden Magic:** Avoid deeply nested or complex ActiveRecord callbacks (`before_save`, `after_commit`). They obscure the flow of data. If an action has side effects, orchestrate it in a Service Object.
9
+ 4. **Strong Parameters Only:** Never trust user input. Always permit explicit parameters in the controller layer before passing data down.
10
+
11
+ ## Architecture & Layering (The Service Object Pattern)
12
+ Default Rails couples the HTTP request cycle tightly to the Database via the Model. We break this.
13
+
14
+ ### 1. Controllers (Transport Layer)
15
+ - **Role:** Handle HTTP requests, parse parameters (Strong Params), authenticate/authorize the user, call the Service Object, and return the HTTP response/JSON.
16
+ - **BANNED:** Calling `Model.create()`, `Model.update()`, or writing any business calculations in the controller.
17
+ - **ALLOWED:** `MyService.call(params)`
18
+
19
+ ### 2. Service Objects (Application Layer)
20
+ - **Role:** The orchestrator. Located in `app/services/`.
21
+ - **Structure:** Usually plain Ruby objects (POROs) with a single public `call` method.
22
+ - **Responsibility:** Executes the business transaction, handling database operations, sending emails, or enqueuing background jobs.
23
+
24
+ ### 3. Models (Domain & Persistence Layer)
25
+ - **Role:** ActiveRecord models should only contain associations (`belongs_to`, `has_many`), scopes, and simple data validations (e.g., `validates :email, presence: true`).
26
+ - **BANNED:** Complex business logic, sending emails, API calls to third parties.
27
+
28
+ ## Ecosystem & Dependencies (March 2026)
29
+ - **API Mode:** Use `rails new my_api --api` for backend-only projects.
30
+ - **Background Jobs:** `sidekiq` is the standard. Default `ActiveJob` should map to a Sidekiq backend (powered by Redis).
31
+ - **Authentication/Authorization:** `devise` (if needed, though often overkill for raw APIs; consider `jwt` + custom auth) and `pundit` (mandatory for authorization). Avoid `cancancan`.
32
+ - **Testing:** `rspec-rails` and `factory_bot_rails`. Default `minitest` and `fixtures` are explicitly banned for Agentic-Senior-Core projects.
33
+ - **Linting:** `rubocop` is mandatory. The build must fail if RuboCop fails.
34
+
35
+ ## Anti-Patterns (Zero Tolerance)
36
+
37
+ ### 1. The Fat Model Callback Hell
38
+ ```ruby
39
+ # ❌ BANNED: The model side-effect
40
+ class User < ApplicationRecord
41
+ after_create :send_welcome_email
42
+
43
+ def send_welcome_email
44
+ UserMailer.welcome(self).deliver_now
45
+ end
46
+ end
47
+
48
+ # ✅ REQUIRED: The Service Object Orchestrator
49
+ class Users::CreateService
50
+ def self.call(params)
51
+ user = User.new(params)
52
+ if user.save
53
+ UserMailer.welcome(user).deliver_later
54
+ end
55
+ user
56
+ end
57
+ end
58
+ ```
59
+
60
+ ### 2. N+1 Queries in Responses
61
+ ```ruby
62
+ # ❌ BANNED: Will execute 101 queries for 100 posts
63
+ def index
64
+ @posts = Post.all
65
+ render json: @posts.map { |p| { title: p.title, author: p.author.name } }
66
+ end
67
+
68
+ # ✅ REQUIRED: Eager loading
69
+ def index
70
+ @posts = Post.includes(:author).all
71
+ # ...
72
+ end
73
+ ```
74
+
75
+ ### 3. Logic in Views/Serializers
76
+ If using ActiveModelSerializers, Jbuilder, or Blueprinter, never perform database queries or heavy calculations in the serialization phase.
77
+
78
+ ## Background Jobs (Sidekiq)
79
+ - **Rule:** Any operation taking longer than 300ms (e.g., sending an email, generating a PDF, calling an external API) **MUST** be pushed to a background job (`.deliver_later` or `MyWorker.perform_async`).
80
+ - **Rule:** Background job parameters must be simple types (strings, integers, IDs). **NEVER** pass an ActiveRecord object directly to a Sidekiq worker (it might be stale when the job runs). Pass the `user_id` instead.
@@ -0,0 +1,86 @@
1
+ # Rust Engineering Standards
2
+
3
+ > Rust guarantees memory safety, but not logic safety. Write code that is as predictable as the compiler.
4
+
5
+ ## Core Tenets
6
+ 1. **Never Panic:** The use of `unwrap()`, `expect()`, or `panic!()` in production business logic is strictly banned.
7
+ 2. **Make Invalid States Unrepresentable:** Use Rust's powerful type system (enums, newtypes) to enforce business rules at compile time.
8
+ 3. **Explicit Errors:** Use `Result` for all fallible operations.
9
+ 4. **Fearless Concurrency:** Leverage `Send` and `Sync`. Avoid shared mutable state; prefer message passing or structured concurrency.
10
+
11
+ ## Ecosystem & Dependencies (March 2026)
12
+ Adhere to the `efficiency-vs-hype` rule. The Rust ecosystem is robust; use community standards:
13
+
14
+ ### Backend / API
15
+ - **Web Framework:** `axum` (Standard for new projects, built on `tokio` and `tower`). Avoid `actix-web` and `rocket` for new microservices unless migrating legacy code.
16
+ - **Async Runtime:** `tokio` (Standard).
17
+ - **Serialization:** `serde` + `serde_json`.
18
+
19
+ ### Data / Persistence
20
+ - **Database:** `sqlx` (preferred for compile-time checked SQL) or `sea-orm` (if an ORM is strictly required). Avoid `diesel` (unless explicitly requested).
21
+ - **Connection Pooling:** Built into `sqlx` (use `PgPool`, etc.).
22
+
23
+ ### Validation / Error Handling / Observability
24
+ - **Error Handling:** `thiserror` (for libraries and domain boundaries) and `anyhow` (for application/binaries and controllers).
25
+ - **Validation:** `validator` crate.
26
+ - **Telemetry/Logging:** `tracing` + `tracing-subscriber`. `log` and `env_logger` are legacy.
27
+
28
+ ## Architecture & Layering
29
+ Strict Clean Architecture / Hexagonal Architecture.
30
+
31
+ 1. **Transport (`/api` or `/transport`)**
32
+ - Axum routers and handlers.
33
+ - Responsible for extracting JSON/Path data, verifying auth claims, and calling the Domain/Service layer.
34
+ - **MUST:** Return standard HTTP status codes mapping to domain errors.
35
+
36
+ 2. **Application / Service (`/services` or `/app`)**
37
+ - Orchestrates business logic, database transactions, and external API calls.
38
+ - **NO** HTTP knowledge (Axum types do not cross this boundary).
39
+
40
+ 3. **Domain (`/domain`)**
41
+ - Pure Rust logic. Structs, Enums, Traits.
42
+ - **Must not** know about the database (SQL) or HTTP. Use traits (interfaces) to define repository contracts.
43
+
44
+ 4. **Infrastructure / Repository (`/repo` or `/infra`)**
45
+ - `sqlx` queries go here. Implements the traits defined in Domain.
46
+
47
+ ## Anti-Patterns (Zero Tolerance)
48
+
49
+ ### 1. The `unwrap()` Fallacy
50
+ ```rust
51
+ // ❌ BANNED: Will crash the server if parsing fails
52
+ let user_id = id_string.parse::<i32>().unwrap();
53
+
54
+ // ✅ REQUIRED: Explicit error mapping
55
+ let user_id = id_string.parse::<i32>().map_err(AppError::InvalidId)?;
56
+ ```
57
+
58
+ ### 2. Stringly-Typed Domain
59
+ ```rust
60
+ // ❌ BANNED: Passing raw strings everywhere
61
+ fn update_email(user_id: String, email: String) {}
62
+
63
+ // ✅ REQUIRED: Newtypes and validated types
64
+ struct UserId(uuid::Uuid);
65
+ struct Email(String); // Should be validated on creation
66
+
67
+ fn update_email(user_id: UserId, email: Email) {}
68
+ ```
69
+
70
+ ### 3. Cloning to Appease the Borrow Checker
71
+ ```rust
72
+ // ❌ POOR PRACTICE: Cloning just to make it compile instead of designing lifetimes/ownership
73
+ let name = user.name.clone();
74
+ process_name(name);
75
+
76
+ // ✅ REQUIRED: Pass by reference (borrowing)
77
+ process_name(&user.name);
78
+ ```
79
+
80
+ ### 4. Catch-all `anyhow::Error` in Traits
81
+ Traits defining contracts between layers (like Repositories) should return explicit errors (`thiserror`), not `anyhow::Error`, so the caller can systematically handle specific failures (e.g., `NotFound`, `ConstraintViolation`).
82
+
83
+ ## Testing Standards
84
+ - **Unit Tests:** Inside the same file as the code (`#[cfg(test)] mod tests { ... }`).
85
+ - **Integration Tests:** In the `tests/` directory at the root level.
86
+ - **Mocking:** Use `mockall` or manually implement traits for test doubles. Avoid testing against a real database in unit tests; use them in integration tests using `sqlx::test`.
@@ -0,0 +1,317 @@
1
+ # TypeScript Stack Profile — The "Galak" Standard
2
+
3
+ > TypeScript is not JavaScript with optional types.
4
+ > It is a contract system. Use it like one.
5
+
6
+ ## Compiler Configuration (Non-Negotiable)
7
+
8
+ ### tsconfig.json Strict Settings
9
+ ```json
10
+ {
11
+ "compilerOptions": {
12
+ "strict": true,
13
+ "noUncheckedIndexedAccess": true,
14
+ "noImplicitReturns": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "exactOptionalPropertyTypes": true,
19
+ "forceConsistentCasingInFileNames": true,
20
+ "isolatedModules": true,
21
+ "esModuleInterop": true,
22
+ "resolveJsonModule": true,
23
+ "moduleResolution": "bundler",
24
+ "module": "ESNext",
25
+ "target": "ES2022",
26
+ "skipLibCheck": true,
27
+ "paths": {
28
+ "@/*": ["./src/*"]
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ **Rule:** `"strict": true` is mandatory. If a project has `"strict": false`, fix it before writing any new code.
35
+
36
+ ---
37
+
38
+ ## The `any` Ban (Zero Tolerance)
39
+
40
+ ### Rule: `any` is BANNED. No exceptions.
41
+
42
+ ```typescript
43
+ // ❌ INSTANT REJECTION
44
+ function processData(data: any) { ... }
45
+ const result = response.json() as any;
46
+ // @ts-ignore
47
+ // @ts-expect-error — only allowed with a comment explaining WHY and a linked issue
48
+
49
+ // ✅ REQUIRED: Use `unknown` with type narrowing
50
+ function processData(data: unknown) {
51
+ const parsed = DataSchema.parse(data); // Zod validates and narrows
52
+ // `parsed` is now fully typed
53
+ }
54
+
55
+ // ✅ REQUIRED: Use generics when the type varies
56
+ function getFirstItem<T>(items: T[]): T | undefined {
57
+ return items[0];
58
+ }
59
+ ```
60
+
61
+ ### What to Use Instead of `any`
62
+ | Situation | Instead of `any`, Use |
63
+ |-----------|----------------------|
64
+ | Unknown external data | `unknown` + Zod parsing |
65
+ | Generic container | `T` (generic type parameter) |
66
+ | Object with unknown keys | `Record<string, unknown>` |
67
+ | Function argument you'll refine | `unknown` + type guard |
68
+ | Library with bad types | Write a `.d.ts` override or `unknown` wrapper |
69
+ | Event handlers | The specific event type (`MouseEvent`, `ChangeEvent<HTMLInputElement>`) |
70
+
71
+ ---
72
+
73
+ ## Zod at Boundaries (Mandatory)
74
+
75
+ ### Rule: ALL External Data MUST Pass Through Zod
76
+
77
+ ```typescript
78
+ // ❌ BANNED: Trusting external data
79
+ app.post('/users', async (req, res) => {
80
+ const { name, email, age } = req.body; // Could be anything!
81
+ await userService.create({ name, email, age });
82
+ });
83
+
84
+ // ✅ REQUIRED: Validate with Zod at the boundary
85
+ import { z } from 'zod';
86
+
87
+ const CreateUserSchema = z.object({
88
+ name: z.string().min(1).max(100).trim(),
89
+ email: z.string().email().toLowerCase(),
90
+ age: z.number().int().min(13).max(150),
91
+ });
92
+
93
+ type CreateUserDto = z.infer<typeof CreateUserSchema>;
94
+
95
+ app.post('/users', async (req, res) => {
96
+ const parsed = CreateUserSchema.safeParse(req.body);
97
+ if (!parsed.success) {
98
+ return res.status(400).json({ errors: parsed.error.flatten() });
99
+ }
100
+ // `parsed.data` is fully typed and validated
101
+ await userService.create(parsed.data);
102
+ });
103
+ ```
104
+
105
+ ### Where Zod is MANDATORY
106
+ - API request bodies (POST, PUT, PATCH)
107
+ - Query parameters and path parameters
108
+ - WebSocket incoming messages
109
+ - Queue/event payloads from external systems
110
+ - Environment variables at startup
111
+ - Third-party API responses (trust but verify)
112
+ - File upload metadata
113
+
114
+ ### Zod Best Practices
115
+ ```typescript
116
+ // ✅ Reuse schemas — define once, use everywhere
117
+ // src/modules/user/user.schema.ts
118
+ export const UserSchema = z.object({
119
+ id: z.string().uuid(),
120
+ email: z.string().email(),
121
+ name: z.string().min(1).max(100),
122
+ role: z.enum(['user', 'admin', 'moderator']),
123
+ createdAt: z.coerce.date(),
124
+ });
125
+
126
+ export const CreateUserSchema = UserSchema.omit({ id: true, createdAt: true });
127
+ export const UpdateUserSchema = CreateUserSchema.partial();
128
+
129
+ // Types derived from schemas — single source of truth
130
+ export type User = z.infer<typeof UserSchema>;
131
+ export type CreateUserDto = z.infer<typeof CreateUserSchema>;
132
+ export type UpdateUserDto = z.infer<typeof UpdateUserSchema>;
133
+ ```
134
+
135
+ ---
136
+
137
+ ## API Documentation (Mandatory)
138
+
139
+ ### Rule: No API Endpoint Exists Without Documentation
140
+
141
+ Every API endpoint MUST have corresponding documentation. When creating or modifying an endpoint, you MUST simultaneously update the API documentation.
142
+
143
+ ### Preferred Approach: OpenAPI (Swagger)
144
+
145
+ ```typescript
146
+ // Option 1: Code-first with decorators (NestJS)
147
+ @ApiOperation({ summary: 'Create a new user' })
148
+ @ApiBody({ type: CreateUserDto })
149
+ @ApiResponse({ status: 201, description: 'User created', type: UserResponseDto })
150
+ @ApiResponse({ status: 400, description: 'Validation error' })
151
+ @ApiResponse({ status: 409, description: 'Email already exists' })
152
+ @Post()
153
+ async createUser(@Body() dto: CreateUserDto): Promise<UserResponseDto> { ... }
154
+
155
+ // Option 2: Schema-first with Zod + zod-to-openapi
156
+ import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
157
+ extendZodWithOpenApi(z);
158
+
159
+ const CreateUserSchema = z.object({
160
+ name: z.string().min(1).openapi({ example: 'John Doe' }),
161
+ email: z.string().email().openapi({ example: 'john@example.com' }),
162
+ }).openapi('CreateUserRequest');
163
+ ```
164
+
165
+ ### Documentation Checklist (Per Endpoint)
166
+ - [ ] HTTP method and path
167
+ - [ ] Request body schema (with examples)
168
+ - [ ] Query/path parameter descriptions
169
+ - [ ] All possible response codes with schemas
170
+ - [ ] Authentication requirements
171
+ - [ ] Rate limiting information (if applicable)
172
+
173
+ ### Documentation Must Stay in Sync
174
+ ```
175
+ ❌ BANNED:
176
+ // Endpoint accepts `role` field but docs don't mention it
177
+ // Endpoint returns 422 but docs only show 400
178
+
179
+ ✅ REQUIRED:
180
+ // When you change an endpoint → update the schema/docs in the SAME commit
181
+ // Use code-first tools so docs are generated from the actual types
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Import Style
187
+
188
+ ### Path Aliases (Required)
189
+ ```typescript
190
+ // ❌ BANNED: Deep relative imports
191
+ import { UserService } from '../../../modules/user/user.service';
192
+ import { AppError } from '../../../../shared/errors/app-error';
193
+
194
+ // ✅ REQUIRED: Path aliases
195
+ import { UserService } from '@/modules/user/user.service';
196
+ import { AppError } from '@/shared/errors/app-error';
197
+ ```
198
+
199
+ ### Import Order (Enforced by ESLint)
200
+ ```typescript
201
+ // 1. Node built-ins
202
+ import { readFile } from 'node:fs/promises';
203
+ import { join } from 'node:path';
204
+
205
+ // 2. External packages
206
+ import { z } from 'zod';
207
+ import { PrismaClient } from '@prisma/client';
208
+
209
+ // 3. Internal modules (path aliases)
210
+ import { UserService } from '@/modules/user/user.service';
211
+ import { AppError } from '@/shared/errors/app-error';
212
+
213
+ // 4. Relative imports (same module only)
214
+ import { CreateUserDto } from './user.dto';
215
+ import { UserRepository } from './user.repository';
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Async Patterns
221
+
222
+ ### Rule: Prefer async/await Over Raw Promises
223
+ ```typescript
224
+ // ❌ BANNED: Promise chain hell
225
+ function getUser(id: string) {
226
+ return userRepo.findById(id)
227
+ .then(user => {
228
+ if (!user) throw new NotFoundError('User', id);
229
+ return orderRepo.findByUserId(user.id);
230
+ })
231
+ .then(orders => ({ ...user, orders }))
232
+ .catch(err => { throw err; });
233
+ }
234
+
235
+ // ✅ REQUIRED: Clean async/await
236
+ async function getUser(id: string): Promise<UserWithOrders> {
237
+ const user = await userRepo.findById(id);
238
+ if (!user) throw new NotFoundError('User', id);
239
+
240
+ const orders = await orderRepo.findByUserId(user.id);
241
+ return { ...user, orders };
242
+ }
243
+ ```
244
+
245
+ ### Parallel Execution
246
+ ```typescript
247
+ // ❌ SLOW: Sequential when operations are independent
248
+ const user = await getUser(id);
249
+ const orders = await getOrders(id);
250
+ const preferences = await getPreferences(id);
251
+
252
+ // ✅ FAST: Parallel independent operations
253
+ const [user, orders, preferences] = await Promise.all([
254
+ getUser(id),
255
+ getOrders(id),
256
+ getPreferences(id),
257
+ ]);
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Enum and Union Types
263
+
264
+ ### Prefer `as const` Unions Over Enums
265
+ ```typescript
266
+ // ⚠️ ACCEPTABLE but verbose:
267
+ enum OrderStatus {
268
+ PENDING = 'pending',
269
+ CONFIRMED = 'confirmed',
270
+ SHIPPED = 'shipped',
271
+ DELIVERED = 'delivered',
272
+ }
273
+
274
+ // ✅ PREFERRED: const assertion + union type
275
+ const ORDER_STATUSES = ['pending', 'confirmed', 'shipped', 'delivered'] as const;
276
+ type OrderStatus = (typeof ORDER_STATUSES)[number];
277
+ // OrderStatus = 'pending' | 'confirmed' | 'shipped' | 'delivered'
278
+
279
+ // Works perfectly with Zod:
280
+ const OrderStatusSchema = z.enum(ORDER_STATUSES);
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Preferred Libraries (V1.0 — 2025)
286
+
287
+ | Need | Library | Why |
288
+ |------|---------|-----|
289
+ | Runtime | Bun / Node 20+ | ESM native, fast, batteries-included |
290
+ | Validation | `zod` | 0 deps, type inference, composable |
291
+ | ORM | `prisma` or `drizzle-orm` | Type-safe queries, migration support |
292
+ | HTTP framework | `hono` / `fastify` / Next.js | Lightweight, modern, tree-shakeable |
293
+ | Testing | `vitest` | Vite-native, Jest-compatible API, fast |
294
+ | Linting | `eslint` + `@typescript-eslint` | Community standard |
295
+ | Formatting | `prettier` | Community standard |
296
+ | Date | `date-fns` or `Temporal` (when stable) | Tree-shakeable, immutable |
297
+ | HTTP client | `ky` / `ofetch` / built-in `fetch` | Lightweight, modern |
298
+ | Password | `bcrypt` / `argon2` | Proven, secure |
299
+ | Logger | `pino` | Fastest JSON logger for Node.js |
300
+ | Env | `@t3-oss/env-core` + Zod | Type-safe env validation |
301
+
302
+ ---
303
+
304
+ ## Banned Patterns
305
+
306
+ | Pattern | Why | Alternative |
307
+ |---------|-----|-------------|
308
+ | `any` type | Defeats TypeScript's purpose | `unknown` + narrowing |
309
+ | `// @ts-ignore` | Hides real type errors | Fix the type or `@ts-expect-error` with comment |
310
+ | `var` keyword | Function scoping bugs | `const` (default) or `let` |
311
+ | `==` loose equality | Type coercion surprises | `===` always |
312
+ | `console.log` in production | Not structured, not configurable | Use `pino` or structured logger |
313
+ | `new Date()` without timezone | Timezone bugs | Explicit UTC or use date-fns |
314
+ | Default exports | Naming inconsistency across imports | Named exports only |
315
+ | Barrel re-exports (`index.ts`) | Circular dependency magnets | Direct imports or module public API only |
316
+ | `moment.js` | Deprecated, massive bundle | `date-fns` or `dayjs` |
317
+ | `class` with inheritance (deep chains) | Fragile hierarchies | Composition + interfaces |
@@ -0,0 +1,25 @@
1
+ # Architecture Map (State Awareness)
2
+
3
+ > This file defines protected architectural boundaries for AI-assisted changes.
4
+
5
+ ## Boundary Classification
6
+
7
+ | Module/Path Pattern | Criticality | Change Policy | Required Checks |
8
+ |---------------------|-------------|---------------|-----------------|
9
+ | `src/modules/payment/**` | critical | Must preserve transactional behavior and idempotency | Unit + integration + rollback test |
10
+ | `src/modules/authentication/**` | critical | Never bypass auth guards or token validation | Security audit + integration tests |
11
+ | `src/modules/**/repository/**` | high | Preserve query contracts and avoid N+1 regressions | Query plan review + performance audit |
12
+ | `src/features/**` | medium | Keep UI contracts stable and avoid API drift | Component tests + contract checks |
13
+ | `src/shared/**` | high | Backward compatibility required for public utilities | Cross-module usage validation |
14
+
15
+ ## Required Agent Behavior
16
+
17
+ 1. Before editing a `critical` area, load `.agent-context/review-checklists/security-audit.md` and `.agent-context/review-checklists/performance-audit.md`.
18
+ 2. For boundary-crossing changes, verify no circular dependencies are introduced (see `dependency-map.md`).
19
+ 3. Every critical-path change must include explicit risk notes in PR description.
20
+
21
+ ## Project-Specific Notes
22
+
23
+ - Replace placeholder path patterns with your actual module map.
24
+ - Mark payment, identity, and financial reconciliation flows as `critical`.
25
+ - Keep this file updated whenever module ownership changes.
@@ -0,0 +1,32 @@
1
+ # Dependency Map (State Awareness)
2
+
3
+ > This map documents allowed dependency direction to prevent circular references during refactors.
4
+
5
+ ## Layer Dependency Rules
6
+
7
+ 1. Transport layer may depend on Service layer.
8
+ 2. Service layer may depend on Domain contracts and Repository interfaces.
9
+ 3. Infrastructure layer may implement Repository interfaces.
10
+ 4. Domain layer must not depend on Transport or Infrastructure.
11
+
12
+ ## Module-Level Constraints
13
+
14
+ | Source Module | Allowed Dependencies | Forbidden Dependencies |
15
+ |---------------|----------------------|------------------------|
16
+ | `authentication` | `shared`, `user` | `payment` internals |
17
+ | `payment` | `shared`, `billing`, `notification` contracts | `authentication` internals |
18
+ | `reporting` | `shared`, read-only repository ports | write-side service internals |
19
+ | `frontend` | public API clients only | direct repository access |
20
+
21
+ ## Circular Dependency Guardrail
22
+
23
+ When refactoring:
24
+
25
+ 1. Detect import graph changes before applying bulk edits.
26
+ 2. Reject any change introducing `A -> B -> A` cycles.
27
+ 3. Move shared contracts to `shared` module when two-way dependencies appear.
28
+
29
+ ## Project-Specific Notes
30
+
31
+ - Replace sample modules with your real domain modules.
32
+ - Keep this map synchronized with architecture decisions and ADRs.
@@ -0,0 +1,36 @@
1
+ # Rule Overrides
2
+
3
+ > Exception file for enterprise needs.
4
+ > Default policy: all rules remain strict unless explicitly overridden below.
5
+
6
+ ## Override Template
7
+
8
+ Use this exact structure for every exception:
9
+
10
+ ```markdown
11
+ [Rule: <rule-name>]
12
+ Scope: <module/path>
13
+ Reason: <business or technical constraint>
14
+ Permitted Deviation: <what is allowed>
15
+ Risk Mitigation: <how risk is controlled>
16
+ Expiry: <YYYY-MM-DD>
17
+ Owner: <team/person>
18
+ ```
19
+
20
+ ## Example Override
21
+
22
+ ```markdown
23
+ [Rule: Naming]
24
+ Scope: legacy-erp-sync module
25
+ Reason: External DB schema uses snake_case columns and strict mapping contracts.
26
+ Permitted Deviation: snake_case variable names are allowed only in mapper files.
27
+ Risk Mitigation: enforce mapper-only scope with codeowners and lint ignore pattern.
28
+ Expiry: 2026-12-31
29
+ Owner: platform-integration-team
30
+ ```
31
+
32
+ ## Enforcement Notes
33
+
34
+ 1. Overrides must be narrow and time-bound.
35
+ 2. Expired overrides are invalid and must be removed.
36
+ 3. Broad overrides such as "allow any everywhere" are prohibited.
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Initialize a new project using Agentic-Senior-Core blueprints and engineering standards
3
+ ---
4
+
5
+ // turbo-all
6
+
7
+ ## Workflow: Initialize Project
8
+
9
+ 1. Read all rule files from `.agent-context/rules/` to understand engineering standards.
10
+
11
+ 2. Read the language-specific profile from `.agent-context/stacks/` based on the project's tech stack.
12
+
13
+ 3. Read the chosen blueprint from `.agent-context/blueprints/` (e.g., `api-nextjs.md` or `nestjs-logic.md`).
14
+
15
+ 4. Scaffold the complete project structure following the blueprint exactly:
16
+ - Create all directories and files
17
+ - Set up strict `tsconfig.json` (all flags from `stacks/typescript.md`)
18
+ - Create `.env.example` with placeholder values
19
+ - Set up Zod-validated environment config
20
+ - Set up error handling foundation (base error class + global handler)
21
+ - Set up structured logger (pino)
22
+ - Create a `/health` endpoint
23
+ - Initialize the ORM with initial schema
24
+
25
+ 5. Verify every file follows `rules/naming-conv.md` naming conventions.
26
+
27
+ 6. Verify the architecture follows `rules/architecture.md` layer separation.
28
+
29
+ 7. Run the PR checklist from `.agent-context/review-checklists/pr-checklist.md` as a final quality gate.
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Refactor code or extract a module following architecture and naming rules
3
+ ---
4
+
5
+ ## Workflow: Refactor Code
6
+
7
+ 1. Read `.agent-context/rules/architecture.md` to understand the required layer separation.
8
+
9
+ 2. Read `.agent-context/rules/naming-conv.md` to understand naming standards.
10
+
11
+ 3. Read `.agent-context/rules/error-handling.md` to understand error handling patterns.
12
+
13
+ 4. Read the active language profile from `.agent-context/stacks/` (e.g., `typescript.md`).
14
+
15
+ 5. Analyze the target code for violations:
16
+ - Layer leaks (business logic in controllers, SQL in services)
17
+ - Naming violations (generic names, missing verb prefixes, missing boolean prefixes)
18
+ - Error handling issues (swallowed errors, generic Error types)
19
+ - Type safety issues (any types, unvalidated input)
20
+
21
+ 6. Apply refactoring while maintaining ALL existing functionality:
22
+ - Separate into proper layers if needed (controller/service/repository)
23
+ - Fix all naming violations
24
+ - Add Zod validation at boundaries if missing
25
+ - Replace generic errors with typed error classes
26
+
27
+ 7. For every change, provide a Reasoning Chain explaining what was wrong and why the new approach is better.
28
+
29
+ 8. Run `.agent-context/review-checklists/pr-checklist.md` as a final quality gate.
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Run a comprehensive code review using PR checklist and security audit
3
+ ---
4
+
5
+ ## Workflow: Review Code
6
+
7
+ 1. Read `.agent-context/review-checklists/pr-checklist.md` and apply every item against the current codebase.
8
+
9
+ 2. Read `.agent-context/review-checklists/security-audit.md` and apply every item against the current codebase.
10
+
11
+ 3. For every violation found, provide a Reasoning Chain:
12
+ - State the exact file and line
13
+ - Reference the specific rule (file + section from `.agent-context/rules/`)
14
+ - Explain WHY it's a problem
15
+ - Provide the corrected code
16
+
17
+ 4. Output results in this format:
18
+
19
+ ```
20
+ ## PR REVIEW RESULTS
21
+ - PASS or FAIL for each item
22
+ - Reasoning Chain for each failure
23
+
24
+ ## SECURITY AUDIT RESULTS
25
+ - Severity rating (CRITICAL / HIGH / MEDIUM / LOW) for each finding
26
+ - Specific remediation for each finding
27
+
28
+ ## VERDICT: PASS or FAIL
29
+ ```