@atlashub/smartstack-cli 4.74.0 → 4.76.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 (121) hide show
  1. package/dist/index.js +152 -31
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +14 -3
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/agents/ba-reader.md +17 -15
  7. package/templates/agents/ba-writer.md +49 -51
  8. package/templates/skills/apex/SKILL.md +2 -2
  9. package/templates/skills/apex/_shared.md +1 -1
  10. package/templates/skills/apex/references/checks/backend-checks.sh +21 -7
  11. package/templates/skills/apex/references/checks/frontend-checks.sh +26 -0
  12. package/templates/skills/apex/references/checks/infrastructure-checks.sh +47 -10
  13. package/templates/skills/apex/references/checks/seed-checks.sh +47 -7
  14. package/templates/skills/apex/references/core-seed-data.md +20 -18
  15. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +3 -0
  16. package/templates/skills/apex/references/post-checks.md +23 -3
  17. package/templates/skills/apex/references/smartstack-api.md +4 -4
  18. package/templates/skills/apex/references/smartstack-frontend.md +54 -8
  19. package/templates/skills/apex/references/smartstack-layers.md +6 -6
  20. package/templates/skills/apex/steps/step-00-init.md +75 -1
  21. package/templates/skills/apex/steps/step-03-execute.md +16 -4
  22. package/templates/skills/apex/steps/step-03b-layer1-seed.md +65 -6
  23. package/templates/skills/apex/steps/step-03c-layer2-backend.md +50 -5
  24. package/templates/skills/apex/steps/step-03d-layer3-frontend.md +226 -4
  25. package/templates/skills/apex/steps/step-04-examine.md +163 -0
  26. package/templates/skills/apex-verify/SKILL.md +110 -0
  27. package/templates/skills/apex-verify/references/audit-rules.md +50 -0
  28. package/templates/skills/apex-verify/steps/step-00-init.md +119 -0
  29. package/templates/skills/apex-verify/steps/step-01-nav-audit.md +92 -0
  30. package/templates/skills/apex-verify/steps/step-02-crud-audit.md +127 -0
  31. package/templates/skills/apex-verify/steps/step-03-perm-audit.md +119 -0
  32. package/templates/skills/apex-verify/steps/step-04-route-audit.md +98 -0
  33. package/templates/skills/apex-verify/steps/step-05-report.md +110 -0
  34. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +3 -0
  35. package/templates/skills/application/templates-frontend.md +2 -2
  36. package/templates/skills/business-analyse/SKILL.md +17 -3
  37. package/templates/skills/business-analyse/_shared.md +64 -0
  38. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +34 -26
  39. package/templates/skills/business-analyse/questionnaire/01-context.md +13 -9
  40. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +20 -27
  41. package/templates/skills/business-analyse/questionnaire.md +86 -9
  42. package/templates/skills/business-analyse/references/03-json-schemas.md +221 -0
  43. package/templates/skills/business-analyse/references/03-post-check-validation.md +208 -0
  44. package/templates/skills/business-analyse/references/03-smartstack-entity-guards.md +32 -0
  45. package/templates/skills/business-analyse/references/04-cross-module-validation.md +95 -0
  46. package/templates/skills/business-analyse/references/04-file-allocation.md +162 -0
  47. package/templates/skills/business-analyse/references/04-naming-audit-checks.md +174 -0
  48. package/templates/skills/business-analyse/references/04-semantic-validation-matrix.md +118 -0
  49. package/templates/skills/business-analyse/references/canonical-json-formats.md +7 -3
  50. package/templates/skills/business-analyse/references/domain-research-playbook.md +234 -0
  51. package/templates/skills/business-analyse/references/entity-sourcing-presentation.md +166 -0
  52. package/templates/skills/business-analyse/references/init-resume-logic.md +70 -0
  53. package/templates/skills/business-analyse/references/module-completeness-challenge.md +174 -0
  54. package/templates/skills/business-analyse/references/multi-app-detection.md +149 -0
  55. package/templates/skills/business-analyse/references/portal-classification.md +52 -0
  56. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  57. package/templates/skills/business-analyse/references/validation-checklist.md +35 -6
  58. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +50 -6
  59. package/templates/skills/business-analyse/steps/step-00-init.md +22 -190
  60. package/templates/skills/business-analyse/steps/step-01-cadrage.md +365 -269
  61. package/templates/skills/business-analyse/steps/step-02-structure.md +98 -20
  62. package/templates/skills/business-analyse/steps/step-03-specify.md +810 -229
  63. package/templates/skills/business-analyse/steps/step-04-consolidate.md +509 -278
  64. package/templates/skills/business-analyse-design/SKILL.md +10 -0
  65. package/templates/skills/business-analyse-design/references/screens-post-check.md +221 -0
  66. package/templates/skills/business-analyse-design/references/screens-type-mapping.md +138 -0
  67. package/templates/skills/business-analyse-design/references/smartcomponents-templates.md +225 -0
  68. package/templates/skills/{business-analyse → business-analyse-design}/references/spec-auto-inference.md +117 -117
  69. package/templates/skills/business-analyse-design/steps/step-01-screens.md +36 -162
  70. package/templates/skills/business-analyse-design/steps/step-02-wireframes.md +8 -7
  71. package/templates/skills/business-analyse-design/steps/step-03-navigation.md +89 -42
  72. package/templates/skills/business-analyse-develop/references/compact-loop.md +9 -0
  73. package/templates/skills/business-analyse-develop/references/handoff-quality-gate.md +132 -0
  74. package/templates/skills/business-analyse-develop/references/prd-v3-transformation.md +326 -0
  75. package/templates/skills/business-analyse-develop/references/report-reconciliation.md +140 -0
  76. package/templates/skills/business-analyse-develop/references/report-template.md +142 -0
  77. package/templates/skills/business-analyse-develop/steps/step-01-task.md +5 -177
  78. package/templates/skills/business-analyse-develop/steps/step-02-execute.md +17 -4
  79. package/templates/skills/business-analyse-develop/steps/step-03-commit.md +6 -2
  80. package/templates/skills/business-analyse-develop/steps/step-04-check.md +6 -0
  81. package/templates/skills/business-analyse-develop/steps/step-05-report.md +3 -269
  82. package/templates/skills/business-analyse-handoff/SKILL.md +10 -0
  83. package/templates/skills/business-analyse-handoff/references/agent-handoff-transform-prompt.md +211 -0
  84. package/templates/skills/business-analyse-handoff/references/context-isolation-pattern.md +47 -0
  85. package/templates/skills/business-analyse-handoff/references/handoff-file-inventory.md +49 -0
  86. package/templates/skills/business-analyse-handoff/references/handoff-global-validation.md +142 -0
  87. package/templates/skills/business-analyse-handoff/references/prd-validation-checks.md +125 -0
  88. package/templates/skills/business-analyse-handoff/references/project-index-update.md +98 -0
  89. package/templates/skills/business-analyse-handoff/steps/step-01-transform.md +9 -160
  90. package/templates/skills/business-analyse-handoff/steps/step-02-export.md +10 -99
  91. package/templates/skills/business-analyse-html/SKILL.md +10 -0
  92. package/templates/skills/business-analyse-html/html/ba-interactive.html +504 -97
  93. package/templates/skills/business-analyse-html/html/src/scripts/01-data-init.js +79 -2
  94. package/templates/skills/business-analyse-html/html/src/scripts/02-navigation.js +6 -46
  95. package/templates/skills/business-analyse-html/html/src/scripts/05-render-specs.js +80 -11
  96. package/templates/skills/business-analyse-html/html/src/scripts/06-render-consolidation.js +2 -2
  97. package/templates/skills/business-analyse-html/html/src/scripts/06-render-mockups.js +94 -36
  98. package/templates/skills/business-analyse-html/html/src/scripts/12-render-diagrams.js +162 -0
  99. package/templates/skills/business-analyse-html/html/src/styles/10-diagrams.css +73 -0
  100. package/templates/skills/business-analyse-html/html/src/template.html +2 -0
  101. package/templates/skills/business-analyse-html/references/02-embedded-artifacts-building.md +144 -0
  102. package/templates/skills/business-analyse-html/references/02-feature-data-building.md +143 -0
  103. package/templates/skills/business-analyse-html/references/02-mapping-tables.md +442 -0
  104. package/templates/skills/business-analyse-html/references/02-normalization-helpers.md +139 -0
  105. package/templates/skills/business-analyse-html/references/02-screen-format-detection.md +283 -0
  106. package/templates/skills/business-analyse-html/references/02-self-check-validation.md +199 -0
  107. package/templates/skills/business-analyse-html/references/data-build.md +24 -1
  108. package/templates/skills/business-analyse-html/references/data-mapping.md +119 -17
  109. package/templates/skills/business-analyse-html/steps/step-02-build-data.md +18 -555
  110. package/templates/skills/business-analyse-html/steps/step-04-verify.md +92 -3
  111. package/templates/skills/business-analyse-quick/SKILL.md +807 -0
  112. package/templates/skills/{sketch → business-analyse-quick}/references/domain-heuristics.md +59 -3
  113. package/templates/skills/business-analyse-quick/references/prd-schema.md +268 -0
  114. package/templates/skills/business-analyse-review/SKILL.md +10 -0
  115. package/templates/skills/business-analyse-review/references/review-data-mapping.md +6 -0
  116. package/templates/skills/business-analyse-status/SKILL.md +8 -0
  117. package/templates/skills/dev-start/SKILL.md +143 -307
  118. package/templates/skills/efcore/SKILL.md +13 -0
  119. package/templates/skills/sketch/SKILL.md +15 -153
  120. package/templates/skills/ui-components/SKILL.md +1 -1
  121. package/templates/skills/ui-components/patterns/data-table.md +1 -1
