@atlashub/smartstack-cli 1.1.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 (144) hide show
  1. package/.documentation/agents.html +912 -0
  2. package/.documentation/apex.html +1014 -0
  3. package/.documentation/business-analyse.html +1074 -0
  4. package/.documentation/commands.html +676 -0
  5. package/.documentation/css/styles.css +2030 -0
  6. package/.documentation/efcore.html +2501 -0
  7. package/.documentation/gitflow.html +2053 -0
  8. package/.documentation/hooks.html +409 -0
  9. package/.documentation/index.html +319 -0
  10. package/.documentation/installation.html +458 -0
  11. package/.documentation/js/app.js +794 -0
  12. package/.documentation/test-web.html +509 -0
  13. package/README.md +90 -0
  14. package/config/default-config.json +86 -0
  15. package/config/settings.json +53 -0
  16. package/config/settings.local.example.json +16 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.js +38198 -0
  19. package/dist/index.js.map +1 -0
  20. package/package.json +86 -0
  21. package/templates/agents/action.md +36 -0
  22. package/templates/agents/efcore/conflicts.md +57 -0
  23. package/templates/agents/efcore/db-deploy.md +51 -0
  24. package/templates/agents/efcore/db-reset.md +59 -0
  25. package/templates/agents/efcore/db-seed.md +56 -0
  26. package/templates/agents/efcore/db-status.md +43 -0
  27. package/templates/agents/efcore/migration.md +85 -0
  28. package/templates/agents/efcore/rebase-snapshot.md +62 -0
  29. package/templates/agents/efcore/scan.md +60 -0
  30. package/templates/agents/efcore/squash.md +67 -0
  31. package/templates/agents/explore-codebase.md +65 -0
  32. package/templates/agents/explore-docs.md +97 -0
  33. package/templates/agents/fix-grammar.md +49 -0
  34. package/templates/agents/gitflow/abort.md +45 -0
  35. package/templates/agents/gitflow/cleanup.md +85 -0
  36. package/templates/agents/gitflow/commit.md +40 -0
  37. package/templates/agents/gitflow/exec.md +48 -0
  38. package/templates/agents/gitflow/finish.md +92 -0
  39. package/templates/agents/gitflow/init.md +139 -0
  40. package/templates/agents/gitflow/merge.md +62 -0
  41. package/templates/agents/gitflow/plan.md +42 -0
  42. package/templates/agents/gitflow/pr.md +78 -0
  43. package/templates/agents/gitflow/review.md +49 -0
  44. package/templates/agents/gitflow/start.md +61 -0
  45. package/templates/agents/gitflow/status.md +32 -0
  46. package/templates/agents/snipper.md +36 -0
  47. package/templates/agents/websearch.md +46 -0
  48. package/templates/commands/_resources/formatting-guide.md +124 -0
  49. package/templates/commands/ai-prompt.md +315 -0
  50. package/templates/commands/apex/1-analyze.md +100 -0
  51. package/templates/commands/apex/2-plan.md +145 -0
  52. package/templates/commands/apex/3-execute.md +171 -0
  53. package/templates/commands/apex/4-examine.md +116 -0
  54. package/templates/commands/apex/5-tasks.md +209 -0
  55. package/templates/commands/apex.md +76 -0
  56. package/templates/commands/application/create.md +362 -0
  57. package/templates/commands/application/templates-backend.md +463 -0
  58. package/templates/commands/application/templates-frontend.md +517 -0
  59. package/templates/commands/application/templates-i18n.md +478 -0
  60. package/templates/commands/application/templates-seed.md +362 -0
  61. package/templates/commands/application.md +303 -0
  62. package/templates/commands/business-analyse/1-init.md +269 -0
  63. package/templates/commands/business-analyse/2-discover.md +520 -0
  64. package/templates/commands/business-analyse/3-analyse.md +408 -0
  65. package/templates/commands/business-analyse/4-specify.md +598 -0
  66. package/templates/commands/business-analyse/5-validate.md +326 -0
  67. package/templates/commands/business-analyse/6-handoff.md +746 -0
  68. package/templates/commands/business-analyse/7-doc-html.md +602 -0
  69. package/templates/commands/business-analyse/bug.md +325 -0
  70. package/templates/commands/business-analyse/change-request.md +368 -0
  71. package/templates/commands/business-analyse/hotfix.md +200 -0
  72. package/templates/commands/business-analyse.md +559 -0
  73. package/templates/commands/controller/create.md +216 -0
  74. package/templates/commands/controller/postman-templates.md +528 -0
  75. package/templates/commands/controller/templates.md +600 -0
  76. package/templates/commands/controller.md +278 -0
  77. package/templates/commands/debug.md +95 -0
  78. package/templates/commands/documentation/module.md +202 -0
  79. package/templates/commands/documentation/templates.md +432 -0
  80. package/templates/commands/documentation.md +190 -0
  81. package/templates/commands/efcore/_env-check.md +153 -0
  82. package/templates/commands/efcore/conflicts.md +269 -0
  83. package/templates/commands/efcore/db-deploy.md +193 -0
  84. package/templates/commands/efcore/db-reset.md +426 -0
  85. package/templates/commands/efcore/db-seed.md +326 -0
  86. package/templates/commands/efcore/db-status.md +214 -0
  87. package/templates/commands/efcore/migration.md +388 -0
  88. package/templates/commands/efcore/rebase-snapshot.md +264 -0
  89. package/templates/commands/efcore/scan.md +202 -0
  90. package/templates/commands/efcore/squash.md +298 -0
  91. package/templates/commands/efcore.md +176 -0
  92. package/templates/commands/epct.md +69 -0
  93. package/templates/commands/explain.md +186 -0
  94. package/templates/commands/explore.md +45 -0
  95. package/templates/commands/feature-full.md +267 -0
  96. package/templates/commands/gitflow/1-init.md +1038 -0
  97. package/templates/commands/gitflow/10-start.md +768 -0
  98. package/templates/commands/gitflow/11-finish.md +323 -0
  99. package/templates/commands/gitflow/12-cleanup.md +276 -0
  100. package/templates/commands/gitflow/13-sync.md +216 -0
  101. package/templates/commands/gitflow/14-rebase.md +251 -0
  102. package/templates/commands/gitflow/2-status.md +167 -0
  103. package/templates/commands/gitflow/3-commit.md +194 -0
  104. package/templates/commands/gitflow/4-plan.md +145 -0
  105. package/templates/commands/gitflow/5-exec.md +147 -0
  106. package/templates/commands/gitflow/6-abort.md +344 -0
  107. package/templates/commands/gitflow/7-pull-request.md +226 -0
  108. package/templates/commands/gitflow/8-review.md +176 -0
  109. package/templates/commands/gitflow/9-merge.md +224 -0
  110. package/templates/commands/gitflow.md +128 -0
  111. package/templates/commands/implement.md +663 -0
  112. package/templates/commands/notification.md +129 -0
  113. package/templates/commands/oneshot.md +57 -0
  114. package/templates/commands/quick-search.md +72 -0
  115. package/templates/commands/review.md +106 -0
  116. package/templates/commands/utils/test-web-config.md +160 -0
  117. package/templates/commands/utils/test-web.md +151 -0
  118. package/templates/commands/workflow.md +193 -0
  119. package/templates/gitflow/config.json +138 -0
  120. package/templates/hooks/ef-migration-check.md +139 -0
  121. package/templates/hooks/hooks.json +15 -0
  122. package/templates/skills/ai-prompt/SKILL.md +778 -0
  123. package/templates/skills/application/SKILL.md +563 -0
  124. package/templates/skills/application/templates-backend.md +450 -0
  125. package/templates/skills/application/templates-frontend.md +531 -0
  126. package/templates/skills/application/templates-i18n.md +520 -0
  127. package/templates/skills/application/templates-seed.md +647 -0
  128. package/templates/skills/business-analyse/SKILL.md +191 -0
  129. package/templates/skills/business-analyse/questionnaire.md +283 -0
  130. package/templates/skills/business-analyse/templates-frd.md +477 -0
  131. package/templates/skills/business-analyse/templates-react.md +580 -0
  132. package/templates/skills/controller/SKILL.md +240 -0
  133. package/templates/skills/controller/postman-templates.md +614 -0
  134. package/templates/skills/controller/templates.md +1468 -0
  135. package/templates/skills/documentation/SKILL.md +133 -0
  136. package/templates/skills/documentation/templates.md +476 -0
  137. package/templates/skills/feature-full/SKILL.md +838 -0
  138. package/templates/skills/notification/SKILL.md +555 -0
  139. package/templates/skills/ui-components/SKILL.md +870 -0
  140. package/templates/skills/workflow/SKILL.md +582 -0
  141. package/templates/test-web/api-health.json +38 -0
  142. package/templates/test-web/minimal.json +19 -0
  143. package/templates/test-web/npm-package.json +46 -0
  144. package/templates/test-web/seo-check.json +54 -0
