@atlashub/smartstack-cli 4.34.0 → 4.36.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 (50) hide show
  1. package/dist/index.js +28 -32
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +35 -303
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/skills/apex/references/checks/seed-checks.sh +1 -1
  7. package/templates/skills/apex/references/core-seed-data.md +39 -21
  8. package/templates/skills/application/references/application-roles-template.md +14 -8
  9. package/templates/skills/application/references/provider-template.md +32 -20
  10. package/templates/skills/application/templates-frontend.md +350 -89
  11. package/templates/skills/application/templates-seed.md +23 -11
  12. package/templates/skills/audit-route/SKILL.md +107 -0
  13. package/templates/skills/audit-route/references/routing-pattern.md +129 -0
  14. package/templates/skills/audit-route/steps/step-00-init.md +128 -0
  15. package/templates/skills/audit-route/steps/step-01-inventory.md +157 -0
  16. package/templates/skills/audit-route/steps/step-02-conformity.md +193 -0
  17. package/templates/skills/audit-route/steps/step-03-report.md +201 -0
  18. package/templates/skills/cli-app-sync/SKILL.md +2 -2
  19. package/templates/skills/cli-app-sync/references/comparison-map.md +1 -1
  20. package/templates/skills/dev-start/SKILL.md +12 -2
  21. package/templates/skills/documentation/steps/step-03-validate.md +12 -14
  22. package/templates/skills/efcore/SKILL.md +219 -67
  23. package/templates/agents/efcore/conflicts.md +0 -114
  24. package/templates/agents/efcore/db-deploy.md +0 -86
  25. package/templates/agents/efcore/db-reset.md +0 -98
  26. package/templates/agents/efcore/db-seed.md +0 -73
  27. package/templates/agents/efcore/db-status.md +0 -97
  28. package/templates/agents/efcore/scan.md +0 -124
  29. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +0 -126
  30. package/templates/skills/efcore/references/both-contexts.md +0 -32
  31. package/templates/skills/efcore/references/destructive-operations.md +0 -38
  32. package/templates/skills/efcore/steps/db/step-deploy.md +0 -217
  33. package/templates/skills/efcore/steps/db/step-reset.md +0 -186
  34. package/templates/skills/efcore/steps/db/step-seed.md +0 -166
  35. package/templates/skills/efcore/steps/db/step-status.md +0 -173
  36. package/templates/skills/efcore/steps/migration/step-00-init.md +0 -102
  37. package/templates/skills/efcore/steps/migration/step-01-check.md +0 -164
  38. package/templates/skills/efcore/steps/migration/step-02-create.md +0 -160
  39. package/templates/skills/efcore/steps/migration/step-03-validate.md +0 -168
  40. package/templates/skills/efcore/steps/rebase-snapshot/step-00-init.md +0 -173
  41. package/templates/skills/efcore/steps/rebase-snapshot/step-01-backup.md +0 -100
  42. package/templates/skills/efcore/steps/rebase-snapshot/step-02-fetch.md +0 -115
  43. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +0 -112
  44. package/templates/skills/efcore/steps/rebase-snapshot/step-04-validate.md +0 -157
  45. package/templates/skills/efcore/steps/shared/step-00-init.md +0 -131
  46. package/templates/skills/efcore/steps/squash/step-00-init.md +0 -141
  47. package/templates/skills/efcore/steps/squash/step-01-backup.md +0 -120
  48. package/templates/skills/efcore/steps/squash/step-02-fetch.md +0 -168
  49. package/templates/skills/efcore/steps/squash/step-03-create.md +0 -184
  50. package/templates/skills/efcore/steps/squash/step-04-validate.md +0 -174
@@ -9,92 +9,244 @@ disable-model-invocation: true
9
9
  - Preflight: !`if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"; printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git && echo "repaired"; else echo "ok"; fi`
10
10
  - Branch: !`git branch --show-current 2>/dev/null || echo "UNAVAILABLE"`
11
11
 