@@ -3,7 +3,7 @@ name: dev-start
3
3
  description: Launch SmartStack dev environment (backend + frontend + admin credentials)
4
4
  argument-hint: "[--stop] [--reset] [--backend-only] [--frontend-only]"
5
5
  model: haiku
6
- allowed-tools: Read, Bash, Glob, Write, TaskOutput
6
+ allowed-tools: Read, Bash, Write, TaskOutput
7
7
  ---
8
8
 
9
9
  ## Arguments
@@ -16,345 +16,189 @@ $ARGUMENTS
16
16
  - Ports running: !`netstat.exe -ano 2>/dev/null | grep -E "LISTENING" | grep -E ":(5[0-9]{3}|6173|3000) " | head -5 || echo "none"`
17
17
 
18
18
  <objective>
19
- Launch the SmartStack development environment in one command: detect configuration, validate config coherence, check SQL connectivity, start backend + frontend, and provide admin credentials.
20
- Idempotent: safe to run multiple times. Detects already-running processes.
21
- Uses a config cache to skip re-detection on subsequent runs when config files haven't changed.
19
+ Launch SmartStack dev environment FAST. The injected state above is already loaded use it directly, never re-read those files. Target: 0 tool calls if everything running, 2-3 to launch, 5 max cold start.
22
20
  </objective>
23
21
 
24
22
  <quick_start>
