nurosys-agents 2.0.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 (106) hide show
  1. package/.agent/INSTRUCTIONS.md +82 -0
  2. package/.agent/README.md +483 -0
  3. package/.agent/backend/skills/architect/SKILL.md +436 -0
  4. package/.agent/backend/skills/auth-and-permissions/SKILL.md +168 -0
  5. package/.agent/backend/skills/brainstorm/SKILL.md +127 -0
  6. package/.agent/backend/skills/code-reviewer/SKILL.md +324 -0
  7. package/.agent/backend/skills/create-blueprint/SKILL.md +650 -0
  8. package/.agent/backend/skills/debug-issue/SKILL.md +53 -0
  9. package/.agent/backend/skills/explore-codebase/SKILL.md +45 -0
  10. package/.agent/backend/skills/quick-execute/SKILL.md +99 -0
  11. package/.agent/backend/skills/refactor-safely/SKILL.md +46 -0
  12. package/.agent/backend/skills/security-assessment/SKILL.md +174 -0
  13. package/.agent/backend/workflows/module-runner.claude.md +226 -0
  14. package/.agent/backend/workflows/module-runner.codex.md +155 -0
  15. package/.agent/backend/workflows/module-runner.cursor.md +212 -0
  16. package/.agent/frontend/skills/architect/SKILL.md +644 -0
  17. package/.agent/frontend/skills/auth-and-permissions/SKILL.md +43 -0
  18. package/.agent/frontend/skills/create-blueprint/SKILL.md +635 -0
  19. package/.agent/frontend/skills/debug-issue/SKILL.md +28 -0
  20. package/.agent/frontend/skills/explore-codebase/SKILL.md +29 -0
  21. package/.agent/frontend/skills/feature-workflow/SKILL.md +61 -0
  22. package/.agent/frontend/skills/react-quality-review/SKILL.md +126 -0
  23. package/.agent/frontend/skills/react-quality-review/examples.md +24 -0
  24. package/.agent/frontend/skills/react-quality-review/rules/_sections.md +26 -0
  25. package/.agent/frontend/skills/react-quality-review/rules/_template.md +28 -0
  26. package/.agent/frontend/skills/react-quality-review/rules/advanced-event-handler-refs.md +55 -0
  27. package/.agent/frontend/skills/react-quality-review/rules/advanced-init-once.md +42 -0
  28. package/.agent/frontend/skills/react-quality-review/rules/react-rules-calling.md +66 -0
  29. package/.agent/frontend/skills/react-quality-review/rules/react-rules-hooks.md +91 -0
  30. package/.agent/frontend/skills/react-quality-review/rules/react-rules-purity.md +121 -0
  31. package/.agent/frontend/skills/react-quality-review/rules/rendering-activity.md +26 -0
  32. package/.agent/frontend/skills/react-quality-review/rules/rendering-conditional-render.md +40 -0
  33. package/.agent/frontend/skills/react-quality-review/rules/rendering-content-visibility.md +38 -0
  34. package/.agent/frontend/skills/react-quality-review/rules/rendering-hoist-jsx.md +46 -0
  35. package/.agent/frontend/skills/react-quality-review/rules/rendering-usetransition-loading.md +75 -0
  36. package/.agent/frontend/skills/react-quality-review/rules/rerender-defer-reads.md +39 -0
  37. package/.agent/frontend/skills/react-quality-review/rules/rerender-dependencies.md +45 -0
  38. package/.agent/frontend/skills/react-quality-review/rules/rerender-derived-state-no-effect.md +40 -0
  39. package/.agent/frontend/skills/react-quality-review/rules/rerender-derived-state.md +29 -0
  40. package/.agent/frontend/skills/react-quality-review/rules/rerender-functional-setstate.md +74 -0
  41. package/.agent/frontend/skills/react-quality-review/rules/rerender-lazy-state-init.md +58 -0
  42. package/.agent/frontend/skills/react-quality-review/rules/rerender-memo-with-default-value.md +38 -0
  43. package/.agent/frontend/skills/react-quality-review/rules/rerender-memo.md +44 -0
  44. package/.agent/frontend/skills/react-quality-review/rules/rerender-move-effect-to-event.md +45 -0
  45. package/.agent/frontend/skills/react-quality-review/rules/rerender-no-inline-components.md +82 -0
  46. package/.agent/frontend/skills/react-quality-review/rules/rerender-simple-expression-in-memo.md +35 -0
  47. package/.agent/frontend/skills/react-quality-review/rules/rerender-transitions.md +40 -0
  48. package/.agent/frontend/skills/react-quality-review/rules/rerender-use-ref-transient-values.md +73 -0
  49. package/.agent/frontend/skills/refactor-safely/SKILL.md +29 -0
  50. package/.agent/frontend/skills/vuexy-component-guide/SKILL.md +369 -0
  51. package/.agent/frontend/skills/vuexy-component-guide/examples.md +662 -0
  52. package/.agent/frontend/skills/vuexy-component-guide/reference.md +1036 -0
  53. package/.agent/frontend/workflows/build-feature-react.workflow.md +82 -0
  54. package/.agent/frontend/workflows/feature-module-runner.md +101 -0
  55. package/.agent/monolith/skills/architect/SKILL.md +648 -0
  56. package/.agent/monolith/skills/auth-and-permissions/SKILL.md +43 -0
  57. package/.agent/monolith/skills/code-reviewer/SKILL.md +281 -0
  58. package/.agent/monolith/skills/create-blueprint/SKILL.md +635 -0
  59. package/.agent/monolith/skills/debug-issue/SKILL.md +28 -0
  60. package/.agent/monolith/skills/explore-codebase/SKILL.md +29 -0
  61. package/.agent/monolith/skills/feature-workflow/SKILL.md +61 -0
  62. package/.agent/monolith/skills/react-quality-review/SKILL.md +126 -0
  63. package/.agent/monolith/skills/react-quality-review/examples.md +24 -0
  64. package/.agent/monolith/skills/react-quality-review/rules/_sections.md +26 -0
  65. package/.agent/monolith/skills/react-quality-review/rules/_template.md +28 -0
  66. package/.agent/monolith/skills/react-quality-review/rules/advanced-event-handler-refs.md +55 -0
  67. package/.agent/monolith/skills/react-quality-review/rules/advanced-init-once.md +42 -0
  68. package/.agent/monolith/skills/react-quality-review/rules/react-rules-calling.md +66 -0
  69. package/.agent/monolith/skills/react-quality-review/rules/react-rules-hooks.md +91 -0
  70. package/.agent/monolith/skills/react-quality-review/rules/react-rules-purity.md +121 -0
  71. package/.agent/monolith/skills/react-quality-review/rules/rendering-activity.md +26 -0
  72. package/.agent/monolith/skills/react-quality-review/rules/rendering-conditional-render.md +40 -0
  73. package/.agent/monolith/skills/react-quality-review/rules/rendering-content-visibility.md +38 -0
  74. package/.agent/monolith/skills/react-quality-review/rules/rendering-hoist-jsx.md +46 -0
  75. package/.agent/monolith/skills/react-quality-review/rules/rendering-usetransition-loading.md +75 -0
  76. package/.agent/monolith/skills/react-quality-review/rules/rerender-defer-reads.md +39 -0
  77. package/.agent/monolith/skills/react-quality-review/rules/rerender-dependencies.md +45 -0
  78. package/.agent/monolith/skills/react-quality-review/rules/rerender-derived-state-no-effect.md +40 -0
  79. package/.agent/monolith/skills/react-quality-review/rules/rerender-derived-state.md +29 -0
  80. package/.agent/monolith/skills/react-quality-review/rules/rerender-functional-setstate.md +74 -0
  81. package/.agent/monolith/skills/react-quality-review/rules/rerender-lazy-state-init.md +58 -0
  82. package/.agent/monolith/skills/react-quality-review/rules/rerender-memo-with-default-value.md +38 -0
  83. package/.agent/monolith/skills/react-quality-review/rules/rerender-memo.md +44 -0
  84. package/.agent/monolith/skills/react-quality-review/rules/rerender-move-effect-to-event.md +45 -0
  85. package/.agent/monolith/skills/react-quality-review/rules/rerender-no-inline-components.md +82 -0
  86. package/.agent/monolith/skills/react-quality-review/rules/rerender-simple-expression-in-memo.md +35 -0
  87. package/.agent/monolith/skills/react-quality-review/rules/rerender-transitions.md +40 -0
  88. package/.agent/monolith/skills/react-quality-review/rules/rerender-use-ref-transient-values.md +73 -0
  89. package/.agent/monolith/skills/refactor-safely/SKILL.md +29 -0
  90. package/.agent/monolith/skills/vuexy-component-guide/SKILL.md +369 -0
  91. package/.agent/monolith/skills/vuexy-component-guide/examples.md +662 -0
  92. package/.agent/monolith/skills/vuexy-component-guide/reference.md +1036 -0
  93. package/.agent/monolith/workflows/add-new-api-feature-module.md +63 -0
  94. package/.agent/monolith/workflows/backend-quality-review.md +27 -0
  95. package/.agent/monolith/workflows/build-feature-backend.workflow.md +91 -0
  96. package/.agent/monolith/workflows/build-feature-react.workflow.md +82 -0
  97. package/.agent/monolith/workflows/feature-module-runner.md +97 -0
  98. package/.agent/templates/FEATURE_PLAN.md +42 -0
  99. package/.agent/templates/MODULE.md +45 -0
  100. package/.agent/templates/REVIEW_REPORT.md +44 -0
  101. package/.agent/templates/SECURITY_REPORT.md +70 -0
  102. package/.agent/templates/TEST_PLAN.md +49 -0
  103. package/README.md +131 -0
  104. package/package.json +42 -0
  105. package/scripts/setup-rules.js +224 -0
  106. package/scripts/setup.js +518 -0