12
- <objective>
13
- Manage EF Core migrations and database operations. **ALWAYS delegate to Task agents** for fast execution.
14
- </objective>
12
+ <routing>
13
+
14
+ Parse `$ARGUMENTS` to determine the command:
15
+
16
+ | Command | Execution | Model |
17
+ |---------|-----------|-------|
18
+ | `db-status` | **Inline** `<command-db-status>` | — |
19
+ | `db-deploy` | **Inline** `<command-db-deploy>` | — |
20
+ | `db-reset` | **Inline** `<command-db-reset>` | — |
21
+ | `db-seed` | **Inline** `<command-db-seed>` | — |
22
+ | `scan` | **Inline** `<command-scan>` | — |
23
+ | `conflicts` | **Inline** `<command-conflicts>` | — |
24
+ | `migration` | **Agent** `efcore-migration` | sonnet |
25
+ | `squash` | **Agent** `efcore-squash` | sonnet |
26
+ | `rebase-snapshot` | **Agent** `efcore-rebase-snapshot` | sonnet |
27
+
28
+ **Inline commands:** Execute directly following the matching `<command-*>` section below.
29
+ **Agent commands:** Delegate via Agent tool:
30
+ ```
31
+ Agent(
32
+ subagent_type: "{agent_name}",
33
+ model: "sonnet",
34
+ prompt: "Execute /efcore {command} in {cwd}. Branch: {branch}. Flags: {flags}. Description: {description}"
35
+ )
36
+ ```
37
+
38
+ **Flags:** `--context <name>` (CoreDbContext/ExtensionsDbContext), `--force` (skip confirmations)
39
+
40
+ </routing>
41
+
42
+ <shared>
43
+
44
+ ### WSL Preflight (MANDATORY before any git command)
15
45
 
16
- <quick_start>
17
- **Database operations:**
18
46
  ```bash
19
- /efcore db-status # Check migration status
20
- /efcore db-deploy # Apply pending migrations
21
- /efcore db-reset # Drop + recreate database
22
- /efcore db-seed # Populate with test data
47
+ if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then
48
+ p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"
49
+ printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git
50
+ fi
23
51
  ```
24
52
 
25
- **Migration operations:**
53
+ ### dotnet-ef PATH fix (MANDATORY before any dotnet ef command)
54
+
26
55
  ```bash
27
- /efcore migration # Create migration for current branch
28
- /efcore squash # Consolidate branch migrations
29
- /efcore rebase-snapshot # Sync snapshot with parent branch
30
- /efcore scan # Scan for cross-branch conflicts
31
- /efcore conflicts # Analyze migration conflicts
56
+ if ! dotnet ef --version &>/dev/null; then
57
+ for TOOLS_DIR in "$USERPROFILE/.dotnet/tools" "$HOME/.dotnet/tools" "$LOCALAPPDATA/Microsoft/dotnet/tools"; do
58
+ [ -n "$TOOLS_DIR" ] && [ -d "$TOOLS_DIR" ] && export PATH="$TOOLS_DIR:$PATH"
59
+ done
60
+ dotnet ef --version &>/dev/null || { echo "ERROR: dotnet-ef not found. Install: dotnet tool install --global dotnet-ef"; exit 1; }
61
+ fi
32
62
  ```
33
- </quick_start>
34
63
 
35
- <flags>
36
- | Flag | Description |
37
- |------|-------------|
38
- | `--context <name>` | Specify DbContext (CoreDbContext/ExtensionsDbContext) |
39
- | `--force` | Skip confirmations |
40
- </flags>
64
+ ### Dual DbContext Architecture
41
65
 
42
- <entry_point>
66
+ | Context | DbContext | Schema | History Table |
67
+ |---------|-----------|--------|---------------|
68
+ | `core` | `CoreDbContext` | `core` | `core.__EFMigrationsHistory` |
69
+ | `extensions` | `ExtensionsDbContext` | `extensions` | `extensions.__EFMigrationsHistory` |
70
+
71
+ **Deploy order:** Core FIRST, then Extensions (FK dependency).
72
+ Both contexts share the same physical database but use different schemas.
73
+
74
+ ### Safety Rules
43
75
 
