@atlashub/smartstack-cli 3.8.0 → 3.10.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 (130) hide show
  1. package/dist/index.js +365 -2
  2. package/dist/index.js.map +1 -1
  3. package/package.json +2 -1
  4. package/templates/agents/action.md +1 -0
  5. package/templates/agents/ba-writer.md +211 -0
  6. package/templates/agents/explore-codebase.md +1 -0
  7. package/templates/agents/explore-docs.md +1 -0
  8. package/templates/agents/fix-grammar.md +1 -0
  9. package/templates/agents/snipper.md +1 -0
  10. package/templates/skills/admin/SKILL.md +6 -0
  11. package/templates/skills/ai-prompt/SKILL.md +32 -136
  12. package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
  13. package/templates/skills/apex/SKILL.md +120 -0
  14. package/templates/skills/apex/_shared.md +86 -0
  15. package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
  16. package/templates/skills/apex/references/smartstack-layers.md +173 -0
  17. package/templates/skills/apex/steps/step-00-init.md +156 -0
  18. package/templates/skills/apex/steps/step-01-analyze.md +169 -0
  19. package/templates/skills/apex/steps/step-02-plan.md +160 -0
  20. package/templates/skills/apex/steps/step-03-execute.md +166 -0
  21. package/templates/skills/apex/steps/step-04-validate.md +138 -0
  22. package/templates/skills/apex/steps/step-05-examine.md +124 -0
  23. package/templates/skills/apex/steps/step-06-resolve.md +105 -0
  24. package/templates/skills/apex/steps/step-07-tests.md +130 -0
  25. package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
  26. package/templates/skills/application/SKILL.md +10 -0
  27. package/templates/skills/application/references/application-roles-template.md +227 -0
  28. package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
  29. package/templates/skills/application/references/backend-entity-seeding.md +72 -0
  30. package/templates/skills/application/references/backend-verification.md +88 -0
  31. package/templates/skills/application/references/frontend-verification.md +111 -0
  32. package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
  33. package/templates/skills/application/references/provider-template.md +158 -0
  34. package/templates/skills/application/references/test-frontend.md +73 -0
  35. package/templates/skills/application/references/test-prerequisites.md +72 -0
  36. package/templates/skills/application/steps/step-01-navigation.md +7 -198
  37. package/templates/skills/application/steps/step-03-roles.md +45 -7
  38. package/templates/skills/application/steps/step-03b-provider.md +15 -132
  39. package/templates/skills/application/steps/step-04-backend.md +20 -350
  40. package/templates/skills/application/steps/step-05-frontend.md +12 -101
  41. package/templates/skills/application/steps/step-07-tests.md +12 -132
  42. package/templates/skills/business-analyse/SKILL.md +67 -6
  43. package/templates/skills/business-analyse/html/ba-interactive.html +176 -14
  44. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +1 -0
  45. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +16 -4
  46. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +7 -2
  47. package/templates/skills/business-analyse/html/src/scripts/09-export.js +103 -0
  48. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +12 -6
  49. package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +24 -2
  50. package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +12 -0
  51. package/templates/skills/business-analyse/html/src/template.html +1 -0
  52. package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +477 -0
  53. package/templates/skills/business-analyse/references/cache-warming-strategy.md +578 -0
  54. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
  55. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
  56. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
  57. package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
  58. package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
  59. package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
  60. package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
  61. package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
  62. package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
  63. package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
  64. package/templates/skills/business-analyse/references/robustness-checks.md +538 -0
  65. package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
  66. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
  67. package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
  68. package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
  69. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +33 -1
  70. package/templates/skills/business-analyse/steps/step-00-init.md +186 -53
  71. package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
  72. package/templates/skills/business-analyse/steps/step-03a-data.md +42 -49
  73. package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
  74. package/templates/skills/business-analyse/steps/step-03c-compile.md +71 -2
  75. package/templates/skills/business-analyse/steps/step-03d-validate.md +277 -48
  76. package/templates/skills/business-analyse/steps/step-04-consolidation.md +175 -104
  77. package/templates/skills/business-analyse/steps/step-05a-handoff.md +66 -438
  78. package/templates/skills/business-analyse/steps/step-05b-deploy.md +35 -184
  79. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +526 -0
  80. package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
  81. package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
  82. package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
  83. package/templates/skills/check-version/SKILL.md +7 -0
  84. package/templates/skills/controller/references/controller-code-templates.md +159 -0
  85. package/templates/skills/controller/references/permission-sync-templates.md +152 -0
  86. package/templates/skills/controller/steps/step-03-generate.md +166 -158
  87. package/templates/skills/controller/steps/step-04-perms.md +5 -144
  88. package/templates/skills/controller/templates.md +11 -2
  89. package/templates/skills/debug/SKILL.md +7 -0
  90. package/templates/skills/explore/SKILL.md +6 -0
  91. package/templates/skills/feature-full/SKILL.md +39 -142
  92. package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
  93. package/templates/skills/gitflow/references/init-config-template.md +135 -0
  94. package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
  95. package/templates/skills/gitflow/references/plan-template.md +69 -0
  96. package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
  97. package/templates/skills/gitflow/references/start-local-config.md +110 -0
  98. package/templates/skills/gitflow/steps/step-init.md +18 -289
  99. package/templates/skills/gitflow/steps/step-plan.md +6 -63
  100. package/templates/skills/gitflow/steps/step-start.md +16 -126
  101. package/templates/skills/mcp/SKILL.md +9 -213
  102. package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
  103. package/templates/skills/mcp/steps/step-02-tools.md +73 -0
  104. package/templates/skills/notification/SKILL.md +7 -0
  105. package/templates/skills/quick-search/SKILL.md +5 -0
  106. package/templates/skills/ralph-loop/SKILL.md +99 -381
  107. package/templates/skills/ralph-loop/references/category-rules.md +259 -0
  108. package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
  109. package/templates/skills/ralph-loop/references/core-seed-data.md +173 -21
  110. package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
  111. package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
  112. package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
  113. package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
  114. package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
  115. package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
  116. package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
  117. package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
  118. package/templates/skills/refactor/SKILL.md +12 -176
  119. package/templates/skills/refactor/steps/step-01-discover.md +60 -0
  120. package/templates/skills/refactor/steps/step-02-execute.md +67 -0
  121. package/templates/skills/review-code/SKILL.md +19 -257
  122. package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
  123. package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
  124. package/templates/skills/review-code/steps/step-03-react.md +44 -0
  125. package/templates/skills/ui-components/SKILL.md +7 -0
  126. package/templates/skills/utils/SKILL.md +6 -0
  127. package/templates/skills/validate/SKILL.md +6 -0
  128. package/templates/skills/validate-feature/SKILL.md +8 -0
  129. package/templates/skills/workflow/SKILL.md +40 -118
  130. package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: apex
