@atlashub/smartstack-cli 1.5.1 → 1.5.2

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 (147) hide show
  1. package/.documentation/css/styles.css +2168 -2168
  2. package/.documentation/js/app.js +794 -794
  3. package/config/default-config.json +86 -86
  4. package/config/settings.json +53 -53
  5. package/config/settings.local.example.json +16 -16
  6. package/dist/index.js +0 -0
  7. package/dist/index.js.map +1 -1
  8. package/package.json +88 -88
  9. package/templates/agents/action.md +36 -36
  10. package/templates/agents/efcore/conflicts.md +84 -84
  11. package/templates/agents/efcore/db-deploy.md +51 -51
  12. package/templates/agents/efcore/db-reset.md +59 -59
  13. package/templates/agents/efcore/db-seed.md +56 -56
  14. package/templates/agents/efcore/db-status.md +64 -64
  15. package/templates/agents/efcore/migration.md +85 -85
  16. package/templates/agents/efcore/rebase-snapshot.md +62 -62
  17. package/templates/agents/efcore/scan.md +90 -90
  18. package/templates/agents/efcore/squash.md +67 -67
  19. package/templates/agents/explore-codebase.md +65 -65
  20. package/templates/agents/explore-docs.md +97 -97
  21. package/templates/agents/fix-grammar.md +49 -49
  22. package/templates/agents/gitflow/abort.md +45 -45
  23. package/templates/agents/gitflow/cleanup.md +85 -85
  24. package/templates/agents/gitflow/commit.md +40 -40
  25. package/templates/agents/gitflow/exec.md +48 -48
  26. package/templates/agents/gitflow/finish.md +92 -92
  27. package/templates/agents/gitflow/init.md +139 -139
  28. package/templates/agents/gitflow/merge.md +62 -62
  29. package/templates/agents/gitflow/plan.md +42 -42
  30. package/templates/agents/gitflow/pr.md +78 -78
  31. package/templates/agents/gitflow/review.md +49 -49
  32. package/templates/agents/gitflow/start.md +61 -61
  33. package/templates/agents/gitflow/status.md +32 -32
  34. package/templates/agents/snipper.md +36 -36
  35. package/templates/agents/websearch.md +46 -46
  36. package/templates/commands/_resources/formatting-guide.md +124 -124
  37. package/templates/commands/ai-prompt.md +315 -315
  38. package/templates/commands/apex/1-analyze.md +100 -100
  39. package/templates/commands/apex/2-plan.md +145 -145
  40. package/templates/commands/apex/3-execute.md +171 -171
  41. package/templates/commands/apex/4-examine.md +116 -116
  42. package/templates/commands/apex/5-tasks.md +209 -209
  43. package/templates/commands/apex.md +76 -76
  44. package/templates/commands/application/create.md +362 -362
  45. package/templates/commands/application/templates-backend.md +463 -463
  46. package/templates/commands/application/templates-frontend.md +517 -517
  47. package/templates/commands/application/templates-i18n.md +478 -478
  48. package/templates/commands/application/templates-seed.md +362 -362
  49. package/templates/commands/application.md +303 -303
  50. package/templates/commands/business-analyse/0-orchestrate.md +640 -640
  51. package/templates/commands/business-analyse/1-init.md +269 -269
  52. package/templates/commands/business-analyse/2-discover.md +520 -520
  53. package/templates/commands/business-analyse/3-analyse.md +408 -408
  54. package/templates/commands/business-analyse/4-specify.md +598 -598
  55. package/templates/commands/business-analyse/5-validate.md +326 -326
  56. package/templates/commands/business-analyse/6-handoff.md +746 -746
  57. package/templates/commands/business-analyse/7-doc-html.md +602 -602
  58. package/templates/commands/business-analyse/bug.md +325 -325
  59. package/templates/commands/business-analyse/change-request.md +368 -368
  60. package/templates/commands/business-analyse/hotfix.md +200 -200
  61. package/templates/commands/business-analyse.md +640 -640
  62. package/templates/commands/controller/create.md +216 -216
  63. package/templates/commands/controller/postman-templates.md +528 -528
  64. package/templates/commands/controller/templates.md +600 -600
  65. package/templates/commands/controller.md +337 -337
  66. package/templates/commands/create/agent.md +138 -138
  67. package/templates/commands/create/command.md +166 -166
  68. package/templates/commands/create/hook.md +234 -234
  69. package/templates/commands/create/plugin.md +329 -329
  70. package/templates/commands/create/project.md +507 -507
  71. package/templates/commands/create/skill.md +199 -199
  72. package/templates/commands/create.md +220 -220
  73. package/templates/commands/debug.md +95 -95
  74. package/templates/commands/documentation/module.md +202 -202
  75. package/templates/commands/documentation/templates.md +432 -432
  76. package/templates/commands/documentation.md +190 -190
  77. package/templates/commands/efcore/_env-check.md +153 -153
  78. package/templates/commands/efcore/conflicts.md +186 -186
  79. package/templates/commands/efcore/db-deploy.md +193 -193
  80. package/templates/commands/efcore/db-reset.md +426 -426
  81. package/templates/commands/efcore/db-seed.md +326 -326
  82. package/templates/commands/efcore/db-status.md +226 -226
  83. package/templates/commands/efcore/migration.md +400 -400
  84. package/templates/commands/efcore/rebase-snapshot.md +264 -264
  85. package/templates/commands/efcore/scan.md +198 -198
  86. package/templates/commands/efcore/squash.md +298 -298
  87. package/templates/commands/efcore.md +224 -224
  88. package/templates/commands/epct.md +69 -69
  89. package/templates/commands/explain.md +186 -186
  90. package/templates/commands/explore.md +45 -45
  91. package/templates/commands/feature-full.md +267 -267
  92. package/templates/commands/gitflow/1-init.md +1038 -1038
  93. package/templates/commands/gitflow/10-start.md +768 -768
  94. package/templates/commands/gitflow/11-finish.md +457 -457
  95. package/templates/commands/gitflow/12-cleanup.md +276 -276
  96. package/templates/commands/gitflow/13-sync.md +216 -216
  97. package/templates/commands/gitflow/14-rebase.md +251 -251
  98. package/templates/commands/gitflow/2-status.md +277 -277
  99. package/templates/commands/gitflow/3-commit.md +344 -344
  100. package/templates/commands/gitflow/4-plan.md +145 -145
  101. package/templates/commands/gitflow/5-exec.md +147 -147
  102. package/templates/commands/gitflow/6-abort.md +344 -344
  103. package/templates/commands/gitflow/7-pull-request.md +453 -355
  104. package/templates/commands/gitflow/8-review.md +240 -176
  105. package/templates/commands/gitflow/9-merge.md +451 -365
  106. package/templates/commands/gitflow.md +128 -128
  107. package/templates/commands/implement.md +663 -663
  108. package/templates/commands/init.md +567 -567
  109. package/templates/commands/mcp-integration.md +330 -330
  110. package/templates/commands/notification.md +129 -129
  111. package/templates/commands/oneshot.md +57 -57
  112. package/templates/commands/quick-search.md +72 -72
  113. package/templates/commands/ralph-loop/cancel-ralph.md +18 -18
  114. package/templates/commands/ralph-loop/help.md +126 -126
  115. package/templates/commands/ralph-loop/ralph-loop.md +18 -18
  116. package/templates/commands/review.md +106 -106
  117. package/templates/commands/utils/test-web-config.md +160 -160
  118. package/templates/commands/utils/test-web.md +151 -151
  119. package/templates/commands/validate.md +233 -233
  120. package/templates/commands/workflow.md +193 -193
  121. package/templates/gitflow/config.json +138 -138
  122. package/templates/hooks/ef-migration-check.md +139 -139
  123. package/templates/hooks/hooks.json +25 -25
  124. package/templates/hooks/stop-hook.sh +177 -177
  125. package/templates/skills/ai-prompt/SKILL.md +778 -778
  126. package/templates/skills/application/SKILL.md +563 -563
  127. package/templates/skills/application/templates-backend.md +450 -450
  128. package/templates/skills/application/templates-frontend.md +531 -531
  129. package/templates/skills/application/templates-i18n.md +520 -520
  130. package/templates/skills/application/templates-seed.md +647 -647
  131. package/templates/skills/business-analyse/SKILL.md +191 -191
  132. package/templates/skills/business-analyse/questionnaire.md +283 -283
  133. package/templates/skills/business-analyse/templates-frd.md +477 -477
  134. package/templates/skills/business-analyse/templates-react.md +580 -580
  135. package/templates/skills/controller/SKILL.md +240 -240
  136. package/templates/skills/controller/postman-templates.md +614 -614
  137. package/templates/skills/controller/templates.md +1468 -1468
  138. package/templates/skills/documentation/SKILL.md +133 -133
  139. package/templates/skills/documentation/templates.md +476 -476
  140. package/templates/skills/feature-full/SKILL.md +838 -838
  141. package/templates/skills/notification/SKILL.md +555 -555
  142. package/templates/skills/ui-components/SKILL.md +870 -870
  143. package/templates/skills/workflow/SKILL.md +582 -582
  144. package/templates/test-web/api-health.json +38 -38
  145. package/templates/test-web/minimal.json +19 -19
  146. package/templates/test-web/npm-package.json +46 -46
  147. package/templates/test-web/seo-check.json +54 -54