44
- **ROUTING: ALWAYS delegate to Task agent. Never execute inline.**
76
+ 1. **Production BLOCKED** Never run on production
77
+ 2. **Backup MANDATORY** for destructive operations (db-reset, squash)
78
+ 3. **1 migration per feature** — Recreate, don't accumulate
79
+ 4. **MCP for naming** — Never hardcode migration names
80
+
81
+ ### Migration Naming (MCP MANDATORY)
82
+
83
+ Pattern: `{context}_v{version}_{sequence}_{Description}`
84
+ **FORBIDDEN:** Manual name calculation. Always use `mcp__smartstack__suggest_migration`.
45
85
 
46
- Parse the command from `$ARGUMENTS` and delegate to the matching agent:
86
+ </shared>
47
87
 
48
- | Command | Task Agent (`subagent_type`) | Model | Description |
49
- |---------|----------------------------|-------|-------------|
50
- | `db-status` | `efcore-db-status` | haiku | Fast migration state check |
51
- | `db-deploy` | `efcore-db-deploy` | haiku | Apply pending migrations |
52
- | `db-reset` | `efcore-db-reset` | haiku | Drop + recreate database |
53
- | `db-seed` | `efcore-db-seed` | haiku | Populate with test data |
54
- | `migration` | `efcore-migration` | sonnet | Create/recreate migration (MCP) |
55
- | `squash` | `efcore-squash` | sonnet | Consolidate migrations (MCP) |
56
- | `rebase-snapshot` | `efcore-rebase-snapshot` | sonnet | Sync snapshot with parent (MCP) |
57
- | `scan` | `efcore-scan` | haiku | Cross-branch conflict scan |
58
- | `conflicts` | `efcore-conflicts` | haiku | Conflict analysis |
88
+ <command-db-status>
59
89
 
60
- **Delegation template:**
90
+ ## db-status — Fast migration state check
91
+
92
+ **READ-ONLY: Never modify database or migrations.**
93
+
94
+ 1. Call MCP `mcp__smartstack__check_migrations` with `branch: {current_branch}`
95
+ 2. If MCP unavailable, fallback: `dotnet ef migrations list --no-build --context {Context}` per context
96
+ 3. Display compact summary
61
97
 
62
98
  ```
63
- Task(
64
- subagent_type: "{agent_name}",
65
- prompt: "Execute /efcore {command} in {cwd}. Branch: {branch}. Flags: {flags}",
66
- mode: "bypassPermissions"
67
- )
99
+ EF CORE — DATABASE STATUS
100
+ ──────────────────────────
101
+ CORE (CoreDbContext)
102
+ Migrations: {applied}/{total} | {pending} pending
103
+
104
+ EXTENSIONS (ExtensionsDbContext)
105
+ Migrations: {applied}/{total} | {pending} pending
106
+
107
+ BRANCH: {branch}
108
+ Naming: {ok|warnings}
109
+ 1-migration rule: {ok|warning}
68
110
  ```
69
111
 
70
- **Pass to agent prompt:**
71
- - Current working directory (absolute path)
72
- - Current branch name
73
- - Any flags (--context, --force)
74
- - User's description (for migration command)
112
+ </command-db-status>
75
113
 
76
- </entry_point>
114
+ <command-db-deploy>
77
115
 
78
- <dual_dbcontext>
79
- SmartStack uses **two separate DbContexts**:
116
+ ## db-deploy — Apply pending migrations
80
117
 
81
- | Context | DbContext | Schema | History Table |
82
- |---------|-----------|--------|---------------|
83
- | `core` | `CoreDbContext` | `core` | `core.__EFMigrationsHistory` |
84
- | `extensions` | `ExtensionsDbContext` | `extensions` | `extensions.__EFMigrationsHistory` |
85
- </dual_dbcontext>
118
+ **ONLY runs `dotnet ef database update`. Never creates/deletes migrations.**
86
119
 