3
+ description: |
4
+ SmartStack incremental development using APEX methodology (Analyze-Plan-Execute-eXamine).
5
+ Use this skill when:
6
+ - Adding a new section/resource to an existing module
7
+ - Developing feature by feature without /business-analyse
8
+ - Fixing or extending code generated by /ralph-loop
9
+ - Any incremental SmartStack development task
10
+ argument-hint: "[-a] [-x] [-s] [-t] [-e] [-r] [-pr] <task description>"
11
+ ---
12
+
13
+ <objective>
14
+ Execute incremental SmartStack development using the APEX methodology. This skill knows the SmartStack hierarchy (context/application/module/section/resource), delegates code creation to existing skills (/controller, /application, /ui-components, /efcore, /notification, /workflow) and MCP tools, and validates via MCP conventions.
15
+
16
+ **Key principle:** /apex ORCHESTRATES — it never generates SmartStack code directly. All generation goes through skills and MCP tools.
17
+ </objective>
18
+
19
+ <quick_start>
20
+
21
+ ```bash
22
+ /apex add absence management to HR module # Add section to module
23
+ /apex -a fix the leave request controller # Auto fix
24
+ /apex -a -x -s -t -pr add PDF export to Orders # Full workflow
25
+ /apex -e add status field to Project entity # Economy (no agents)
26
+ /apex -r # Resume previous
27
+ ```
28
+
29
+ </quick_start>
30
+
31
+ <parameters>
32
+
33
+ | Flag | Description |
34
+ |------|-------------|
35
+ | `-a` | Auto mode: skip confirmations |
36
+ | `-x` | Examine mode: adversarial code review |
37
+ | `-s` | Save mode: output to `.claude/output/apex/` |
38
+ | `-t` | Test mode: scaffold + run tests via MCP |
39
+ | `-e` | Economy mode: no subagents |
40
+ | `-r` | Resume: continue from previous state |
41
+ | `-pr` | PR mode: create pull request at end |
42
+
43
+ </parameters>
44
+
45
+ <state_variables>
46
+
47
+ | Variable | Type | Description |
48
+ |----------|------|-------------|
49
+ | `{task_description}` | string | What to implement (flags removed) |
50
+ | `{task_id}` | string | Kebab-case identifier |
51
+ | `{auto_mode}` | boolean | Skip confirmations |
52
+ | `{examine_mode}` | boolean | Adversarial review |
53
+ | `{save_mode}` | boolean | Save outputs to `.claude/output/apex/{task-id}/` |
54
+ | `{test_mode}` | boolean | Include test steps (07-08) |
55
+ | `{economy_mode}` | boolean | No subagents |
56
+ | `{pr_mode}` | boolean | Create PR at end |
57
+ | `{context_code}` | string | "business", "platform", "personal" |
58
+ | `{app_name}` | string | Application name |
59
+ | `{module_code}` | string | Module code |
60
+ | `{sections}` | string[] | Sections being added/modified |
61
+ | `{prd_path}` | string? | `.ralph/prd-{module}.json` if exists |
62
+ | `{feature_path}` | string? | `docs/business/.../feature.json` if exists |
63
+ | `{needs_seed_data}` | boolean | Seed data creation required |
64
+ | `{needs_migration}` | boolean | EF Core migration required |
65
+ </state_variables>
66
+
67
+ <entry_point>
68
+
69
+ **FIRST ACTION:** Load `steps/step-00-init.md`
70
+
71
+ </entry_point>
72
+
73
+ <step_files>
74
+ **Progressive loading - only load current step:**
75
+
76
+ | Step | File | Model | Purpose |
77
+ |------|------|-------|---------|
78
+ | 00 | `steps/step-00-init.md` | Sonnet | Parse flags, detect SmartStack context, verify MCP |
79
+ | 01 | `steps/step-01-analyze.md` | Opus | Explore existing code (Agent Teams or direct) |
80
+ | 02 | `steps/step-02-plan.md` | Opus | Layer-by-layer plan with skill/MCP mapping |
81
+ | 03 | `steps/step-03-execute.md` | Opus | Orchestrate execution via skills and MCP |
82
+ | 04 | `steps/step-04-validate.md` | Opus | MCP validation, build, seed data check |
83
+ | 05 | `steps/step-05-examine.md` | Opus | Adversarial review (if -x) |
84
+ | 06 | `steps/step-06-resolve.md` | Opus | Fix BLOCKING findings (if any) |
85
+ | 07 | `steps/step-07-tests.md` | Opus | Scaffold tests via MCP (if -t) |
86
+ | 08 | `steps/step-08-run-tests.md` | Opus | Run tests until 100% pass (if -t) |
87
+ </step_files>
88
+
89
+ <reference_files>
90
+ **Loaded conditionally by steps that need them:**
91
+
92
+ | File | Purpose | Loaded by |
93
+ |------|---------|-----------|
94
+ | `references/smartstack-layers.md` | Layer execution rules, skill/MCP mapping, seed data | step-02, step-03 |
95
+ | `references/agent-teams-protocol.md` | TeamCreate, coordination, shutdown protocol | step-01, step-03 |
96
+ </reference_files>
97
+
98
+ <execution_rules>
99
+
100
+ - **Load one step at a time** - Progressive loading to manage context
101
+ - **ORCHESTRATE, never generate** - All SmartStack code via skills (/controller, /application, etc.) or MCP tools
102
+ - **MCP-first** - Use MCP scaffold/validate tools before manual approaches
103
+ - **Verify MCP at startup** - step-00 checks MCP availability
104
+ - **Layer order** - domain -> infra -> migration(BLOCKING) -> app -> api -> frontend -> i18n -> tests
105
+ - **Agent Teams** - Parallel execution for scan (step-01) and Layer 1 (step-03), unless economy_mode
106
+ - **Save outputs** if `{save_mode}` = true
107
+ - **Commits per layer** - Atomic commits after each execution layer
108
+
109
+ </execution_rules>
110
+
111
+ <success_criteria>
112
+ - SmartStack context detected (context/app/module)
113
+ - Plan validated with skill/MCP mapped for each file
114
+ - Code created/corrected via existing skills and MCP (no direct generation)
115
+ - MCP validate_conventions: 0 errors
116
+ - Build: dotnet build PASS + npm run typecheck PASS (if frontend)
117
+ - Seed data complete (navigation, permissions, roles, provider) if required
118
+ - Tests: 100% pass, >= 80% coverage (if -t)
119
+ - Commits atomic per layer
120
+ </success_criteria>
@@ -0,0 +1,86 @@
1
+ # APEX Shared — SmartStack Detection & MCP References
2
+
3
+ > **Loaded by:** step-00-init (always), other steps as needed
4
+
5
+ ---
6
+
7
+ ## SmartStack Project Detection
8
+
9
+ ### Scan Pattern
10
+
11
+ 1. `*.sln` → .NET backend confirmed
12
+ 2. `docs/business/` → BA artifacts exist
13
+ 3. `.ralph/prd-*.json` → PRDs exist
14
+ 4. `src/pages/` → React frontend exists
15
+
16
+ ### Context-to-Folder Mapping
17
+
18
+ | Context | Backend | Controller | Frontend Layout |
19
+ |---------|---------|------------|----------------|
20
+ | `business` | `Business` | `Business` | `BusinessLayout` |
21
+ | `platform.administration` | `Platform/Administration` | `Admin` | `AdminLayout` |
22
+ | `platform.support` | `Platform/Support` | `Support` | `AdminLayout` |
23
+ | `personal` | `Personal` | `User` | `UserLayout` |
24
+
25
+ ---
26
+
27
+ ## MCP Tools Reference
28
+
29
+ ### Mandatory (every execution)
30
+
31
+ | Tool | Purpose | Step |
32
+ |------|---------|------|
33
+ | `validate_conventions` | Validate SmartStack conventions | 00 (check), 04 (validate) |
34
+
35
+ ### Generation (step-03)
36
+
37
+ | Tool | Purpose | Condition |
38
+ |------|---------|-----------|
39
+ | `scaffold_extension` | Generate entities, services, controllers | New code creation |
40
+ | `suggest_migration` | Get standardized migration name | EF Core changes |
41
+ | `generate_permissions` | Generate RBAC permissions + seed data | New module/section |
42
+ | `scaffold_api_client` | Generate TypeScript API client | Frontend changes |
43
+ | `scaffold_routes` | Generate React Router routes | Frontend changes |
44
+
45
+ ### Validation (step-04)
46
+
47
+ | Tool | Purpose | Condition |
48
+ |------|---------|-----------|
49
+ | `check_migrations` | Validate EF Core migrations | Migration created |
50
+ | `validate_frontend_routes` | Validate route/layout alignment | Frontend changes |
51
+ | `validate_security` | Check security patterns | API changes |
52
+
53
+ ### Analysis (step-01)
54
+
55
+ | Tool | Purpose |
56
+ |------|---------|
57
+ | `api_docs` | Existing API documentation |
58
+ | `analyze_extension_points` | React extension points |
59
+
60
+ ### Tests (step-07, if -t)
61
+
62
+ | Tool | Purpose |
63
+ |------|---------|
64
+ | `scaffold_tests` | Generate tests (domain, app, api, security) |
65
+ | `suggest_test_scenarios` | Suggest test scenarios |
66
+ | `analyze_test_coverage` | Check coverage percentage |
67
+
68
+ ### Review (step-05, if -x)
69
+
70
+ | Tool | Purpose |
71
+ |------|---------|
72
+ | `review_code` | Adversarial code review |
73
+ | `analyze_code_quality` | Code quality metrics |
74
+
75
+ ---
76
+
77
+ ## Existing Skills Delegation
78
+
79
+ | Skill | When to delegate |
80
+ |-------|-----------------|
81
+ | `/controller` | Complex controller with custom routes |
82
+ | `/application` | New context/application/module structure |
83
+ | `/ui-components` | Complex React pages (tables, grids, dashboards) |
84
+ | `/efcore` | Complex EF Core configurations |
85
+ | `/notification` | In-app or email notifications |
86
+ | `/workflow` | Automated workflow triggers |
@@ -0,0 +1,164 @@
1
+ # Agent Teams Protocol — APEX
2
+
3
+ > **Loaded by:** step-01 (analysis scan) and step-03 (parallel execution)
4
+ > **Condition:** NOT economy_mode
5
+ > **Purpose:** Reusable protocol for TeamCreate, coordination, and shutdown.
6
+
7
+ ---
8
+
9
+ ## Team Creation (T08)
10
+
11
+ ```yaml
12
+ TeamCreate:
13
+ team_name: "apex-{phase}" # e.g., "apex-analyze", "apex-exec"
14
+ description: "{phase purpose}" # e.g., "Scan SmartStack project for existing code"
15
+ ```
16
+
17
+ Always provide both `team_name` and `description`.
18
+
19
+ ---
20
+
21
+ ## Teammate Spawning (T12)
22
+
23
+ ```yaml
24
+ Task:
25
+ subagent_type: "general-purpose"
26
+ team_name: "apex-{phase}" # Must match TeamCreate
27
+ name: "{teammate-name}" # e.g., "scan-backend", "exec-frontend"
28
+ model: "sonnet" | "opus" # sonnet for scan, opus for dev (T02/T06)
29
+ mode: "bypassPermissions"
30
+ prompt: "{detailed task prompt}"
31
+ ```
32
+
33
+ ### Model Assignment (T02/T06)
34
+
35
+ | Task Type | Model | Justification |
36
+ |-----------|-------|---------------|
37
+ | Scan/read files | Sonnet | Read-only, no analysis needed |
38
+ | Read context (PRD, feature.json) | Sonnet | Read-only extraction |
39
+ | Code development | Opus | Complex generation via skills/MCP |
40
+ | Fix/resolve | Opus | Requires reasoning |
41
+
42
+ ---
43
+
44
+ ## Task List Coordination (T10)
45
+
46
+ Team lead manages the task list:
47
+
48
+ ```
49
+ 1. TaskCreate: create task for each work item, assign owner
50
+ 2. Teammate: TaskUpdate(status: "in_progress") before starting
51
+ 3. Teammate: TaskUpdate(status: "completed") after finishing
52
+ 4. Lead: TaskList to monitor progress
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Communication (T09)
58
+
59
+ **Default:** Direct messages (DM) between specific agents.
60
+
61
+ ```yaml
62
+ SendMessage:
63
+ type: "message" # DM, not broadcast
64
+ recipient: "{teammate-name}" # By name, not UUID
65
+ content: "{message}"
66
+ summary: "{5-10 word preview}"
67
+ ```
68
+
69
+ **Broadcast:** ONLY for emergency (all-stop, critical blocker).
70
+
71
+ ```yaml
72
+ SendMessage:
73
+ type: "broadcast" # Expensive: N teammates = N deliveries
74
+ content: "{urgent message}"
75
+ summary: "{critical issue summary}"
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Team Decomposition (C01)
81
+
82
+ ### Step-01 Analyze: Split by scan scope
83
+
84
+ ```
85
+ scan-backend : Domain/ + Infrastructure/ + Application/ + Api/
86
+ scan-frontend : src/pages/ + src/components/ + src/locales/
87
+ scan-context : .ralph/ + docs/business/
88
+ ```
89
+
90
+ ### Step-03 Execute: Split by execution layer
91
+
92
+ ```
93
+ exec-backend : Application services + API controllers + Seed data
94
+ exec-frontend : Pages + Components + Routes + I18n
95
+ ```
96
+
97
+ Each teammate has an **isolated scope** (C02): backend never touches frontend.
98
+
99
+ ---
100
+
101
+ ## Coordination (C03)
102
+
103
+ ### Step-01: Lead aggregates scan results
104
+
105
+ ```
106
+ 1. Spawn 3 scan teammates
107
+ 2. Each reports findings via DM to lead
108
+ 3. Lead merges into unified analysis
109
+ ```
110
+
111
+ ### Step-03: Lead verifies between layers
112
+
113
+ ```
114
+ 1. Layer 0: lead executes (domain + infra + migration)
115
+ 2. Build gate: dotnet build --no-restore → MUST PASS
116
+ 3. Layer 1: spawn exec-backend + exec-frontend
117
+ 4. Wait for both to complete
118
+ 5. Build gate: dotnet build + npm typecheck → MUST PASS
119
+ 6. Layer 2: lead executes final validation
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Idle Handling (T13)
125
+
126
+ Teammates go idle after every turn — this is **normal**.
127
+ - Idle does NOT mean done or unavailable
128
+ - Sending a message to an idle teammate wakes them up
129
+ - Do NOT treat idle as an error
130
+
131
+ ---
132
+
133
+ ## Graceful Shutdown (T11)
134
+
135
+ After phase completes:
136
+
137
+ ```yaml
138
+ # For each teammate:
139
+ SendMessage:
140
+ type: "shutdown_request"
141
+ recipient: "{teammate-name}"
142
+ content: "Phase complete, shutting down"
143
+
144
+ # Teammate responds:
145
+ SendMessage:
146
+ type: "shutdown_response"
147
+ request_id: "{from_request}"
148
+ approve: true
149
+
150
+ # After all confirmations:
151
+ TeamDelete
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Decision Matrix
157
+
158
+ | Condition | Action |
159
+ |-----------|--------|
160
+ | economy_mode = true | NO teams, all sequential |
161
+ | Only backend work | NO teams, agent principal |
162
+ | Only frontend work | NO teams, agent principal |
163
+ | Backend + Frontend | Teams: exec-backend + exec-frontend |
164
+ | Analysis phase | Teams: scan-backend + scan-frontend + scan-context |
@@ -0,0 +1,173 @@
1
+ # SmartStack Layers — Execution Rules & Skill/MCP Mapping
2
+
3
+ > **Loaded by:** step-02 (planning) and step-03 (execution)
4
+ > **Purpose:** Defines per-layer folder conventions, skill/MCP tools, and verification rules.
5
+
6
+ ---
7
+
8
+ ## Layer 0 — Domain (sequential)
9
+
10
+ **Entities:** `Domain/Entities/{ContextPascal}/{App}/{Module}/`
11
+ **Enums:** `Domain/Enums/{ContextPascal}/{App}/{Module}/`
12
+ **Exceptions:** `Domain/Exceptions/{ContextPascal}/{App}/{Module}/`
13
+
14
+ | Action | Tool |
15
+ |--------|------|
16
+ | Create entity | MCP `scaffold_extension` (type: entity) |
17
+ | Validate | MCP `validate_conventions` |
18
+
19
+ **Rules:**
20
+ - Inherit `AuditableEntity`, implement `IHasData` for multi-tenant
21
+ - Audit fields: CreatedAt, CreatedBy, ModifiedAt, ModifiedBy
22
+ - Domain events for state changes
23
+ - Value objects for composite values
24
+
25
+ ---
26
+
27
+ ## Layer 0 — Infrastructure: EF Core (sequential)
28
+
29
+ **Configs:** `Infrastructure/Persistence/Configurations/{ContextPascal}/{App}/{Module}/`
30
+ **Migrations:** `Infrastructure/Persistence/Migrations/` (NEVER subdirectories)
31
+
32
+ | Action | Tool |
33
+ |--------|------|
34
+ | Create config | MCP `scaffold_extension` (type: configuration) |
35
+ | Create migration | MCP `suggest_migration` → `dotnet ef migrations add` |
36
+ | Validate | MCP `check_migrations` |
37
+
38
+ **Rules:**
39
+ - One config per entity, table name = plural
40
+ - All relationships explicitly configured
41
+ - Indexes on FKs and frequent queries
42
+ - Register DbSet in ExtensionsDbContext
43
+ - Migration name ALWAYS from MCP `suggest_migration`
44
+ - Migration flag: `-o Persistence/Migrations`
45
+
46
+ **BLOCKING:** `dotnet build --no-restore` MUST pass after migration.
47
+
48
+ ---
49
+
50
+ ## Layer 1 — Application (parallel with API)
51
+
52
+ **Services:** `Application/Services/{ContextPascal}/{App}/{Module}/`
53
+ **DTOs:** `Application/DTOs/{ContextPascal}/{App}/{Module}/`
54
+ **Validators:** `Application/Validators/{ContextPascal}/{App}/{Module}/`
55
+
56
+ | Action | Tool |
57
+ |--------|------|
58
+ | Create service/DTO | MCP `scaffold_extension` |
59
+ | Complex service logic | /application skill |
60
+ | Validate | MCP `validate_conventions` |
61
+
62
+ **Rules:**
63
+ - CQRS with MediatR
64
+ - FluentValidation for all commands
65
+ - DTOs separate from domain entities
66
+ - Service interfaces in Application, implementations in Infrastructure
67
+
68
+ ---
69
+
70
+ ## Layer 1 — API (parallel with Application)
71
+
72
+ **Controllers:** `Api/Controllers/{ContextShort}/{App}/{Entity}Controller.cs`
73
+
74
+ | Context | Controller Folder |
75
+ |---------|-------------------|
76
+ | `platform.administration` | `Admin` |
77
+ | `platform.support` | `Support` |
78
+ | `business.*` | `Business` |
79
+ | `personal.*` | `User` |
80
+
81
+ | Action | Tool |
82
+ |--------|------|
83
+ | Simple CRUD controller | MCP `scaffold_extension` |
84
+ | Complex controller | /controller skill |
85
+ | Validate | MCP `validate_security` |
86
+
87
+ **Rules:**
88
+ - `[RequirePermission(Permissions.{Module}.{Action})]` on EVERY endpoint
89
+ - NEVER use `[Authorize]` without specific permission
90
+ - Swagger XML documentation
91
+ - Return DTOs, never domain entities
92
+
93
+ ---
94
+
95
+ ## Layer 1 — Seed Data (parallel)
96
+
97
+ **Folder:** `Infrastructure/Persistence/Seeding/Data/{ModulePascal}/`
98
+
99
+ | Action | Tool |
100
+ |--------|------|
101
+ | Generate permissions | MCP `generate_permissions` (PRIMARY) |
102
+ | Navigation seed | Template below |
103
+ | Roles seed | Template below |
104
+ | Provider | Template below |
105
+
106
+ ### Seed Data Chain (5 files)
107
+
108
+ 1. **NavigationModuleSeedData.cs** — Deterministic GUIDs (SHA256), 4 languages
109
+ 2. **PermissionsSeedData.cs** — MCP `generate_permissions` first, fallback template
110
+ 3. **RolesSeedData.cs** — Context-based: Admin=CRUD, Manager=CRU, Contributor=CR, Viewer=R
111
+ 4. **SeedConstants.cs** — Shared deterministic GUIDs
112
+ 5. **{App}SeedDataProvider.cs** — Implements IClientSeedDataProvider
113
+ - SeedNavigationAsync + SeedPermissionsAsync + SeedRolePermissionsAsync
114
+ - DI: `services.AddScoped<IClientSeedDataProvider, {App}SeedDataProvider>()`
115
+
116
+ **FORBIDDEN:**
117
+ - `Guid.NewGuid()` → use deterministic GUIDs (SHA256)
118
+ - Missing translations (must have fr, en, it, de)
119
+ - Empty seed classes with no seeding logic
120
+
121
+ ---
122
+
123
+ ## Layer 2 — Frontend (parallel with I18n)
124
+
125
+ **Pages:** `src/pages/{ContextPascal}/{AppPascal}/{Module}/`
126
+ **Components:** `src/components/{Module}/`
127
+
128
+ | Action | Tool |
129
+ |--------|------|
130
+ | API client | MCP `scaffold_api_client` |
131
+ | Routes | MCP `scaffold_routes` |
132
+ | Complex pages | /ui-components skill |
133
+ | Validate routes | MCP `validate_frontend_routes` |
134
+
135
+ **Layout mapping:**
136
+
137
+ | Context | Layout | Route prefix |
138
+ |---------|--------|-------------|
139
+ | `platform.*` | `AdminLayout` | `/platform` |
140
+ | `business.*` | `BusinessLayout` | `/business` |
141
+ | `personal.*` | `UserLayout` | `/personal/myspace` |
142
+
143
+ **Components:** SmartTable, SmartFilter, EntityCard, SmartForm, StatCard (NEVER raw HTML)
144
+ **CSS:** Variables only → `bg-[var(--bg-card)]`, `text-[var(--text-primary)]`
145
+
146
+ **FORBIDDEN:**
147
+ - `src/pages/{Module}/` (flat, missing Context/App)
148
+ - `import axios` → use `@/services/api/apiClient`
149
+ - `<table>` → use SmartTable
150
+ - Hardcoded colors → use CSS variables
151
+ - Only fr/en → MUST have 4 languages
152
+
153
+ ---
154
+
155
+ ## Layer 2 — I18n
156
+
157
+ 4 JSON files: fr, en, it, de — identical key structures.
158
+
159
+ ---
160
+
161
+ ## Layer 3 — Tests (sequential, if -t)
162
+
163
+ | Action | Tool |
164
+ |--------|------|
165
+ | Unit tests (domain) | MCP `scaffold_tests` (target_layer: domain) |
166
+ | Unit tests (app) | MCP `scaffold_tests` (target_layer: application) |
167
+ | Integration tests (api) | MCP `scaffold_tests` (target_layer: api, type: integration) |
168
+ | Security tests | MCP `scaffold_tests` (type: security) |
169
+ | Coverage check | MCP `analyze_test_coverage` |
170
+ | Scenarios | MCP `suggest_test_scenarios` |
171
+
172
+ **Target:** >= 80% coverage, 100% pass rate.
173
+ **Fix CODE, not tests.**
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: step-00-init
3
+ description: Parse flags, detect SmartStack context, verify MCP availability
4
+ model: sonnet
5
+ next_step: steps/step-01-analyze.md
6
+ ---
7
+
8
+ # Step 0: Initialize
9
+
10
+ ## LOAD SHARED
11
+
12
+ Read `_shared.md` for SmartStack detection patterns and MCP tools reference.
13
+
14
+ ---
15
+
16
+ ## 1. Parse Flags
17
+
18
+ Extract flags from the raw input:
19
+
20
+ ```
21
+ Input: "{raw_input}"
22
+
23
+ Flags to detect: -a, -x, -s, -t, -e, -r, -pr
24
+ Remaining text after flag removal = {task_description}
25
+ ```
26
+
27
+ **Defaults:**
28
+
29
+ ```yaml
30
+ auto_mode: false
31
+ examine_mode: false
32
+ save_mode: false
33
+ test_mode: false
34
+ economy_mode: false
35
+ pr_mode: false
36
+ resume_mode: false
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 2. Detect SmartStack Context
42
+
43
+ Scan the project to identify the SmartStack hierarchy:
44
+
45
+ ```
46
+ 1. Glob("*.sln") → confirm .NET project
47
+ 2. Glob("docs/business/**/*") → list existing BA artifacts
48
+ 3. Glob(".ralph/prd-*.json") → list existing PRDs
49
+ 4. Glob("src/pages/**/*.tsx") → confirm frontend exists
50
+ ```
51
+
52
+ **From task description, infer:**
53
+ - `{context_code}`: business (default), platform, personal
54
+ - `{app_name}`: application name
55
+ - `{module_code}`: target module
56
+ - `{sections}`: sections being added/modified
57
+
58
+ **From existing artifacts:**
59
+ - `{prd_path}`: `.ralph/prd-{module_code}.json` if exists
60
+ - `{feature_path}`: `docs/business/{app}/{module}/business-analyse/*/feature.json` if exists
61
+
62
+ **If hierarchy cannot be inferred, ask the user:**
63
+
64
+ ```yaml
65
+ questions:
66
+ - header: "Context"
67
+ question: "What is the SmartStack context for this work?"
68
+ options:
69
+ - label: "Business (Recommended)"
70
+ description: "Business application module"
71
+ - label: "Platform"
72
+ description: "Platform administration or support"
73
+ - label: "Personal"
74
+ description: "Personal user space"
75
+ multiSelect: false
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 3. Verify MCP Availability
81
+
82
+ ```
83
+ Call: mcp__smartstack__validate_conventions (quick connectivity test)
84
+
85
+ IF success → MCP available, proceed normally
86
+ IF failure → warn user, continue in degraded mode (manual tools only)
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 4. Determine Needs
92
+
93
+ ```
94
+ needs_seed_data = true IF:
95
+ - New module or new section with navigation entries
96
+ - Task mentions "navigation", "permissions", "roles", "seed"
97
+
98
+ needs_migration = true IF:
99
+ - New entities or entity modifications detected
100
+ - Task mentions "entity", "field", "table", "column", "migration"
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 5. Resume Mode (if -r)
106
+
107
+ ```
108
+ IF resume_mode:
109
+ 1. Read .claude/output/apex/ → find latest task folder
110
+ 2. Read 00-context.md → restore state variables
111
+ 3. Find last completed step file
112
+ 4. Route to next step directly
113
+ → SKIP to identified next step
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 6. Save Mode Setup (if -s)
119
+
120
+ ```
121
+ IF save_mode:
122
+ 1. Generate task_id: NN-kebab-case from task_description
123
+ 2. Create .claude/output/apex/{task_id}/
124
+ 3. Write 00-context.md with:
125
+ - Timestamp
126
+ - All state variables (generic + SmartStack)
127
+ - Flags
128
+ - Detected hierarchy
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 7. Display Context Summary
134
+
135
+ ```
136
+ **APEX SmartStack - Initialization Complete**
137
+
138
+ **Task:** {task_description}
139
+ **Context:** {context_code} / {app_name} / {module_code}
140
+ **Sections:** {sections}
141
+
142
+ **Sources:**
143
+ - PRD: {prd_path || "none"}
144
+ - Feature: {feature_path || "none"}
145
+
146
+ **Flags:** {active_flags}
147
+ **MCP:** {available|degraded}
148
+ **Needs migration:** {yes|no}
149
+ **Needs seed data:** {yes|no}
150
+ ```
151
+
152
+ ---
153
+
154
+ ## NEXT STEP
155
+
156
+ Load `steps/step-01-analyze.md`