@@ -0,0 +1,388 @@
1
+ ---
2
+ description: Create or recreate the EF Core migration for the current branch (1 migration per feature)
3
+ agent: efcore-migration
4
+ model: sonnet
5
+ ---
6
+
7
+ # EF Core Migration - 1 Migration per Feature
8
+
9
+ Creates or recreates the unique migration for the current branch.
10
+
11
+ **GOLDEN RULE: 1 single migration per feature/hotfix. If it already exists, delete and recreate it.**
12
+
13
+ > **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.
14
+
15
+ ---
16
+
17
+ ## STEP 0: Cross-Branch Validation (v1.2)
18
+
19
+ **NEW:** Before creating a migration, check for conflicts with other branches.
20
+
21
+ ```bash
22
+ # Check if cross-branch validation is enabled
23
+ CROSS_BRANCH_ENABLED=$(git config --get efcore.crossBranch.enabled 2>/dev/null || echo "true")
24
+ BLOCK_ON_CONFLICT=$(git config --get efcore.crossBranch.blockOnConflict 2>/dev/null || echo "true")
25
+
26
+ if [ "$CROSS_BRANCH_ENABLED" = "true" ]; then
27
+ echo "Cross-branch validation..."
28
+
29
+ # Scan other branches via worktrees
30
+ WORKTREE_BASE=$(git config --get gitflow.worktrees.basePath 2>/dev/null || echo "../worktrees")
31
+
32
+ if [ -d "$WORKTREE_BASE/develop" ]; then
33
+ # Compare ModelSnapshot with develop
34
+ LOCAL_SNAPSHOT=$(find . -name "*ModelSnapshot.cs" -not -path "*/node_modules/*" | head -1)
35
+ DEVELOP_SNAPSHOT=$(find "$WORKTREE_BASE/develop" -name "*ModelSnapshot.cs" | head -1)
36
+
37
+ if [ -n "$LOCAL_SNAPSHOT" ] && [ -n "$DEVELOP_SNAPSHOT" ]; then
38
+ if ! diff -q "$LOCAL_SNAPSHOT" "$DEVELOP_SNAPSHOT" > /dev/null 2>&1; then
39
+ # Differences detected - analyze risk level
40
+ DIFF_LINES=$(diff "$DEVELOP_SNAPSHOT" "$LOCAL_SNAPSHOT" 2>/dev/null | wc -l)
41
+
42
+ if [ "$DIFF_LINES" -gt 100 ]; then
43
+ echo ""
44
+ echo "WARNING: CROSS-BRANCH CONFLICT DETECTED"
45
+ echo ""
46
+ echo "Your ModelSnapshot differs significantly from develop."
47
+ echo "Differences: $DIFF_LINES lines"
48
+ echo ""
49
+ echo "RESOLUTIONS:"
50
+ echo " 1. /efcore:rebase-snapshot (recommended)"
51
+ echo " 2. /efcore:conflicts (see details)"
52
+ echo " 3. /efcore:migration --force (not recommended)"
53
+ echo ""
54
+
55
+ if [ "$BLOCK_ON_CONFLICT" = "true" ]; then
56
+ echo "BLOCKED: Use --force to ignore"
57
+ exit 1
58
+ fi
59
+ fi
60
+ fi
61
+ fi
62
+ fi
63
+
64
+ echo "Cross-branch validation: OK"
65
+ fi
66
+ ```
67
+
68
+ **Options to ignore:**
69
+ - `--force` : Ignore cross-branch validation
70
+ - `--no-cross-check` : Disable validation for this execution
71
+ - `--rebase-first` : Run rebase-snapshot automatically if conflict
72
+
73
+ ---
74
+
75
+ ## STEP 1: Analyze Git Context
76
+
77
+ ```bash
78
+ # Current branch
79
+ CURRENT_BRANCH=$(git branch --show-current)
80
+
81
+ # Extract type and name
82
+ if [[ "$CURRENT_BRANCH" == feature/* ]]; then
83
+ BRANCH_TYPE="Feature"
84
+ BRANCH_NAME=$(echo "$CURRENT_BRANCH" | sed 's/feature\///' | sed 's/-/_/g' | sed 's/\b\w/\u&/g')
85
+ elif [[ "$CURRENT_BRANCH" == hotfix/* ]]; then
86
+ BRANCH_TYPE="Hotfix"
87
+ BRANCH_NAME=$(echo "$CURRENT_BRANCH" | sed 's/hotfix\///' | sed 's/-/_/g' | sed 's/\b\w/\u&/g')
88
+ elif [[ "$CURRENT_BRANCH" == release/* ]]; then
89
+ BRANCH_TYPE="Release"
90
+ BRANCH_NAME=$(echo "$CURRENT_BRANCH" | sed 's/release\///' | sed 's/v//')
91
+ else
92
+ BRANCH_TYPE="Dev"
93
+ BRANCH_NAME="Manual"
94
+ fi
95
+
96
+ # Current version
97
+ VERSION=$(grep -oP '"version":\s*"\K[^"]+' package.json 2>/dev/null || grep -oP '(?<=<Version>).*(?=</Version>)' *.csproj 2>/dev/null | head -1)
98
+ VERSION_CLEAN=$(echo "$VERSION" | sed 's/\./_/g')
99
+ ```
100
+
101
+ ---
102
+
103
+ ## STEP 2: Detect EF Core Project et Environnement
104
+
105
+ ```bash
106
+ # Find the project with EF Core
107
+ CSPROJ=$(find . -name "*.csproj" -exec grep -l "Microsoft.EntityFrameworkCore" {} \; | head -1)
108
+ PROJECT_DIR=$(dirname "$CSPROJ")
109
+ PROJECT_NAME=$(basename "$CSPROJ" .csproj)
110
+
111
+ # Migrations folder
112
+ MIGRATIONS_DIR="$PROJECT_DIR/Migrations"
113
+
114
+ # Detect API project for environment display
115
+ API_DIR=$(find . -type d -name "*.Api" | head -1)
116
+ [ -z "$API_DIR" ] && API_DIR="src/SmartStack.Api"
117
+
118
+ # Detect appsettings to show which DB will be affected on deploy
119
+ SELECTED_ENV="appsettings.Local.json"
120
+ if [ -f "$API_DIR/$SELECTED_ENV" ]; then
121
+ CONNECTION_STRING=$(powershell -Command "
122
+ \$json = Get-Content '$API_DIR/$SELECTED_ENV' -ErrorAction SilentlyContinue | ConvertFrom-Json
123
+ \$json.ConnectionStrings.DefaultConnection
124
+ " 2>/dev/null)
125
+ DATABASE_NAME=$(echo "$CONNECTION_STRING" | grep -oP 'Database=\K[^;]+' 2>/dev/null)
126
+ fi
127
+ ```
128
+
129
+ **Afficher info environnement (informatif):**
130
+
131
+ ```
132
+ NOTE: La migration sera appliquee sur: {DATABASE_NAME:-"(detecte au deploy)"}
133
+ Config: {SELECTED_ENV}
134
+ ```
135
+
136
+ ---
137
+
138
+ ## STEP 3: Search for Existing Migration for This Branch
139
+
140
+ ```bash
141
+ # Search pattern based on branch name
142
+ SEARCH_PATTERN="${BRANCH_TYPE}_.*_${BRANCH_NAME}"
143
+
144
+ # Find matching migration files
145
+ EXISTING_MIGRATIONS=$(find "$MIGRATIONS_DIR" -name "*.cs" | grep -E "$SEARCH_PATTERN" | grep -v "Designer" | grep -v "Snapshot")
146
+ MIGRATION_COUNT=$(echo "$EXISTING_MIGRATIONS" | grep -c "." || echo "0")
147
+ ```
148
+
149
+ **Display context:**
150
+
151
+ ```
152
+ ================================================================================
153
+ EF CORE MIGRATION - CONTEXT
154
+ ================================================================================
155
+
156
+ BRANCH
157
+ Current: {CURRENT_BRANCH}
158
+ Type: {BRANCH_TYPE}
159
+ Name: {BRANCH_NAME}
160
+
161
+ VERSION: {VERSION}
162
+
163
+ EXISTING MIGRATIONS FOR THIS BRANCH:
164
+ {MIGRATION_COUNT} migration(s) found
165
+ {File list if > 0}
166
+
167
+ ================================================================================
168
+ ```
169
+
170
+ ---
171
+
172
+ ## STEP 4: Decision - Create or Recreate
173
+
174
+ ### If existing migration (MIGRATION_COUNT > 0):
175
+
176
+ ```javascript
177
+ AskUserQuestion({
178
+ questions: [{
179
+ question: "A migration already exists for this branch. What to do?",
180
+ header: "Migration",
181
+ options: [
182
+ { label: "Recreate", description: "Delete and recreate the migration (Recommended)" },
183
+ { label: "Keep", description: "Keep existing, add a new one (Not recommended)" },
184
+ { label: "Cancel", description: "Do nothing" }
185
+ ],
186
+ multiSelect: false
187
+ }]
188
+ })
189
+ ```
190
+
191
+ **If Recreate:**
192
+
193
+ ```bash
194
+ # 1. List migrations to delete
195
+ echo "Migrations to delete:"
196
+ for file in $EXISTING_MIGRATIONS; do
197
+ echo " - $file"
198
+ # Find associated files (Designer, etc.)
199
+ BASE_NAME=$(basename "$file" .cs)
200
+ rm -f "$MIGRATIONS_DIR/${BASE_NAME}.cs"
201
+ rm -f "$MIGRATIONS_DIR/${BASE_NAME}.Designer.cs"
202
+ done
203
+
204
+ # 2. Rollback in DB if applied
205
+ LAST_GOOD_MIGRATION=$(dotnet ef migrations list 2>/dev/null | grep -v "(Pending)" | tail -2 | head -1)
206
+ if [ -n "$LAST_GOOD_MIGRATION" ]; then
207
+ dotnet ef database update "$LAST_GOOD_MIGRATION" --force
208
+ fi
209
+ ```
210
+
211
+ ---
212
+
213
+ ## STEP 5: Request Description
214
+
215
+ ```javascript
216
+ AskUserQuestion({
217
+ questions: [{
218
+ question: "Short migration description (e.g., AddUserRoles, FixEmailIndex)",
219
+ header: "Description",
220
+ options: [
221
+ { label: "Add", description: "Adding tables/columns" },
222
+ { label: "Update", description: "Structure modification" },
223
+ { label: "Fix", description: "Schema correction" },
224
+ { label: "Remove", description: "Removing elements" }
225
+ ],
226
+ multiSelect: false
227
+ }]
228
+ })
229
+
230
+ // Then ask for specific name in free text
231
+ // E.g., "AddUserRoles", "FixEmailNullable", "RemoveObsoleteTable"
232
+ ```
233
+
234
+ ---
235
+
236
+ ## STEP 6: Generate Migration Name
237
+
238
+ ```bash
239
+ # Pattern: {BranchType}_{Version}_{BranchName}_{Description}
240
+ # Example: Feature_1_2_0_UserAuth_AddRolesTable
241
+
242
+ MIGRATION_NAME="${BRANCH_TYPE}_${VERSION_CLEAN}_${BRANCH_NAME}_${DESCRIPTION}"
243
+
244
+ # Clean the name (no spaces, no special characters)
245
+ MIGRATION_NAME=$(echo "$MIGRATION_NAME" | sed 's/[^a-zA-Z0-9_]//g')
246
+
247
+ echo "Migration name: $MIGRATION_NAME"
248
+ ```
249
+
250
+ **Generated name examples:**
251
+
252
+ | Branch | Version | Description | Final Name |
253
+ |--------|---------|-------------|------------|
254
+ | feature/user-auth | 1.2.0 | AddRolesTable | Feature_1_2_0_UserAuth_AddRolesTable |
255
+ | hotfix/login-fix | 1.2.1 | FixNullEmail | Hotfix_1_2_1_LoginFix_FixNullEmail |
256
+ | release/v1.3.0 | 1.3.0 | Initial | Release_1_3_0_Initial |
257
+
258
+ ---
259
+
260
+ ## STEP 7: Create Migration
261
+
262
+ ```bash
263
+ cd "$PROJECT_DIR"
264
+
265
+ # Create migration with generated name
266
+ dotnet ef migrations add "$MIGRATION_NAME" --verbose
267
+
268
+ # Verify creation
269
+ if [ $? -eq 0 ]; then
270
+ echo "OK Migration created successfully"
271
+
272
+ # List created files
273
+ NEW_FILES=$(find "$MIGRATIONS_DIR" -name "*${MIGRATION_NAME}*" -type f)
274
+ echo ""
275
+ echo "Created files:"
276
+ for f in $NEW_FILES; do
277
+ echo " - $f"
278
+ done
279
+ else
280
+ echo "ERROR Failed to create migration"
281
+ exit 1
282
+ fi
283
+ ```
284
+
285
+ ---
286
+
287
+ ## STEP 8: Content Validation
288
+
289
+ ```bash
290
+ # Display migration preview
291
+ MIGRATION_FILE=$(find "$MIGRATIONS_DIR" -name "*${MIGRATION_NAME}.cs" | grep -v "Designer" | head -1)
292
+
293
+ echo ""
294
+ echo "================================================================================
295
+ MIGRATION PREVIEW
296
+ ================================================================================"
297
+ echo ""
298
+
299
+ # Display Up() and Down() methods
300
+ grep -A 20 "protected override void Up" "$MIGRATION_FILE"
301
+ echo ""
302
+ echo "..."
303
+ echo ""
304
+ grep -A 10 "protected override void Down" "$MIGRATION_FILE"
305
+ ```
306
+
307
+ **Verify operations:**
308
+
309
+ ```javascript
310
+ AskUserQuestion({
311
+ questions: [{
312
+ question: "Does the migration look correct?",
313
+ header: "Validation",
314
+ options: [
315
+ { label: "Yes, apply", description: "Deploy to local DB" },
316
+ { label: "Yes, not now", description: "Keep without applying" },
317
+ { label: "No, delete", description: "Cancel and start over" }
318
+ ],
319
+ multiSelect: false
320
+ }]
321
+ })
322
+ ```
323
+
324
+ ---
325
+
326
+ ## STEP 9: Summary
327
+
328
+ ```
329
+ ================================================================================
330
+ MIGRATION CREATED
331
+ ================================================================================
332
+
333
+ NAME: {MIGRATION_NAME}
334
+ BRANCH: {CURRENT_BRANCH}
335
+ VERSION: {VERSION}
336
+
337
+ FILES:
338
+ OK {timestamp}_{MIGRATION_NAME}.cs
339
+ OK {timestamp}_{MIGRATION_NAME}.Designer.cs
340
+ OK ApplicationDbContextModelSnapshot.cs (updated)
341
+
342
+ RULES FOLLOWED:
343
+ OK 1 migration per feature
344
+ OK Standardized naming
345
+ OK Branch/version traceability
346
+
347
+ ================================================================================
348
+ NEXT STEPS
349
+ ================================================================================
350
+
351
+ 1. Review generated code in Migrations/
352
+ 2. /efcore:db-deploy -> Apply to local DB
353
+ 3. /gitflow:3-commit -> Commit changes
354
+ 4. Before merge: rebase on develop + recreate if conflicts
355
+
356
+ ================================================================================
357
+ ```
358
+
359
+ ---
360
+
361
+ ## Migration Conflict Handling
362
+
363
+ When you rebase on develop and there are conflicts on ModelSnapshot:
364
+
365
+ ```bash
366
+ # 1. Accept develop version for ModelSnapshot
367
+ git checkout --theirs Migrations/ApplicationDbContextModelSnapshot.cs
368
+
369
+ # 2. Delete your migration
370
+ rm Migrations/*_{MIGRATION_NAME}.*
371
+
372
+ # 3. Recreate the migration
373
+ /efcore:migration
374
+ ```
375
+
376
+ This command will do it automatically if it detects a conflict.
377
+
378
+ ---
379
+
380
+ ## Options
381
+
382
+ | Option | Description |
383
+ |--------|-------------|
384
+ | `--name {name}` | Force a specific name |
385
+ | `--no-apply` | Don't offer to apply |
386
+ | `--force` | Delete existing without confirmation |
387
+ | `--no-cross-check` | Disable cross-branch validation |
388
+ | `--rebase-first` | Run rebase-snapshot automatically if conflict |
@@ -0,0 +1,264 @@
1
+ ---
2
+ description: Rebase ModelSnapshot on develop and regenerate migration
3
+ agent: efcore-rebase-snapshot
4
+ model: sonnet
5
+ ---
6
+
7
+ # EF Core Rebase-Snapshot - Resync with Develop
8
+
9
+ Rebases the ModelSnapshot on develop and regenerates a consolidated migration. Used when conflict is detected.
10
+
11
+ **USAGE:** After `/efcore:conflicts` signals a HIGH conflict.
12
+
13
+ **WARNING:** This operation modifies migration files. A backup is created automatically.
14
+
15
+ ---
16
+
17
+ ## STEP 1: Check prerequisites
18
+
19
+ ```bash
20
+ CURRENT_BRANCH=$(git branch --show-current)
21
+ echo "Current branch: $CURRENT_BRANCH"
22
+
23
+ # Check that it's a feature/release/hotfix branch
24
+ if [[ ! $CURRENT_BRANCH =~ ^(feature|release|hotfix)/ ]]; then
25
+ echo "ERROR: This command can only be executed from a GitFlow branch"
26
+ exit 1
27
+ fi
28
+
29
+ # Check that working directory is clean
30
+ if [ -n "$(git status --porcelain)" ]; then
31
+ echo "ERROR: Working directory not clean"
32
+ echo "Commit or stash your changes first"
33
+ exit 1
34
+ fi
35
+
36
+ # Find EF Core project
37
+ CSPROJ=$(find . -name "*.csproj" -exec grep -l "Microsoft.EntityFrameworkCore" {} \; 2>/dev/null | head -1)
38
+ if [ -z "$CSPROJ" ]; then
39
+ echo "ERROR: No EF Core project found"
40
+ exit 1
41
+ fi
42
+
43
+ PROJECT_DIR=$(dirname "$CSPROJ")
44
+ MIGRATIONS_DIR="$PROJECT_DIR/Migrations"
45
+ echo "Project: $PROJECT_DIR"
46
+ echo "Migrations: $MIGRATIONS_DIR"
47
+ ```
48
+
49
+ ---
50
+
51
+ ## STEP 2: Backup current migrations
52
+
53
+ ```bash
54
+ BACKUP_DIR=".claude/gitflow/backup/migrations/rebase_$(date +%Y%m%d_%H%M%S)"
55
+ mkdir -p "$BACKUP_DIR"
56
+
57
+ echo ""
58
+ echo "BACKUP"
59
+ echo "======"
60
+ cp "$MIGRATIONS_DIR"/*.cs "$BACKUP_DIR/" 2>/dev/null
61
+ BACKUP_COUNT=$(ls -1 "$BACKUP_DIR" | wc -l)
62
+ echo " $BACKUP_COUNT files backed up to $BACKUP_DIR"
63
+ ```
64
+
65
+ ---
66
+
67
+ ## STEP 3: Identify this branch's migrations
68
+
69
+ ```bash
70
+ # Find migrations added on this branch (not on develop)
71
+ echo ""
72
+ echo "THIS BRANCH'S MIGRATIONS"
73
+ echo "==========================="
74
+
75
+ # Get migration list on develop
76
+ DEVELOP_MIGRATIONS=$(git show develop:$MIGRATIONS_DIR 2>/dev/null | grep "\.cs$" | grep -v "Designer" | grep -v "Snapshot")
77
+
78
+ # Local migrations
79
+ LOCAL_MIGRATIONS=$(ls -1 "$MIGRATIONS_DIR"/*.cs 2>/dev/null | xargs -n1 basename | grep -v "Designer" | grep -v "Snapshot")
80
+
81
+ # New migrations (on this branch but not on develop)
82
+ BRANCH_MIGRATIONS=""
83
+ for migration in $LOCAL_MIGRATIONS; do
84
+ if ! echo "$DEVELOP_MIGRATIONS" | grep -q "$migration"; then
85
+ BRANCH_MIGRATIONS="$BRANCH_MIGRATIONS $migration"
86
+ echo " + $migration"
87
+ fi
88
+ done
89
+
90
+ if [ -z "$BRANCH_MIGRATIONS" ]; then
91
+ echo " No migration specific to this branch"
92
+ echo " Nothing to rebase"
93
+ exit 0
94
+ fi
95
+ ```
96
+
97
+ ---
98
+
99
+ ## STEP 4: Reset ModelSnapshot on develop
100
+
101
+ ```bash
102
+ echo ""
103
+ echo "RESET MODELSNAPSHOT"
104
+ echo "==================="
105
+
106
+ # Get develop's ModelSnapshot
107
+ git fetch origin develop
108
+ SNAPSHOT_FILE=$(find "$MIGRATIONS_DIR" -name "*ModelSnapshot.cs" | head -1)
109
+ SNAPSHOT_NAME=$(basename "$SNAPSHOT_FILE")
110
+
111
+ git checkout origin/develop -- "$MIGRATIONS_DIR/$SNAPSHOT_NAME"
112
+ echo " ModelSnapshot reset on develop"
113
+ ```
114
+
115
+ ---
116
+
117
+ ## STEP 5: Delete this branch's migrations
118
+
119
+ ```bash
120
+ echo ""
121
+ echo "DELETE BRANCH MIGRATIONS"
122
+ echo "=============================="
123
+
124
+ for migration in $BRANCH_MIGRATIONS; do
125
+ BASE_NAME="${migration%.cs}"
126
+ rm -f "$MIGRATIONS_DIR/$BASE_NAME.cs"
127
+ rm -f "$MIGRATIONS_DIR/$BASE_NAME.Designer.cs"
128
+ echo " - $BASE_NAME"
129
+ done
130
+ ```
131
+
132
+ ---
133
+
134
+ ## STEP 6: Regenerate consolidated migration
135
+
136
+ ```bash
137
+ echo ""
138
+ echo "REGENERATE MIGRATION"
139
+ echo "======================"
140
+
141
+ # Extract branch info for name
142
+ BRANCH_TYPE=$(echo "$CURRENT_BRANCH" | cut -d'/' -f1)
143
+ BRANCH_NAME=$(echo "$CURRENT_BRANCH" | cut -d'/' -f2 | sed 's/-/_/g' | sed 's/.*/\u&/')
144
+
145
+ # Version
146
+ VERSION=$(grep -oP '(?<=<Version>).*(?=</Version>)' "$CSPROJ" 2>/dev/null | head -1 || echo "1.0.0")
147
+ VERSION_CLEAN=$(echo "$VERSION" | sed 's/\./_/g')
148
+
149
+ # Migration name
150
+ case $BRANCH_TYPE in
151
+ "feature")
152
+ MIGRATION_NAME="Feature_${VERSION_CLEAN}_${BRANCH_NAME}_Consolidated"
153
+ ;;
154
+ "hotfix")
155
+ MIGRATION_NAME="Hotfix_${VERSION_CLEAN}_${BRANCH_NAME}_Fix"
156
+ ;;
157
+ "release")
158
+ MIGRATION_NAME="Release_${VERSION_CLEAN}_Consolidated"
159
+ ;;
160
+ *)
161
+ MIGRATION_NAME="Branch_${VERSION_CLEAN}_${BRANCH_NAME}"
162
+ ;;
163
+ esac
164
+
165
+ echo "Name: $MIGRATION_NAME"
166
+
167
+ cd "$PROJECT_DIR"
168
+ dotnet ef migrations add "$MIGRATION_NAME" --verbose
169
+
170
+ if [ $? -eq 0 ]; then
171
+ echo " Migration created successfully"
172
+ else
173
+ echo " ERROR: Failed to create migration"
174
+ echo " Restoring backup..."
175
+ cp "$BACKUP_DIR"/*.cs "$MIGRATIONS_DIR/"
176
+ exit 1
177
+ fi
178
+ ```
179
+
180
+ ---
181
+
182
+ ## STEP 7: Validation
183
+
184
+ ```bash
185
+ echo ""
186
+ echo "VALIDATION"
187
+ echo "=========="
188
+
189
+ # Build
190
+ dotnet build --no-restore
191
+ if [ $? -ne 0 ]; then
192
+ echo " ERROR: Build failed"
193
+ echo " Restoring backup..."
194
+ cp "$BACKUP_DIR"/*.cs "$MIGRATIONS_DIR/"
195
+ exit 1
196
+ fi
197
+ echo " Build: OK"
198
+
199
+ # Check that migration can generate script
200
+ dotnet ef migrations script --no-build > /dev/null 2>&1
201
+ if [ $? -ne 0 ]; then
202
+ echo " ERROR: Script generation failed"
203
+ exit 1
204
+ fi
205
+ echo " Script: OK"
206
+ ```
207
+
208
+ ---
209
+
210
+ ## STEP 8: Summary
211
+
212
+ ```
213
+ ================================================================================
214
+ REBASE-SNAPSHOT COMPLETE
215
+ ================================================================================
216
+
217
+ BRANCH: {current_branch}
218
+ BACKUP: {backup_dir}
219
+
220
+ BEFORE:
221
+ Migrations: {old_migrations}
222
+ ModelSnapshot: {old_hash}
223
+
224
+ AFTER:
225
+ Migration: {new_migration_name}
226
+ ModelSnapshot: {new_hash} (= develop)
227
+
228
+ ================================================================================
229
+ NEXT STEPS
230
+ ================================================================================
231
+
232
+ 1. Check migration content
233
+ 2. Test: /efcore:db-reset && /efcore:db-deploy
234
+ 3. Commit: /gitflow:3-commit
235
+
236
+ ================================================================================
237
+ RESTORE (if needed)
238
+ ================================================================================
239
+
240
+ cp {backup_dir}/*.cs {migrations_dir}/
241
+
242
+ ================================================================================
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Options
248
+
249
+ | Option | Description |
250
+ |--------|-------------|
251
+ | `--no-backup` | Don't create backup (dangerous) |
252
+ | `--name <name>` | Force a specific migration name |
253
+ | `--dry-run` | Show what would be done without executing |
254
+
255
+ ---
256
+
257
+ ## When to use
258
+
259
+ | Situation | Action |
260
+ |-----------|--------|
261
+ | `/efcore:conflicts` returns HIGH | Use rebase-snapshot |
262
+ | Merge conflict on ModelSnapshot | Use rebase-snapshot |
263
+ | Multiple migrations to consolidate | Use rebase-snapshot |
264
+ | Broken migration | Use rebase-snapshot |