87
- <naming_convention>
88
- **Migration naming (MCP MANDATORY):**
120
+ 1. Verify `appsettings.Local.json` exists in the API project
121
+ 2. Apply Core: `dotnet ef database update --context CoreDbContext --verbose`
122
+ 3. Apply Extensions: `dotnet ef database update --context ExtensionsDbContext --verbose`
89
123
 
90
- Pattern: `{context}_v{version}_{sequence}_{Description}`
124
+ If connection fails: suggest verifying SQL Server, appsettings.Local.json, or `/efcore db-reset`.
91
125
 
92
- **FORBIDDEN:** Manual name calculation. Always use `mcp__smartstack__suggest_migration`.
93
- </naming_convention>
94
-
95
- <safety_rules>
96
- 1. **Backup MANDATORY** for destructive operations (db-reset, squash)
97
- 2. **Production BLOCKED** - Never run on production
98
- 3. **1 migration per feature** - Recreate, don't accumulate
99
- 4. **MCP for naming** - Never hardcode migration names
100
- </safety_rules>
126
+ ```
127
+ DB DEPLOY
128
+ Config: appsettings.Local.json
129
+ CORE: {n} migration(s) applied — {success|error}
130
+ EXTENSIONS: {n} migration(s) applied {success|error|skipped}
131
+ ```
132
+
133
+ </command-db-deploy>
134
+
135
+ <command-db-reset>
136
+
137
+ ## db-reset — Drop + recreate database (DESTRUCTIVE)
138
+
139
+ **ONLY operates on database. Never creates/deletes migration files.**
140
+
141
+ 1. **Confirm** (MANDATORY unless `--force`):
142
+ ```
143
+ AskUserQuestion({ question: "DELETE the database? All data will be lost.", options: ["Yes, delete", "No, cancel"] })
144
+ ```
145
+ 2. **Backup** (optional): `sqlcmd -S "$SERVER" -E -Q "BACKUP DATABASE [$DB] TO DISK='$FILE' WITH FORMAT, INIT, COMPRESSION"`
146
+ 3. **Drop**: `dotnet ef database drop --force`
147
+ 4. **Recreate Core**: `dotnet ef database update --context CoreDbContext`
148
+ 5. **Recreate Extensions**: `dotnet ef database update --context ExtensionsDbContext`
149
+ 6. **Ask** if user wants `/efcore db-seed`
150
+
151
+ Block if ASPNETCORE_ENVIRONMENT=Production.
152
+
153
+ ```
154
+ DB RESET
155
+ Backup: {path|none}
156
+ CORE: {n} migrations applied — {success|error}
157
+ EXTENSIONS: {n} migrations applied — {success|error}
158
+
159
+ Next: /efcore db-status, /efcore db-seed
160
+ ```
161
+
162
+ </command-db-reset>
163
+
164
+ <command-db-seed>
165
+
166
+ ## db-seed — Populate test data
167
+
168
+ **Never drop or recreate database.**
169
+
170
+ 1. **Detect** seeding method:
171
+ - `HasData()` in EF configs → apply via `dotnet ef database update --context {Context}`
172
+ - `IDataSeeder` / `--seed` CLI arg → `dotnet run --project {startup} -- --seed`
173
+ - SQL script `scripts/seed.sql` → **WARNING**: forbidden by conventions, suggest HasData migration
174
+ 2. **Execute** the detected method
175
+ 3. **Verify** insertion
176
+
177
+ ```
178
+ DB SEED
179
+ Method: {hasdata|cli-seed|seeder-class}
180
+ Status: {success|error}
181
+ Records: {n} inserted (if available)
182
+ ```
183
+
184
+ </command-db-seed>
185
+
186
+ <command-scan>
187
+
188
+ ## scan — Cross-branch migration scanner
189
+
190
+ **READ-ONLY. Uses MCP to detect conflicts across branches.**
191
+
192
+ 1. List active worktrees: `git worktree list`
193
+ 2. For each branch, determine base:
194
+ - `feature/*` → `develop`
195
+ - `release/*` / `hotfix/*` / `develop` → `main`
196
+ 3. Call MCP `mcp__smartstack__check_migrations` with `branch` + `compareBranch` for each
197
+ 4. Aggregate risks and recommend merge order
198
+
199
+ | MCP Type | Level | Action |
200
+ |----------|-------|--------|
201
+ | (none) | NONE | Merge OK |
202
+ | `naming` | LOW | Merge OK |
203
+ | `order` | MEDIUM | Attention |
204
+ | `dependency` | HIGH | Rebase required |
205
+ | `snapshot` | CRITICAL | Manual intervention |
206
+
207
+ Fallback (MCP unavailable): `git worktree list` + `md5sum Migrations/*ModelSnapshot.cs`
208
+
209
+ ```
210
+ EF CORE CROSS-BRANCH SCAN
211
+ ──────────────────────────
212
+ BRANCHES ({n})
213
+ {branch} | {count} migrations | Risk: {level}
214
+
215
+ RECOMMENDED MERGE ORDER
216
+ 1. {branch} (reason)
217
+ ```
218
+
219
+ </command-scan>
220
+
221
+ <command-conflicts>
222
+
223
+ ## conflicts — Migration conflict analyzer (BLOCKING)
224
+
225
+ **READ-ONLY. Blocks on HIGH/CRITICAL conflicts.**
226
+
227
+ 1. Determine base branch: `feature/*` → `develop`, others → `main`
228
+ 2. Call MCP `mcp__smartstack__check_migrations` with `branch` + `compareBranch`
229
+ 3. Display results. **EXIT CODE 1** if HIGH or CRITICAL.
230
+
231
+ | Type | Level | Exit |
232
+ |------|-------|------|
233
+ | (none) | NONE | 0 |
234
+ | `naming` | LOW | 0 |
235
+ | `order` | MEDIUM | 0 (warning) |
236
+ | `dependency` | HIGH | 1 (BLOCK) |
237
+ | `snapshot` | CRITICAL | 1 (BLOCK) |
238
+
239
+ Fallback (MCP unavailable): `diff` on ModelSnapshot files.
240
+
241
+ ```
242
+ EF CORE CONFLICT ANALYSIS
243
+ ─────────────────────────
244
+ STATUS: {OK|WARNING|CONFLICT}
245
+ EXIT CODE: {0|1}
246
+
247
+ If conflict:
248
+ /efcore rebase-snapshot (recommended)
249
+ /efcore squash (alternative)
250
+ ```
251
+
252
+ </command-conflicts>
@@ -1,114 +0,0 @@
1
- ---
2
- name: efcore-conflicts
3
- description: EF Core conflict analyzer - BLOCKING if conflict detected
4
- color: red
5
- model: haiku
6
- tools: Bash, Glob, Read
7
- ---
8
-
9
- # EF Core Conflicts Agent
10
-
11
- Analyzes migration conflicts between branches using **SmartStack MCP**. **BLOCKING** if conflict detected.
12
-
13
- ## WSL Preflight (MANDATORY - run BEFORE any git command)
14
-
15
- ```bash
16
- # Repair worktree .git file if Windows path detected under WSL
17
- if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then
18
- p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"
19
- printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git
20
- echo "Worktree .git path repaired for WSL"
21
- fi
22
- ```
23
-
24
- ## Mission
25
-
26
- 1. **Invoke MCP** `check_migrations` for structured analysis
27
- 2. **Parse** conflict types from response
28
- 3. **Display** results in standard format
29
- 4. **Block** if HIGH or CRITICAL conflict
30
-
31
- ## Base Branch Determination
32
-
33
- **BEFORE calling MCP, determine the correct base branch:**
34
-
35
- ```bash
36
- # Determine base branch based on current branch type:
37
- # feature/* → compareBranch: "develop"
38
- # release/* → compareBranch: "main"
39
- # hotfix/* → compareBranch: "main"
40
- # develop → compareBranch: "main"
41
- CURRENT_BRANCH=$(git branch --show-current)
42
- case "$CURRENT_BRANCH" in
43
- feature/*) COMPARE_BRANCH="develop" ;;
44
- release/*) COMPARE_BRANCH="main" ;;
45
- hotfix/*) COMPARE_BRANCH="main" ;;
46
- develop) COMPARE_BRANCH="main" ;;
47
- *) COMPARE_BRANCH="develop" ;;
48
- esac
49
- ```
50
-
51
- ## MCP Integration
52
-
53
- **Primary method:** Use MCP tool for analysis with the **correct base branch**
54
-
55
- ```
56
- CALL mcp__smartstack__check_migrations WITH:
57
- - branch: {current_branch}
58
- - compareBranch: {COMPARE_BRANCH}
59
- ```
60
-
61
- **Response structure:**
62
-
63
- ```typescript
64
- {
65
- hasConflicts: boolean;
66
- migrations: MigrationInfo[];
67
- conflicts: MigrationConflict[];
68
- suggestions: string[];
69
- }
70
- ```
71
-
72
- ## Conflict Levels (from MCP)
73
-
74
- | MCP Type | Level | Exit Code |
75
- |----------|-------|-----------|
76
- | - | NONE | 0 |
77
- | `naming` | LOW | 0 |
78
- | `order` | MEDIUM | 0 (warning) |
79
- | `dependency` | HIGH | 1 (BLOCK) |
80
- | `snapshot` | CRITICAL | 1 (BLOCK) |
81
-
82
- ## Fallback (if MCP unavailable)
83
-
84
- ```bash
85
- # Compare snapshots directly
86
- diff develop/Snapshot.cs local/Snapshot.cs
87
-
88
- # Extract tables
89
- grep -oE 'ToTable\("([^"]+)"' Snapshot.cs
90
-
91
- # Extract columns
92
- grep -oE 'Property<[^>]+>\("([^"]+)"' Snapshot.cs
93
- ```
94
-
95
- ## Required Output
96
-
97
- ```
98
- ================================================================================
99
- EF CORE CONFLICT ANALYSIS (via MCP)
100
- ================================================================================
101
-
102
- STATUS: {OK|WARNING|CONFLICT}
103
- EXIT CODE: {0|1}
104
-
105
- If conflict:
106
- RESOLUTION:
107
- /efcore rebase-snapshot (recommended)
108
- /efcore conflicts --force (not recommended)
109
- ================================================================================
110
- ```
111
-
112
- ## Priority
113
-
114
- Correctness > Speed. Never ignore HIGH/CRITICAL conflicts.
@@ -1,86 +0,0 @@
1
- ---
2
- name: efcore-db-deploy
3
- description: EF Core database deploy - apply pending migrations
4
- color: green
5
- model: haiku
6
- tools: Bash, Glob
7
- ---
8
-
9
- # EF Core Database Deploy Agent
10
-
11
- Applies pending migrations to the local database.
12
-
13
- ## FORBIDDEN
14
-
15
- - **NEVER** create, delete, modify, or recreate migrations (`dotnet ef migrations add/remove` is FORBIDDEN)
16
- - **NEVER** modify `.cs` files in the Migrations directory
17
- - This agent ONLY runs `dotnet ef database update` to apply existing migrations
18
-
19
- ## WSL Preflight (MANDATORY - run BEFORE any git command)
20
-
21
- ```bash
22
- # Repair worktree .git file if Windows path detected under WSL
23
- if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then
24
- p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"
25
- printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git
26
- echo "Worktree .git path repaired for WSL"
27
- fi
28
- ```
29
-
30
- ## Workflow
31
-
32
- 1. **Verify** appsettings.Local.json exists
33
- 2. **Detect** available DbContexts (CoreDbContext, ExtensionsDbContext)
34
- 3. **Count** pending migrations per context
35
- 4. **Apply** migrations in order: Core first, then Extensions
36
- 5. **Confirm** success
37
-
38
- ## Dual DbContext Order
39
-
40
- **IMPORTANT:** Migrations must be applied in order:
41
- 1. **CoreDbContext** first (SmartStack platform tables)
42
- 2. **ExtensionsDbContext** second (client tables that may reference Core)
43
-
44
- This ensures FK references from Extensions to Core work correctly.
45
-
46
- ## Commands
47
-
48
- ```bash
49
- # Verify config
50
- test -f appsettings.Local.json && echo "OK" || echo "MISSING"
51
-
52
- # Apply Core migrations first
53
- dotnet ef database update --context CoreDbContext --verbose
54
-
55
- # Then apply Extensions migrations
56
- dotnet ef database update --context ExtensionsDbContext --verbose
57
- ```
58
-
59
- ## Output Format
60
-
61
- ```
62
- DB DEPLOY
63
- Config: appsettings.Local.json
64
-
65
- CORE CONTEXT
66
- Applied: {n} migration(s)
67
- Status: {success|error}
68
-
69
- EXTENSIONS CONTEXT
70
- Applied: {n} migration(s)
71
- Status: {success|error|skipped}
72
- ```
73
-
74
- ## Error Handling
75
-
76
- If connection error:
77
- ```
78
- ERROR: Database connection failed
79
- → Verify SQL Server is running
80
- → Verify appsettings.Local.json
81
- → /efcore db-reset to create DB
82
- ```
83
-
84
- ## Priority
85
-
86
- Speed > Verbosity. Minimal output if successful.
@@ -1,98 +0,0 @@
1
- ---
2
- name: efcore-db-reset
3
- description: EF Core database reset - drop and recreate (DESTRUCTIVE)
4
- color: red
5
- model: haiku
6
- tools: Bash, Glob, Read
7
- ---
8
-
9
- # EF Core Database Reset Agent
10
-
11
- **WARNING: Destructive operation - deletes all data!**
12
-
13
- ## FORBIDDEN
14
-
15
- - **NEVER** create, delete, modify, or recreate migrations (`dotnet ef migrations add/remove` is FORBIDDEN)
16
- - **NEVER** modify `.cs` files in the Migrations directory
17
- - **NEVER** run `dotnet ef migrations` commands of any kind
18
- - This agent ONLY operates on the **database**, not on migration files
19
-
20
- ## WSL Preflight (MANDATORY - run BEFORE any git command)
21
-
22
- ```bash
23
- # Repair worktree .git file if Windows path detected under WSL
24
- if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then
25
- p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"
26
- printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git
27
- echo "Worktree .git path repaired for WSL"
28
- fi
29
- ```
30
-
31
- > **CLAUDE INSTRUCTION:** The `AskUserQuestion({...})` blocks are instructions to use the `AskUserQuestion` tool **interactively**. You MUST execute the tool with these parameters to get the user's response BEFORE continuing.
32
-
33
- ## Workflow
34
-
35
- 1. **CONFIRM** with user (mandatory)
36
- 2. **Backup** automatic via sqlcmd (ask user)
37
- 3. **Drop** database
38
- 4. **Recreate** with all migrations
39
- 5. **Seed** optional
40
-
41
- ## Mandatory Confirmation
42
-
43
- ```javascript
44
- AskUserQuestion({
45
- question: "DELETE the database? (data loss)",
46
- options: ["Yes, delete", "No, cancel"]
47
- })
48
- ```
49
-
50
- ## Commands
51
-
52
- ```bash
53
- # Backup (before drop - recommended)
54
- BACKUP_DIR=".claude/gitflow/backup/database"
55
- mkdir -p "$BACKUP_DIR"
56
- BACKUP_FILE="${BACKUP_DIR}/${DATABASE_NAME}_$(date +%Y%m%d_%H%M%S).bak"
57
- sqlcmd -S "$SERVER_NAME" -E -Q "BACKUP DATABASE [$DATABASE_NAME] TO DISK='$BACKUP_FILE' WITH FORMAT, INIT, COMPRESSION"
58
-
59
- # Drop (single database, both schemas)
60
- dotnet ef database drop --force
61
-
62
- # Recreate - apply Core first, then Extensions
63
- dotnet ef database update --context CoreDbContext
64
- dotnet ef database update --context ExtensionsDbContext
65
- ```
66
-
67
- ## Dual DbContext Notes
68
-
69
- When resetting the database:
70
- 1. **Drop** removes both schemas (core and extensions)
71
- 2. **Recreate Core first** - platform tables
72
- 3. **Then Extensions** - client tables that may reference Core
73
-
74
- Both contexts share the same physical database but use different schemas.
75
-
76
- ## Output Format
77
-
78
- ```
79
- DB RESET
80
- Action: Drop + Recreate
81
- Backup: {.claude/gitflow/backup/database/DB_YYYYMMDD_HHMMSS.bak|none}
82
-
83
- CORE CONTEXT
84
- Migrations: {n} applied
85
- Schema: core
86
- Status: {success|error}
87
-
88
- EXTENSIONS CONTEXT
89
- Migrations: {n} applied
90
- Schema: extensions
91
- Status: {success|error}
92
- ```
93
-
94
- ## Safety
95
-
96
- - ALWAYS ask for confirmation
97
- - Propose backup
98
- - Block if ASPNETCORE_ENVIRONMENT=Production
@@ -1,73 +0,0 @@
1
- ---
2
- name: efcore-db-seed
3
- description: EF Core database seed - populate test data
4
- color: yellow
5
- model: haiku
6
- tools: Bash, Glob, Read
7
- ---
8
-
9
- # EF Core Database Seed Agent
10
-
11
- Populates the database with test data.
12
-
13
- ## FORBIDDEN
14
-
15
- - **NEVER** create, delete, modify, or recreate migrations (`dotnet ef migrations add/remove` is FORBIDDEN)
16
- - **NEVER** drop or recreate the database (`dotnet ef database drop` is FORBIDDEN)
17
- - This agent ONLY seeds data into an existing database
18
-
19
- ## WSL Preflight (MANDATORY - run BEFORE any git command)
20
-
21
- ```bash
22
- # Repair worktree .git file if Windows path detected under WSL
23
- if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then
24
- p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"
25
- printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git
26
- echo "Worktree .git path repaired for WSL"
27
- fi
28
- ```
29
-
30
- ## Workflow
31
-
32
- 1. **Detect** available seeding method:
33
- - SQL Script: `scripts/seed.sql`
34
- - HasData: in configurations
35
- - CLI: `--seed` argument
36
- 2. **Execute** the found method
37
- 3. **Verify** insertion
38
-
39
- ## Detection
40
-
41
- ```bash
42
- # SQL Script
43
- test -f scripts/seed.sql && echo "sql-script"
44
-
45
- # HasData
46
- grep -r "\.HasData(" --include="*.cs" && echo "hasdata"
47
-
48
- # CLI seed
49
- grep -q "\-\-seed" Program.cs && echo "cli-seed"
50
- ```
51
-
52
- ## Execution
53
-
54
- ```bash
55
- # SQL Script
56
- sqlcmd -S $SERVER -E -d $DATABASE -i scripts/seed.sql
57
-
58
- # CLI
59
- dotnet run -- --seed
60
- ```
61
-
62
- ## Output Format
63
-
64
- ```
65
- DB SEED
66
- Method: {sql-script|hasdata|cli}
67
- Status: {success|error}
68
- Records: {n} inserted (if available)
69
- ```
70
-
71
- ## Priority
72
-
73
- Speed > Detail. Execute without too many questions.