25
23
  ```bash
26
- /dev-start # Launch everything (idempotent)
27
- /dev-start --stop # Stop backend + frontend
28
- /dev-start --reset # Force admin password reset + re-detect config
29
- /dev-start --backend-only # Launch only the backend
30
- /dev-start --frontend-only # Launch only the frontend
24
+ /dev-start # Launch all (idempotent, reuses cache+session)
25
+ /dev-start --stop # Stop all services
26
+ /dev-start --reset # Force re-detect config + reset password
27
+ /dev-start --backend-only # Launch backend only
28
+ /dev-start --frontend-only # Launch frontend only
31
29
  ```
32
30
  </quick_start>
33
31
 
34
32
  <subcommands>
35
33
 
36
- | Command | Description |
37
- |---------|-------------|
38
- | `/dev-start` | Launch all (idempotent) + validate configs |
39
- | `/dev-start --stop` | Stop backend + frontend via taskkill.exe |
40
- | `/dev-start --reset` | Force reset admin password + re-detect config |
41
- | `/dev-start --backend-only` | Launch only backend |
42
- | `/dev-start --frontend-only` | Launch only frontend |
34
+ | Command | Effect |
35
+ |---------|--------|
36
+ | `/dev-start` | Launch all services (0 tool calls if all running) |
37
+ | `/dev-start --stop` | Kill backend + frontend |
38
+ | `/dev-start --reset` | Re-detect config + reset admin password |
39
+ | `/dev-start --backend-only` | Launch backend only |
40
+ | `/dev-start --frontend-only` | Launch frontend only |
43
41
 
44
42
  </subcommands>
45
43
 
46
44
  <workflow>
47
45
 
48
- ## Handle --stop
46
+ ## Handle --stop (Exit After)
49
47
 
