@atlashub/smartstack-cli 1.13.2 → 1.14.1

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 (214) hide show
  1. package/.documentation/agents.html +1 -1
  2. package/.documentation/apex.html +1 -1
  3. package/.documentation/business-analyse.html +1 -1
  4. package/.documentation/cli-commands.html +3 -3
  5. package/.documentation/commands.html +1 -1
  6. package/.documentation/efcore.html +1 -1
  7. package/.documentation/gitflow.html +231 -236
  8. package/.documentation/hooks.html +1 -1
  9. package/.documentation/index.html +1 -1
  10. package/.documentation/init.html +3 -3
  11. package/.documentation/installation.html +1075 -351
  12. package/.documentation/ralph-loop.html +1 -1
  13. package/.documentation/test-web.html +1 -1
  14. package/README.md +88 -20
  15. package/config/default-config.json +10 -1
  16. package/dist/index.js +276 -85
  17. package/dist/index.js.map +1 -1
  18. package/package.json +1 -1
  19. package/templates/agents/code-reviewer.md +163 -0
  20. package/templates/agents/efcore/db-deploy.md +25 -7
  21. package/templates/agents/efcore/db-reset.md +31 -10
  22. package/templates/agents/efcore/db-status.md +22 -5
  23. package/templates/agents/efcore/migration.md +70 -20
  24. package/templates/agents/gitflow/cleanup.md +8 -1
  25. package/templates/agents/gitflow/commit.md +7 -5
  26. package/templates/agents/gitflow/finish.md +6 -4
  27. package/templates/agents/gitflow/pr.md +8 -1
  28. package/templates/agents/gitflow/start.md +1 -1
  29. package/templates/commands/check-version.md +267 -0
  30. package/templates/commands/efcore/_shared.md +31 -2
  31. package/templates/commands/efcore/db-reset.md +18 -6
  32. package/templates/commands/efcore/migration.md +1 -1
  33. package/templates/commands/efcore/rebase-snapshot.md +1 -1
  34. package/templates/commands/efcore/squash.md +1 -0
  35. package/templates/commands/refactor.md +164 -0
  36. package/templates/project/DependencyInjection.Application.cs.template +25 -0
  37. package/templates/project/DependencyInjection.Infrastructure.cs.template +61 -0
  38. package/templates/project/DesignTimeExtensionsDbContextFactory.cs.template +70 -0
  39. package/templates/project/ExampleEntity.cs.template +116 -0
  40. package/templates/project/ExampleEntityConfiguration.cs.template +64 -0
  41. package/templates/project/ExampleService.cs.template +146 -0
  42. package/templates/project/ExtensionsDbContext.cs.template +41 -0
  43. package/templates/project/IExtensionsDbContext.cs.template +22 -0
  44. package/templates/project/Program.cs.template +47 -0
  45. package/templates/project/README.md +79 -0
  46. package/templates/ralph/README.md +10 -8
  47. package/templates/ralph/ralph.config.yaml +2 -2
  48. package/templates/skills/_shared.md +44 -44
  49. package/templates/skills/ai-prompt/SKILL.md +55 -55
  50. package/templates/skills/apex/SKILL.md +235 -0
  51. package/templates/skills/apex/steps/step-00-init.md +203 -0
  52. package/templates/skills/apex/steps/step-01-analyze.md +210 -0
  53. package/templates/skills/apex/steps/step-02-plan.md +217 -0
  54. package/templates/skills/apex/steps/step-03-execute.md +178 -0
  55. package/templates/skills/apex/steps/step-04-validate.md +217 -0
  56. package/templates/skills/apex/steps/step-05-examine.md +207 -0
  57. package/templates/skills/apex/steps/step-06-resolve.md +181 -0
  58. package/templates/skills/apex/steps/step-07-tests.md +206 -0
  59. package/templates/skills/apex/steps/step-08-run-tests.md +207 -0
  60. package/templates/skills/apex/templates/00-context.md +46 -0
  61. package/templates/skills/apex/templates/01-analyze.md +63 -0
  62. package/templates/skills/apex/templates/02-plan.md +63 -0
  63. package/templates/skills/apex/templates/03-execute.md +34 -0
  64. package/templates/skills/apex/templates/04-validate.md +61 -0
  65. package/templates/skills/apex/templates/05-examine.md +58 -0
  66. package/templates/skills/apex/templates/06-resolve.md +39 -0
  67. package/templates/skills/apex/templates/07-tests.md +56 -0
  68. package/templates/skills/apex/templates/08-run-tests.md +41 -0
  69. package/templates/skills/apex/templates/README.md +69 -0
  70. package/templates/skills/application/SKILL.md +50 -50
  71. package/templates/skills/application/templates-backend.md +25 -25
  72. package/templates/skills/application/templates-frontend.md +43 -43
  73. package/templates/skills/application/templates-i18n.md +29 -29
  74. package/templates/skills/application/templates-seed.md +77 -77
  75. package/templates/skills/business-analyse/SKILL.md +223 -0
  76. package/templates/skills/business-analyse/_shared.md +258 -0
  77. package/templates/skills/business-analyse/questionnaire/01-context.md +33 -0
  78. package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +35 -0
  79. package/templates/skills/business-analyse/questionnaire/03-scope.md +35 -0
  80. package/templates/skills/business-analyse/questionnaire/04-data.md +36 -0
  81. package/templates/skills/business-analyse/questionnaire/05-integrations.md +36 -0
  82. package/templates/skills/business-analyse/questionnaire/06-security.md +40 -0
  83. package/templates/skills/business-analyse/questionnaire/07-ui.md +36 -0
  84. package/templates/skills/business-analyse/questionnaire/08-performance.md +35 -0
  85. package/templates/skills/business-analyse/questionnaire/09-constraints.md +35 -0
  86. package/templates/skills/business-analyse/questionnaire/10-documentation.md +35 -0
  87. package/templates/skills/business-analyse/questionnaire.md +177 -177
  88. package/templates/skills/business-analyse/react/components.md +340 -0
  89. package/templates/skills/business-analyse/react/i18n-template.md +245 -0
  90. package/templates/skills/business-analyse/react/schema.md +151 -0
  91. package/templates/skills/business-analyse/steps/step-00-init.md +293 -0
  92. package/templates/skills/business-analyse/steps/step-01-discover.md +267 -0
  93. package/templates/skills/business-analyse/steps/step-02-analyse.md +243 -0
  94. package/templates/skills/business-analyse/steps/step-03-specify.md +317 -0
  95. package/templates/skills/business-analyse/steps/step-04-validate.md +239 -0
  96. package/templates/skills/business-analyse/steps/step-05-handoff.md +336 -0
  97. package/templates/skills/business-analyse/steps/step-06-doc-html.md +261 -0
  98. package/templates/skills/business-analyse/templates/00-context.md +105 -0
  99. package/templates/skills/business-analyse/templates/frd-brd.md +97 -0
  100. package/templates/skills/business-analyse/templates/frd-discovery.md +78 -0
  101. package/templates/skills/business-analyse/templates/frd-handoff.md +118 -0
  102. package/templates/skills/business-analyse/templates/frd-spec.md +168 -0
  103. package/templates/skills/business-analyse/templates-frd.md +217 -217
  104. package/templates/skills/business-analyse/templates-react.md +26 -26
  105. package/templates/skills/controller/SKILL.md +141 -92
  106. package/templates/skills/controller/postman-templates.md +15 -15
  107. package/templates/skills/controller/steps/step-00-init.md +191 -0
  108. package/templates/skills/controller/steps/step-01-analyze.md +146 -0
  109. package/templates/skills/controller/steps/step-02-plan.md +176 -0
  110. package/templates/skills/controller/steps/step-03-generate.md +219 -0
  111. package/templates/skills/controller/steps/step-04-perms.md +219 -0
  112. package/templates/skills/controller/steps/step-05-validate.md +107 -0
  113. package/templates/skills/controller/templates.md +77 -77
  114. package/templates/skills/documentation/SKILL.md +79 -79
  115. package/templates/skills/feature-full/SKILL.md +38 -38
  116. package/templates/skills/gitflow/SKILL.md +277 -0
  117. package/templates/{commands → skills}/gitflow/_shared.md +20 -20
  118. package/templates/skills/gitflow/phases/abort.md +173 -0
  119. package/templates/skills/gitflow/phases/cleanup.md +226 -0
  120. package/templates/skills/gitflow/phases/status.md +178 -0
  121. package/templates/skills/gitflow/steps/step-commit.md +255 -0
  122. package/templates/skills/gitflow/steps/step-finish.md +255 -0
  123. package/templates/skills/gitflow/steps/step-init.md +209 -0
  124. package/templates/skills/gitflow/steps/step-merge.md +225 -0
  125. package/templates/skills/gitflow/steps/step-plan.md +208 -0
  126. package/templates/skills/gitflow/steps/step-pr.md +235 -0
  127. package/templates/skills/gitflow/steps/step-start.md +334 -0
  128. package/templates/skills/gitflow/steps/step-sync.md +200 -0
  129. package/templates/skills/gitflow/templates/config.json +53 -0
  130. package/templates/skills/notification/SKILL.md +51 -51
  131. package/templates/skills/ralph-loop/SKILL.md +228 -0
  132. package/templates/skills/ralph-loop/steps/step-00-init.md +201 -0
  133. package/templates/skills/ralph-loop/steps/step-01-task.md +169 -0
  134. package/templates/skills/ralph-loop/steps/step-02-execute.md +173 -0
  135. package/templates/skills/ralph-loop/steps/step-03-commit.md +170 -0
  136. package/templates/skills/ralph-loop/steps/step-04-check.md +162 -0
  137. package/templates/skills/ralph-loop/steps/step-05-report.md +181 -0
  138. package/templates/skills/review-code/SKILL.md +219 -0
  139. package/templates/skills/review-code/references/clean-code-principles.md +140 -0
  140. package/templates/skills/review-code/references/code-quality-metrics.md +174 -0
  141. package/templates/skills/review-code/references/feedback-patterns.md +149 -0
  142. package/templates/skills/review-code/references/security-checklist.md +127 -0
  143. package/templates/skills/ui-components/SKILL.md +54 -54
  144. package/templates/skills/workflow/SKILL.md +46 -46
  145. package/templates/commands/ai-prompt.md +0 -315
  146. package/templates/commands/apex/1-analyze.md +0 -100
  147. package/templates/commands/apex/2-plan.md +0 -145
  148. package/templates/commands/apex/3-execute.md +0 -171
  149. package/templates/commands/apex/4-examine.md +0 -116
  150. package/templates/commands/apex/5-tasks.md +0 -209
  151. package/templates/commands/apex.md +0 -76
  152. package/templates/commands/application/create.md +0 -362
  153. package/templates/commands/application/templates-backend.md +0 -463
  154. package/templates/commands/application/templates-frontend.md +0 -517
  155. package/templates/commands/application/templates-i18n.md +0 -478
  156. package/templates/commands/application/templates-seed.md +0 -362
  157. package/templates/commands/application.md +0 -303
  158. package/templates/commands/business-analyse/0-orchestrate.md +0 -156
  159. package/templates/commands/business-analyse/1-init.md +0 -99
  160. package/templates/commands/business-analyse/2-discover.md +0 -143
  161. package/templates/commands/business-analyse/3-analyse.md +0 -106
  162. package/templates/commands/business-analyse/4-specify.md +0 -133
  163. package/templates/commands/business-analyse/5-validate.md +0 -132
  164. package/templates/commands/business-analyse/6-handoff.md +0 -157
  165. package/templates/commands/business-analyse/7-doc-html.md +0 -103
  166. package/templates/commands/business-analyse/_shared.md +0 -176
  167. package/templates/commands/business-analyse/bug.md +0 -118
  168. package/templates/commands/business-analyse/change-request.md +0 -144
  169. package/templates/commands/business-analyse/hotfix.md +0 -116
  170. package/templates/commands/business-analyse.md +0 -121
  171. package/templates/commands/controller/create.md +0 -216
  172. package/templates/commands/controller/postman-templates.md +0 -528
  173. package/templates/commands/controller/templates.md +0 -600
  174. package/templates/commands/controller.md +0 -337
  175. package/templates/commands/create/agent.md +0 -138
  176. package/templates/commands/create/command.md +0 -166
  177. package/templates/commands/create/hook.md +0 -234
  178. package/templates/commands/create/plugin.md +0 -329
  179. package/templates/commands/create/project.md +0 -508
  180. package/templates/commands/create/skill.md +0 -199
  181. package/templates/commands/create.md +0 -220
  182. package/templates/commands/documentation/module.md +0 -202
  183. package/templates/commands/documentation/templates.md +0 -432
  184. package/templates/commands/documentation.md +0 -190
  185. package/templates/commands/epct.md +0 -69
  186. package/templates/commands/explain.md +0 -186
  187. package/templates/commands/feature-full.md +0 -267
  188. package/templates/commands/gitflow/1-init.md +0 -188
  189. package/templates/commands/gitflow/10-start.md +0 -190
  190. package/templates/commands/gitflow/11-finish.md +0 -382
  191. package/templates/commands/gitflow/12-cleanup.md +0 -103
  192. package/templates/commands/gitflow/13-sync.md +0 -216
  193. package/templates/commands/gitflow/14-rebase.md +0 -251
  194. package/templates/commands/gitflow/2-status.md +0 -122
  195. package/templates/commands/gitflow/3-commit.md +0 -209
  196. package/templates/commands/gitflow/4-plan.md +0 -174
  197. package/templates/commands/gitflow/5-exec.md +0 -202
  198. package/templates/commands/gitflow/6-abort.md +0 -121
  199. package/templates/commands/gitflow/7-pull-request.md +0 -176
  200. package/templates/commands/gitflow/8-review.md +0 -113
  201. package/templates/commands/gitflow/9-merge.md +0 -157
  202. package/templates/commands/gitflow.md +0 -128
  203. package/templates/commands/implement.md +0 -663
  204. package/templates/commands/init.md +0 -567
  205. package/templates/commands/mcp-integration.md +0 -330
  206. package/templates/commands/notification.md +0 -129
  207. package/templates/commands/oneshot.md +0 -57
  208. package/templates/commands/quickstart.md +0 -154
  209. package/templates/commands/ralph-loop/cancel-ralph.md +0 -18
  210. package/templates/commands/ralph-loop/help.md +0 -126
  211. package/templates/commands/ralph-loop/ralph-loop.md +0 -120
  212. package/templates/commands/review.md +0 -106
  213. package/templates/commands/workflow.md +0 -193
  214. package/templates/gitflow/config.json +0 -138