@@ -0,0 +1,650 @@
1
+ ---
2
+ name: create-blueprint
3
+ description: Bootstrap or refresh `project-memory/` artifacts (constitution, auth-model, repo-map, architecture, models, quality-playbook, core-memory) from the current codebase. The canonical onboarding skill — run this FIRST when installing nurosys-agents in a new project. Uses Serena for symbolic codebase analysis. Trigger with `/create-blueprint all` to bootstrap everything, or `/create-blueprint <artifact_type>` for a single artifact.
4
+ disable-model-invocation: false
5
+ ---
6
+
7
+ # Skill: create-blueprint
8
+
9
+ Use this skill to generate or refresh project-memory documentation artifacts based on the current state of the codebase. Each artifact becomes a reference document that constrains and guides feature implementation.
10
+
11
+ ---
12
+
13
+ ## When to trigger
14
+
15
+ - User asks `create-blueprint all` — runs all artifact types in sequence (full project-memory setup).
16
+ - User asks `create-blueprint <artifact_type>` or `update-blueprint <artifact_type>` — creates or refreshes a single artifact.
17
+ - Artifact types: `constitution`, `auth-model`, `repo-map`, `core-memory`, `models`, `architecture`, `quality-playbook`.
18
+ - When codebase has evolved significantly and project-memory docs are stale or missing.
19
+ - After completing a major feature or architectural refactor to capture new patterns.
20
+
21
+ ### `create-blueprint all` — full setup sequence
22
+
23
+ When the user passes `all`, run each artifact **in this order** (dependencies first):
24
+
25
+ 1. `architecture` — establish system topology before anything else
26
+ 2. `models` — domain entities inform the repo map and constitution
27
+ 3. `repo-map` — module layout needed by all other docs
28
+ 4. `constitution` — rules derived from observed patterns in the codebase
29
+ 5. `auth-model` — auth flow and guards (depends on repo-map for file locations)
30
+ 6. `quality-playbook` — patterns and anti-patterns (derived from real code)
31
+ 7. `core-memory` — last, as it captures decisions made above
32
+
33
+ After each artifact is generated and approved, continue to the next without stopping for further user input unless a blocking question arises (e.g., ambiguous auth pattern). At the end, report a summary table of all artifacts created.
34
+
35
+ ---
36
+
37
+ ## Supported artifacts
38
+
39
+ | Artifact | Purpose | When to create/update |
40
+ |----------|---------|----------------------|
41
+ | `constitution` | Non-negotiable rules (security, validation, DI, auth, SQL, error handling) | After major security decisions or framework upgrades |
42
+ | `auth-model` | Complete JWT flow, guard chain, RBAC entities, identity propagation, tenant/resource scoping | After auth system changes or new permission patterns |
43
+ | `repo-map` | Module layout, naming conventions, reusable components, key entry points, file registry | After adding new module categories or changing structure |
44
+ | `core-memory` | Historical implementation decisions, completed modules, design lessons, known patterns | End of each completed feature or milestone |
45
+ | `models` | Domain model inventory (ORM entities, associations, field contracts, constraints) | After new model additions or significant schema changes |
46
+ | `architecture` | System-level architecture decisions, module topology, data flow, integration points | After architectural refactors or major coupling changes |
47
+ | `quality-playbook` | High-signal check patterns with symptoms, root causes, preferred fixes | After discovering recurring bugs or anti-patterns |
48
+
49
+ ---
50
+
51
+ ## Phase 1 — Understand intent
52
+
53
+ ### 1.1 Parse user request
54
+
55
+ Extract:
56
+ - **Artifact type**: the specific project-memory file to create/update.
57
+ - **Intent**: is this a creation (new), update (refresh stale content), or refactor (reorganize)?
58
+ - **Scope**: does the user want all artifacts or a specific one?
59
+
60
+ ### 1.2 Check for existing artifact
61
+
62
+ ```bash
63
+ ls -la project-memory/<artifact-type>.md
64
+ ```
65
+
66
+ If exists: → read the full file and understand its current state.
67
+ If absent: → proceed to Phase 2 with a blank slate.
68
+
69
+ ---
70
+
71
+ ## Phase 2 — Analyze codebase with Serena
72
+
73
+ Use Serena's symbolic tools to extract structured information **first** — avoid large file reads until you have a focused direction.
74
+
75
+ ### 2.1 Orient yourself
76
+
77
+ Start with the project layout:
78
+
79
+ ```bash
80
+ ls -la # see top-level layout
81
+ cat package.json # detect framework (NestJS/Express/Fastify/Koa) and key deps
82
+ ```
83
+
84
+ Then check Serena memories from prior sessions (if any):
85
+
86
+ ```
87
+ list_memories
88
+ ```
89
+
90
+ If memories exist with names like `project_overview`, `tech_stack`, `project_structure`, read them — they may already contain bootstrap context.
91
+
92
+ ### 2.2 Artifact-specific Serena queries
93
+
94
+ Call the appropriate sequence based on what you're building. **Target: ≤8 Serena calls per artifact.**
95
+
96
+ #### For `repo-map` (module layout, conventions):
97
+ 1. `get_symbols_overview(relative_path="src")` — top-level structure
98
+ 2. For each major subdirectory found, `get_symbols_overview(relative_path="src/<subdir>")` — drill down 1-2 levels
99
+ 3. `find_symbol(name_path="...", substring_matching=true)` on patterns like `"Module"` or `"Service"` to enumerate module types
100
+
101
+ #### For `architecture` (topology, layers):
102
+ 1. `get_symbols_overview` on the app entry file (e.g. `src/main.ts`, `src/app.module.ts`, `src/index.ts`)
103
+ 2. `find_symbol(name_path="AppModule", include_body=true)` (or equivalent) to see top-level wiring
104
+ 3. `find_referencing_symbols` on a couple of bridge classes (e.g. shared service, base controller) to map coupling
105
+
106
+ #### For `auth-model` (auth flow, guards, RBAC):
107
+ 1. `find_symbol(name_path="...", substring_matching=true)` on terms like `Guard`, `Auth`, `Jwt`, `Permission`
108
+ 2. For each guard found, `find_symbol` with `include_body=true` to read its mechanism
109
+ 3. `find_referencing_symbols` on the auth guard to see where it's applied (gives the protected-endpoint inventory)
110
+ 4. Read auth config files directly with `Read` if non-symbol (e.g. `src/config/jwt.ts`)
111
+
112
+ #### For `models` (entities, associations):
113
+ 1. `find_symbol(name_path="...", substring_matching=true)` on patterns like `Model` or `Entity` (filter by language convention)
114
+ 2. For each model found, `find_symbol(include_body=true)` to read decorators/associations
115
+ 3. Sample 3-5 representative models — don't enumerate all
116
+
117
+ #### For `quality-playbook` (patterns, anti-patterns):
118
+ 1. Look at recent fix commits: `git log --grep="fix:" --oneline | head -20` to spot recurring issues
119
+ 2. `find_symbol` on commonly-fixed areas (validation, error handling)
120
+ 3. Read a representative service file to extract baseline patterns
121
+
122
+ #### For `constitution` (security, validation, DI, errors):
123
+ 1. `find_symbol(name_path="...", substring_matching=true)` on patterns: `Dto`, `Pipe`, `Filter`, `Interceptor`, `Module`
124
+ 2. Read 1-2 examples of each to extract project conventions
125
+ 3. Read root module file for DI/wiring style
126
+
127
+ #### For `core-memory` (history):
128
+ 1. Read existing `project-memory/core-memory.md` if present (this is a manual record, not auto-derived)
129
+ 2. `git log --oneline | head -30` to see recent work
130
+ 3. Cross-reference with existing core-memory to identify what's new or changed
131
+
132
+ ### 2.3 Efficiency
133
+
134
+ - Always prefer `get_symbols_overview` + targeted `find_symbol` over raw `Read`
135
+ - Target ≤8 Serena calls total for Phase 2
136
+ - For files that aren't code (configs, migrations, json), use `Read` with `offset`/`limit` to read only relevant sections
137
+
138
+ ---
139
+
140
+ ## Phase 3 — Extract patterns from codebase
141
+
142
+ Based on the graph results, perform targeted reads **only** for files the graph identified as relevant. Never read entire directories or all files of a type.
143
+
144
+ ### 3.1 For each artifact type, identify key sections
145
+
146
+ | Artifact | What to extract | How | Sources |
147
+ |----------|-----------------|-----|---------|
148
+ | `repo-map` | Module directories, naming conventions, required files per module type, reusable components, entry points | Read 1–3 representative module files per community; extract patterns | Graph: list_communities results; File reads: module index files, example modules |
149
+ | `architecture` | Layer structure, communication flows, module boundaries, coupling points | Read architecture-touching files (root module wiring, main controller/handler patterns) | Graph: get_architecture_overview, bridge/hub nodes; Spot-check: root module, integration points |
150
+ | `auth-model` | Guard types, token structure, permission check flow, tenant/resource scoping patterns | Read auth entry points and example auth-gated endpoints | Graph: semantic_search results for "auth guard", "jwt", "permission"; Spot-check: auth.module, sample protected endpoints |
151
+ | `models` | ORM conventions, association patterns, field naming, timestamps/soft deletes | Read 3–5 representative model files | Graph: semantic_search for "model entity"; Read: models from different domains |
152
+ | `constitution` | Validation rules, error envelope, DI patterns, SQL safety, logging, secret handling | Read representative implementations of each concern | Graph: semantic_search for "validation", "error", "provider", "query"; Spot-check: sample service, controller, query file |
153
+ | `quality-playbook` | Recurring bugs, anti-patterns, preferred fixes | Analyze graph results for hotspots; read examples of fixes in git history or test files | Graph: find_large_functions, get_knowledge_gaps; Bash: `git log --grep="fix:" --oneline \| head -20` |
154
+ | `core-memory` | Completed modules, design decisions, patterns to reuse/avoid | Existing file + graph enumeration | Existing core-memory.md; Graph: list_communities |
155
+
156
+ ### 3.2 Read targeted files
157
+
158
+ For each file the graph flagged:
159
+ - Read it in full **once** (do not re-read).
160
+ - Extract the pattern or decision it exemplifies.
161
+ - Note: if file_path is long, use `offset` and `limit` to read only relevant sections.
162
+
163
+ ---
164
+
165
+ ## Phase 4 — Generate the artifact
166
+
167
+ Create or update the project-memory file following the standard structure for that artifact type.
168
+
169
+ ### Structure templates
170
+
171
+ #### constitution.md
172
+
173
+ ```markdown
174
+ # Constitution
175
+
176
+ Non-negotiable rules for this codebase.
177
+
178
+ ## 1. Project structure
179
+ - [Rule about module layout, naming, file organization]
180
+ - [Rule about where to put features]
181
+ - [Rule about shared vs feature-specific code]
182
+
183
+ ## 2. Security
184
+ - [Rule about auth guards, token handling]
185
+ - [Rule about secrets, config, environment variables]
186
+ - [Rule about input validation, injection safety]
187
+
188
+ ## 3. Validation
189
+ - [Rule about DTO usage, validation pipes]
190
+ - [Rule about boundary validation vs internal trust]
191
+ - [Rule about error messages, logging PII]
192
+
193
+ ## 4. Auth invariants
194
+ - [Rule about request context ownership]
195
+ - [Rule about tenant/resource scoping]
196
+ - [Rule about permission checks (controller vs service level)]
197
+
198
+ ## 5. Dependency injection
199
+ - [Rule about module structure, imports/exports]
200
+ - [Rule about token naming, reuse]
201
+ - [Rule about avoiding circular dependencies]
202
+
203
+ ## 6. Database & SQL
204
+ - [Rule about parameterization, no string interpolation]
205
+ - [Rule about row-level security, ownership predicates]
206
+ - [Rule about migrations, schema versioning]
207
+
208
+ ## 7. Error handling
209
+ - [Rule about status codes, error envelope]
210
+ - [Rule about logging vs swallowing errors]
211
+
212
+ ## 8. Caching
213
+ - [Rule about cache key derivation]
214
+ - [Rule about cache bypass/refresh triggers]
215
+
216
+ ## 9. Logging
217
+ - [Rule about PII, secrets, sensitive data]
218
+ - [Rule about structured logging, context]
219
+
220
+ ## 10. Dependencies
221
+ - [Rule about adding external libraries]
222
+ - [Rule about framework usage, anti-patterns]
223
+ ```
224
+
225
+ #### auth-model.md
226
+
227
+ ```markdown
228
+ # Auth Model
229
+
230
+ Complete JWT flow, guard chain, RBAC entities, identity propagation.
231
+
232
+ ## Token issuance
233
+ - [How JWT is created: algorithm, claims, expiry]
234
+ - [Where token issuance happens: auth controller/service endpoint]
235
+ - [Token refresh strategy if applicable]
236
+
237
+ ## Guard chain
238
+ - [List of guards in order: auth guard, permission guard, custom guards]
239
+ - [How each guard is applied: decorators, middleware, imports]
240
+ - [Example endpoint with guard chain]
241
+
242
+ ## Request context propagation
243
+ - [How authenticated user context flows into services]
244
+ - [How to access current user in controller/service: decorator, injection]
245
+ - [How tenant/ownership context is passed]
246
+
247
+ ## RBAC entities
248
+ - [User role structure: built-in roles, custom roles]
249
+ - [Permission structure: what permissions exist, how they're grouped]
250
+ - [Role-permission associations: how roles get permissions]
251
+
252
+ ## Tenant/resource scoping
253
+ - [How tenant is determined: from JWT claim, request context, or other]
254
+ - [How resources are filtered by tenant: query predicates, service-level checks]
255
+ - [How ownership is enforced: user ID checks, team ID checks]
256
+
257
+ ## Identity propagation patterns
258
+ - [Example: controller accepting CurrentUser decorator → passing to service]
259
+ - [Example: service using authenticated context for filtering]
260
+ - [Example: cross-service calls preserving identity]
261
+ ```
262
+
263
+ #### repo-map.md
264
+
265
+ ```markdown
266
+ # Repo Map
267
+
268
+ Module layout, naming conventions, reusable components, file organization.
269
+
270
+ ## Naming conventions
271
+ - Modules: [kebab-case, snake_case, camelCase?]
272
+ - Files: [extension patterns, file naming rules]
273
+ - Classes/functions: [camelCase, PascalCase rules]
274
+ - DTOs/entities: [naming patterns for requests, responses, database models]
275
+
276
+ ## Directory structure
277
+ [Show the canonical structure: which folders hold features, which hold core, where config/shared lives]
278
+
279
+ ## Module types
280
+ [For each type of module (API feature, core service, shared utility, etc.), list required files]
281
+
282
+ Example:
283
+ ```
284
+ src/apis/my-feature/
285
+ ├── my-feature.controller.ts
286
+ ├── my-feature.service.ts
287
+ ├── my-feature.dto.ts
288
+ ├── my-feature.model.ts
289
+ ├── my-feature.module.ts
290
+ ├── my-feature.repository.ts
291
+ └── my-feature.spec.ts
292
+ ```
293
+
294
+ ## Reusable components
295
+ - [Auth guards, decorators, and where to import them]
296
+ - [Validation pipes, decorators]
297
+ - [Common services (logger, config, cache, storage)]
298
+ - [How to extend/use them in new features]
299
+
300
+ ## Key entry points
301
+ - [Root module: where features are wired in]
302
+ - [Server entry: main.ts, app.module.ts, or equivalent]
303
+ - [Database: migrations, models registry]
304
+ - [Config: env var patterns, bootstrap]
305
+
306
+ ## Known cross-module imports
307
+ - [What modules are safe to import from: e.g., src/common/, src/core/]
308
+ - [What modules should NOT be imported: avoid coupling]
309
+ ```
310
+
311
+ #### core-memory.md
312
+
313
+ ```markdown
314
+ # Core Memory
315
+
316
+ Historical implementation decisions, completed modules, design lessons.
317
+
318
+ ## Completed modules / features
319
+ - [Feature name and milestone]
320
+ - [Brief description of what was built]
321
+ - [Key design decisions made (if interesting)]
322
+ - [Known limitations or follow-up work]
323
+
324
+ Example:
325
+ - **Auth system (M1-M3)**: Implemented JWT flow with Guardian guards. Uses @CurrentUser() for context propagation. Tenant scoping via JWT `tenant_id` claim. Follow-up: add refresh token rotation (deferred to M5).
326
+
327
+ ## Design decisions & rationale
328
+ - [Decision]: [Why it was made] [Tradeoff or lessons learned]
329
+
330
+ Example:
331
+ - **Services handle all business logic, not controllers**: Keeps controllers thin, allows service reuse, testable in isolation. Downside: services can become large (mitigated by splitting into focused services per domain).
332
+
333
+ ## Patterns to follow
334
+ - [Pattern name]: [When to use] [Example file]
335
+
336
+ Example:
337
+ - **Repository pattern for data access**: All database queries go through a repository. Controllers → Services → Repositories. Keeps SQL/ORM details out of business logic.
338
+
339
+ ## Patterns to avoid
340
+ - [Anti-pattern]: [Why it's bad] [If encountered, how to fix]
341
+
342
+ Example:
343
+ - **Direct request data in queries**: Never pass req.body.userId into a SQL filter. Extract authenticated user context from JWT/request context instead.
344
+ ```
345
+
346
+ #### models.md
347
+
348
+ ```markdown
349
+ # Domain Models
350
+
351
+ Inventory of ORM entities, associations, field contracts, constraints.
352
+
353
+ ## Model: [Entity name]
354
+ - **Table**: [table_name]
355
+ - **ORM**: [Sequelize / TypeORM / other]
356
+ - **Fields**:
357
+ - [field_name]: [type] [constraints: nullable, unique, default, indexed]
358
+ - [...]
359
+ - **Associations**:
360
+ - hasMany: [Target model] (via foreign key [fk_name])
361
+ - belongsTo: [Target model] (via foreign key [fk_name])
362
+ - [...]
363
+ - **Timestamps**: [createdAt, updatedAt strategy]
364
+ - **Soft delete**: [Yes/No, how]
365
+ - **Indexing**: [Indexes on [fields]]
366
+ - **Constraints**: [Unique, check, or business rules]
367
+
368
+ [Example for User model]
369
+ ## Model: User
370
+ - **Table**: users
371
+ - **ORM**: Sequelize
372
+ - **Fields**:
373
+ - id (UUID, primary key)
374
+ - email (string, unique, not null)
375
+ - password_hash (string, not null)
376
+ - role_id (UUID, foreign key to roles, not null)
377
+ - tenant_id (UUID, foreign key to tenants, not null)
378
+ - created_at (timestamp, auto)
379
+ - updated_at (timestamp, auto)
380
+ - deleted_at (timestamp, soft delete)
381
+ - **Associations**:
382
+ - belongsTo: Role (via role_id)
383
+ - belongsTo: Tenant (via tenant_id)
384
+ - hasMany: Sessions (via user_id)
385
+ - **Timestamps**: Yes (created_at, updated_at)
386
+ - **Soft delete**: Yes (deleted_at)
387
+ - **Indexing**: tenant_id, role_id, email
388
+ ```
389
+
390
+ #### architecture.md
391
+
392
+ ```markdown
393
+ # Architecture
394
+
395
+ System-level architecture decisions, module topology, data flow, integration points.
396
+
397
+ ## System layers
398
+ [Description of application layers: e.g., Controller → Service → Repository → Database]
399
+
400
+ ## Module topology
401
+ - [Core modules]: [services that all other modules depend on]
402
+ - [API modules]: [feature-specific modules in src/apis/]
403
+ - [External integrations]: [modules for API clients, queues, storage, etc.]
404
+
405
+ ## Data flow
406
+ [Diagram or description of how data moves through the system]
407
+
408
+ Example:
409
+ ```
410
+ Request → Controller → Guard (auth) → Service → Repository → Database
411
+
412
+ Interceptor (logging, error handling)
413
+ ```
414
+
415
+ ## Key integration points
416
+ - [External API]: [How it's called, timeout/retry strategy, error handling]
417
+ - [Message queue]: [How messages are published/consumed]
418
+ - [Cache layer]: [What's cached, TTL strategy]
419
+ - [Storage]: [File storage, blob service, bucket strategy]
420
+
421
+ ## Cross-module boundaries
422
+ - [Module A imports from Module B]: [OK/Not OK; if OK, what interface]
423
+ - [Known coupling]: [Description of unavoidable cross-module dependency]
424
+
425
+ ## Architectural decisions & tradeoffs
426
+ - [Decision]: [Why] [Tradeoff]
427
+
428
+ Example:
429
+ - **Monolithic API backend**: Simple to deploy and reason about. Tradeoff: harder to scale individual features independently (mitigated with feature flags and service extraction when needed).
430
+ ```
431
+
432
+ #### quality-playbook.md
433
+
434
+ ```markdown
435
+ # Quality Playbook
436
+
437
+ High-signal check patterns with symptoms, root causes, and preferred fixes.
438
+
439
+ ## Pattern: [Name]
440
+
441
+ **When you see**: [Symptoms; what code looks like when this goes wrong]
442
+
443
+ **Root cause**: [Why this happens]
444
+
445
+ **Preferred fix**: [How to fix it; code pattern to follow]
446
+
447
+ **Example**:
448
+ [Code snippet showing the antipattern and the fix]
449
+
450
+ ---
451
+
452
+ ## Pattern: Unvalidated endpoint input
453
+
454
+ **When you see**: Controller method accepts `req.body` and passes it directly to a service, or passes `req.body.userId` directly into a query filter.
455
+
456
+ **Root cause**: Assuming the framework or downstream layers validate input. Trusting client data.
457
+
458
+ **Preferred fix**: Always validate at the controller boundary. Use DTOs + ValidationPipe. Extract authenticated context (user ID, tenant) from JWT/request context, never from request body.
459
+
460
+ **Example**:
461
+ ```typescript
462
+ // ❌ Bad
463
+ @Post('transfer')
464
+ transfer(@Body() body: any) {
465
+ return this.service.transfer(body.fromId, body.toId, body.amount);
466
+ }
467
+
468
+ // ✅ Good
469
+ @Post('transfer')
470
+ @UseGuards(CanAuthGuard)
471
+ transfer(
472
+ @CurrentUser() user: UserContext,
473
+ @Body() dto: TransferDto,
474
+ ) {
475
+ return this.service.transfer(user.id, dto.toId, dto.amount);
476
+ }
477
+ ```
478
+
479
+ ---
480
+
481
+ ## Pattern: [Next pattern]
482
+ ...
483
+ ```
484
+
485
+ ---
486
+
487
+ ## Phase 5 — Compare with existing artifact (if update)
488
+
489
+ ### 5.1 Identify changes
490
+
491
+ If the artifact already exists, compare:
492
+ - **New sections**: sections in your generated version that don't exist in the current file.
493
+ - **Updated sections**: sections where content has changed (decisions, patterns, module list).
494
+ - **Stale sections**: sections that are outdated (modules that no longer exist, deprecated patterns).
495
+
496
+ ### 5.2 Preserve manual decisions
497
+
498
+ For artifacts like `core-memory` that include manual decisions and lessons:
499
+ - **Do NOT delete** existing completed modules or design decisions.
500
+ - **Do ADD** new modules/decisions from the latest feature work.
501
+ - **Do UPDATE** rationale if the reasoning has changed.
502
+
503
+ ---
504
+
505
+ ## Phase 6 — Present changes to user
506
+
507
+ ### 6.1 Show a diff-style summary
508
+
509
+ For an **update**:
510
+ ```
511
+ # Changes to project-memory/auth-model.md
512
+
513
+ ## New sections
514
+ - [New section name]: [brief description]
515
+
516
+ ## Updated sections
517
+ - [Section name]: [what changed]
518
+
519
+ ## Removed sections
520
+ - [Section name]: [why no longer relevant]
521
+ ```
522
+
523
+ For a **creation**:
524
+ ```
525
+ # New artifact: project-memory/repo-map.md
526
+
527
+ This artifact defines:
528
+ - [Key item 1]
529
+ - [Key item 2]
530
+ - ...
531
+ ```
532
+
533
+ ### 6.2 Ask for confirmation
534
+
535
+ Present the changes and ask:
536
+ - "Does this match the current codebase structure?"
537
+ - "Are there sections you'd like me to expand or clarify?"
538
+ - "Any decisions or patterns you want me to add manually?"
539
+
540
+ Wait for user approval before writing the file.
541
+
542
+ ---
543
+
544
+ ## Phase 7 — Write the artifact
545
+
546
+ ### 7.1 Write to project-memory/
547
+
548
+ ```
549
+ project-memory/<artifact-type>.md
550
+ ```
551
+
552
+ ### 7.2 Update project-memory/README.md
553
+
554
+ If the artifact is new, add an entry to the index:
555
+
556
+ ```markdown
557
+ | [artifact-type].md | [Brief description] | [Who updates it: auto / manual / both] |
558
+ ```
559
+
560
+ If artifact already exists, ensure the index is still accurate.
561
+
562
+ ### 7.3 Set up symlinks
563
+
564
+ #### 7.3.1 Artifact symlinks (for new artifacts only)
565
+
566
+ If this is a **new artifact**, create symlinks in `.claude/` and `.cursor/` pointing to the single source of truth in `project-memory/`:
567
+
568
+ ```bash
569
+ # For .claude/
570
+ ln -sf ../project-memory/<artifact-type>.md .claude/docs/<artifact-type>.md
571
+
572
+ # For .cursor/
573
+ ln -sf ../project-memory/<artifact-type>.md .cursor/docs/<artifact-type>.md
574
+ ```
575
+
576
+ **Verify links exist and are correct**:
577
+ ```bash
578
+ ls -la .claude/docs/<artifact-type>.md .cursor/docs/<artifact-type>.md
579
+ ```
580
+
581
+ If either symlink already exists, skip (do not overwrite).
582
+
583
+ #### 7.3.2 Module execution
584
+
585
+ Feature execution is now handled entirely by the `/module-runner` skill (no shell script needed). `/module-runner` is wired during `npm exec nurosys-agent-setup` for the user's chosen IDE. No additional setup required here.
586
+
587
+ ### 7.4 Wire artifact as a Cursor rule
588
+
589
+ After writing the artifact, run the cursor rules setup script to create (or refresh) the `.cursor/rules/<artifact-type>.mdc` symlink pointing to the new file:
590
+
591
+ ```bash
592
+ node scripts/setup-cursor-rules.js
593
+ ```
594
+
595
+ Or if installed as a package bin:
596
+ ```bash
597
+ npm exec nurosys-setup-rules
598
+ ```
599
+
600
+ This script:
601
+ - Creates `.cursor/rules/` if it does not exist
602
+ - Adds a `.mdc` symlink for every `project-memory/*.md` that exists
603
+ - Skips files that already have a symlink
604
+ - Reports which files were linked, skipped, or missing
605
+
606
+ The `.cursor/rules/<artifact>.mdc` files are written by `nurosys-setup-rules` with the correct MDC frontmatter automatically — you do not need to embed frontmatter in the `project-memory/` source files. For reference, the frontmatter applied per artifact is:
607
+
608
+ | Artifact | `description` | `globs` | `alwaysApply` |
609
+ |----------|--------------|---------|---------------|
610
+ | `constitution.md` | "Non-negotiable project rules and coding standards" | — | `true` |
611
+ | `architecture.md` | "System architecture, module topology, and data flow" | — | `true` |
612
+ | `repo-map.md` | "Repository module layout, naming conventions, and reusable components" | — | `true` |
613
+ | `auth-model.md` | "Auth model, JWT flow, guard chain, RBAC, and tenant scoping" | `["src/auth/**", "src/core/auth/**"]` | `false` |
614
+ | `models.md` | "Domain model inventory and entity definitions" | `["src/**/*.model.ts", "src/**/*.entity.ts"]` | `false` |
615
+ | `quality-playbook.md` | "Code quality patterns, anti-patterns, and preferred fixes for this project" | — | `false` |
616
+ | `core-memory.md` | "Project history, design decisions, and completed modules" | — | `false` |
617
+
618
+ When `create-blueprint all` runs, call the script once at the end after all artifacts are written.
619
+
620
+ ### 7.5 Confirm with user
621
+
622
+ Report:
623
+ - The artifact file path: `project-memory/<artifact-type>.md`
624
+ - Whether `.cursor/rules/<artifact-type>.mdc` symlink was created or already existed
625
+ - Whether this was a creation or update
626
+ - Number of sections/changes
627
+
628
+ ---
629
+
630
+ ## Quality gates
631
+
632
+ Before finalizing the artifact:
633
+
634
+ - [ ] All sections are present and complete for this artifact type.
635
+ - [ ] Examples are concrete and drawn from actual codebase (not hypothetical).
636
+ - [ ] Decisions/patterns are consistent with what the code actually does (not aspirational).
637
+ - [ ] No broken file paths or module names (spot-check against actual files).
638
+ - [ ] Language is clear and actionable (team members could follow the rules without asking).
639
+ - [ ] For updates: no useful content from the prior version was removed without reason.
640
+
641
+ ---
642
+
643
+ ## Notes
644
+
645
+ - **Single source of truth**: project-memory artifacts are the authoritative reference stored in `project-memory/<artifact-type>.md`. If they conflict with code, the code is wrong — update the code, not the artifact.
646
+ - **Symlink architecture**: Artifacts in `project-memory/` are symlinked from `.claude/docs/` and `.cursor/docs/` to avoid duplication. Symlinks are created automatically when a new artifact is generated. **Always edit the artifact in `project-memory/`, never in the symlink copies.**
647
+ - **Regular refresh cadence**: After each completed feature module (or every 2–3 weeks), run `create-blueprint` on `core-memory` and `repo-map` to keep them current.
648
+ - **Serena-first approach**: Always use Serena's symbolic tools (`get_symbols_overview`, `find_symbol`, `find_referencing_symbols`) before reading whole files. Symbolic navigation is faster and uses far fewer tokens.
649
+ - **Curation, not exhaustion**: Artifact sections describe the most important patterns and decisions, not every detail. If a pattern is used once, it probably doesn't need to be in the playbook.
650
+ - **Portable artifacts**: These skill generates artifacts that are project-specific in content but portable in structure. You can copy the `project-memory/` folder to another project and run the skill again to regenerate them with that project's codebase.