50
- If `--stop` argument detected, execute the stop workflow and exit:
51
-
52
- 1. Determine ports to stop:
53
- - If `.claude/config/dev-run.json` exists → read `api_port` and `web_port` from cache
54
- - Otherwise → scan default ports: 5142, 5290 (API) and 6173, 3000 (Web)
55
-
56
- 2. Find backend PID:
57
- ```bash
58
- netstat.exe -ano | grep ":${API_PORT} .*LISTENING" | awk '{print $5}' | head -1
59
- ```
60
- 3. If found: `taskkill.exe /PID $PID /F`
61
- 4. Find frontend PID:
62
- ```bash
63
- netstat.exe -ano | grep ":${WEB_PORT} .*LISTENING" | awk '{print $5}' | head -1
64
- ```
65
- 5. If found: `taskkill.exe /PID $PID /F`
66
- 6. Display stopped status and exit.
67
-
68
- If no processes found, display "Nothing running" and exit.
69
-
70
- ## Step 0: Load cache
71
-
72
- If `--stop` argument → skip this step entirely (--stop uses netstat only).
73
-
74
- 1. Read cache file:
75
- ```bash
76
- cat .claude/config/dev-run.json 2>/dev/null
77
- ```
78
-
79
- 2. **If no cache OR `--reset` argument** → CACHE_HIT=false, go to Step 1.
80
-
81
- 3. **If cache exists**, verify config files haven't changed:
82
- ```bash
83
- API_DIR=$(grep -o '"api_dir": *"[^"]*"' .claude/config/dev-run.json | cut -d'"' -f4)
84
- WEB_DIR=$(grep -o '"web_dir": *"[^"]*"' .claude/config/dev-run.json | cut -d'"' -f4)
85
- MODE=$(grep -o '"mode": *"[^"]*"' .claude/config/dev-run.json | cut -d'"' -f4)
86
-
87
- if [ "$MODE" = "Local" ]; then
88
- CURRENT_HASH=$(stat -c %Y "$API_DIR/appsettings.Local.json" "$WEB_DIR/.env.standalone" "$API_DIR/Properties/launchSettings.json" 2>/dev/null | md5sum | cut -d' ' -f1)
89
- else
90
- CURRENT_HASH=$(stat -c %Y "$API_DIR/appsettings.json" "$WEB_DIR/.env.development" "$API_DIR/Properties/launchSettings.json" 2>/dev/null | md5sum | cut -d' ' -f1)
91
- fi
92
-
93
- CACHED_HASH=$(grep -o '"config_hash": *"[^"]*"' .claude/config/dev-run.json | cut -d'"' -f4)
94
- ```
95
-
96
- 4. **If CURRENT_HASH = CACHED_HASH** → CACHE_HIT=true :
97
- - Load all values from cache (api_dir, web_dir, mode, ports, commands, sql_status)
98
- - Display: `[CACHE] Using cached config (from {cached_at})`
99
- - **Skip directly to Step 4** (check if already running)
100
-
101
- 5. **If hash mismatch** → CACHE_HIT=false :
102
- - Display: `[CACHE] Config changed, re-detecting...`
103
- - Continue to Step 1
104
-
105
- ## Step 1: Detect project
106
-
107
- **Skip if CACHE_HIT=true (values loaded from cache in Step 0).**
108
-
109
- Find the API and Web directories using bash (Glob doesn't match directories):
48
+ Extract api_port, web_port from injected cache (default 5142, 6173). Single Bash:
110
49
  ```bash
111
- API_DIR=$(ls -d src/*.Api 2>/dev/null | head -1)
112
- WEB_DIR=$(ls -d web/*-web 2>/dev/null | head -1)
50
+ AP={api_port from cache, default 5142}
51
+ WP={web_port from cache, default 6173}
52
+ APID=$(netstat.exe -ano | grep ":${AP} .*LISTENING" | awk '{print $5}' | head -1)
53
+ WPID=$(netstat.exe -ano | grep ":${WP} .*LISTENING" | awk '{print $5}' | head -1)
54
+ [ -n "$APID" ] && taskkill.exe /PID $APID /F 2>&1 && echo "Backend stopped (PID $APID)"
55
+ [ -n "$WPID" ] && taskkill.exe /PID $WPID /F 2>&1 && echo "Frontend stopped (PID $WPID)"
56
+ [ -z "$APID" ] && [ -z "$WPID" ] && echo "Nothing running"
113
57
  ```
58
+ Display result. Done. Exit.
114
59
 
115
- If neither found, display error and exit.
116
-
117
- ## Step 2: Detect environment and ports
118
-
119
- **Skip if CACHE_HIT=true (values loaded from cache in Step 0).**
60
+ ---
120
61
 
121
- Check if `appsettings.Local.json` exists in the API directory:
62
+ ## Step 0: Cache Decision
122
63
 
123
- | Condition | Mode | Backend | Frontend | Backend command | Frontend command |
124
- |-----------|------|---------|----------|-----------------|------------------|
125
- | `appsettings.Local.json` exists | **Local** | Port from `Kestrel:Endpoints:Http:Url` | Port from `.env.standalone` or `package.json` local script | `dotnet run --launch-profile Local` | `npm run local` |
126
- | No local config | **Development** | Port 5142 (launchSettings http profile) | Port 6173 (vite default) | `dotnet run --environment Development` | `npm run dev` |
64
+ **CRITICAL: The injected state above IS your data source. NEVER re-read cache or session files.**
127
65
 
128
- **Reading ports:**
129
- - **Local backend port**: Parse `appsettings.Local.json` -> `Kestrel.Endpoints.Http.Url` -> extract port from URL (e.g., `http://localhost:5290` -> `5290`)
130
- - **Local frontend port**: Parse `.env.standalone` -> look for port in `VITE_API_URL`, or parse `package.json` -> `scripts.local` for `--port` flag
131
- - **Dev backend port**: Default `5142`
132
- - **Dev frontend port**: Default `6173`
66
+ **If injected cache = "no cache" OR --reset flag → CACHE_HIT=false, go to Step 1 (cold start).**
133
67
 
134
- **IMPORTANT: Read config files in parallel.** Use a single message with multiple Read tool calls for:
135
- - `{API_DIR}/appsettings.json` (or `appsettings.Local.json`)
136
- - `{WEB_DIR}/.env.development` (or `.env.standalone`)
137
- - `{API_DIR}/Properties/launchSettings.json`
68
+ **If injected cache has JSON values AND no --reset:**
69
+ - Extract directly from injected cache: api_dir, web_dir, api_port, web_port, backend_cmd, frontend_cmd, connection_string, sql_server, sql_database
70
+ - CACHE_HIT=true
71
+ - **Skip directly to Step 4 (check ports)**
138
72
 
139
- ## Step 3: Validate config coherence
73
+ ---
140
74
 
141
- **Skip if CACHE_HIT=true (values loaded from cache in Step 0).**
75
+ ## Step 1: Detect project (Cold Start Only)
142
76
 
143
- **CRITICAL: Verify that backend and frontend configs are consistent.**
77
+ **Only if CACHE_HIT=false.**
144
78
 
145
- ### Rules to check:
79
+ Single message with 3 PARALLEL tool calls:
146
80
 
147
- | Rule | Backend source | Frontend source | Validation |
148
- |------|---------------|-----------------|------------|
149
- | Frontend calls correct backend | Port API (Kestrel or launchSettings) | `VITE_API_URL` in `.env.standalone` (Local) or `.env.development` (Dev) | Port in VITE_API_URL must match API port |
150
- | Backend allows frontend (CORS) | `SmartStack:CorsOrigins[]` in appsettings | Frontend port | CorsOrigins must contain `http://localhost:{WEB_PORT}` |
151
- | OAuth redirects to correct frontend | `Authentication:FrontendUrl` in appsettings | Frontend port | FrontendUrl must point to `http://localhost:{WEB_PORT}` |
152
- | Local files exist in pairs | `appsettings.Local.json` | `.env.standalone` | If one exists, the other must too |
81
+ 1. **Read** `src/SmartStack.Api/appsettings.json` (limit: 40 lines connection string, CORS, FrontendUrl)
82
+ 2. **Read** `src/SmartStack.Api/Properties/launchSettings.json`
83
+ 3. **Bash** detect mode + frontend env + SQL check:
84
+ ```bash
85
+ echo "=== MODE ==="
86
+ [ -f src/SmartStack.Api/appsettings.Local.json ] && echo "Local" || echo "Development"
87
+ echo "=== ENV ==="
88
+ cat web/smartstack-web/.env.development 2>/dev/null || cat web/smartstack-web/.env.standalone 2>/dev/null || echo "NONE"
89
+ echo "=== SQL ==="
90
+ CS=$(sed -n 's/.*"DefaultConnection":\s*"\([^"]*\)".*/\1/p' src/SmartStack.Api/appsettings.json 2>/dev/null)
91
+ SN=$(echo "$CS" | sed -n 's/.*[Ss]erver=\([^;]*\).*/\1/p' | sed 's/(local)/./')
92
+ DB=$(echo "$CS" | sed -n 's/.*[Dd]atabase=\([^;]*\).*/\1/p')
93
+ sqlcmd -S "$SN" -Q "SET NOCOUNT ON;SELECT name FROM sys.databases WHERE name='$DB'" -t 5 -E -C -h -1 -W 2>/dev/null | grep -q "$DB" && echo "ok $SN $DB" || echo "warn $SN $DB"
94
+ ```
153
95
 
154
- ### In Local mode:
96
+ Determine config from results:
155
97
 
156
- 1. Read `appsettings.Local.json` -> extract `Kestrel:Endpoints:Http:Url` (API port)
157
- 2. Read `appsettings.Local.json` -> extract `Authentication:FrontendUrl` (expected frontend URL)
158
- 3. Read `.env.standalone` -> extract `VITE_API_URL` (expected API URL by frontend)
159
- 4. Verify `VITE_API_URL` port matches Kestrel port
160
- 5. Verify `Authentication:FrontendUrl` port matches frontend port
161
- 6. If `appsettings.Local.json` exists but NOT `.env.standalone` -> **create `.env.standalone`** with correct values (ask user first)
162
- 7. If `.env.standalone` exists but NOT `appsettings.Local.json` -> **warn** (config incomplete)
98
+ | | Development (no Local config) | Local (appsettings.Local.json exists) |
99
+ |--|-------------------------------|--------------------------------------|
100
+ | api_port | 5142 (launchSettings "http") | Port from launchSettings "Local" |
101
+ | web_port | 6173 | From .env.standalone or 5305 |
102
+ | backend_cmd | `dotnet run --launch-profile http` | `dotnet run --launch-profile Local` |
103
+ | frontend_cmd | `npm run dev` | `npm run local` |
163
104
 
164
- ### In Development mode:
105
+ ## Step 2: Validate config coherence (Cold Start Only)
165
106
 
166
- 1. Verify `.env.development` contains `VITE_API_URL=http://localhost:5142` (NOT 5290 which is Local profile)
167
- 2. Verify `appsettings.json` -> `SmartStack:CorsOrigins` contains `http://localhost:6173`
168
- 3. Verify `Authentication:FrontendUrl` = `http://localhost:6173`
107
+ **Only if CACHE_HIT=false.**
169
108
 
170
- ### If incoherence detected:
109
+ Display one line per check, continue even on warnings:
110
+ - VITE_API_URL port matches api_port → `[OK]` or `[WARN] expected X, got Y`
111
+ - CorsOrigins includes `http://localhost:{web_port}` → `[OK]` or `[WARN]`
112
+ - Authentication:FrontendUrl = `http://localhost:{web_port}` → `[OK]` or `[WARN]`
113
+ - SQL status → `[OK] {server}/{db}` or `[WARN] SQL unreachable`
171
114
 
172
- 1. Display a clear WARNING with detected values vs expected values
173
- 2. Propose to auto-correct (write the correct files)
174
- 3. If user refuses, continue with a warning
115
+ ## Step 3: Write cache (Cold Start Only)
175
116
 
176
- ### Output format for coherence:
117
+ **Only if CACHE_HIT=false.**
177
118
 
178
- ```
179
- Config Coherence Check:
180
- [OK] VITE_API_URL matches backend port (5290)
181
- [OK] CORS allows frontend (http://localhost:3000)
182
- [OK] OAuth redirect matches frontend
183
- [OK] Local config files paired
184
-
185
- -- OR --
186
-
187
- [WARN] VITE_API_URL=http://localhost:5290 but backend runs on port 5142
188
- Expected: VITE_API_URL=http://localhost:5142
189
- [WARN] .env.standalone missing (appsettings.Local.json exists)
190
- -> Creating .env.standalone with correct values...
119
+ Use Bash to write (avoids Write tool read-first requirement):
120
+ ```bash
121
+ mkdir -p .claude/config && cat > .claude/config/dev-run.json << 'EOF'
122
+ {"version":2,"api_dir":"{api_dir}","web_dir":"{web_dir}","mode":"{mode}","api_port":{api_port},"web_port":{web_port},"backend_cmd":"{backend_cmd}","frontend_cmd":"{frontend_cmd}","connection_string":"{conn_str}","sql_server":"{srv}","sql_database":"{db}","sql_status":"{status}","cached_at":"{ISO now}"}
123
+ EOF
191
124
  ```
192
125
 
193
- ### Rule 5: SQL Server connectivity
194
-
195
- 1. Extract connection string from appsettings:
196
- - **Local mode**: `appsettings.Local.json` → `ConnectionStrings.DefaultConnection`
197
- - **Dev mode**: `appsettings.json` → `ConnectionStrings.DefaultConnection`
198
-
199
- 2. Parse server and database:
200
- ```bash
201
- SQL_SERVER=$(echo "$CONN_STR" | grep -oiP '(?:Server|Data Source)=\K[^;]+')
202
- SQL_DATABASE=$(echo "$CONN_STR" | grep -oiP '(?:Database|Initial Catalog)=\K[^;]+')
203
- USE_WIN_AUTH=$(echo "$CONN_STR" | grep -qi 'Integrated Security=true\|Trusted_Connection=true' && echo "true" || echo "false")
204
- ```
205
-
206
- 3. Test connectivity (5s timeout):
207
- ```bash
208
- # Normalize (local) → .
209
- SQL_SERVER_NORM=$(echo "$SQL_SERVER" | sed 's/(local)/./')
210
-
211
- if [ "$USE_WIN_AUTH" = "true" ]; then
212
- sqlcmd -S "$SQL_SERVER_NORM" -d master -Q "SELECT 1" -t 5 -E -C -h -1 -W 2>/dev/null
213
- else
214
- SQL_USER=$(echo "$CONN_STR" | grep -oiP '(?:User Id|Uid)=\K[^;]+')
215
- SQL_PASS=$(echo "$CONN_STR" | grep -oiP '(?:Password|Pwd)=\K[^;]+')
216
- sqlcmd -S "$SQL_SERVER_NORM" -d master -Q "SELECT 1" -t 5 -U "$SQL_USER" -P "$SQL_PASS" -C -h -1 -W 2>/dev/null
217
- fi
218
- ```
219
-
220
- 4. If reachable, check database exists:
221
- ```bash
222
- sqlcmd -S "$SQL_SERVER_NORM" -Q "SET NOCOUNT ON; SELECT name FROM sys.databases WHERE name = '$SQL_DATABASE'" -t 5 -E -C -h -1 -W 2>/dev/null
223
- ```
224
-
225
- 5. Output format:
226
- | Scenario | Output | Blocking? |
227
- |----------|--------|-----------|
228
- | Server OK + DB exists | `[OK] SQL Server (server) — Database 'db' exists` | No |
229
- | Server OK + DB missing | `[WARN] Database 'db' not found (AutoMigrate will create it)` | No |
230
- | Server unreachable | `[FAIL] SQL Server (server) unreachable — Is the service running?` | No |
231
- | sqlcmd not installed | `[SKIP] sqlcmd not found — SQL check skipped` | No |
232
- | No connection string | `[SKIP] No connection string — SQL check skipped` | No |
233
-
234
- ## Step 3b: Write cache
235
-
236
- **Only execute if CACHE_HIT=false (Steps 1-3 were executed).**
237
-
238
- 1. Ensure directory exists: `mkdir -p .claude/config`
239
-
240
- 2. Compute config hash:
241
- ```bash
242
- if [ "$MODE" = "Local" ]; then
243
- CONFIG_HASH=$(stat -c %Y "$API_DIR/appsettings.Local.json" "$WEB_DIR/.env.standalone" "$API_DIR/Properties/launchSettings.json" 2>/dev/null | md5sum | cut -d' ' -f1)
244
- else
245
- CONFIG_HASH=$(stat -c %Y "$API_DIR/appsettings.json" "$WEB_DIR/.env.development" "$API_DIR/Properties/launchSettings.json" 2>/dev/null | md5sum | cut -d' ' -f1)
246
- fi
247
- ```
248
-
249
- 3. Write `.claude/config/dev-run.json` using the Write tool with all detected values:
250
- ```json
251
- {
252
- "version": 2,
253
- "api_dir": "{API_DIR}",
254
- "web_dir": "{WEB_DIR}",
255
- "mode": "{MODE}",
256
- "api_port": {API_PORT},
257
- "web_port": {WEB_PORT},
258
- "backend_cmd": "{BACKEND_CMD}",
259
- "frontend_cmd": "{FRONTEND_CMD}",
260
- "connection_string": "{CONN_STR}",
261
- "sql_server": "{SQL_SERVER}",
262
- "sql_database": "{SQL_DATABASE}",
263
- "sql_status": "{ok|unreachable|db_missing|skipped}",
264
- "config_hash": "{CONFIG_HASH}",
265
- "cached_at": "{ISO_TIMESTAMP}"
266
- }
267
- ```
126
+ **IMPORTANT:** This Bash call can be parallelized with Step 5/6 launches in a single message.
268
127
 
269
128
  ## Step 4: Check if already running
270
129
 
271
- ```bash
272
- netstat.exe -ano | grep ":${API_PORT} .*LISTENING"
273
- netstat.exe -ano | grep ":${WEB_PORT} .*LISTENING"
274
- ```
130
+ Check the injected "Ports running" state to see what's already listening:
131
+ - Backend running = api_port appears in Ports
132
+ - Frontend running = web_port appears in Ports
275
133
 
276
134
  If `--backend-only`: skip frontend checks.
277
135
  If `--frontend-only`: skip backend checks.
278
136
 
279
- ## Step 5: Launch backend
137
+ **If both running → skip to Step 7.** ZERO tool calls needed.
280
138
 
281
- Track whether the backend was just launched: `BACKEND_JUST_LAUNCHED=true/false`. This is used in Step 7 for cache invalidation.
139
+ ## Step 5: Launch backend
282
140
 
283
- If NOT already running and NOT `--frontend-only` (set `BACKEND_JUST_LAUNCHED=true`):
141
+ If NOT already running and NOT `--frontend-only`:
284
142
 
285
143
  ```bash
286
- # cd into the API directory first
287
- cd {API_DIR} && dotnet run {LAUNCH_ARGS}
144
+ cd {api_dir} && {backend_cmd}
288
145
  ```
289
146
 
290
- Use `Bash(run_in_background=true)` so it runs in background. **Save the task ID** returned by the background command.
291
-
292
- ### Fail-fast crash detection
293
-
294
- After launching, wait 5 seconds then check if the process crashed:
295
- ```bash
296
- sleep 5
297
- ```
298
- Then call `TaskOutput(task_id="{TASK_ID}", block=false)` to read the background output.
147
+ Use `Bash(run_in_background=true)`. Track: `BACKEND_LAUNCHED=true`.
299
148
 
300
- **If the output contains a stack trace, "Unhandled exception", or the process has already exited:**
301
- 1. Display the error output to the user
302
- 2. Display: `[FAIL] Backend crashed on startup. Fix the error above and retry /dev-start`
303
- 3. **STOP immediately. Do NOT attempt to diagnose, fix, rebuild, or retry.**
149
+ **Launch backend AND frontend in the SAME message as parallel Bash(run_in_background) calls.**
304
150
 
305
151
  ## Step 6: Launch frontend
306
152
 
307
153
  If NOT already running and NOT `--backend-only`:
308
154
 
309
155
  ```bash
310
- # cd into the Web directory first
311
- cd {WEB_DIR} && npm run {SCRIPT}
156
+ cd {web_dir} && {frontend_cmd}
312
157
  ```
313
158
 
314
- Use `Bash(run_in_background=true)` so it runs in background.
159
+ Use `Bash(run_in_background=true)`.
160
+
161
+ **This MUST be in the same message as Step 5 (parallel launches).**
162
+ **If cold start, also include Step 3 (cache write) in the same message.**
315
163
 
316
164
  ## Step 7: Handle admin password
317
165
 
318
- **Cache invalidation rule:** If the backend was just launched in Step 5 (i.e., it was NOT already running), the cache is STALE because `MigrateAsync()` + `HasData()` may have re-seeded the admin user with the default password hash, overwriting any previously set password. In this case, ALWAYS run a fresh admin reset regardless of `dev-session.json`.
319
-
320
- 1. If `.claude/dev-session.json` exists and contains a password AND `--reset` NOT specified AND the backend was already running (NOT launched in Step 5) -> reuse stored credentials
321
- 2. If `--reset` OR no stored password OR backend was just launched in Step 5:
322
- a. If backend was just launched, wait for it to be UP first.
323
- Run the full wait in a **single bash command** to avoid multiple tool calls:
324
- ```bash
325
- # Phase 1: Wait for port to be bound (up to 30s)
326
- echo "Waiting for backend port ${API_PORT}..."
327
- for i in $(seq 1 10); do
328
- netstat.exe -ano | grep ":${API_PORT} .*LISTENING" > /dev/null 2>&1 && echo "Port bound." && break
329
- sleep 3
330
- done
331
- # Phase 2: Wait for API to respond (up to 30s) accept 200 or 302
332
- echo "Waiting for API to respond..."
333
- for i in $(seq 1 10); do
334
- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:${API_PORT}/scalar" 2>/dev/null)
335
- [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ] && echo "API ready (HTTP $HTTP_CODE)." && break
336
- sleep 3
337
- done
338
- ```
339
- If `/scalar` does not respond after 30s, warn the user and attempt the reset anyway.
340
- b. Run admin reset using the connection string extracted from appsettings (Step 3):
341
- ```bash
342
- smartstack admin reset --connection '{CONN_STR}' --force --json
343
- ```
344
- **IMPORTANT:** Always pass `--connection` with the full connection string (single-quoted to avoid shell expansion). Without it, the CLI shows an interactive environment picker that blocks execution.
345
- c. Parse JSON output to extract email and password
346
- d. Write `.claude/dev-session.json`:
347
- ```json
348
- {
349
- "admin_password": "...",
350
- "admin_email": "local.admin@smartstack.local",
351
- "last_reset": "2026-03-10T14:30:00Z",
352
- "api_port": 5142,
353
- "web_port": 6173,
354
- "environment": "Development"
355
- }
356
- ```
357
- e. Verify `.claude/dev-session.json` is in `.gitignore`. If not, warn the user (contains credentials).
166
+ Choose ONE path based on BACKEND_LAUNCHED and session state:
167
+
168
+ ### Path A: Backend just launched (ALWAYS reset session or not)
169
+ The backend may have re-seeded the database on startup, invalidating any cached password.
170
+ Single Bash wait for API then reset:
171
+ ```bash
172
+ echo "Waiting for backend..."
173
+ for i in $(seq 1 20); do
174
+ HTTP=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:{api_port}/scalar 2>/dev/null)
175
+ [ "$HTTP" = "200" ] || [ "$HTTP" = "302" ] && echo "API ready" && break
176
+ [ $i -eq 20 ] && echo "API timeout continuing anyway"
177
+ sleep 2
178
+ done
179
+ RESULT=$(timeout 20 smartstack admin reset --connection '{connection_string}' --force --json 2>&1 | grep -E '^\{')
180
+ EMAIL=$(echo "$RESULT" | sed -n 's/.*"email":"\([^"]*\)".*/\1/p')
181
+ PASS=$(echo "$RESULT" | sed -n 's/.*"password":"\([^"]*\)".*/\1/p')
182
+ cat > .claude/dev-session.json << SESSEOF
183
+ {"admin_email":"$EMAIL","admin_password":"$PASS","last_reset":"$(date -Iseconds)","api_port":{api_port},"web_port":{web_port},"environment":"{mode}","status":"ready"}
184
+ SESSEOF
185
+ echo "CREDENTIALS: $EMAIL / $PASS"
186
+ ```
187
+
188
+ ### Path B: Backend already running + no session (or --reset)
189
+ Single Bash — reset only (no wait needed):
190
+ ```bash
191
+ RESULT=$(timeout 20 smartstack admin reset --connection '{connection_string}' --force --json 2>&1 | grep -E '^\{')
192
+ EMAIL=$(echo "$RESULT" | sed -n 's/.*"email":"\([^"]*\)".*/\1/p')
193
+ PASS=$(echo "$RESULT" | sed -n 's/.*"password":"\([^"]*\)".*/\1/p')
194
+ cat > .claude/dev-session.json << SESSEOF
195
+ {"admin_email":"$EMAIL","admin_password":"$PASS","last_reset":"$(date -Iseconds)","api_port":{api_port},"web_port":{web_port},"environment":"{mode}","status":"ready"}
196
+ SESSEOF
197
+ echo "CREDENTIALS: $EMAIL / $PASS"
198
+ ```
199
+
200
+ ### Path C: Everything running + session exists (no --reset)
201
+ ZERO tool calls. Use email + password from injected session directly.
358
202
 
359
203
  ## Step 8: Display connection info
360
204
 
@@ -362,18 +206,15 @@ Use `Bash(run_in_background=true)` so it runs in background.
362
206
  ================================================================
363
207
  SMARTSTACK DEV ENVIRONMENT
364
208
  ================================================================
209
+ Backend: http://localhost:{api_port} [{RUNNING|LAUNCHED}]
210
+ Frontend: http://localhost:{web_port} [{RUNNING|LAUNCHED}]
211
+ Swagger: http://localhost:{api_port}/scalar
212
+ SQL Server: {sql_server}/{sql_database} [{OK|WARN}]
365
213
 
366
- Backend: http://localhost:{API_PORT} [RUNNING|STARTING]
367
- Frontend: http://localhost:{WEB_PORT} [RUNNING|STARTING]
368
- Swagger: http://localhost:{API_PORT}/scalar
369
- SQL Server: {SQL_SERVER}/{SQL_DATABASE} [OK|WARN|FAIL|SKIP]
370
-
371
- Email: local.admin@smartstack.local
372
- Password: xxxxxxxxxxxxxx
214
+ Email: {email}
215
+ Password: {password}
373
216
 
374
- Environment: {Development|Local}
375
- Config: OK | WARNING (details)
376
- Cache: HIT (from {cached_at}) | MISS (re-detected)
217
+ Mode: {Development|Local}
377
218
  ================================================================
378
219
  ```