@@ -0,0 +1,235 @@
1
+ ---
2
+ name: step-pr
3
+ description: Create pull request with auto-detection
4
+ next_step: null
5
+ ---
6
+
7
+ # Step: PR - Create Pull Request
8
+
9
+ ## YOUR TASK:
10
+
11
+ Create a pull request with proper target, title, and description based on branch type.
12
+
13
+ **ULTRA THINK about PR requirements.**
14
+
15
+ ---
16
+
17
+ ## EXECUTION SEQUENCE:
18
+
19
+ ### 1. Detect Git Provider
20
+
21
+ ```bash
22
+ REMOTE_URL=$(git remote get-url origin)
23
+
24
+ if [[ "$REMOTE_URL" == *"github.com"* ]]; then
25
+ GIT_PROVIDER="github"
26
+ elif [[ "$REMOTE_URL" == *"dev.azure.com"* ]] || [[ "$REMOTE_URL" == *"visualstudio.com"* ]]; then
27
+ GIT_PROVIDER="azuredevops"
28
+ # Extract Azure DevOps details
29
+ [[ "$REMOTE_URL" =~ dev\.azure\.com/([^/]+)/([^/]+)/_git/([^/]+) ]] && {
30
+ AZURE_ORG="${BASH_REMATCH[1]}"
31
+ AZURE_PROJECT="${BASH_REMATCH[2]}"
32
+ AZURE_REPO="${BASH_REMATCH[3]}"
33
+ }
34
+ else
35
+ GIT_PROVIDER="unknown"
36
+ fi
37
+ ```
38
+
39
+ ### 2. Determine PR Target
40
+
41
+ ```bash
42
+ CURRENT=$(git rev-parse --abbrev-ref HEAD)
43
+
44
+ case "$CURRENT" in
45
+ feature/*) TARGET_BRANCH="develop" ;;
46
+ release/*) TARGET_BRANCH="main" ;;
47
+ hotfix/*) TARGET_BRANCH="main" ;;
48
+ *) TARGET_BRANCH="develop" ;;
49
+ esac
50
+ ```
51
+
52
+ ### 3. Check Prerequisites
53
+
54
+ ```bash
55
+ # Ensure branch is pushed
56
+ git fetch origin
57
+ REMOTE_EXISTS=$(git branch -r --list "origin/$CURRENT")
58
+ [ -z "$REMOTE_EXISTS" ] && {
59
+ echo "Branch not pushed to remote. Pushing..."
60
+ git push -u origin $CURRENT
61
+ }
62
+
63
+ # Check for uncommitted changes
64
+ DIRTY=$(git status --porcelain | wc -l)
65
+ [ "$DIRTY" -gt 0 ] && {
66
+ echo "⚠️ Uncommitted changes detected"
67
+ echo "→ Run /gitflow commit first"
68
+ STOP
69
+ }
70
+
71
+ # Check if PR already exists
72
+ EXISTING_PR=$(gh pr list --head "$CURRENT" --json number --jq '.[0].number' 2>/dev/null)
73
+ [ -n "$EXISTING_PR" ] && {
74
+ echo "PR #$EXISTING_PR already exists for this branch"
75
+ echo "→ View: gh pr view $EXISTING_PR"
76
+ STOP
77
+ }
78
+ ```
79
+
80
+ ### 4. Run Pre-PR Checks
81
+
82
+ ```bash
83
+ # Build check
84
+ echo "Running build check..."
85
+ dotnet build --no-restore 2>&1 || {
86
+ echo "❌ Build failed. Fix before creating PR."
87
+ STOP
88
+ }
89
+
90
+ # Migration check
91
+ echo "Checking migrations..."
92
+ dotnet ef migrations list 2>&1 || echo "No migrations or EF Core not configured"
93
+ ```
94
+
95
+ ### 5. Generate PR Content
96
+
97
+ **Title:**
98
+ ```bash
99
+ BRANCH_NAME=$(echo $CURRENT | sed 's/.*\///')
100
+ BRANCH_TYPE=$(echo $CURRENT | cut -d'/' -f1)
101
+
102
+ case "$BRANCH_TYPE" in
103
+ feature) TITLE="feat: $BRANCH_NAME" ;;
104
+ hotfix) TITLE="fix: $BRANCH_NAME" ;;
105
+ release) TITLE="release: v$(grep -oP '"current":\s*"\K[^"]+' .claude/gitflow/config.json)" ;;
106
+ esac
107
+ ```
108
+
109
+ **Body:**
110
+ ```markdown
111
+ ## Summary
112
+
113
+ {Auto-generated from commit messages}
114
+
115
+ ## Changes
116
+
117
+ {List of files changed with categories}
118
+
119
+ ## Testing
120
+
121
+ - [ ] Build passes
122
+ - [ ] Unit tests pass
123
+ - [ ] Manual testing completed
124
+
125
+ ## EF Core Migrations
126
+
127
+ {Migration status: None | Added | Modified}
128
+
129
+ ---
130
+
131
+ 🤖 Generated with [Claude Code](https://claude.ai/code)
132
+ ```
133
+
134
+ ### 6. Create Pull Request
135
+
136
+ **GitHub:**
137
+ ```bash
138
+ gh pr create \
139
+ --title "$TITLE" \
140
+ --body "$(cat <<'EOF'
141
+ {PR_BODY}
142
+ EOF
143
+ )" \
144
+ --base "$TARGET_BRANCH" \
145
+ --head "$CURRENT"
146
+
147
+ PR_URL=$(gh pr view --json url --jq '.url')
148
+ PR_NUMBER=$(gh pr view --json number --jq '.number')
149
+ ```
150
+
151
+ **Azure DevOps:**
152
+ ```bash
153
+ az repos pr create \
154
+ --title "$TITLE" \
155
+ --description "{PR_BODY}" \
156
+ --source-branch "$CURRENT" \
157
+ --target-branch "$TARGET_BRANCH" \
158
+ --repository "$AZURE_REPO" \
159
+ --project "$AZURE_PROJECT" \
160
+ --org "https://dev.azure.com/$AZURE_ORG"
161
+
162
+ PR_ID=$(az repos pr list --source-branch "$CURRENT" --query "[0].pullRequestId" -o tsv)
163
+ ```
164
+
165
+ ### 7. Add Labels (GitHub)
166
+
167
+ ```bash
168
+ if [ "$GIT_PROVIDER" = "github" ]; then
169
+ case "$BRANCH_TYPE" in
170
+ feature) gh pr edit $PR_NUMBER --add-label "enhancement" ;;
171
+ hotfix) gh pr edit $PR_NUMBER --add-label "bug,priority" ;;
172
+ release) gh pr edit $PR_NUMBER --add-label "release" ;;
173
+ esac
174
+ fi
175
+ ```
176
+
177
+ ### 8. Store PR Info
178
+
179
+ ```bash
180
+ # Save for merge step
181
+ {
182
+ "pr_number": $PR_NUMBER,
183
+ "pr_url": "$PR_URL",
184
+ "target_branch": "$TARGET_BRANCH",
185
+ "git_provider": "$GIT_PROVIDER"
186
+ }
187
+ ```
188
+
189
+ ### 9. Summary
190
+
191
+ ```
192
+ ╔══════════════════════════════════════════════════════════════════╗
193
+ ║ PULL REQUEST CREATED ║
194
+ ╠══════════════════════════════════════════════════════════════════╣
195
+ ║ PR: #{PR_NUMBER} ║
196
+ ║ Title: {TITLE} ║
197
+ ║ URL: {PR_URL} ║
198
+ ╠══════════════════════════════════════════════════════════════════╣
199
+ ║ Source: {CURRENT} ║
200
+ ║ Target: {TARGET_BRANCH} ║
201
+ ╠══════════════════════════════════════════════════════════════════╣
202
+ ║ Checks: ║
203
+ ║ - Build: ✅ ║
204
+ ║ - Migrations: {status} ║
205
+ ╠══════════════════════════════════════════════════════════════════╣
206
+ ║ NEXT STEPS: ║
207
+ ║ 1. Wait for CI checks ║
208
+ ║ 2. Request review ║
209
+ ║ 3. After approval: /gitflow merge ║
210
+ ╚══════════════════════════════════════════════════════════════════╝
211
+ ```
212
+
213
+ ---
214
+
215
+ ## ERROR HANDLING:
216
+
217
+ | Error | Solution |
218
+ |-------|----------|
219
+ | Branch not pushed | Auto-push before PR |
220
+ | PR already exists | Show existing PR |
221
+ | Build fails | Fix and re-run |
222
+ | No git provider | Manual PR creation |
223
+
224
+ ---
225
+
226
+ ## SUCCESS CRITERIA:
227
+
228
+ - PR created with proper target
229
+ - Title and body generated
230
+ - Labels added (if GitHub)
231
+ - PR number stored for merge step
232
+
233
+ ## NEXT STEP:
234
+
235
+ Wait for review, then `/gitflow merge`.
@@ -0,0 +1,334 @@
1
+ ---
2
+ name: step-start
3
+ description: Create new branch with worktree
4
+ next_step: null
5
+ ---
6
+
7
+ # Step: START - Create Branch
8
+
9
+ ## YOUR TASK:
10
+
11
+ Create a new feature/release/hotfix branch with optional worktree setup.
12
+
13
+ **ULTRA THINK about branch naming and base selection.**
14
+
15
+ ---
16
+
17
+ ## INPUT PARSING:
18
+
19
+ ```
20
+ {branch_type} = feature | release | hotfix
21
+ {branch_name} = normalized name (kebab-case)
22
+ {no_worktree} = --no-worktree flag present
23
+ ```
24
+
25
+ **From flags:**
26
+ - `-f {name}` → branch_type=feature, branch_name={name}
27
+ - `-r {name}` → branch_type=release, branch_name={name}
28
+ - `-h {name}` → branch_type=hotfix, branch_name={name}
29
+
30
+ ---
31
+
32
+ ## EXECUTION SEQUENCE:
33
+
34
+ ### 1. Analyze Context
35
+
36
+ ```bash
37
+ CURRENT_BRANCH=$(git branch --show-current)
38
+ git fetch origin --quiet
39
+
40
+ # Version detection
41
+ VERSION=$(grep -oP '"current":\s*"\K[^"]+' .claude/gitflow/config.json 2>/dev/null || echo "0.1.0")
42
+ LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
43
+
44
+ # Develop ahead of main?
45
+ DEVELOP_AHEAD=$(git rev-list --count origin/main..origin/develop 2>/dev/null || echo "0")
46
+
47
+ # Working directory status
48
+ DIRTY=$(git status --porcelain | wc -l)
49
+ ```
50
+
51
+ **Display:**
52
+ ```
53
+ Current: {CURRENT_BRANCH} | Version: {VERSION} | Tag: {LAST_TAG}
54
+ Develop → Main: {DEVELOP_AHEAD} commits {DEVELOP_AHEAD > 10 ? "(Release recommended)" : ""}
55
+ ```
56
+
57
+ ### 2. Interactive Questions (if no args)
58
+
59
+ **If branch_type missing:**
60
+ ```yaml
61
+ AskUserQuestion:
62
+ header: "Type"
63
+ question: "What type of branch?"
64
+ options:
65
+ - label: "Feature"
66
+ description: "New feature from develop"
67
+ - label: "Release v{X.Y+1.0}"
68
+ description: "Prepare release from develop"
69
+ - label: "Hotfix"
70
+ description: "Urgent fix from main"
71
+ ```
72
+
73
+ **If branch_name missing:**
74
+ ```yaml
75
+ AskUserQuestion:
76
+ header: "Name"
77
+ question: "Branch name? (will be normalized to kebab-case)"
78
+ # Free text input
79
+ ```
80
+
81
+ ### 3. Normalize and Validate
82
+
83
+ ```bash
84
+ # Normalize name
85
+ normalize_branch_name() {
86
+ echo "$1" | tr '[:upper:]' '[:lower:]' | \
87
+ sed 'y/àâäéèêëïîôùûüçœæ/aaaeeeeiioouucoa/' | \
88
+ sed "s/[ _']/-/g" | sed 's/[^a-z0-9-]//g' | \
89
+ sed 's/--*/-/g' | sed 's/^-//;s/-$//' | cut -c1-50
90
+ }
91
+
92
+ BRANCH_NAME=$(normalize_branch_name "$branch_name")
93
+ FULL_BRANCH="${branch_type}/${BRANCH_NAME}"
94
+
95
+ # Check if exists
96
+ LOCAL_EXISTS=$(git branch --list "$FULL_BRANCH")
97
+ REMOTE_EXISTS=$(git branch -r --list "origin/$FULL_BRANCH")
98
+
99
+ [ -n "$LOCAL_EXISTS" ] || [ -n "$REMOTE_EXISTS" ] && {
100
+ echo "ERROR: Branch '$FULL_BRANCH' already exists"
101
+ # Options: Different name | Checkout existing | Delete and recreate
102
+ }
103
+ ```
104
+
105
+ ### 4. Determine Base Branch
106
+
107
+ | Type | Base Branch | Target |
108
+ |------|-------------|--------|
109
+ | feature | develop | develop |
110
+ | release | develop | main + develop |
111
+ | hotfix | main | main + develop |
112
+
113
+ ```bash
114
+ case "$branch_type" in
115
+ feature) BASE_BRANCH="develop"; TARGET="develop" ;;
116
+ release) BASE_BRANCH="develop"; TARGET="main" ;;
117
+ hotfix) BASE_BRANCH="main"; TARGET="main" ;;
118
+ esac
119
+ ```
120
+
121
+ ### 5. Handle Dirty Working Directory
122
+
123
+ ```bash
124
+ [ "$DIRTY" -gt 0 ] && {
125
+ echo "Working directory has uncommitted changes"
126
+ # Options: Stash | Commit | Continue anyway | Cancel
127
+ }
128
+ ```
129
+
130
+ ### 6. Create Branch and Worktree
131
+
132
+ **Read worktree mode from config:**
133
+ ```bash
134
+ WORKTREE_MODE=$(grep -oP '"mode":\s*"\K[^"]+' .claude/gitflow/config.json 2>/dev/null || echo "organized")
135
+ ```
136
+
137
+ **Mode: organized**
138
+ ```bash
139
+ case "$branch_type" in
140
+ feature) WORKTREE_PATH="../features/$BRANCH_NAME" ;;
141
+ release) WORKTREE_PATH="../releases/v$VERSION" ;;
142
+ hotfix) WORKTREE_PATH="../hotfixes/$BRANCH_NAME" ;;
143
+ esac
144
+
145
+ mkdir -p "$(dirname $WORKTREE_PATH)"
146
+ git worktree add -b "$FULL_BRANCH" "$WORKTREE_PATH" "origin/$BASE_BRANCH"
147
+ ```
148
+
149
+ **Mode: --no-worktree**
150
+ ```bash
151
+ git checkout "$BASE_BRANCH" && git pull origin "$BASE_BRANCH"
152
+ git checkout -b "$FULL_BRANCH"
153
+ ```
154
+
155
+ ### 7. Create Local Environment Config (Backend + Frontend)
156
+
157
+ **Detect project structure:**
158
+ ```bash
159
+ # Find API project directory
160
+ API_DIR=$(find "$WORKTREE_PATH" -type d -name "*.Api" -path "*/src/*" | head -1)
161
+ # Find Web project directory
162
+ WEB_DIR=$(find "$WORKTREE_PATH" -type d -name "*-web" -path "*/web/*" | head -1)
163
+
164
+ # Generate unique ports based on branch name hash (to avoid conflicts between worktrees)
165
+ HASH=$(echo "$BRANCH_NAME" | md5sum | cut -c1-4)
166
+ HASH_NUM=$((16#$HASH % 100))
167
+ API_PORT=$((5200 + HASH_NUM))
168
+ WEB_PORT=$((5300 + HASH_NUM))
169
+
170
+ # Project and DB naming
171
+ PROJECT_NAME=$(basename $(pwd) | tr '[:upper:]' '[:lower:]')
172
+ DB_NAME=$(echo "${PROJECT_NAME}_${branch_type}_${BRANCH_NAME}" | cut -c1-63)
173
+ ```
174
+
175
+ #### 7a. Backend: appsettings.Local.json
176
+
177
+ **If API project detected:**
178
+ ```bash
179
+ [ -n "$API_DIR" ] && [ -f "$API_DIR/appsettings.json" ] && {
180
+ cat > "$API_DIR/appsettings.Local.json" << EOF
181
+ {
182
+ "ConnectionStrings": {
183
+ "DefaultConnection": "Server=localhost;Database=${DB_NAME};Trusted_Connection=true;TrustServerCertificate=true"
184
+ },
185
+ "Authentication": {
186
+ "FrontendUrl": "http://localhost:${WEB_PORT}"
187
+ },
188
+ "Kestrel": {
189
+ "Endpoints": {
190
+ "Http": {
191
+ "Url": "http://localhost:${API_PORT}"
192
+ }
193
+ }
194
+ },
195
+ "Serilog": {
196
+ "MinimumLevel": {
197
+ "Default": "Debug"
198
+ }
199
+ }
200
+ }
201
+ EOF
202
+ echo "Created: $API_DIR/appsettings.Local.json (DB: $DB_NAME, Port: $API_PORT)"
203
+ }
204
+ ```
205
+
206
+ #### 7b. Frontend: .env.local + npm script
207
+
208
+ **If Web project detected:**
209
+ ```bash
210
+ [ -n "$WEB_DIR" ] && [ -f "$WEB_DIR/package.json" ] && {
211
+ # Create .env.local
212
+ cat > "$WEB_DIR/.env.local" << EOF
213
+ # Local environment configuration
214
+ # Generated by /gitflow:start for branch: ${FULL_BRANCH}
215
+ # Run with: npm run local
216
+
217
+ VITE_API_URL=http://localhost:${API_PORT}
218
+ VITE_APP_ENV=local
219
+ VITE_DEBUG=true
220
+ EOF
221
+ echo "Created: $WEB_DIR/.env.local (API: localhost:$API_PORT)"
222
+
223
+ # Add "local" script to package.json if not exists
224
+ if ! grep -q '"local"' "$WEB_DIR/package.json"; then
225
+ # Use Node.js to safely modify package.json
226
+ node -e "
227
+ const fs = require('fs');
228
+ const pkg = JSON.parse(fs.readFileSync('$WEB_DIR/package.json', 'utf8'));
229
+ if (!pkg.scripts.local) {
230
+ pkg.scripts.local = 'vite --mode local --port ${WEB_PORT}';
231
+ fs.writeFileSync('$WEB_DIR/package.json', JSON.stringify(pkg, null, 2) + '\n');
232
+ console.log('Added script: npm run local');
233
+ }
234
+ "
235
+ fi
236
+ }
237
+ ```
238
+
239
+ #### 7c. Summary of local config
240
+
241
+ ```
242
+ ┌─────────────────────────────────────────────────────────────┐
243
+ │ LOCAL ENVIRONMENT CONFIGURED │
244
+ ├─────────────────────────────────────────────────────────────┤
245
+ │ Database: ${DB_NAME} │
246
+ │ API Port: ${API_PORT} → dotnet run --environment Local │
247
+ │ Web Port: ${WEB_PORT} → npm run local │
248
+ └─────────────────────────────────────────────────────────────┘
249
+ ```
250
+
251
+ ### 8. Store State
252
+
253
+ ```bash
254
+ # Save to state for next steps
255
+ {
256
+ "branch_type": "{branch_type}",
257
+ "branch_name": "{FULL_BRANCH}",
258
+ "base_branch": "{BASE_BRANCH}",
259
+ "target_branch": "{TARGET}",
260
+ "worktree_path": "{WORKTREE_PATH}",
261
+ "version_current": "{VERSION}",
262
+ "local_config": {
263
+ "database": "{DB_NAME}",
264
+ "api_port": "{API_PORT}",
265
+ "web_port": "{WEB_PORT}",
266
+ "api_dir": "{API_DIR}",
267
+ "web_dir": "{WEB_DIR}"
268
+ }
269
+ }
270
+ ```
271
+
272
+ ### 9. Summary
273
+
274
+ ```
275
+ ╔══════════════════════════════════════════════════════════════════╗
276
+ ║ {BRANCH_TYPE} CREATED ║
277
+ ╠══════════════════════════════════════════════════════════════════╣
278
+ ║ Branch: {FULL_BRANCH} ║
279
+ ║ Base: {BASE_BRANCH} ║
280
+ ║ Target: {TARGET} ║
281
+ ║ Worktree: {WORKTREE_PATH} ║
282
+ ╠══════════════════════════════════════════════════════════════════╣
283
+ ║ LOCAL ENVIRONMENT: ║
284
+ ║ Database: {DB_NAME} ║
285
+ ║ API: http://localhost:{API_PORT} ║
286
+ ║ Web: http://localhost:{WEB_PORT} ║
287
+ ╠══════════════════════════════════════════════════════════════════╣
288
+ ║ NEXT STEPS: ║
289
+ ║ ║
290
+ ║ 1. Go to worktree: ║
291
+ ║ cd {WORKTREE_PATH} ║
292
+ ║ ║
293
+ ║ 2. Start local environment: ║
294
+ ║ # Terminal 1 - Backend: ║
295
+ ║ cd src/SmartStack.Api && dotnet run --environment Local ║
296
+ ║ # Terminal 2 - Frontend: ║
297
+ ║ cd web/smartstack-web && npm run local ║
298
+ ║ ║
299
+ ║ 3. Make changes and commit: ║
300
+ ║ /gitflow commit ║
301
+ ║ ║
302
+ ║ 4. Create pull request: ║
303
+ ║ /gitflow pr ║
304
+ ║ ║
305
+ ║ 5. After PR merged, finalize: ║
306
+ ║ /gitflow finish ║
307
+ ╚══════════════════════════════════════════════════════════════════╝
308
+ ```
309
+
310
+ ---
311
+
312
+ ## ERROR HANDLING:
313
+
314
+ | Error | Solution |
315
+ |-------|----------|
316
+ | Branch exists | Offer: rename, checkout, or delete |
317
+ | Dirty working directory | Offer: stash, commit, or continue |
318
+ | Worktree path exists | Remove orphan or use different path |
319
+ | Base branch behind remote | Pull before creating |
320
+
321
+ ---
322
+
323
+ ## SUCCESS CRITERIA:
324
+
325
+ - Branch created from correct base
326
+ - Worktree set up (if enabled)
327
+ - Backend local config created: `appsettings.Local.json` (if .NET API detected)
328
+ - Frontend local config created: `.env.local` + `npm run local` script (if web project detected)
329
+ - Ports synchronized between backend and frontend (unique per branch)
330
+ - State stored for subsequent steps
331
+
332
+ ## NEXT STEP:
333
+
334
+ User works on code, then runs `/gitflow commit`.