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,436 @@
1
+ ---
2
+ name: architect
3
+ description: Pure planner. Designs a multi-module implementation plan for a feature, system refactor, or capability change. Reads project-memory, decomposes work into ordered modules, consults read-only sub-agents (auth-and-permissions, security-assessment) for cross-cutting concerns, and writes ONLY planning documents under `documentation/features/<feature>/`. NEVER WRITES CODE. Hands off to `/module-runner` for execution.
4
+ disable-model-invocation: false
5
+ ---
6
+
7
+ # Skill: architect
8
+
9
+ The planner. Designs a feature's modules, dependencies, contracts, and risks. Outputs documents the user can review before any code is written.
10
+
11
+ ## Hard guarantee — architect NEVER writes code
12
+
13
+ This is the single most important rule of this skill.
14
+
15
+ **What architect produces (and ONLY this):**
16
+ - `documentation/features/<feature_name>/<feature>_MODULE_WISE_PLAN.md` — master plan
17
+ - `documentation/features/<feature_name>/<feature>_MODULE_<N>_<MODULE_NAME>.md` — one prompt per module (input for `/module-runner`)
18
+
19
+ **What architect MUST NOT touch:**
20
+ - Anything under `src/`, `lib/`, `app/`, or any source-code directory
21
+ - Tests, migrations, configs
22
+ - Git (no commits, no branches, no pushes)
23
+ - Dependencies (no `npm install`, no edits to `package.json`)
24
+ - `project-memory/` except optionally appending to `core-memory.md` to note "feature X planned on <date>" — and even that is deferred to `/module-runner`'s wrap-up
25
+
26
+ If at any point you feel the urge to write code "just to validate the plan", **stop**. The plan is a document; the execution is `/module-runner`'s job.
27
+
28
+ ---
29
+
30
+ ## When to trigger
31
+
32
+ - User asks to "architect", "plan", "design", "break down", or "decompose" a feature
33
+ - Work spans more than one module or service
34
+ - A `/brainstorm` session produced a chosen approach and the user is ready to plan
35
+
36
+ ---
37
+
38
+ ## Output locations
39
+
40
+ All outputs go under `documentation/features/<feature_name>/`:
41
+
42
+ | File | Purpose |
43
+ |------|---------|
44
+ | `<feature>_MODULE_WISE_PLAN.md` | Master plan: modules, dependencies, contracts, rollout |
45
+ | `<feature>_MODULE_<N>_<MODULE_NAME>.md` | Per-module prompt consumed by `/module-runner` |
46
+
47
+ Naming:
48
+ - `<feature_name>` is `snake_case` (e.g. `sse_streaming`, `audit_logging`)
49
+ - `<N>` is the module number (e.g. `1`, `2`, `3`)
50
+ - `<MODULE_NAME>` is abbreviated `UPPER_SNAKE_CASE` (e.g. `MODEL_LAYER`, `AUTH_GUARD`)
51
+
52
+ ---
53
+
54
+ ## Phase 0 — Prerequisites (HARD STOP)
55
+
56
+ Confirm `project-memory/` exists. Required:
57
+
58
+ - `project-memory/constitution.md`
59
+ - `project-memory/repo-map.md`
60
+ - `project-memory/auth-model.md`
61
+ - `project-memory/architecture.md`
62
+ - `project-memory/core-memory.md`
63
+
64
+ If any are missing, **STOP** and respond:
65
+
66
+ > ⚠️ `/architect` requires `project-memory/` artifacts to ground the plan. Missing:
67
+ > - [list each missing file]
68
+ >
69
+ > Run `/create-blueprint all` (or `/create-blueprint <artifact>` for individual ones), then re-invoke `/architect <feature>`.
70
+
71
+ Do not proceed to Phase 1 until every required file exists.
72
+
73
+ ---
74
+
75
+ ## Phase 1 — Research & Discovery (read-only)
76
+
77
+ ### 1.1 Read foundation docs
78
+
79
+ Read in this order:
80
+
81
+ | File | What you extract |
82
+ |------|------------------|
83
+ | `project-memory/constitution.md` | Non-negotiable rules the plan must honor |
84
+ | `project-memory/architecture.md` | System layering, module boundaries, data flow |
85
+ | `project-memory/repo-map.md` | Where things live, naming, reusable components |
86
+ | `project-memory/auth-model.md` | Auth/permission model — needed if the feature touches protected resources |
87
+ | `project-memory/core-memory.md` | Prior decisions, completed modules, lessons |
88
+ | `project-memory/models.md` (if present) | Existing entities the feature may touch |
89
+ | `project-memory/quality-playbook.md` (if present) | Patterns/anti-patterns to honor |
90
+
91
+ ### 1.2 Map existing code with Serena (≤8 calls)
92
+
93
+ Use Serena's symbolic tools, not raw reads:
94
+
95
+ | Need | Tool |
96
+ |---|---|
97
+ | List symbols in a relevant file | `get_symbols_overview(relative_path="...")` |
98
+ | Find a class, service, or controller by name | `find_symbol(name_path="...", include_body=false)` |
99
+ | Read a specific symbol body | `find_symbol(name_path="...", include_body=true)` |
100
+ | Trace who calls a function | `find_referencing_symbols(...)` |
101
+ | Project memories (Serena-stored notes from prior sessions) | `list_memories`, then `read_memory` if useful |
102
+
103
+ Target: ≤8 calls. Only escalate to full-file `Read` if Serena can't surface what you need.
104
+
105
+ ### 1.3 Capture scope decisions (present to user before continuing)
106
+
107
+ Write down explicitly:
108
+
109
+ - **In scope** — what this plan delivers
110
+ - **Out of scope** — what is deferred or handled elsewhere
111
+ - **Assumptions** — anything the design depends on
112
+
113
+ Show these to the user and ask for confirmation. Adjust before continuing.
114
+
115
+ ---
116
+
117
+ ## Phase 2 — Cross-cutting sub-agent consultations (read-only)
118
+
119
+ For any module that touches a cross-cutting concern, consult the relevant sub-agent **as a planning input**. These sub-agents do not write code — they return structured advice that goes into the plan.
120
+
121
+ Run consultations **in parallel** where supported (Claude Code Task / Cursor subagent background mode). Sub-agents only need a short prompt with the proposed module surface.
122
+
123
+ | Concern | Sub-agent to invoke | What you ask for |
124
+ |---|---|---|
125
+ | New protected endpoints, role/permission changes, tenant scoping | `/auth-and-permissions` (planning_input mode) | Recommended guard, permission key, current-user extractor, ownership scope per endpoint |
126
+ | Sensitive data, new external integrations, anything handling auth/PII/secrets | `/security-assessment` (pre-design review) | Risks specific to the proposed surface; constraints the design should respect |
127
+
128
+ Sub-agent invocation contract (parent prompt):
129
+
130
+ > Sub-agent mode. Proposed module surface: [list endpoints, services, entities, data flow]. Return planning_input JSON per your SKILL.md.
131
+
132
+ Capture each sub-agent's returned JSON. Use it directly in the module specs (Phase 3) — don't paraphrase away the specifics.
133
+
134
+ If a sub-agent flags a BLOCKER (e.g. no documented auth pattern fits, fundamental security flaw in the proposed approach), **stop and surface it to the user**. Do not silently adjust the plan around it.
135
+
136
+ ---
137
+
138
+ ## Phase 3 — Module Decomposition
139
+
140
+ ### 3.1 Decomposition principles
141
+
142
+ 1. **Single responsibility** — one module does one thing
143
+ 2. **Independent deployability** — a module can ship without breaking what's there
144
+ 3. **Explicit dependencies** — if Module B needs Module A, state it
145
+ 4. **Incremental value** — each module delivers testable value on its own
146
+ 5. **Smallest viable unit** — prefer more smaller modules; if a module is estimated >8 hours, split it
147
+
148
+ ### 3.2 Per-module fields
149
+
150
+ For every module, define:
151
+
152
+ | Field | Content |
153
+ |---|---|
154
+ | **Goal** | One-sentence purpose |
155
+ | **Depends on** | Prerequisite modules (omit if standalone) |
156
+ | **Estimated effort** | Time range (e.g. "4–6 hours") |
157
+ | **Key deliverables** | Files / services / endpoints created or modified |
158
+ | **New files** | Table of new files + purpose (omit if none) |
159
+ | **Modified files** | Files this module changes (omit if none) |
160
+ | **Architecture** | ASCII diagram or short description of interactions |
161
+ | **Core interfaces / API** | TypeScript types, function signatures, endpoint contracts (text only) |
162
+ | **Auth approach** | From `/auth-and-permissions` sub-agent output for this module (if applicable) |
163
+ | **Security considerations** | From `/security-assessment` sub-agent output for this module (if applicable) |
164
+ | **Implementation notes** | Patterns, edge cases, constraints, things to watch for |
165
+ | **Error handling** | Explicit error scenarios and responses |
166
+ | **How to test** | Concrete verification steps for this module alone |
167
+
168
+ ### 3.3 Architecture diagrams
169
+
170
+ Use ASCII for any non-trivial module:
171
+
172
+ ```
173
+ ┌──────────────┐ ┌──────────────────┐
174
+ │ Controller │──────▶│ Service │──────▶ DB / External
175
+ └──────────────┘ └──────────────────┘
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Phase 4 — Dependency Ordering
181
+
182
+ ### 4.1 Build the dependency graph
183
+
184
+ - Map dependencies between modules
185
+ - Identify standalone modules (these ship first)
186
+ - Identify the critical path (longest dependent chain)
187
+
188
+ ### 4.2 Implementation order
189
+
190
+ Present as a numbered vertical chain:
191
+
192
+ ```
193
+ Module 1 — MODEL_LAYER (standalone)
194
+
195
+ Module 2 — SERVICE_LAYER (depends on M1)
196
+
197
+ Module 3 — API_ENDPOINTS (depends on M2)
198
+ ```
199
+
200
+ ### 4.3 Merge points
201
+
202
+ - Which modules can merge individually (purely additive, backward compatible)?
203
+ - Which must merge together (tightly coupled contract)?
204
+ - Which need a feature flag?
205
+
206
+ ---
207
+
208
+ ## Phase 5 — Write `<feature>_MODULE_WISE_PLAN.md`
209
+
210
+ Save to `documentation/features/<feature_name>/<feature>_MODULE_WISE_PLAN.md`.
211
+
212
+ Structure:
213
+
214
+ ```markdown
215
+ # [Feature Name] — Module-Wise Plan
216
+
217
+ [One-paragraph description of what this plan delivers and why.]
218
+
219
+ > **Scope decisions (confirmed):**
220
+ > - In scope: ...
221
+ > - Out of scope: ...
222
+ > - Assumptions: ...
223
+
224
+ ---
225
+
226
+ ## Module Overview
227
+
228
+ | # | Module | Depends On | Effort | Key Deliverables |
229
+ |---|--------|-----------|--------|------------------|
230
+ | 1 | ... | — | X–Y hr | ... |
231
+ | 2 | ... | M1 | X–Y hr | ... |
232
+
233
+ ---
234
+
235
+ ## Module 1 — [Name]
236
+
237
+ **Goal**: ...
238
+
239
+ ### Auth approach (from /auth-and-permissions consultation)
240
+ [Inline the relevant snippet from sub-agent JSON, if applicable]
241
+
242
+ ### Security considerations (from /security-assessment consultation)
243
+ [Inline the relevant snippet, if applicable]
244
+
245
+ ### New Files
246
+ | File | Purpose |
247
+ |------|---------|
248
+ | ... | ... |
249
+
250
+ ### Architecture
251
+ [ASCII diagram]
252
+
253
+ ### Core interfaces / API
254
+ [Text only — TypeScript signatures, endpoint contracts]
255
+
256
+ ### Implementation notes
257
+ - ...
258
+
259
+ ### Error handling
260
+ - ...
261
+
262
+ ### How to test
263
+ - ...
264
+
265
+ ---
266
+
267
+ ## Module 2 — [Name]
268
+ ...
269
+
270
+ ---
271
+
272
+ ## Implementation Order
273
+
274
+ [Dependency chain diagram]
275
+
276
+ **Recommended merge points:**
277
+ - ...
278
+
279
+ ---
280
+
281
+ ## Environment / Config Additions
282
+
283
+ | Variable | Default | Purpose |
284
+ |----------|---------|---------|
285
+ | ... | ... | ... |
286
+
287
+ ---
288
+
289
+ ## Files Inventory
290
+
291
+ | File | Action | Module |
292
+ |------|--------|--------|
293
+ | ... | Create/Modify | M1 |
294
+ ```
295
+
296
+ ---
297
+
298
+ ## Phase 6 — Approval Gate (HARD STOP)
299
+
300
+ After writing `_MODULE_WISE_PLAN.md`, **STOP**. Do not proceed to Phase 7. Do not generate module prompt files yet.
301
+
302
+ Present the plan to the user:
303
+ - Path to the plan file
304
+ - One-paragraph summary of the modules
305
+ - The implementation order
306
+ - Any sub-agent findings that materially shaped the plan
307
+
308
+ Wait for explicit user approval. If the user requests changes, update the plan and re-present.
309
+
310
+ ---
311
+
312
+ ## Phase 7 — Generate Per-Module Prompts
313
+
314
+ Only after explicit user approval.
315
+
316
+ ### 7.1 Output files
317
+
318
+ For each module `N`:
319
+ ```
320
+ documentation/features/<feature_name>/<feature>_MODULE_<N>_<MODULE_NAME>.md
321
+ ```
322
+
323
+ ### 7.2 Per-module prompt format
324
+
325
+ Each file must follow this template:
326
+
327
+ ````markdown
328
+ You are implementing **Module <N> — <Module Name>** of the `<feature_name>` feature.
329
+ The master plan was reviewed and approved. Proceed autonomously through all phases.
330
+
331
+ Execute under the `/module-runner` skill — it owns the per-module lifecycle (implement → test → review → fix → security audit → fix → commit → push).
332
+
333
+ ---
334
+
335
+ ## 1. Relevant context (curated for this module only)
336
+
337
+ ### Repo context
338
+ <Curated repo-map excerpt — see §7.3 curation rules>
339
+
340
+ ### Constitution rules (those this module can violate)
341
+ <Inline only the constitution sections relevant to this module>
342
+
343
+ ### Auth approach (from architect's /auth-and-permissions consultation)
344
+ <Inline the endpoint-level auth plan, if applicable>
345
+
346
+ ### Prior decisions (from core-memory)
347
+ <Inline only the entries this module builds on or must not contradict>
348
+
349
+ ---
350
+
351
+ ## 2. Module specification
352
+
353
+ <Full module section copied verbatim from the approved _MODULE_WISE_PLAN.md.
354
+ Omit empty subsections.>
355
+
356
+ ---
357
+
358
+ ## 3. Execution rules
359
+
360
+ - No placeholder code. No skipping validation, authz, or error handling.
361
+ - Preserve module boundaries documented in `project-memory/repo-map.md`.
362
+ - Use the project's documented config mechanism for env vars — never hardcode.
363
+ - After implementation, the `/module-runner` pipeline will run build + tests + code review + security audit. Do not bypass these.
364
+ - After all phases complete, `/module-runner` updates `project-memory/core-memory.md` for this module — you do not.
365
+ ````
366
+
367
+ ### 7.3 Content curation rules
368
+
369
+ 1. **Module specification** — copy the full module section from `_MODULE_WISE_PLAN.md` verbatim into §2. Omit empty subsections (no "New Files" if none, no "Depends on" if standalone).
370
+
371
+ 2. **Curated repo-map context** — under §1 "Repo context", include only the sections from `repo-map.md` this module needs:
372
+
373
+ | Always | Conditional |
374
+ |---|---|
375
+ | Naming conventions | Modules this one touches or depends on |
376
+ | Key entry points | Reusable components this module will use |
377
+ | | Core/shared service entries if this module uses auth/config/persistence/messaging |
378
+ | | Models registry entries if this module creates or references entities |
379
+
380
+ Target: ~30–50 lines of focused context. Omit the rest.
381
+
382
+ 3. **Curated constitution rules** — under §1 "Constitution rules", inline only sections this module could actually violate:
383
+
384
+ | Module touches | Include these sections |
385
+ |---|---|
386
+ | New endpoints | Auth/guard rules, input validation, error envelope |
387
+ | DB models/queries | SQL safety, parameterization, row-level scoping |
388
+ | External services | Outbound timeout/retry rules |
389
+ | Config/secrets | Config rules, no `process.env` in feature logic |
390
+ | Any new code | DI/module wiring rules |
391
+
392
+ Never paste the full constitution.
393
+
394
+ 4. **Auth approach inline** — if the architect's `/auth-and-permissions` consultation produced a planning JSON for this module, inline its endpoint-by-endpoint guidance directly. Don't summarize away the specifics.
395
+
396
+ 5. **Core-memory inline** — only entries this module depends on or must not contradict. Unrelated history is noise.
397
+
398
+ 6. **Replace placeholders** — `<feature_name>`, `<N>`, `<MODULE_NAME>` with actual values.
399
+
400
+ 7. **No code** — the prompt file describes what to build, not how to write it.
401
+
402
+ ### 7.4 Confirmation
403
+
404
+ After generating all module prompt files, present:
405
+ - List of all generated file paths
406
+ - The implementation order
407
+ - The hand-off command: `/module-runner documentation/features/<feature_name>/`
408
+
409
+ ---
410
+
411
+ ## Quality gates
412
+
413
+ Before finalizing the plan, verify:
414
+
415
+ - [ ] All modules have a clear Goal
416
+ - [ ] Dependencies between modules are explicit and acyclic
417
+ - [ ] Each module has a concrete How-to-test section
418
+ - [ ] No module violates `project-memory/constitution.md`
419
+ - [ ] Modules with auth surfaces have an inlined auth approach from sub-agent consultation
420
+ - [ ] Modules with sensitive data have inlined security considerations
421
+ - [ ] Implementation order respects the dependency graph
422
+ - [ ] Files Inventory covers every file change
423
+ - [ ] Scope decisions are documented and user-confirmed
424
+
425
+ ---
426
+
427
+ ## Hand-off to `/module-runner`
428
+
429
+ The plan is now ready for execution. Architect's work is done.
430
+
431
+ The user runs:
432
+ ```
433
+ /module-runner documentation/features/<feature_name>/
434
+ ```
435
+
436
+ `/module-runner` reads each module prompt in order, spawns sub-agents for build/review/security/fix, and commits each module before moving on. Architect does not participate in execution.
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: auth-and-permissions
3
+ description: Backend auth & authorization guardrails. Audits endpoints, guards, request-context propagation, and ownership/tenant scoping against the project's documented auth model. Generic across NestJS/Express/Fastify/Koa — driven entirely by `project-memory/auth-model.md`. Trigger on changes touching auth, login, jwt, session, middleware, permission, role, tenant, guard. Also invoked as a sub-agent by `/architect` and `/module-runner`.
4
+ disable-model-invocation: false
5
+ ---
6
+
7
+ # Skill: auth-and-permissions
8
+
9
+ Audits a change for auth correctness. This skill is **fully generic** — it owns the *checks*, but the project's specific guard names, permission decorators, context-extraction patterns, and ownership rules come from `project-memory/auth-model.md`.
10
+
11
+ **Two invocation modes:**
12
+
13
+ 1. **Manual / standalone** — Triggered by user or by `/code-reviewer` for a PR-level auth review. Produces a structured checklist note in chat (and optionally appended to a review report).
14
+ 2. **Sub-agent mode** — Invoked by `/architect` (during planning, to draft the auth approach for a planned module) or `/module-runner` (during per-module review). Returns a JSON object. Detect this mode from the parent's prompt — it will say "sub-agent mode".
15
+
16
+ ---
17
+
18
+ ## Phase 1 — Load the auth model
19
+
20
+ Read `project-memory/auth-model.md`. From it, extract:
21
+
22
+ | Concept (generic) | What you learn from auth-model.md (project-specific) |
23
+ |---|---|
24
+ | **Auth guard / middleware** | The class/function name(s) that enforce authentication |
25
+ | **Permission decorator / metadata** | How permission requirements are declared on a handler |
26
+ | **Current-user extractor** | The decorator/helper that yields authenticated identity inside a handler |
27
+ | **Tenant / ownership key** | Which JWT claim or context field carries tenant/org/user identity for filtering |
28
+ | **Public-endpoint convention** | How endpoints are explicitly marked public (e.g. `@Public()`, route exclusion list) |
29
+ | **Token issuance flow** | Where tokens are minted, what algorithm, expiry, refresh strategy |
30
+
31
+ If `project-memory/auth-model.md` does not exist, **STOP**. Tell the user: "Cannot audit auth without `project-memory/auth-model.md`. Run `/create-blueprint auth-model` first."
32
+
33
+ Also read (if present, skip silently if absent):
34
+ - `project-memory/constitution.md` §Security / §Validation / §Auth invariants — non-negotiable rules
35
+ - `project-memory/repo-map.md` — file locations for auth implementation
36
+
37
+ ---
38
+
39
+ ## Phase 2 — Determine scope
40
+
41
+ | Invocation | Scope |
42
+ |---|---|
43
+ | User-triggered with no args | Changed files on current branch (`git diff --name-only origin/main...HEAD`) |
44
+ | `/auth-and-permissions path:<path>` | Specific path |
45
+ | `/auth-and-permissions endpoint:<route>` | Single endpoint |
46
+ | Sub-agent (from `/architect`) | The proposed module's planned surface (described in the parent prompt) |
47
+ | Sub-agent (from `/module-runner`) | The current module's diff |
48
+
49
+ ---
50
+
51
+ ## Phase 3 — Identify the audit surface with Serena
52
+
53
+ Locate the auth-relevant code in scope. Target ≤6 calls.
54
+
55
+ - For each changed file, `get_symbols_overview` to list controllers/handlers
56
+ - `find_symbol` on the auth guard / permission decorator names from `auth-model.md` — verify they appear where expected
57
+ - `find_referencing_symbols` on the current-user extractor — verify handlers that need identity actually use it
58
+ - If services touch a sensitive entity, `find_referencing_symbols` on the entity's repository/query helpers to trace ownership filtering
59
+
60
+ ---
61
+
62
+ ## Phase 4 — Run the checks (generic, driven by auth-model)
63
+
64
+ For every endpoint/handler in scope:
65
+
66
+ ### 4.1 Authentication
67
+ - [ ] Endpoint has an explicit auth decision: protected by the documented guard, **or** explicitly marked public via the documented convention. Implicit/missing is a finding.
68
+
69
+ ### 4.2 Authorization (permissions)
70
+ - [ ] If the action is permission-gated (per `auth-model.md`), the documented permission decorator/metadata is present with the correct permission key.
71
+ - [ ] Permission strings/enums match values defined in `auth-model.md` (no ad-hoc strings).
72
+
73
+ ### 4.3 Request-context propagation
74
+ - [ ] Handlers that need user/tenant identity use the documented current-user extractor — never `req.body.userId`, `req.headers['x-user-id']`, or similar untrusted sources.
75
+ - [ ] Context is propagated to services as a typed object, not as raw request fragments.
76
+
77
+ ### 4.4 Ownership / tenant scoping
78
+ - [ ] For every query touching a tenant-scoped or user-owned entity, the query filters by the tenant/ownership key from auth context. Missing scope = blocker for sensitive resources.
79
+ - [ ] Mutations (UPDATE/DELETE) verify ownership before applying — not by trusting an ID from the request body alone.
80
+
81
+ ### 4.5 Input validation at the auth boundary
82
+ - [ ] Auth-sensitive inputs (credentials, tokens, permission grants, role assignments) are validated at the controller boundary with a typed DTO / schema.
83
+ - [ ] Validation rejects unknown fields where the framework supports it (e.g. `forbidNonWhitelisted`).
84
+
85
+ ### 4.6 No business logic in the auth layer; no auth logic in the business layer
86
+ - [ ] Guards/middleware do not perform business decisions (e.g. complex ownership traversal — that belongs in the service).
87
+ - [ ] Services do not re-implement authentication (e.g. re-validating JWTs that the guard already validated).
88
+
89
+ ### 4.7 Token handling
90
+ - [ ] No new ad-hoc token system introduced (use the issuance flow documented in `auth-model.md`).
91
+ - [ ] No hardcoded JWT secrets, no `process.env.JWT_SECRET` access outside the documented auth module.
92
+ - [ ] Token expiry/refresh behavior matches `auth-model.md`.
93
+
94
+ ---
95
+
96
+ ## Phase 5 — Output
97
+
98
+ ### 5.1 Manual / standalone mode
99
+
100
+ Produce a chat response with this exact structure:
101
+
102
+ ```
103
+ ## Auth & Permissions Audit — <feature or scope>
104
+
105
+ **Scope**: <files / endpoints reviewed>
106
+ **Auth-model reference**: project-memory/auth-model.md (<one-line summary of relevant section>)
107
+
108
+ ### Endpoint inventory
109
+ | Endpoint | Method | Auth decision | Permission | Owner/tenant scope | Verdict |
110
+ |---|---|---|---|---|---|
111
+ | /api/... | POST | <guard> | <permission-key> | by `tenantId` from context | ✅ |
112
+
113
+ ### Findings
114
+ | Severity | Issue | File:line | Fix |
115
+ |---|---|---|---|
116
+ | BLOCKER / HIGH / MED / LOW | ... | ... | ... |
117
+
118
+ ### Verdict
119
+ - **Decision**: ✅ Clear / ⚠️ Fix required / 🛑 Block
120
+ - **Required fixes before merge**: <list, or "none">
121
+ ```
122
+
123
+ `BLOCKER` for missing auth on a sensitive endpoint, missing ownership scoping on a sensitive resource, or hardcoded auth secrets. `HIGH` for missing validation on auth-sensitive input. `MED` for redundancy/layer-bleed issues. `LOW` for stylistic.
124
+
125
+ ### 5.2 Sub-agent mode — when called by `/architect` (planning input)
126
+
127
+ Return a JSON object describing the **recommended auth approach** for the planned module. No file is written.
128
+
129
+ ```json
130
+ {
131
+ "mode": "planning_input",
132
+ "endpoints": [
133
+ {
134
+ "route": "<method + path>",
135
+ "auth": "<guard name from auth-model>",
136
+ "permission": "<permission key from auth-model, or null>",
137
+ "current_user_extractor": "<decorator/helper name>",
138
+ "ownership_scope": "<which entity field filters by which context key>",
139
+ "validation_dto": "<recommended DTO name>"
140
+ }
141
+ ],
142
+ "notes": "<one short paragraph of any non-obvious considerations>"
143
+ }
144
+ ```
145
+
146
+ ### 5.3 Sub-agent mode — when called by `/module-runner` (review)
147
+
148
+ Return a JSON object with audit findings (same shape as `/security-assessment` sub-agent output, scoped to auth):
149
+
150
+ ```json
151
+ {
152
+ "verdict": "clean" | "fix_required" | "block",
153
+ "findings": [
154
+ { "severity": "BLOCKER|HIGH|MED|LOW", "issue": "...", "file": "<path:line>", "fix": "..." }
155
+ ]
156
+ }
157
+ ```
158
+
159
+ `verdict = block` for any BLOCKER. `verdict = fix_required` for any HIGH. `verdict = clean` otherwise.
160
+
161
+ ---
162
+
163
+ ## Do not
164
+
165
+ - Hardcode any framework-specific names (guards, decorators, helpers). If you find yourself writing a literal class name in this skill, stop — the right name lives in `project-memory/auth-model.md`.
166
+ - Recommend installing an alternate auth library. The documented system is the system.
167
+ - Fix code in this skill. Surface findings; fixes happen in `/module-runner` or by the user.
168
+ - Update `project-memory/auth-model.md`. If the model itself is wrong, the user should run `/create-blueprint auth-model` to refresh it.