379
220
 
@@ -381,27 +222,22 @@ Use `Bash(run_in_background=true)` so it runs in background.
381
222
 
382
223
  <important_notes>
383
224
 
384
- 1. **NEVER debug or fix code** - This skill ONLY starts processes. If the backend or frontend fails to start, display the error and STOP. Do NOT attempt to: clean/restore/rebuild, upgrade packages, inspect DLLs, clear NuGet cache, read .csproj files, or any other diagnostic/repair action. The user will fix the issue themselves.
385
- 2. **Fail-fast on crash** - After launching backend in background, wait 5s then check TaskOutput. If the process already exited or shows errors, report and STOP immediately.
386
- 3. **Backend must be READY before admin reset** - First poll the port (netstat), then poll the `/scalar` endpoint (HTTP 200/302) to confirm the API is fully initialized. Kestrel binds the port before the app finishes starting, so port-only checks are insufficient.
387
- 4. **Admin reset requires --connection** - Always pass `--connection '{CONN_STR}'` (single-quoted to avoid shell expansion) to avoid the interactive environment picker.
388
- 5. **Read config files in parallel** - When reading appsettings, .env, and launchSettings, use multiple Read calls in a single message.
389
- 6. **Cross-worktree support** - Detect the correct API directory regardless of which worktree we're in.
390
- 7. **No MCP required** - This skill only uses bash commands and the `smartstack` CLI.
391
- 8. **Config coherence is critical** - Mismatched ports between backend/frontend is the #1 cause of "it doesn't work" issues.
392
- 9. **Idempotent** - Running twice should detect already-running processes and reuse stored credentials.
393
- 10. **dev-session.json contains secrets** - Must be in `.gitignore`.
394
- 11. **Cache** - Config detection is cached in `.claude/config/dev-run.json`. Cache is invalidated when config files change (mtime-based hash). Use `--reset` to force re-detection.
395
- 12. **SQL check is non-blocking** - A failed SQL check displays a warning but does not prevent launch. AutoMigrate may create the database on startup.
225
+ 1. **Injected state IS source of truth** Cache, session, and ports are already loaded above. NEVER re-read these files. This is the #1 speed optimization.
226
+ 2. **NEVER debug or fix code** If backend/frontend fails to start, display the error and STOP. No rebuilds, no NuGet restore, no diagnosis.
227
+ 3. **Parallel launches** Backend + frontend MUST be launched in the same message (parallel Bash background calls).
228
+ 4. **Timeout = warn** If API doesn't respond after 40s, warn user and show what you have.
229
+ 5. **Admin reset needs --connection** — Single-quoted: `--connection '{conn_str}'`. Without it, CLI blocks on interactive picker.
230
+ 6. **dev-session.json has secrets** Must be in .gitignore.
231
+ 7. **SQL check non-blocking** Warnings don't prevent launch.
232
+ 8. **Cold start writes cache** So next run uses CACHED path (fast).
233
+ 9. **Idempotent** Running twice detects already-running processes via injected Ports.
396
234
 