@@ -1,1038 +1,1038 @@
1
- ---
2
- description: Phase 1 - Initialize GitFlow structure with versioning and EF Core configuration
3
- agent: gitflow-init
4
- model: sonnet
5
- ---
6
-
7
- # GitFlow Init
8
-
9
- **Arguments:** `$ARGUMENTS`
10
-
11
- ---
12
-
13
- ## PREMIÈRE CHOSE À FAIRE
14
-
15
- Regarde si `$ARGUMENTS` contient une URL (commence par `https://` ou `git@`).
16
-
17
- **Si OUI (URL détectée)** → Tu DOIS suivre le workflow ci-dessous. NE SAUTE AUCUNE ÉTAPE.
18
-
19
- **Si NON** → Va directement à la section "MODE B ou C" plus bas.
20
-
21
- ---
22
-
23
- ## WORKFLOW QUAND URL DÉTECTÉE
24
-
25
- Tu as reçu une URL de repository. Avant de créer quoi que ce soit, tu DOIS poser 3 questions à l'utilisateur.
26
-
27
- ### ÉTAPE 1 : Extraire les informations de l'URL
28
-
29
- Extrais le nom suggéré du projet depuis l'URL :
30
- - `https://github.com/org/mon-projet.git` → nom suggéré = "mon-projet"
31
- - `https://dev.azure.com/org/project/_git/repo` → nom suggéré = "repo"
32
-
33
- **NE CRÉE AUCUN DOSSIER MAINTENANT.** Tu dois d'abord poser les questions.
34
-
35
- ---
36
-
37
- ### ÉTAPE 2 : DEMANDER OÙ CRÉER LE PROJET
38
-
39
- **MAINTENANT, utilise le tool AskUserQuestion pour demander à l'utilisateur où créer le projet.**
40
-
41
- Pose cette question avec ces options :
42
- - Question : "Où voulez-vous créer ce projet ?"
43
- - Header : "Location"
44
- - Options :
45
- 1. "C:/Dev" - Dossier de développement recommandé
46
- 2. "Répertoire courant" - Créer ici (affiche le chemin actuel)
47
- 3. "Chemin personnalisé" - Entrer un autre chemin
48
-
49
- **ATTENDS LA RÉPONSE DE L'UTILISATEUR.**
50
-
51
- Si l'utilisateur choisit "Chemin personnalisé", demande-lui de saisir le chemin.
52
-
53
- Stocke le résultat dans `TARGET_FOLDER`.
54
-
55
- ---
56
-
57
- ### ÉTAPE 3 : DEMANDER LE NOM DU PROJET
58
-
59
- **MAINTENANT, utilise le tool AskUserQuestion pour demander le nom du dossier projet.**
60
-
61
- Pose cette question avec ces options :
62
- - Question : "Quel nom pour le dossier du projet ? (Suggéré : {nom_extrait_de_url})"
63
- - Header : "Name"
64
- - Options :
65
- 1. "{nom_extrait_de_url}" - Utiliser le nom de l'URL (Recommandé)
66
- 2. "Nom personnalisé" - Entrer un autre nom
67
-
68
- **ATTENDS LA RÉPONSE DE L'UTILISATEUR.**
69
-
70
- Si l'utilisateur choisit "Nom personnalisé", demande-lui de saisir le nom.
71
-
72
- Stocke le résultat dans `PROJECT_NAME`.
73
-
74
- ---
75
-
76
- ### ÉTAPE 4 : CONFIRMATION FINALE
77
-
78
- **MAINTENANT, utilise le tool AskUserQuestion pour confirmer la création.**
79
-
80
- Affiche un récapitulatif et demande confirmation :
81
- - Question : "Créer le projet GitFlow avec ces paramètres ?\n\nProjet : {PROJECT_NAME}\nEmplacement : {TARGET_FOLDER}/\nChemin complet : {TARGET_FOLDER}/{PROJECT_NAME}/\nRepository : {URL}"
82
- - Header : "Confirm"
83
- - Options :
84
- 1. "Oui, créer le projet" - Procéder à la création (Recommandé)
85
- 2. "Modifier" - Revenir en arrière pour changer les paramètres
86
-
87
- **ATTENDS LA RÉPONSE DE L'UTILISATEUR.**
88
-
89
- Si l'utilisateur choisit "Modifier", retourne à l'ÉTAPE 2.
90
-
91
- ---
92
-
93
- ### ÉTAPE 5 : CRÉER LE PROJET (seulement après confirmation)
94
-
95
- **SEULEMENT si l'utilisateur a confirmé "Oui, créer le projet" à l'étape 4**, tu peux maintenant :
96
-
97
- 1. Vérifier que l'URL est accessible
98
- 2. Vérifier que le dossier n'existe pas déjà
99
- 3. Créer la structure
100
-
101
- Le chemin final est : `{TARGET_FOLDER}/{PROJECT_NAME}/`
102
-
103
- ---
104
-
105
- ### ÉTAPE 6 : Validation
106
-
107
- Vérifie que :
108
- 1. L'URL du repository est accessible (test avec `git ls-remote`)
109
- 2. Le dossier `{TARGET_FOLDER}/{PROJECT_NAME}` n'existe pas déjà
110
-
111
- Si un problème, informe l'utilisateur et arrête.
112
-
113
- ---
114
-
115
- ### ÉTAPE 7 : Créer la structure organisée
116
-
117
- ```bash
118
- # Create project folder with organized structure
119
- mkdir -p "$PROJECT_BASE"
120
- cd "$PROJECT_BASE"
121
-
122
- # Clone as bare repository (hidden)
123
- git clone --bare "$REPO_URL" .bare
124
- echo "gitdir: ./.bare" > .git
125
-
126
- # Configure bare repo for worktrees
127
- cd .bare
128
- git config core.bare false
129
- git config core.worktree ".."
130
- cd ..
131
-
132
- # Create organized worktree structure
133
- mkdir -p features releases hotfixes
134
-
135
- # Create permanent worktrees with numbered prefixes
136
- git worktree add "01-Main" main
137
- git worktree add "02-Develop" develop
138
-
139
- # Initialize GitFlow config in 02-Develop (working directory)
140
- cd "02-Develop"
141
- mkdir -p .claude/gitflow/{plans,logs,migrations,backup,cache}
142
- ```
143
-
144
- **Resulting structure:**
145
- ```
146
- {target_folder}/{repo_name}/
147
- ├── .bare/ # Hidden bare repository
148
- ├── .git # gitdir pointer to .bare
149
- ├── 01-Main/ # Permanent worktree (main branch)
150
- │ └── ...
151
- ├── 02-Develop/ # Permanent worktree (develop branch) ← WORKING DIR
152
- │ ├── .claude/gitflow/
153
- │ │ ├── config.json
154
- │ │ ├── plans/
155
- │ │ ├── logs/
156
- │ │ └── migrations/
157
- │ └── ...
158
- ├── features/ # Feature worktrees go here
159
- │ └── {feature-name}/
160
- ├── releases/ # Release worktrees go here
161
- │ └── v{version}/
162
- └── hotfixes/ # Hotfix worktrees go here
163
- └── {hotfix-name}/
164
- ```
165
-
166
- ### ÉTAPE 8 : Configuration
167
-
168
- ```json
169
- {
170
- "version": "1.3.0",
171
- "initMode": "clone",
172
- "repository": {
173
- "name": "{repo_name}",
174
- "remoteUrl": "{REPO_URL}",
175
- "defaultBranch": "main"
176
- },
177
- "worktrees": {
178
- "enabled": true,
179
- "mode": "organized",
180
- "basePath": "..",
181
- "bareRepo": "../.bare",
182
- "permanent": {
183
- "main": { "path": "../01-Main", "prefix": "01" },
184
- "develop": { "path": "../02-Develop", "prefix": "02" }
185
- },
186
- "structure": {
187
- "features": "../features/",
188
- "releases": "../releases/",
189
- "hotfixes": "../hotfixes/"
190
- },
191
- "cleanupOnFinish": true
192
- }
193
- }
194
- ```
195
-
196
- ### ÉTAPE 9 : Afficher le résumé
197
-
198
- ```
199
- ================================================================================
200
- GITFLOW INITIALIZED (Clone Mode)
201
- ================================================================================
202
-
203
- REPOSITORY
204
- Name: {repo_name}
205
- Remote: {REPO_URL}
206
-
207
- STRUCTURE CREATED
208
- {PROJECT_BASE}/
209
- ├── 01-Main/ ← main branch
210
- ├── 02-Develop/ ← develop branch (current directory)
211
- ├── features/ ← feature worktrees
212
- ├── releases/ ← release worktrees
213
- └── hotfixes/ ← hotfix worktrees
214
-
215
- WORKING DIRECTORY
216
- {PROJECT_BASE}/02-Develop
217
-
218
- NEXT STEPS
219
- 1. cd "{PROJECT_BASE}/02-Develop"
220
- 2. code . (or your preferred IDE)
221
- 3. /gitflow:10-start feature {name}
222
-
223
- ================================================================================
224
- ```
225
-
226
- ---
227
-
228
- ## MODE C: Interactive (No Repo Detected)
229
-
230
- **Trigger:** Current directory is NOT a git repository AND no URL provided in arguments
231
-
232
- This mode guides the user through setting up a new GitFlow project interactively.
233
-
234
- **Critical Flow Order:**
235
- ```
236
- C.1 Target Directory (WHERE?) → C.2 Repository URL → C.3 Project Name (WHAT?) → C.4 Confirmation → C.5 Execute
237
- ```
238
-
239
- ### C.1 Ask for Target Directory (FIRST - Critical)
240
-
241
- **IMPORTANT:** Ask WHERE to create the project BEFORE asking for repository details.
242
-
243
- ```javascript
244
- AskUserQuestion({
245
- questions: [{
246
- question: "Where do you want to create your GitFlow project?",
247
- header: "Location",
248
- options: [
249
- { label: "Current directory", description: `Create in: ${process.cwd()} (Recommended)` },
250
- { label: "C:/Dev", description: "Common development folder (Windows)" },
251
- { label: "~/projects", description: "Common development folder (Unix)" },
252
- { label: "Custom path", description: "Enter a different location" }
253
- ],
254
- multiSelect: false
255
- }]
256
- })
257
- ```
258
-
259
- **If "Custom path" selected:**
260
- ```
261
- Enter the target parent folder (project will be created inside):
262
- > Example: C:/Projects or /home/user/dev
263
- ```
264
-
265
- **Validate path exists:**
266
- ```bash
267
- # Expand ~ if present
268
- TARGET_PATH="${TARGET_PATH/#\~/$HOME}"
269
-
270
- # Check directory exists
271
- if [ ! -d "$TARGET_PATH" ]; then
272
- echo "WARNING: Directory does not exist: $TARGET_PATH"
273
- # Ask: Create it? or Choose different path?
274
- AskUserQuestion({
275
- questions: [{
276
- question: "Directory '$TARGET_PATH' does not exist. Create it?",
277
- header: "Create Dir",
278
- options: [
279
- { label: "Yes, create it", description: "Create the directory and continue (Recommended)" },
280
- { label: "Choose different path", description: "Enter another location" }
281
- ],
282
- multiSelect: false
283
- }]
284
- })
285
- fi
286
-
287
- # Check write permissions
288
- if [ ! -w "$TARGET_PATH" ]; then
289
- echo "ERROR: No write permission to: $TARGET_PATH"
290
- # Ask again
291
- fi
292
- ```
293
-
294
- ### C.2 Ask for Repository URL
295
-
296
- ```javascript
297
- AskUserQuestion({
298
- questions: [{
299
- question: "What repository do you want to clone?",
300
- header: "Repository",
301
- options: [
302
- { label: "GitHub", description: "https://github.com/org/repo.git" },
303
- { label: "GitLab", description: "https://gitlab.com/org/repo.git" },
304
- { label: "Azure DevOps", description: "https://dev.azure.com/org/project/_git/repo" },
305
- { label: "Other", description: "Any git remote URL (SSH or HTTPS)" }
306
- ],
307
- multiSelect: false
308
- }]
309
- })
310
- ```
311
-
312
- **Then prompt for the actual URL:**
313
- ```
314
- Enter the repository URL:
315
- > Example: https://github.com/organization/my-project.git
316
- ```
317
-
318
- **Validate URL is accessible:**
319
- ```bash
320
- git ls-remote "$REPO_URL" HEAD > /dev/null 2>&1 || {
321
- echo "ERROR: Cannot access repository: $REPO_URL"
322
- echo "Please verify:"
323
- echo " - URL is correct"
324
- echo " - You have access permissions"
325
- echo " - Network connectivity"
326
- # Ask again
327
- }
328
- ```
329
-
330
- ### C.3 Ask for Project Name (EXPLICIT - Critical)
331
-
332
- **IMPORTANT:** This is a CRITICAL step. Ask EXPLICITLY for the project name, don't just confirm.
333
-
334
- Extract suggestion from URL:
335
- ```bash
336
- # Extract repo name from various URL formats
337
- # https://github.com/org/my-project.git → my-project
338
- # git@github.com:org/my-project.git → my-project
339
- # https://dev.azure.com/org/project/_git/repo → repo
340
-
341
- SUGGESTED_NAME=$(basename "$REPO_URL" .git)
342
- ```
343
-
344
- **Ask user EXPLICITLY for project name:**
345
-
346
- ```javascript
347
- AskUserQuestion({
348
- questions: [{
349
- question: "What should we name this project folder?",
350
- header: "Project Name", // Critical: explicit header
351
- options: [
352
- { label: "${SUGGESTED_NAME}", description: `Use repository name: "${SUGGESTED_NAME}" (Recommended)` },
353
- { label: "Custom name", description: "Enter a different folder name" }
354
- ],
355
- multiSelect: false
356
- }]
357
- })
358
- ```
359
-
360
- **If "Custom name" selected:**
361
- ```
362
- Enter the project folder name:
363
- >
364
- ```
365
-
366
- **Strict validation:**
367
- ```bash
368
- # 1. Not empty
369
- if [ -z "$PROJECT_NAME" ]; then
370
- echo "ERROR: Project name cannot be empty"
371
- # Ask again
372
- fi
373
-
374
- # 2. Valid characters only
375
- if [[ ! "$PROJECT_NAME" =~ ^[a-zA-Z0-9._-]+$ ]]; then
376
- echo "ERROR: Invalid characters in project name"
377
- echo "Allowed: letters, numbers, dots (.), underscores (_), hyphens (-)"
378
- echo "Not allowed: spaces, special characters"
379
- # Ask again
380
- fi
381
-
382
- # 3. Doesn't already exist in target location
383
- FULL_PROJECT_PATH="$TARGET_PATH/$PROJECT_NAME"
384
- if [ -d "$FULL_PROJECT_PATH" ]; then
385
- echo "ERROR: Folder already exists: $FULL_PROJECT_PATH"
386
- # Ask for different name
387
- fi
388
-
389
- # 4. Reasonable length
390
- if [ ${#PROJECT_NAME} -gt 100 ]; then
391
- echo "ERROR: Project name too long (max 100 characters)"
392
- # Ask again
393
- fi
394
- ```
395
-
396
- ### C.4 Final Confirmation with Full Path
397
-
398
- **Display complete summary before creating:**
399
-
400
- ```javascript
401
- AskUserQuestion({
402
- questions: [{
403
- question: `Create GitFlow project with these settings?\n
404
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
405
- Project Name: ${PROJECT_NAME}
406
- Location: ${TARGET_PATH}/
407
- Full Path: ${FULL_PROJECT_PATH}/
408
- Repository: ${REPO_URL}
409
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
410
-
411
- Structure to be created:
412
- ${PROJECT_NAME}/
413
- ├── .bare/ (hidden bare repository)
414
- ├── 01-Main/ (main branch)
415
- ├── 02-Develop/ (develop branch) ← Working directory
416
- ├── features/
417
- ├── releases/
418
- └── hotfixes/`,
419
- header: "Confirm",
420
- options: [
421
- { label: "Yes, create project", description: "Create structure and clone repository (Recommended)" },
422
- { label: "Change settings", description: "Go back and modify name, location, or repository" }
423
- ],
424
- multiSelect: false
425
- }]
426
- })
427
- ```
428
-
429
- **If "Change settings" selected:**
430
- - Return to C.1 and let user modify any setting
431
-
432
- ### C.5 Create Structure and Clone
433
-
434
- Once all inputs are confirmed, execute the same steps as MODE A:
435
-
436
- ```bash
437
- # Final path is already set from C.3 validation
438
- # FULL_PROJECT_PATH="$TARGET_PATH/$PROJECT_NAME"
439
-
440
- # Create project folder with organized structure
441
- mkdir -p "$FULL_PROJECT_PATH"
442
- cd "$FULL_PROJECT_PATH"
443
-
444
- # Clone as bare repository (hidden)
445
- git clone --bare "$REPO_URL" .bare
446
- echo "gitdir: ./.bare" > .git
447
-
448
- # Configure bare repo for worktrees
449
- cd .bare
450
- git config core.bare false
451
- git config core.worktree ".."
452
- cd ..
453
-
454
- # Create organized worktree structure
455
- mkdir -p features releases hotfixes
456
-
457
- # Create permanent worktrees with numbered prefixes
458
- git worktree add "01-Main" main
459
- git worktree add "02-Develop" develop 2>/dev/null || {
460
- # If develop doesn't exist, create it from main
461
- git worktree add "02-Develop" -b develop main
462
- }
463
-
464
- # Initialize GitFlow config in 02-Develop (working directory)
465
- cd "02-Develop"
466
- mkdir -p .claude/gitflow/{plans,logs,migrations,backup,cache}
467
- ```
468
-
469
- ### C.6 Generate Config and Display Summary
470
-
471
- Generate the same config as MODE A (see A.4) and display:
472
-
473
- ```
474
- ================================================================================
475
- GITFLOW INITIALIZED (Interactive Mode)
476
- ================================================================================
477
-
478
- REPOSITORY
479
- Name: ${PROJECT_NAME}
480
- Remote: ${REPO_URL}
481
-
482
- STRUCTURE CREATED
483
- ${FULL_PROJECT_PATH}/
484
- ├── .bare/ ← Bare repository (hidden)
485
- ├── .git ← Pointer to .bare
486
- ├── 01-Main/ ← main branch (read-only reference)
487
- ├── 02-Develop/ ← develop branch (WORKING DIRECTORY)
488
- ├── features/ ← Feature worktrees will go here
489
- ├── releases/ ← Release worktrees will go here
490
- └── hotfixes/ ← Hotfix worktrees will go here
491
-
492
- WORKING DIRECTORY
493
- ${FULL_PROJECT_PATH}/02-Develop
494
-
495
- NEXT STEPS
496
- 1. Open the project:
497
- cd "${FULL_PROJECT_PATH}/02-Develop"
498
- code .
499
-
500
- 2. Start a new feature:
501
- /gitflow:10-start feature my-feature
502
-
503
- ================================================================================
504
- ```
505
-
506
- ---
507
-
508
- ## MODE B: Existing Repository (Default)
509
-
510
- **Trigger:** Currently inside a git repository without URL argument
511
-
512
- ### 0. Check existing structure
513
-
514
- **IMPORTANT:** Before analyzing, check if GitFlow is already initialized.
515
-
516
- Check for existing structure at [.claude/gitflow/config.json](.claude/gitflow/config.json).
517
-
518
- **If structure exists, analyze differences:**
519
-
520
- | Check | Expected | Current | Status |
521
- |-------|----------|---------|--------|
522
- | Config version | 1.2.0 | {existing} | {OK/OUTDATED} |
523
- | Worktrees enabled | true | {value} | {OK/MISSING} |
524
- | EF Core config | crossBranch section | {exists?} | {OK/MISSING} |
525
- | Folders | [plans/](.claude/gitflow/plans/), [logs/](.claude/gitflow/logs/), [migrations/](.claude/gitflow/migrations/) | {exists?} | {OK/INCOMPLETE} |
526
-
527
- **If differences detected, ask user:**
528
-
529
- ```javascript
530
- AskUserQuestion({
531
- questions: [{
532
- question: "Existing GitFlow structure detected (v{existing_version}). What do you want to do?",
533
- header: "Init",
534
- options: [
535
- { label: "Migrate", description: "Update to v1.2.0 - preserve existing config (Recommended)" },
536
- { label: "Reset", description: "Delete and recreate from scratch (loses config)" },
537
- { label: "Skip", description: "Keep current structure unchanged" }
538
- ],
539
- multiSelect: false
540
- }]
541
- })
542
- ```
543
-
544
- **Migration actions (if "Migrate" selected):**
545
- 1. Backup existing config to [.claude/gitflow/backup/](.claude/gitflow/backup/)
546
- 2. Add missing config sections (worktrees, efcore.crossBranch, etc.)
547
- 3. Create missing folders
548
- 4. Update version to 1.2.0
549
- 5. Preserve user customizations (branch names, versioning source, etc.)
550
-
551
- **Reset actions (if "Reset" selected):**
552
- 1. Backup entire [.claude/gitflow/](.claude/gitflow/) to `.claude/gitflow.bak_<timestamp>/`
553
- 2. Delete [.claude/gitflow/](.claude/gitflow/)
554
- 3. Continue with fresh initialization
555
-
556
- **Skip actions:**
557
- 1. Display current config summary
558
- 2. Exit without changes
559
-
560
- ---
561
-
562
- ### 1. Analysis
563
-
564
- Analyze the repository and detect:
565
-
566
- **Git:**
567
- - Check if it's a Git repo
568
- - List existing branches (main/master, develop)
569
- - Get remote origin URL
570
-
571
- **Version (.NET - priority order):**
572
- 1. `*.csproj` → `<Version>` tag
573
- 2. `Directory.Build.props` → `<Version>` tag
574
- 3. `AssemblyInfo.cs` → `[AssemblyVersion]` attribute
575
- 4. `VERSION` file → raw content
576
- 5. Last git tag → format `vX.Y.Z`
577
- 6. None → suggest `0.1.0` with `VERSION` file
578
-
579
- **EF Core:**
580
- - Detect if EF Core is referenced in csproj files
581
- - List existing DbContexts
582
-
583
- ### 2. Generate the plan file
584
-
585
- Create plan file in [.claude/gitflow/plans/](.claude/gitflow/plans/) named `init_<YYYYMMDD>.md` containing:
586
-
587
- ````markdown
588
- # GitFlow Initialization Plan
589
-
590
- > Read this file then execute:
591
-
592
- ```
593
- /gitflow:1-init --exec
594
- ```
595
-
596
- ## Repository
597
- | Info | Value |
598
- |------|-------|
599
- | Name | {repo_name} |
600
- | Remote | {url_or_local} |
601
-
602
- ## Version
603
- | Source | File | Version |
604
- |--------|------|---------|
605
- | {type} | {path} | {version} |
606
-
607
- ## Planned Actions
608
- - [ ] Branches: main ({create|exists}), develop ({create|exists})
609
- - [ ] Structure: .claude/gitflow/{config.json, plans/, logs/, migrations/}
610
- - [ ] CLAUDE.md: Repository section
611
- - [ ] EF Core: {active|inactive} - Contexts: {list}
612
-
613
- ## Configuration
614
- - Versioning: SemVer
615
- - Tag prefix: v
616
- - Auto-increment: feature→minor, hotfix→patch, release→manual
617
-
618
- ## Modify?
619
- Edit this file before executing.
620
-
621
- ## Execute
622
-
623
- ```
624
- /gitflow:1-init --exec
625
- ```
626
- ````
627
-
628
- ### 3. Display message
629
-
630
- ````
631
- Plan generated: .claude/gitflow/plans/init_<DATE>.md
632
-
633
- 1. Read the file
634
- 2. Modify if necessary
635
- 3. Execute:
636
-
637
- ```
638
- /gitflow:1-init --exec
639
- ```
640
- ````
641
-
642
- ---
643
-
644
- ## --exec mode: Execute the plan
645
-
646
- ### Prerequisites
647
- - Init plan exists in [.claude/gitflow/plans/](.claude/gitflow/plans/)
648
-
649
- ### Actions
650
- 1. **Branches**: Create main and develop if absent, checkout develop
651
- 2. **Structure**: Create [.claude/gitflow/](.claude/gitflow/) with subdirectories:
652
- - [plans/](.claude/gitflow/plans/) - Integration plans
653
- - [logs/](.claude/gitflow/logs/) - Operation history
654
- - [migrations/](.claude/gitflow/migrations/) - EF Core snapshots
655
- 3. **Worktrees** (if `--with-worktrees`): Create worktrees structure (see below)
656
- 4. **Config**: Create [config.json](.claude/gitflow/config.json) with plan configuration
657
- 5. **CLAUDE.md**: Add Repository section if branches existed
658
- 6. **VERSION**: Create file if no source detected
659
- 7. **Commit** (ask): `chore(gitflow): initialization v{VERSION}`
660
-
661
- ### Creating Worktrees (v1.3)
662
-
663
- If `--with-worktrees` is specified (default: true), ask user for structure preference:
664
-
665
- ```javascript
666
- AskUserQuestion({
667
- questions: [{
668
- question: "Choose worktree organization style",
669
- header: "Structure",
670
- options: [
671
- { label: "Organized (Recommended)", description: "01-Main/, 02-Develop/, features/, releases/, hotfixes/ in parent folder" },
672
- { label: "Adjacent", description: "../worktrees/ folder next to repo (legacy mode)" },
673
- { label: "Skip worktrees", description: "No worktree structure, use branch switching" }
674
- ],
675
- multiSelect: false
676
- }]
677
- })
678
- ```
679
-
680
- #### Option 1: Organized Structure (Recommended)
681
-
682
- ```bash
683
- # Move current repo to subfolder with numbered prefix
684
- CURRENT_DIR=$(pwd)
685
- PARENT_DIR=$(dirname "$CURRENT_DIR")
686
- REPO_NAME=$(basename "$CURRENT_DIR")
687
-
688
- # Create organized structure in parent
689
- cd "$PARENT_DIR"
690
- mkdir -p "${REPO_NAME}-gitflow"
691
- mv "$REPO_NAME" "${REPO_NAME}-gitflow/.bare-temp"
692
-
693
- cd "${REPO_NAME}-gitflow"
694
-
695
- # Convert to bare repo structure
696
- git clone --bare ".bare-temp" .bare
697
- rm -rf .bare-temp
698
- echo "gitdir: ./.bare" > .git
699
-
700
- # Configure bare repo
701
- cd .bare
702
- git config core.bare false
703
- git config core.worktree ".."
704
- cd ..
705
-
706
- # Create worktree structure
707
- mkdir -p features releases hotfixes
708
- git worktree add "01-Main" main
709
- git worktree add "02-Develop" develop
710
-
711
- # Move to 02-Develop as working directory
712
- cd "02-Develop"
713
- ```
714
-
715
- **Resulting structure (Organized):**
716
- ```
717
- parent/
718
- └── {repo-name}-gitflow/ # Project folder
719
- ├── .bare/ # Bare repository
720
- ├── .git # gitdir pointer
721
- ├── 01-Main/ # Permanent worktree (main)
722
- │ └── ...
723
- ├── 02-Develop/ # Permanent worktree (develop) ← WORKING DIR
724
- │ ├── .claude/gitflow/
725
- │ └── ...
726
- ├── features/ # Feature worktrees
727
- │ └── {feature-name}/
728
- ├── releases/ # Release worktrees
729
- │ └── v{version}/
730
- └── hotfixes/ # Hotfix worktrees
731
- └── {hotfix-name}/
732
- ```
733
-
734
- #### Option 2: Adjacent Structure (Legacy)
735
-
736
- ```bash
737
- # Base path (relative to main repo)
738
- WORKTREE_BASE="../worktrees"
739
-
740
- # Create directories
741
- mkdir -p "$WORKTREE_BASE/features"
742
- mkdir -p "$WORKTREE_BASE/releases"
743
- mkdir -p "$WORKTREE_BASE/hotfixes"
744
-
745
- # Create permanent worktrees for main and develop
746
- git worktree add "$WORKTREE_BASE/main" main
747
- git worktree add "$WORKTREE_BASE/develop" develop
748
- ```
749
-
750
- **Resulting structure (Adjacent/Legacy):**
751
- ```
752
- parent/
753
- ├── atlashub-project/ # Main repo (stays as-is)
754
- │ ├── .claude/gitflow/
755
- │ └── ...
756
- └── worktrees/ # Adjacent folder
757
- ├── main/ # Permanent worktree
758
- ├── develop/ # Permanent worktree
759
- ├── features/ # Features in progress
760
- │ └── {feature-name}/
761
- ├── releases/ # Releases in progress
762
- │ └── v{version}/
763
- └── hotfixes/ # Hotfixes in progress
764
- └── {hotfix-name}/
765
- ```
766
-
767
- ### Config.json structure
768
-
769
- #### Organized Mode (v1.3)
770
- ```json
771
- {
772
- "version": "1.3.0",
773
- "initMode": "organized",
774
- "repository": { "name": "", "defaultBranch": "main", "remoteUrl": "" },
775
- "versioning": { "strategy": "semver", "current": "0.1.0", "source": "auto", "sourceFile": "", "tagPrefix": "v", "autoIncrement": { "feature": "minor", "hotfix": "patch", "release": "manual" } },
776
- "git": { "branches": { "main": "main", "develop": "develop", "feature": "feature/", "release": "release/", "hotfix": "hotfix/" }, "mergeStrategy": "--no-ff", "protectedBranches": ["main", "develop"] },
777
- "worktrees": {
778
- "enabled": true,
779
- "mode": "organized",
780
- "basePath": "..",
781
- "bareRepo": "../.bare",
782
- "permanent": {
783
- "main": { "path": "../01-Main", "prefix": "01" },
784
- "develop": { "path": "../02-Develop", "prefix": "02" }
785
- },
786
- "structure": {
787
- "features": "../features/",
788
- "releases": "../releases/",
789
- "hotfixes": "../hotfixes/"
790
- },
791
- "cleanupOnFinish": true
792
- },
793
- "database": {
794
- "enabled": true,
795
- "server": "localhost",
796
- "authType": "windows",
797
- "username": "",
798
- "password": "",
799
- "namePrefix": "",
800
- "autoCreateLocalConfig": true
801
- },
802
- "efcore": {
803
- "enabled": false, "contexts": [], "generateScript": false, "scriptOutputPath": "",
804
- "crossBranch": { "enabled": true, "scanOnMigrationCreate": true, "blockOnConflict": true, "cacheExpiry": "1h" }
805
- },
806
- "workflow": { "requireConfirmation": true, "createCheckpoints": true, "commitConventions": "conventional", "push": { "afterCommit": "worktree", "afterFinish": "always" } }
807
- }
808
- ```
809
-
810
- ### Database Configuration (NEW in v1.3)
811
-
812
- La section `database` configure la creation automatique de `appsettings.Local.json` lors du `/gitflow:10-start`:
813
-
814
- | Parametre | Description | Defaut |
815
- |-----------|-------------|--------|
816
- | `enabled` | Activer la creation automatique | `true` |
817
- | `server` | Serveur SQL Server | `localhost` |
818
- | `authType` | Type d'authentification (`windows` ou `sql`) | `windows` |
819
- | `username` | Utilisateur SQL (si authType=sql) | - |
820
- | `password` | Mot de passe SQL (si authType=sql) | - |
821
- | `namePrefix` | Prefixe des noms de DB (vide = nom du projet) | - |
822
- | `autoCreateLocalConfig` | Creer appsettings.Local.json automatiquement | `true` |
823
-
824
- **Convention de nommage des bases de donnees:**
825
-
826
- | Type branche | Pattern | Exemple |
827
- |--------------|---------|---------|
828
- | develop | `{prefix}_Dev` | `SmartStack_Dev` |
829
- | feature/* | `{prefix}_feat_{name}` | `SmartStack_feat_user_auth` |
830
- | hotfix/* | `{prefix}_fix_{name}` | `SmartStack_fix_login_bug` |
831
- | release/* | `{prefix}_rel_{version}` | `SmartStack_rel_1_3_0` |
832
-
833
- **Avantages:**
834
- - Isolation complete entre worktrees
835
- - Pas de conflits de base de donnees
836
- - Chaque developpeur peut travailler sur plusieurs features simultanement
837
- - Fichier `appsettings.Local.json` ignore par git (credentials securises)
838
-
839
- #### Adjacent/Legacy Mode (v1.2 compatible)
840
- ```json
841
- {
842
- "version": "1.3.0",
843
- "initMode": "adjacent",
844
- "repository": { "name": "", "defaultBranch": "main", "remoteUrl": "" },
845
- "versioning": { "strategy": "semver", "current": "0.1.0", "source": "auto", "sourceFile": "", "tagPrefix": "v", "autoIncrement": { "feature": "minor", "hotfix": "patch", "release": "manual" } },
846
- "git": { "branches": { "main": "main", "develop": "develop", "feature": "feature/", "release": "release/", "hotfix": "hotfix/" }, "mergeStrategy": "--no-ff", "protectedBranches": ["main", "develop"] },
847
- "worktrees": {
848
- "enabled": true,
849
- "mode": "adjacent",
850
- "basePath": "../worktrees",
851
- "permanent": { "main": true, "develop": true },
852
- "structure": { "features": "features/", "releases": "releases/", "hotfixes": "hotfixes/" },
853
- "cleanupOnFinish": true
854
- },
855
- "efcore": {
856
- "enabled": false, "contexts": [], "generateScript": false, "scriptOutputPath": "",
857
- "crossBranch": { "enabled": true, "scanOnMigrationCreate": true, "blockOnConflict": true, "cacheExpiry": "1h" }
858
- },
859
- "workflow": { "requireConfirmation": true, "createCheckpoints": true, "commitConventions": "conventional", "push": { "afterCommit": "worktree", "afterFinish": "always" } }
860
- }
861
- ```
862
-
863
- ### Archive plan
864
- Rename to `init_<DATE>_DONE_<TIMESTAMP>.md`
865
-
866
- ---
867
-
868
- ## Modes
869
-
870
- ### Clone Mode (New in v1.3)
871
-
872
- | Command | Action |
873
- |---------|--------|
874
- | `/gitflow:1-init {url}` | Clone repo to current directory with organized structure |
875
- | `/gitflow:1-init {url} {folder}` | Clone repo to target folder with organized structure |
876
- | `/gitflow:1-init {url} {folder} --yes` | Clone and initialize without prompts |
877
-
878
- **Examples:**
879
- ```bash
880
- /gitflow:1-init https://github.com/org/repo.git
881
- /gitflow:1-init https://github.com/org/repo.git c:/dev
882
- /gitflow:1-init git@github.com:org/repo.git c:/dev --yes
883
- ```
884
-
885
- ### Interactive Mode (New in v1.3)
886
-
887
- **Trigger:** Run `/gitflow:1-init` from a directory that is NOT a git repository
888
-
889
- | Step | Action |
890
- |------|--------|
891
- | 1 | Detect no git repo → **ask for target directory (WHERE?)** |
892
- | 2 | Ask for repository URL |
893
- | 3 | Validate URL is accessible |
894
- | 4 | **Ask EXPLICITLY for project name (WHAT?)** |
895
- | 5 | Final confirmation with full path |
896
- | 6 | Create organized structure and clone |
897
-
898
- **Flow:**
899
- ```
900
- User runs: /gitflow:1-init
901
-
902
- → "Where do you want to create your GitFlow project?"
903
- [Current directory] [C:/Dev] [~/projects] [Custom path]
904
-
905
- → "What repository do you want to clone?"
906
- [GitHub] [GitLab] [Azure DevOps] [Other]
907
-
908
- → "Enter the repository URL:"
909
- > https://github.com/myorg/my-awesome-project.git
910
-
911
- → "What should we name this project folder?"
912
- [my-awesome-project (Recommended)] [Custom name]
913
-
914
- → "Create GitFlow project with these settings?
915
- Project Name: my-awesome-project
916
- Location: C:/Dev/
917
- Full Path: C:/Dev/my-awesome-project/
918
- Repository: https://github.com/myorg/my-awesome-project.git"
919
- [Yes, create project (Recommended)] [Change settings]
920
-
921
- → Creates structure and clones...
922
- → Opens in 02-Develop
923
- ```
924
-
925
- ### Existing Repo Mode
926
-
927
- | Command | Action |
928
- |---------|--------|
929
- | `/gitflow:1-init` | Generate plan (asks if structure exists, asks for structure style) |
930
- | `/gitflow:1-init --exec` | Execute existing plan |
931
- | `/gitflow:1-init --yes` | Generate + execute without intermediate file |
932
- | `/gitflow:1-init --migrate` | Force migration of existing structure to v1.3.0 |
933
- | `/gitflow:1-init --reset` | Force reset (backup + recreate from scratch) |
934
- | `/gitflow:1-init --organized` | Force organized structure (01-Main, 02-Develop) |
935
- | `/gitflow:1-init --adjacent` | Force adjacent/legacy structure (../worktrees) |
936
- | `/gitflow:1-init --no-worktrees` | Generate plan without worktrees |
937
-
938
- ---
939
-
940
- ## Migration Details
941
-
942
- ### v1.2 → v1.3 (Organized Structure)
943
-
944
- When migrating to v1.3, these changes are available:
945
-
946
- #### New Config Fields
947
-
948
- ```json
949
- {
950
- "version": "1.3.0",
951
- "initMode": "organized", // NEW - "organized" | "adjacent" | "clone" | "interactive"
952
- "worktrees": {
953
- "mode": "organized", // NEW - matches initMode
954
- "bareRepo": "../.bare", // NEW - path to bare repo (organized mode)
955
- "permanent": {
956
- "main": { "path": "../01-Main", "prefix": "01" }, // CHANGED - object with path/prefix
957
- "develop": { "path": "../02-Develop", "prefix": "02" } // CHANGED
958
- }
959
- }
960
- }
961
- ```
962
-
963
- #### Migration Options
964
-
965
- ```javascript
966
- AskUserQuestion({
967
- questions: [{
968
- question: "v1.2 config detected. How would you like to upgrade?",
969
- header: "Migrate",
970
- options: [
971
- { label: "Keep adjacent", description: "Stay with ../worktrees structure (just update version)" },
972
- { label: "Convert to organized", description: "Restructure to 01-Main/, 02-Develop/, etc. (Recommended)" },
973
- { label: "Skip", description: "Keep v1.2 config unchanged" }
974
- ],
975
- multiSelect: false
976
- }]
977
- })
978
- ```
979
-
980
- #### Convert to Organized (if selected)
981
-
982
- 1. Backup current worktrees
983
- 2. Create new organized structure
984
- 3. Move worktree contents to new locations
985
- 4. Update config with new paths
986
- 5. Clean up old structure
987
-
988
- ---
989
-
990
- ### v1.0 → v1.2 (Legacy)
991
-
992
- When migrating from v1.0/v1.1 to v1.2:
993
-
994
- #### Config additions
995
-
996
- ```json
997
- {
998
- "version": "1.2.0",
999
- "worktrees": {
1000
- "enabled": true,
1001
- "basePath": "../worktrees",
1002
- "permanent": { "main": true, "develop": true },
1003
- "structure": { "features": "features/", "releases": "releases/", "hotfixes": "hotfixes/" },
1004
- "cleanupOnFinish": true
1005
- },
1006
- "efcore": {
1007
- "crossBranch": {
1008
- "enabled": true,
1009
- "scanOnMigrationCreate": true,
1010
- "blockOnConflict": true,
1011
- "cacheExpiry": "1h"
1012
- }
1013
- },
1014
- "workflow": {
1015
- "push": {
1016
- "afterCommit": "worktree",
1017
- "afterFinish": "always"
1018
- }
1019
- }
1020
- }
1021
- ```
1022
-
1023
- #### Structure additions
1024
-
1025
- ```
1026
- .claude/gitflow/
1027
- ├── backup/ # NEW - for migration backups
1028
- ├── cache/ # NEW - for cross-branch scan cache
1029
- └── (existing folders preserved)
1030
- ```
1031
-
1032
- ### Preserved during all migrations
1033
-
1034
- - `versioning.source` and `versioning.sourceFile`
1035
- - `repository.*` settings
1036
- - `git.branches.*` custom branch names
1037
- - `efcore.contexts` list
1038
- - All existing plans and logs
1
+ ---
2
+ description: Phase 1 - Initialize GitFlow structure with versioning and EF Core configuration
3
+ agent: gitflow-init
4
+ model: sonnet
5
+ ---
6
+
7
+ # GitFlow Init
8
+
9
+ **Arguments:** `$ARGUMENTS`
10
+
11
+ ---
12
+
13
+ ## PREMIÈRE CHOSE À FAIRE
14
+
15
+ Regarde si `$ARGUMENTS` contient une URL (commence par `https://` ou `git@`).
16
+
17
+ **Si OUI (URL détectée)** → Tu DOIS suivre le workflow ci-dessous. NE SAUTE AUCUNE ÉTAPE.
18
+
19
+ **Si NON** → Va directement à la section "MODE B ou C" plus bas.
20
+
21
+ ---
22
+
23
+ ## WORKFLOW QUAND URL DÉTECTÉE
24
+
25
+ Tu as reçu une URL de repository. Avant de créer quoi que ce soit, tu DOIS poser 3 questions à l'utilisateur.
26
+
27
+ ### ÉTAPE 1 : Extraire les informations de l'URL
28
+
29
+ Extrais le nom suggéré du projet depuis l'URL :
30
+ - `https://github.com/org/mon-projet.git` → nom suggéré = "mon-projet"
31
+ - `https://dev.azure.com/org/project/_git/repo` → nom suggéré = "repo"
32
+
33
+ **NE CRÉE AUCUN DOSSIER MAINTENANT.** Tu dois d'abord poser les questions.
34
+
35
+ ---
36
+
37
+ ### ÉTAPE 2 : DEMANDER OÙ CRÉER LE PROJET
38
+
39
+ **MAINTENANT, utilise le tool AskUserQuestion pour demander à l'utilisateur où créer le projet.**
40
+
41
+ Pose cette question avec ces options :
42
+ - Question : "Où voulez-vous créer ce projet ?"
43
+ - Header : "Location"
44
+ - Options :
45
+ 1. "C:/Dev" - Dossier de développement recommandé
46
+ 2. "Répertoire courant" - Créer ici (affiche le chemin actuel)
47
+ 3. "Chemin personnalisé" - Entrer un autre chemin
48
+
49
+ **ATTENDS LA RÉPONSE DE L'UTILISATEUR.**
50
+
51
+ Si l'utilisateur choisit "Chemin personnalisé", demande-lui de saisir le chemin.
52
+
53
+ Stocke le résultat dans `TARGET_FOLDER`.
54
+
55
+ ---
56
+
57
+ ### ÉTAPE 3 : DEMANDER LE NOM DU PROJET
58
+
59
+ **MAINTENANT, utilise le tool AskUserQuestion pour demander le nom du dossier projet.**
60
+
61
+ Pose cette question avec ces options :
62
+ - Question : "Quel nom pour le dossier du projet ? (Suggéré : {nom_extrait_de_url})"
63
+ - Header : "Name"
64
+ - Options :
65
+ 1. "{nom_extrait_de_url}" - Utiliser le nom de l'URL (Recommandé)
66
+ 2. "Nom personnalisé" - Entrer un autre nom
67
+
68
+ **ATTENDS LA RÉPONSE DE L'UTILISATEUR.**
69
+
70
+ Si l'utilisateur choisit "Nom personnalisé", demande-lui de saisir le nom.
71
+
72
+ Stocke le résultat dans `PROJECT_NAME`.
73
+
74
+ ---
75
+
76
+ ### ÉTAPE 4 : CONFIRMATION FINALE
77
+
78
+ **MAINTENANT, utilise le tool AskUserQuestion pour confirmer la création.**
79
+
80
+ Affiche un récapitulatif et demande confirmation :
81
+ - Question : "Créer le projet GitFlow avec ces paramètres ?\n\nProjet : {PROJECT_NAME}\nEmplacement : {TARGET_FOLDER}/\nChemin complet : {TARGET_FOLDER}/{PROJECT_NAME}/\nRepository : {URL}"
82
+ - Header : "Confirm"
83
+ - Options :
84
+ 1. "Oui, créer le projet" - Procéder à la création (Recommandé)
85
+ 2. "Modifier" - Revenir en arrière pour changer les paramètres
86
+
87
+ **ATTENDS LA RÉPONSE DE L'UTILISATEUR.**
88
+
89
+ Si l'utilisateur choisit "Modifier", retourne à l'ÉTAPE 2.
90
+
91
+ ---
92
+
93
+ ### ÉTAPE 5 : CRÉER LE PROJET (seulement après confirmation)
94
+
95
+ **SEULEMENT si l'utilisateur a confirmé "Oui, créer le projet" à l'étape 4**, tu peux maintenant :
96
+
97
+ 1. Vérifier que l'URL est accessible
98
+ 2. Vérifier que le dossier n'existe pas déjà
99
+ 3. Créer la structure
100
+
101
+ Le chemin final est : `{TARGET_FOLDER}/{PROJECT_NAME}/`
102
+
103
+ ---
104
+
105
+ ### ÉTAPE 6 : Validation
106
+
107
+ Vérifie que :
108
+ 1. L'URL du repository est accessible (test avec `git ls-remote`)
109
+ 2. Le dossier `{TARGET_FOLDER}/{PROJECT_NAME}` n'existe pas déjà
110
+
111
+ Si un problème, informe l'utilisateur et arrête.
112
+
113
+ ---
114
+
115
+ ### ÉTAPE 7 : Créer la structure organisée
116
+
117
+ ```bash
118
+ # Create project folder with organized structure
119
+ mkdir -p "$PROJECT_BASE"
120
+ cd "$PROJECT_BASE"
121
+
122
+ # Clone as bare repository (hidden)
123
+ git clone --bare "$REPO_URL" .bare
124
+ echo "gitdir: ./.bare" > .git
125
+
126
+ # Configure bare repo for worktrees
127
+ cd .bare
128
+ git config core.bare false
129
+ git config core.worktree ".."
130
+ cd ..
131
+
132
+ # Create organized worktree structure
133
+ mkdir -p features releases hotfixes
134
+
135
+ # Create permanent worktrees with numbered prefixes
136
+ git worktree add "01-Main" main
137
+ git worktree add "02-Develop" develop
138
+
139
+ # Initialize GitFlow config in 02-Develop (working directory)
140
+ cd "02-Develop"
141
+ mkdir -p .claude/gitflow/{plans,logs,migrations,backup,cache}
142
+ ```
143
+
144
+ **Resulting structure:**
145
+ ```
146
+ {target_folder}/{repo_name}/
147
+ ├── .bare/ # Hidden bare repository
148
+ ├── .git # gitdir pointer to .bare
149
+ ├── 01-Main/ # Permanent worktree (main branch)
150
+ │ └── ...
151
+ ├── 02-Develop/ # Permanent worktree (develop branch) ← WORKING DIR
152
+ │ ├── .claude/gitflow/
153
+ │ │ ├── config.json
154
+ │ │ ├── plans/
155
+ │ │ ├── logs/
156
+ │ │ └── migrations/
157
+ │ └── ...
158
+ ├── features/ # Feature worktrees go here
159
+ │ └── {feature-name}/
160
+ ├── releases/ # Release worktrees go here
161
+ │ └── v{version}/
162
+ └── hotfixes/ # Hotfix worktrees go here
163
+ └── {hotfix-name}/
164
+ ```
165
+
166
+ ### ÉTAPE 8 : Configuration
167
+
168
+ ```json
169
+ {
170
+ "version": "1.3.0",
171
+ "initMode": "clone",
172
+ "repository": {
173
+ "name": "{repo_name}",
174
+ "remoteUrl": "{REPO_URL}",
175
+ "defaultBranch": "main"
176
+ },
177
+ "worktrees": {
178
+ "enabled": true,
179
+ "mode": "organized",
180
+ "basePath": "..",
181
+ "bareRepo": "../.bare",
182
+ "permanent": {
183
+ "main": { "path": "../01-Main", "prefix": "01" },
184
+ "develop": { "path": "../02-Develop", "prefix": "02" }
185
+ },
186
+ "structure": {
187
+ "features": "../features/",
188
+ "releases": "../releases/",
189
+ "hotfixes": "../hotfixes/"
190
+ },
191
+ "cleanupOnFinish": true
192
+ }
193
+ }
194
+ ```
195
+
196
+ ### ÉTAPE 9 : Afficher le résumé
197
+
198
+ ```
199
+ ================================================================================
200
+ GITFLOW INITIALIZED (Clone Mode)
201
+ ================================================================================
202
+
203
+ REPOSITORY
204
+ Name: {repo_name}
205
+ Remote: {REPO_URL}
206
+
207
+ STRUCTURE CREATED
208
+ {PROJECT_BASE}/
209
+ ├── 01-Main/ ← main branch
210
+ ├── 02-Develop/ ← develop branch (current directory)
211
+ ├── features/ ← feature worktrees
212
+ ├── releases/ ← release worktrees
213
+ └── hotfixes/ ← hotfix worktrees
214
+
215
+ WORKING DIRECTORY
216
+ {PROJECT_BASE}/02-Develop
217
+
218
+ NEXT STEPS
219
+ 1. cd "{PROJECT_BASE}/02-Develop"
220
+ 2. code . (or your preferred IDE)
221
+ 3. /gitflow:10-start feature {name}
222
+
223
+ ================================================================================
224
+ ```
225
+
226
+ ---
227
+
228
+ ## MODE C: Interactive (No Repo Detected)
229
+
230
+ **Trigger:** Current directory is NOT a git repository AND no URL provided in arguments
231
+
232
+ This mode guides the user through setting up a new GitFlow project interactively.
233
+
234
+ **Critical Flow Order:**
235
+ ```
236
+ C.1 Target Directory (WHERE?) → C.2 Repository URL → C.3 Project Name (WHAT?) → C.4 Confirmation → C.5 Execute
237
+ ```
238
+
239
+ ### C.1 Ask for Target Directory (FIRST - Critical)
240
+
241
+ **IMPORTANT:** Ask WHERE to create the project BEFORE asking for repository details.
242
+
243
+ ```javascript
244
+ AskUserQuestion({
245
+ questions: [{
246
+ question: "Where do you want to create your GitFlow project?",
247
+ header: "Location",
248
+ options: [
249
+ { label: "Current directory", description: `Create in: ${process.cwd()} (Recommended)` },
250
+ { label: "C:/Dev", description: "Common development folder (Windows)" },
251
+ { label: "~/projects", description: "Common development folder (Unix)" },
252
+ { label: "Custom path", description: "Enter a different location" }
253
+ ],
254
+ multiSelect: false
255
+ }]
256
+ })
257
+ ```
258
+
259
+ **If "Custom path" selected:**
260
+ ```
261
+ Enter the target parent folder (project will be created inside):
262
+ > Example: C:/Projects or /home/user/dev
263
+ ```
264
+
265
+ **Validate path exists:**
266
+ ```bash
267
+ # Expand ~ if present
268
+ TARGET_PATH="${TARGET_PATH/#\~/$HOME}"
269
+
270
+ # Check directory exists
271
+ if [ ! -d "$TARGET_PATH" ]; then
272
+ echo "WARNING: Directory does not exist: $TARGET_PATH"
273
+ # Ask: Create it? or Choose different path?
274
+ AskUserQuestion({
275
+ questions: [{
276
+ question: "Directory '$TARGET_PATH' does not exist. Create it?",
277
+ header: "Create Dir",
278
+ options: [
279
+ { label: "Yes, create it", description: "Create the directory and continue (Recommended)" },
280
+ { label: "Choose different path", description: "Enter another location" }
281
+ ],
282
+ multiSelect: false
283
+ }]
284
+ })
285
+ fi
286
+
287
+ # Check write permissions
288
+ if [ ! -w "$TARGET_PATH" ]; then
289
+ echo "ERROR: No write permission to: $TARGET_PATH"
290
+ # Ask again
291
+ fi
292
+ ```
293
+
294
+ ### C.2 Ask for Repository URL
295
+
296
+ ```javascript
297
+ AskUserQuestion({
298
+ questions: [{
299
+ question: "What repository do you want to clone?",
300
+ header: "Repository",
301
+ options: [
302
+ { label: "GitHub", description: "https://github.com/org/repo.git" },
303
+ { label: "GitLab", description: "https://gitlab.com/org/repo.git" },
304
+ { label: "Azure DevOps", description: "https://dev.azure.com/org/project/_git/repo" },
305
+ { label: "Other", description: "Any git remote URL (SSH or HTTPS)" }
306
+ ],
307
+ multiSelect: false
308
+ }]
309
+ })
310
+ ```
311
+
312
+ **Then prompt for the actual URL:**
313
+ ```
314
+ Enter the repository URL:
315
+ > Example: https://github.com/organization/my-project.git
316
+ ```
317
+
318
+ **Validate URL is accessible:**
319
+ ```bash
320
+ git ls-remote "$REPO_URL" HEAD > /dev/null 2>&1 || {
321
+ echo "ERROR: Cannot access repository: $REPO_URL"
322
+ echo "Please verify:"
323
+ echo " - URL is correct"
324
+ echo " - You have access permissions"
325
+ echo " - Network connectivity"
326
+ # Ask again
327
+ }
328
+ ```
329
+
330
+ ### C.3 Ask for Project Name (EXPLICIT - Critical)
331
+
332
+ **IMPORTANT:** This is a CRITICAL step. Ask EXPLICITLY for the project name, don't just confirm.
333
+
334
+ Extract suggestion from URL:
335
+ ```bash
336
+ # Extract repo name from various URL formats
337
+ # https://github.com/org/my-project.git → my-project
338
+ # git@github.com:org/my-project.git → my-project
339
+ # https://dev.azure.com/org/project/_git/repo → repo
340
+
341
+ SUGGESTED_NAME=$(basename "$REPO_URL" .git)
342
+ ```
343
+
344
+ **Ask user EXPLICITLY for project name:**
345
+
346
+ ```javascript
347
+ AskUserQuestion({
348
+ questions: [{
349
+ question: "What should we name this project folder?",
350
+ header: "Project Name", // Critical: explicit header
351
+ options: [
352
+ { label: "${SUGGESTED_NAME}", description: `Use repository name: "${SUGGESTED_NAME}" (Recommended)` },
353
+ { label: "Custom name", description: "Enter a different folder name" }
354
+ ],
355
+ multiSelect: false
356
+ }]
357
+ })
358
+ ```
359
+
360
+ **If "Custom name" selected:**
361
+ ```
362
+ Enter the project folder name:
363
+ >
364
+ ```
365
+
366
+ **Strict validation:**
367
+ ```bash
368
+ # 1. Not empty
369
+ if [ -z "$PROJECT_NAME" ]; then
370
+ echo "ERROR: Project name cannot be empty"
371
+ # Ask again
372
+ fi
373
+
374
+ # 2. Valid characters only
375
+ if [[ ! "$PROJECT_NAME" =~ ^[a-zA-Z0-9._-]+$ ]]; then
376
+ echo "ERROR: Invalid characters in project name"
377
+ echo "Allowed: letters, numbers, dots (.), underscores (_), hyphens (-)"
378
+ echo "Not allowed: spaces, special characters"
379
+ # Ask again
380
+ fi
381
+
382
+ # 3. Doesn't already exist in target location
383
+ FULL_PROJECT_PATH="$TARGET_PATH/$PROJECT_NAME"
384
+ if [ -d "$FULL_PROJECT_PATH" ]; then
385
+ echo "ERROR: Folder already exists: $FULL_PROJECT_PATH"
386
+ # Ask for different name
387
+ fi
388
+
389
+ # 4. Reasonable length
390
+ if [ ${#PROJECT_NAME} -gt 100 ]; then
391
+ echo "ERROR: Project name too long (max 100 characters)"
392
+ # Ask again
393
+ fi
394
+ ```
395
+
396
+ ### C.4 Final Confirmation with Full Path
397
+
398
+ **Display complete summary before creating:**
399
+
400
+ ```javascript
401
+ AskUserQuestion({
402
+ questions: [{
403
+ question: `Create GitFlow project with these settings?\n
404
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
405
+ Project Name: ${PROJECT_NAME}
406
+ Location: ${TARGET_PATH}/
407
+ Full Path: ${FULL_PROJECT_PATH}/
408
+ Repository: ${REPO_URL}
409
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
410
+
411
+ Structure to be created:
412
+ ${PROJECT_NAME}/
413
+ ├── .bare/ (hidden bare repository)
414
+ ├── 01-Main/ (main branch)
415
+ ├── 02-Develop/ (develop branch) ← Working directory
416
+ ├── features/
417
+ ├── releases/
418
+ └── hotfixes/`,
419
+ header: "Confirm",
420
+ options: [
421
+ { label: "Yes, create project", description: "Create structure and clone repository (Recommended)" },
422
+ { label: "Change settings", description: "Go back and modify name, location, or repository" }
423
+ ],
424
+ multiSelect: false
425
+ }]
426
+ })
427
+ ```
428
+
429
+ **If "Change settings" selected:**
430
+ - Return to C.1 and let user modify any setting
431
+
432
+ ### C.5 Create Structure and Clone
433
+
434
+ Once all inputs are confirmed, execute the same steps as MODE A:
435
+
436
+ ```bash
437
+ # Final path is already set from C.3 validation
438
+ # FULL_PROJECT_PATH="$TARGET_PATH/$PROJECT_NAME"
439
+
440
+ # Create project folder with organized structure
441
+ mkdir -p "$FULL_PROJECT_PATH"
442
+ cd "$FULL_PROJECT_PATH"
443
+
444
+ # Clone as bare repository (hidden)
445
+ git clone --bare "$REPO_URL" .bare
446
+ echo "gitdir: ./.bare" > .git
447
+
448
+ # Configure bare repo for worktrees
449
+ cd .bare
450
+ git config core.bare false
451
+ git config core.worktree ".."
452
+ cd ..
453
+
454
+ # Create organized worktree structure
455
+ mkdir -p features releases hotfixes
456
+
457
+ # Create permanent worktrees with numbered prefixes
458
+ git worktree add "01-Main" main
459
+ git worktree add "02-Develop" develop 2>/dev/null || {
460
+ # If develop doesn't exist, create it from main
461
+ git worktree add "02-Develop" -b develop main
462
+ }
463
+
464
+ # Initialize GitFlow config in 02-Develop (working directory)
465
+ cd "02-Develop"
466
+ mkdir -p .claude/gitflow/{plans,logs,migrations,backup,cache}
467
+ ```
468
+
469
+ ### C.6 Generate Config and Display Summary
470
+
471
+ Generate the same config as MODE A (see A.4) and display:
472
+
473
+ ```
474
+ ================================================================================
475
+ GITFLOW INITIALIZED (Interactive Mode)
476
+ ================================================================================
477
+
478
+ REPOSITORY
479
+ Name: ${PROJECT_NAME}
480
+ Remote: ${REPO_URL}
481
+
482
+ STRUCTURE CREATED
483
+ ${FULL_PROJECT_PATH}/
484
+ ├── .bare/ ← Bare repository (hidden)
485
+ ├── .git ← Pointer to .bare
486
+ ├── 01-Main/ ← main branch (read-only reference)
487
+ ├── 02-Develop/ ← develop branch (WORKING DIRECTORY)
488
+ ├── features/ ← Feature worktrees will go here
489
+ ├── releases/ ← Release worktrees will go here
490
+ └── hotfixes/ ← Hotfix worktrees will go here
491
+
492
+ WORKING DIRECTORY
493
+ ${FULL_PROJECT_PATH}/02-Develop
494
+
495
+ NEXT STEPS
496
+ 1. Open the project:
497
+ cd "${FULL_PROJECT_PATH}/02-Develop"
498
+ code .
499
+
500
+ 2. Start a new feature:
501
+ /gitflow:10-start feature my-feature
502
+
503
+ ================================================================================
504
+ ```
505
+
506
+ ---
507
+
508
+ ## MODE B: Existing Repository (Default)
509
+
510
+ **Trigger:** Currently inside a git repository without URL argument
511
+
512
+ ### 0. Check existing structure
513
+
514
+ **IMPORTANT:** Before analyzing, check if GitFlow is already initialized.
515
+
516
+ Check for existing structure at [.claude/gitflow/config.json](.claude/gitflow/config.json).
517
+
518
+ **If structure exists, analyze differences:**
519
+
520
+ | Check | Expected | Current | Status |
521
+ |-------|----------|---------|--------|
522
+ | Config version | 1.2.0 | {existing} | {OK/OUTDATED} |
523
+ | Worktrees enabled | true | {value} | {OK/MISSING} |
524
+ | EF Core config | crossBranch section | {exists?} | {OK/MISSING} |
525
+ | Folders | [plans/](.claude/gitflow/plans/), [logs/](.claude/gitflow/logs/), [migrations/](.claude/gitflow/migrations/) | {exists?} | {OK/INCOMPLETE} |
526
+
527
+ **If differences detected, ask user:**
528
+
529
+ ```javascript
530
+ AskUserQuestion({
531
+ questions: [{
532
+ question: "Existing GitFlow structure detected (v{existing_version}). What do you want to do?",
533
+ header: "Init",
534
+ options: [
535
+ { label: "Migrate", description: "Update to v1.2.0 - preserve existing config (Recommended)" },
536
+ { label: "Reset", description: "Delete and recreate from scratch (loses config)" },
537
+ { label: "Skip", description: "Keep current structure unchanged" }
538
+ ],
539
+ multiSelect: false
540
+ }]
541
+ })
542
+ ```
543
+
544
+ **Migration actions (if "Migrate" selected):**
545
+ 1. Backup existing config to [.claude/gitflow/backup/](.claude/gitflow/backup/)
546
+ 2. Add missing config sections (worktrees, efcore.crossBranch, etc.)
547
+ 3. Create missing folders
548
+ 4. Update version to 1.2.0
549
+ 5. Preserve user customizations (branch names, versioning source, etc.)
550
+
551
+ **Reset actions (if "Reset" selected):**
552
+ 1. Backup entire [.claude/gitflow/](.claude/gitflow/) to `.claude/gitflow.bak_<timestamp>/`
553
+ 2. Delete [.claude/gitflow/](.claude/gitflow/)
554
+ 3. Continue with fresh initialization
555
+
556
+ **Skip actions:**
557
+ 1. Display current config summary
558
+ 2. Exit without changes
559
+
560
+ ---
561
+
562
+ ### 1. Analysis
563
+
564
+ Analyze the repository and detect:
565
+
566
+ **Git:**
567
+ - Check if it's a Git repo
568
+ - List existing branches (main/master, develop)
569
+ - Get remote origin URL
570
+
571
+ **Version (.NET - priority order):**
572
+ 1. `*.csproj` → `<Version>` tag
573
+ 2. `Directory.Build.props` → `<Version>` tag
574
+ 3. `AssemblyInfo.cs` → `[AssemblyVersion]` attribute
575
+ 4. `VERSION` file → raw content
576
+ 5. Last git tag → format `vX.Y.Z`
577
+ 6. None → suggest `0.1.0` with `VERSION` file
578
+
579
+ **EF Core:**
580
+ - Detect if EF Core is referenced in csproj files
581
+ - List existing DbContexts
582
+
583
+ ### 2. Generate the plan file
584
+
585
+ Create plan file in [.claude/gitflow/plans/](.claude/gitflow/plans/) named `init_<YYYYMMDD>.md` containing:
586
+
587
+ ````markdown
588
+ # GitFlow Initialization Plan
589
+
590
+ > Read this file then execute:
591
+
592
+ ```
593
+ /gitflow:1-init --exec
594
+ ```
595
+
596
+ ## Repository
597
+ | Info | Value |
598
+ |------|-------|
599
+ | Name | {repo_name} |
600
+ | Remote | {url_or_local} |
601
+
602
+ ## Version
603
+ | Source | File | Version |
604
+ |--------|------|---------|
605
+ | {type} | {path} | {version} |
606
+
607
+ ## Planned Actions
608
+ - [ ] Branches: main ({create|exists}), develop ({create|exists})
609
+ - [ ] Structure: .claude/gitflow/{config.json, plans/, logs/, migrations/}
610
+ - [ ] CLAUDE.md: Repository section
611
+ - [ ] EF Core: {active|inactive} - Contexts: {list}
612
+
613
+ ## Configuration
614
+ - Versioning: SemVer
615
+ - Tag prefix: v
616
+ - Auto-increment: feature→minor, hotfix→patch, release→manual
617
+
618
+ ## Modify?
619
+ Edit this file before executing.
620
+
621
+ ## Execute
622
+
623
+ ```
624
+ /gitflow:1-init --exec
625
+ ```
626
+ ````
627
+
628
+ ### 3. Display message
629
+
630
+ ````
631
+ Plan generated: .claude/gitflow/plans/init_<DATE>.md
632
+
633
+ 1. Read the file
634
+ 2. Modify if necessary
635
+ 3. Execute:
636
+
637
+ ```
638
+ /gitflow:1-init --exec
639
+ ```
640
+ ````
641
+
642
+ ---
643
+
644
+ ## --exec mode: Execute the plan
645
+
646
+ ### Prerequisites
647
+ - Init plan exists in [.claude/gitflow/plans/](.claude/gitflow/plans/)
648
+
649
+ ### Actions
650
+ 1. **Branches**: Create main and develop if absent, checkout develop
651
+ 2. **Structure**: Create [.claude/gitflow/](.claude/gitflow/) with subdirectories:
652
+ - [plans/](.claude/gitflow/plans/) - Integration plans
653
+ - [logs/](.claude/gitflow/logs/) - Operation history
654
+ - [migrations/](.claude/gitflow/migrations/) - EF Core snapshots
655
+ 3. **Worktrees** (if `--with-worktrees`): Create worktrees structure (see below)
656
+ 4. **Config**: Create [config.json](.claude/gitflow/config.json) with plan configuration
657
+ 5. **CLAUDE.md**: Add Repository section if branches existed
658
+ 6. **VERSION**: Create file if no source detected
659
+ 7. **Commit** (ask): `chore(gitflow): initialization v{VERSION}`
660
+
661
+ ### Creating Worktrees (v1.3)
662
+
663
+ If `--with-worktrees` is specified (default: true), ask user for structure preference:
664
+
665
+ ```javascript
666
+ AskUserQuestion({
667
+ questions: [{
668
+ question: "Choose worktree organization style",
669
+ header: "Structure",
670
+ options: [
671
+ { label: "Organized (Recommended)", description: "01-Main/, 02-Develop/, features/, releases/, hotfixes/ in parent folder" },
672
+ { label: "Adjacent", description: "../worktrees/ folder next to repo (legacy mode)" },
673
+ { label: "Skip worktrees", description: "No worktree structure, use branch switching" }
674
+ ],
675
+ multiSelect: false
676
+ }]
677
+ })
678
+ ```
679
+
680
+ #### Option 1: Organized Structure (Recommended)
681
+
682
+ ```bash
683
+ # Move current repo to subfolder with numbered prefix
684
+ CURRENT_DIR=$(pwd)
685
+ PARENT_DIR=$(dirname "$CURRENT_DIR")
686
+ REPO_NAME=$(basename "$CURRENT_DIR")
687
+
688
+ # Create organized structure in parent
689
+ cd "$PARENT_DIR"
690
+ mkdir -p "${REPO_NAME}-gitflow"
691
+ mv "$REPO_NAME" "${REPO_NAME}-gitflow/.bare-temp"
692
+
693
+ cd "${REPO_NAME}-gitflow"
694
+
695
+ # Convert to bare repo structure
696
+ git clone --bare ".bare-temp" .bare
697
+ rm -rf .bare-temp
698
+ echo "gitdir: ./.bare" > .git
699
+
700
+ # Configure bare repo
701
+ cd .bare
702
+ git config core.bare false
703
+ git config core.worktree ".."
704
+ cd ..
705
+
706
+ # Create worktree structure
707
+ mkdir -p features releases hotfixes
708
+ git worktree add "01-Main" main
709
+ git worktree add "02-Develop" develop
710
+
711
+ # Move to 02-Develop as working directory
712
+ cd "02-Develop"
713
+ ```
714
+
715
+ **Resulting structure (Organized):**
716
+ ```
717
+ parent/
718
+ └── {repo-name}-gitflow/ # Project folder
719
+ ├── .bare/ # Bare repository
720
+ ├── .git # gitdir pointer
721
+ ├── 01-Main/ # Permanent worktree (main)
722
+ │ └── ...
723
+ ├── 02-Develop/ # Permanent worktree (develop) ← WORKING DIR
724
+ │ ├── .claude/gitflow/
725
+ │ └── ...
726
+ ├── features/ # Feature worktrees
727
+ │ └── {feature-name}/
728
+ ├── releases/ # Release worktrees
729
+ │ └── v{version}/
730
+ └── hotfixes/ # Hotfix worktrees
731
+ └── {hotfix-name}/
732
+ ```
733
+
734
+ #### Option 2: Adjacent Structure (Legacy)
735
+
736
+ ```bash
737
+ # Base path (relative to main repo)
738
+ WORKTREE_BASE="../worktrees"
739
+
740
+ # Create directories
741
+ mkdir -p "$WORKTREE_BASE/features"
742
+ mkdir -p "$WORKTREE_BASE/releases"
743
+ mkdir -p "$WORKTREE_BASE/hotfixes"
744
+
745
+ # Create permanent worktrees for main and develop
746
+ git worktree add "$WORKTREE_BASE/main" main
747
+ git worktree add "$WORKTREE_BASE/develop" develop
748
+ ```
749
+
750
+ **Resulting structure (Adjacent/Legacy):**
751
+ ```
752
+ parent/
753
+ ├── atlashub-project/ # Main repo (stays as-is)
754
+ │ ├── .claude/gitflow/
755
+ │ └── ...
756
+ └── worktrees/ # Adjacent folder
757
+ ├── main/ # Permanent worktree
758
+ ├── develop/ # Permanent worktree
759
+ ├── features/ # Features in progress
760
+ │ └── {feature-name}/
761
+ ├── releases/ # Releases in progress
762
+ │ └── v{version}/
763
+ └── hotfixes/ # Hotfixes in progress
764
+ └── {hotfix-name}/
765
+ ```
766
+
767
+ ### Config.json structure
768
+
769
+ #### Organized Mode (v1.3)
770
+ ```json
771
+ {
772
+ "version": "1.3.0",
773
+ "initMode": "organized",
774
+ "repository": { "name": "", "defaultBranch": "main", "remoteUrl": "" },
775
+ "versioning": { "strategy": "semver", "current": "0.1.0", "source": "auto", "sourceFile": "", "tagPrefix": "v", "autoIncrement": { "feature": "minor", "hotfix": "patch", "release": "manual" } },
776
+ "git": { "branches": { "main": "main", "develop": "develop", "feature": "feature/", "release": "release/", "hotfix": "hotfix/" }, "mergeStrategy": "--no-ff", "protectedBranches": ["main", "develop"] },
777
+ "worktrees": {
778
+ "enabled": true,
779
+ "mode": "organized",
780
+ "basePath": "..",
781
+ "bareRepo": "../.bare",
782
+ "permanent": {
783
+ "main": { "path": "../01-Main", "prefix": "01" },
784
+ "develop": { "path": "../02-Develop", "prefix": "02" }
785
+ },
786
+ "structure": {
787
+ "features": "../features/",
788
+ "releases": "../releases/",
789
+ "hotfixes": "../hotfixes/"
790
+ },
791
+ "cleanupOnFinish": true
792
+ },
793
+ "database": {
794
+ "enabled": true,
795
+ "server": "localhost",
796
+ "authType": "windows",
797
+ "username": "",
798
+ "password": "",
799
+ "namePrefix": "",
800
+ "autoCreateLocalConfig": true
801
+ },
802
+ "efcore": {
803
+ "enabled": false, "contexts": [], "generateScript": false, "scriptOutputPath": "",
804
+ "crossBranch": { "enabled": true, "scanOnMigrationCreate": true, "blockOnConflict": true, "cacheExpiry": "1h" }
805
+ },
806
+ "workflow": { "requireConfirmation": true, "createCheckpoints": true, "commitConventions": "conventional", "push": { "afterCommit": "worktree", "afterFinish": "always" } }
807
+ }
808
+ ```
809
+
810
+ ### Database Configuration (NEW in v1.3)
811
+
812
+ La section `database` configure la creation automatique de `appsettings.Local.json` lors du `/gitflow:10-start`:
813
+
814
+ | Parametre | Description | Defaut |
815
+ |-----------|-------------|--------|
816
+ | `enabled` | Activer la creation automatique | `true` |
817
+ | `server` | Serveur SQL Server | `localhost` |
818
+ | `authType` | Type d'authentification (`windows` ou `sql`) | `windows` |
819
+ | `username` | Utilisateur SQL (si authType=sql) | - |
820
+ | `password` | Mot de passe SQL (si authType=sql) | - |
821
+ | `namePrefix` | Prefixe des noms de DB (vide = nom du projet) | - |
822
+ | `autoCreateLocalConfig` | Creer appsettings.Local.json automatiquement | `true` |
823
+
824
+ **Convention de nommage des bases de donnees:**
825
+
826
+ | Type branche | Pattern | Exemple |
827
+ |--------------|---------|---------|
828
+ | develop | `{prefix}_Dev` | `SmartStack_Dev` |
829
+ | feature/* | `{prefix}_feat_{name}` | `SmartStack_feat_user_auth` |
830
+ | hotfix/* | `{prefix}_fix_{name}` | `SmartStack_fix_login_bug` |
831
+ | release/* | `{prefix}_rel_{version}` | `SmartStack_rel_1_3_0` |
832
+
833
+ **Avantages:**
834
+ - Isolation complete entre worktrees
835
+ - Pas de conflits de base de donnees
836
+ - Chaque developpeur peut travailler sur plusieurs features simultanement
837
+ - Fichier `appsettings.Local.json` ignore par git (credentials securises)
838
+
839
+ #### Adjacent/Legacy Mode (v1.2 compatible)
840
+ ```json
841
+ {
842
+ "version": "1.3.0",
843
+ "initMode": "adjacent",
844
+ "repository": { "name": "", "defaultBranch": "main", "remoteUrl": "" },
845
+ "versioning": { "strategy": "semver", "current": "0.1.0", "source": "auto", "sourceFile": "", "tagPrefix": "v", "autoIncrement": { "feature": "minor", "hotfix": "patch", "release": "manual" } },
846
+ "git": { "branches": { "main": "main", "develop": "develop", "feature": "feature/", "release": "release/", "hotfix": "hotfix/" }, "mergeStrategy": "--no-ff", "protectedBranches": ["main", "develop"] },
847
+ "worktrees": {
848
+ "enabled": true,
849
+ "mode": "adjacent",
850
+ "basePath": "../worktrees",
851
+ "permanent": { "main": true, "develop": true },
852
+ "structure": { "features": "features/", "releases": "releases/", "hotfixes": "hotfixes/" },
853
+ "cleanupOnFinish": true
854
+ },
855
+ "efcore": {
856
+ "enabled": false, "contexts": [], "generateScript": false, "scriptOutputPath": "",
857
+ "crossBranch": { "enabled": true, "scanOnMigrationCreate": true, "blockOnConflict": true, "cacheExpiry": "1h" }
858
+ },
859
+ "workflow": { "requireConfirmation": true, "createCheckpoints": true, "commitConventions": "conventional", "push": { "afterCommit": "worktree", "afterFinish": "always" } }
860
+ }
861
+ ```
862
+
863
+ ### Archive plan
864
+ Rename to `init_<DATE>_DONE_<TIMESTAMP>.md`
865
+
866
+ ---
867
+
868
+ ## Modes
869
+
870
+ ### Clone Mode (New in v1.3)
871
+
872
+ | Command | Action |
873
+ |---------|--------|
874
+ | `/gitflow:1-init {url}` | Clone repo to current directory with organized structure |
875
+ | `/gitflow:1-init {url} {folder}` | Clone repo to target folder with organized structure |
876
+ | `/gitflow:1-init {url} {folder} --yes` | Clone and initialize without prompts |
877
+
878
+ **Examples:**
879
+ ```bash
880
+ /gitflow:1-init https://github.com/org/repo.git
881
+ /gitflow:1-init https://github.com/org/repo.git c:/dev
882
+ /gitflow:1-init git@github.com:org/repo.git c:/dev --yes
883
+ ```
884
+
885
+ ### Interactive Mode (New in v1.3)
886
+
887
+ **Trigger:** Run `/gitflow:1-init` from a directory that is NOT a git repository
888
+
889
+ | Step | Action |
890
+ |------|--------|
891
+ | 1 | Detect no git repo → **ask for target directory (WHERE?)** |
892
+ | 2 | Ask for repository URL |
893
+ | 3 | Validate URL is accessible |
894
+ | 4 | **Ask EXPLICITLY for project name (WHAT?)** |
895
+ | 5 | Final confirmation with full path |
896
+ | 6 | Create organized structure and clone |
897
+
898
+ **Flow:**
899
+ ```
900
+ User runs: /gitflow:1-init
901
+
902
+ → "Where do you want to create your GitFlow project?"
903
+ [Current directory] [C:/Dev] [~/projects] [Custom path]
904
+
905
+ → "What repository do you want to clone?"
906
+ [GitHub] [GitLab] [Azure DevOps] [Other]
907
+
908
+ → "Enter the repository URL:"
909
+ > https://github.com/myorg/my-awesome-project.git
910
+
911
+ → "What should we name this project folder?"
912
+ [my-awesome-project (Recommended)] [Custom name]
913
+
914
+ → "Create GitFlow project with these settings?
915
+ Project Name: my-awesome-project
916
+ Location: C:/Dev/
917
+ Full Path: C:/Dev/my-awesome-project/
918
+ Repository: https://github.com/myorg/my-awesome-project.git"
919
+ [Yes, create project (Recommended)] [Change settings]
920
+
921
+ → Creates structure and clones...
922
+ → Opens in 02-Develop
923
+ ```
924
+
925
+ ### Existing Repo Mode
926
+
927
+ | Command | Action |
928
+ |---------|--------|
929
+ | `/gitflow:1-init` | Generate plan (asks if structure exists, asks for structure style) |
930
+ | `/gitflow:1-init --exec` | Execute existing plan |
931
+ | `/gitflow:1-init --yes` | Generate + execute without intermediate file |
932
+ | `/gitflow:1-init --migrate` | Force migration of existing structure to v1.3.0 |
933
+ | `/gitflow:1-init --reset` | Force reset (backup + recreate from scratch) |
934
+ | `/gitflow:1-init --organized` | Force organized structure (01-Main, 02-Develop) |
935
+ | `/gitflow:1-init --adjacent` | Force adjacent/legacy structure (../worktrees) |
936
+ | `/gitflow:1-init --no-worktrees` | Generate plan without worktrees |
937
+
938
+ ---
939
+
940
+ ## Migration Details
941
+
942
+ ### v1.2 → v1.3 (Organized Structure)
943
+
944
+ When migrating to v1.3, these changes are available:
945
+
946
+ #### New Config Fields
947
+
948
+ ```json
949
+ {
950
+ "version": "1.3.0",
951
+ "initMode": "organized", // NEW - "organized" | "adjacent" | "clone" | "interactive"
952
+ "worktrees": {
953
+ "mode": "organized", // NEW - matches initMode
954
+ "bareRepo": "../.bare", // NEW - path to bare repo (organized mode)
955
+ "permanent": {
956
+ "main": { "path": "../01-Main", "prefix": "01" }, // CHANGED - object with path/prefix
957
+ "develop": { "path": "../02-Develop", "prefix": "02" } // CHANGED
958
+ }
959
+ }
960
+ }
961
+ ```
962
+
963
+ #### Migration Options
964
+
965
+ ```javascript
966
+ AskUserQuestion({
967
+ questions: [{
968
+ question: "v1.2 config detected. How would you like to upgrade?",
969
+ header: "Migrate",
970
+ options: [
971
+ { label: "Keep adjacent", description: "Stay with ../worktrees structure (just update version)" },
972
+ { label: "Convert to organized", description: "Restructure to 01-Main/, 02-Develop/, etc. (Recommended)" },
973
+ { label: "Skip", description: "Keep v1.2 config unchanged" }
974
+ ],
975
+ multiSelect: false
976
+ }]
977
+ })
978
+ ```
979
+
980
+ #### Convert to Organized (if selected)
981
+
982
+ 1. Backup current worktrees
983
+ 2. Create new organized structure
984
+ 3. Move worktree contents to new locations
985
+ 4. Update config with new paths
986
+ 5. Clean up old structure
987
+
988
+ ---
989
+
990
+ ### v1.0 → v1.2 (Legacy)
991
+
992
+ When migrating from v1.0/v1.1 to v1.2:
993
+
994
+ #### Config additions
995
+
996
+ ```json
997
+ {
998
+ "version": "1.2.0",
999
+ "worktrees": {
1000
+ "enabled": true,
1001
+ "basePath": "../worktrees",
1002
+ "permanent": { "main": true, "develop": true },
1003
+ "structure": { "features": "features/", "releases": "releases/", "hotfixes": "hotfixes/" },
1004
+ "cleanupOnFinish": true
1005
+ },
1006
+ "efcore": {
1007
+ "crossBranch": {
1008
+ "enabled": true,
1009
+ "scanOnMigrationCreate": true,
1010
+ "blockOnConflict": true,
1011
+ "cacheExpiry": "1h"
1012
+ }
1013
+ },
1014
+ "workflow": {
1015
+ "push": {
1016
+ "afterCommit": "worktree",
1017
+ "afterFinish": "always"
1018
+ }
1019
+ }
1020
+ }
1021
+ ```
1022
+
1023
+ #### Structure additions
1024
+
1025
+ ```
1026
+ .claude/gitflow/
1027
+ ├── backup/ # NEW - for migration backups
1028
+ ├── cache/ # NEW - for cross-branch scan cache
1029
+ └── (existing folders preserved)
1030
+ ```
1031
+
1032
+ ### Preserved during all migrations
1033
+
1034
+ - `versioning.source` and `versioning.sourceFile`
1035
+ - `repository.*` settings
1036
+ - `git.branches.*` custom branch names
1037
+ - `efcore.contexts` list
1038
+ - All existing plans and logs