397
235
  </important_notes>
398
236
 
399
237
  <success_criteria>
400
- - Backend and frontend detected and launched (or already running)
401
- - Config coherence validated (or warnings displayed)
402
- - Admin credentials available (reused or freshly reset)
403
- - Connection info displayed in clear format
404
- - No errors on repeated invocations (idempotent)
405
- - Cache written on first run, reused on subsequent runs
406
- - SQL Server connectivity reported
238
+ - Path C (all running + session): 0 tool calls — instant display
239
+ - Path A (cached, backend launched): 3 tool calls — launch + wait + reset ~25s
240
+ - Path B (running, no session): 1 tool call — reset only ~10s
241
+ - Cold start: 5 tool calls max — ~30s
242
+ - NEVER more than 5 tool calls total
407
243
  </success_criteria>
@@ -94,6 +94,19 @@ Pattern: `{context}_v{version}_{sequence}_{Description}`
94
94
 
95
95
  </shared>
96
96
 
97
+ <success_criteria>
98
+ - Command displays its summary block with no ERROR lines
99
+ - db-status: both contexts report migration counts (no connection failure)
100
+ - db-deploy: 0 pending migrations after execution
101
+ - db-reset: database recreated, all migrations applied for both contexts
102
+ - db-seed: seed method detected and executed, records inserted
103
+ - scan: all worktree branches analyzed with risk levels
104
+ - conflicts: EXIT CODE 0 (no HIGH/CRITICAL)
105
+ - migration: MCP-named migration created, compiles, applies cleanly
106
+ - squash: consolidated migration compiles and applies identically
107
+ - rebase-snapshot: ModelSnapshot aligned with parent branch
108
+ </success_criteria>
109
+
97
110
  <command-db-status>
98
111
 
99
112
  ## db-status — Fast migration state check