@atlashub/smartstack-cli 1.13.2 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) 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 +1 -1
  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 +1001 -352
  12. package/.documentation/ralph-loop.html +1 -1
  13. package/.documentation/test-web.html +1 -1
  14. package/README.md +88 -20
  15. package/dist/index.js +276 -85
  16. package/dist/index.js.map +1 -1
  17. package/package.json +1 -1
  18. package/templates/agents/code-reviewer.md +163 -0
  19. package/templates/agents/efcore/db-deploy.md +25 -7
  20. package/templates/agents/efcore/db-reset.md +31 -10
  21. package/templates/agents/efcore/db-status.md +22 -5
  22. package/templates/agents/efcore/migration.md +69 -19
  23. package/templates/agents/gitflow/cleanup.md +8 -1
  24. package/templates/agents/gitflow/commit.md +7 -5
  25. package/templates/agents/gitflow/finish.md +6 -4
  26. package/templates/agents/gitflow/pr.md +8 -1
  27. package/templates/agents/gitflow/start.md +1 -1
  28. package/templates/commands/check-version.md +267 -0
  29. package/templates/commands/efcore/_shared.md +30 -1
  30. package/templates/commands/efcore/db-reset.md +18 -6
  31. package/templates/commands/gitflow/OPTIMIZATIONS.md +206 -0
  32. package/templates/commands/refactor.md +164 -0
  33. package/templates/project/DependencyInjection.Application.cs.template +25 -0
  34. package/templates/project/DependencyInjection.Infrastructure.cs.template +61 -0
  35. package/templates/project/DesignTimeExtensionsDbContextFactory.cs.template +70 -0
  36. package/templates/project/ExampleEntity.cs.template +116 -0
  37. package/templates/project/ExampleEntityConfiguration.cs.template +64 -0
  38. package/templates/project/ExampleService.cs.template +146 -0
  39. package/templates/project/ExtensionsDbContext.cs.template +41 -0
  40. package/templates/project/IExtensionsDbContext.cs.template +22 -0
  41. package/templates/project/Program.cs.template +47 -0
  42. package/templates/project/README.md +79 -0
  43. package/templates/ralph/README.md +10 -8
  44. package/templates/ralph/ralph.config.yaml +2 -2
  45. package/templates/skills/_shared.md +44 -44
  46. package/templates/skills/ai-prompt/SKILL.md +55 -55
  47. package/templates/skills/apex/SKILL.md +235 -0
  48. package/templates/skills/apex/steps/step-00-init.md +203 -0
  49. package/templates/skills/apex/steps/step-01-analyze.md +210 -0
  50. package/templates/skills/apex/steps/step-02-plan.md +217 -0
  51. package/templates/skills/apex/steps/step-03-execute.md +178 -0
  52. package/templates/skills/apex/steps/step-04-validate.md +217 -0
  53. package/templates/skills/apex/steps/step-05-examine.md +207 -0
  54. package/templates/skills/apex/steps/step-06-resolve.md +181 -0
  55. package/templates/skills/apex/steps/step-07-tests.md +206 -0
  56. package/templates/skills/apex/steps/step-08-run-tests.md +207 -0
  57. package/templates/skills/apex/templates/00-context.md +46 -0
  58. package/templates/skills/apex/templates/01-analyze.md +63 -0
  59. package/templates/skills/apex/templates/02-plan.md +63 -0
  60. package/templates/skills/apex/templates/03-execute.md +34 -0
  61. package/templates/skills/apex/templates/04-validate.md +61 -0
  62. package/templates/skills/apex/templates/05-examine.md +58 -0
  63. package/templates/skills/apex/templates/06-resolve.md +39 -0
  64. package/templates/skills/apex/templates/07-tests.md +56 -0
  65. package/templates/skills/apex/templates/08-run-tests.md +41 -0
  66. package/templates/skills/apex/templates/README.md +69 -0
  67. package/templates/skills/application/SKILL.md +50 -50
  68. package/templates/skills/application/templates-backend.md +25 -25
  69. package/templates/skills/application/templates-frontend.md +43 -43
  70. package/templates/skills/application/templates-i18n.md +29 -29
  71. package/templates/skills/application/templates-seed.md +77 -77
  72. package/templates/skills/business-analyse/SKILL.md +223 -0
  73. package/templates/skills/business-analyse/_shared.md +258 -0
  74. package/templates/skills/business-analyse/questionnaire/01-context.md +33 -0
  75. package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +35 -0
  76. package/templates/skills/business-analyse/questionnaire/03-scope.md +35 -0
  77. package/templates/skills/business-analyse/questionnaire/04-data.md +36 -0
  78. package/templates/skills/business-analyse/questionnaire/05-integrations.md +36 -0
  79. package/templates/skills/business-analyse/questionnaire/06-security.md +40 -0
  80. package/templates/skills/business-analyse/questionnaire/07-ui.md +36 -0
  81. package/templates/skills/business-analyse/questionnaire/08-performance.md +35 -0
  82. package/templates/skills/business-analyse/questionnaire/09-constraints.md +35 -0
  83. package/templates/skills/business-analyse/questionnaire/10-documentation.md +35 -0
  84. package/templates/skills/business-analyse/questionnaire.md +177 -177
  85. package/templates/skills/business-analyse/react/components.md +340 -0
  86. package/templates/skills/business-analyse/react/i18n-template.md +245 -0
  87. package/templates/skills/business-analyse/react/schema.md +151 -0
  88. package/templates/skills/business-analyse/steps/step-00-init.md +293 -0
  89. package/templates/skills/business-analyse/steps/step-01-discover.md +267 -0
  90. package/templates/skills/business-analyse/steps/step-02-analyse.md +243 -0
  91. package/templates/skills/business-analyse/steps/step-03-specify.md +317 -0
  92. package/templates/skills/business-analyse/steps/step-04-validate.md +239 -0
  93. package/templates/skills/business-analyse/steps/step-05-handoff.md +336 -0
  94. package/templates/skills/business-analyse/steps/step-06-doc-html.md +261 -0
  95. package/templates/skills/business-analyse/templates/00-context.md +105 -0
  96. package/templates/skills/business-analyse/templates/frd-brd.md +97 -0
  97. package/templates/skills/business-analyse/templates/frd-discovery.md +78 -0
  98. package/templates/skills/business-analyse/templates/frd-handoff.md +118 -0
  99. package/templates/skills/business-analyse/templates/frd-spec.md +168 -0
  100. package/templates/skills/business-analyse/templates-frd.md +217 -217
  101. package/templates/skills/business-analyse/templates-react.md +26 -26
  102. package/templates/skills/controller/SKILL.md +141 -92
  103. package/templates/skills/controller/postman-templates.md +15 -15
  104. package/templates/skills/controller/steps/step-00-init.md +191 -0
  105. package/templates/skills/controller/steps/step-01-analyze.md +146 -0
  106. package/templates/skills/controller/steps/step-02-plan.md +176 -0
  107. package/templates/skills/controller/steps/step-03-generate.md +219 -0
  108. package/templates/skills/controller/steps/step-04-perms.md +219 -0
  109. package/templates/skills/controller/steps/step-05-validate.md +107 -0
  110. package/templates/skills/controller/templates.md +77 -77
  111. package/templates/skills/documentation/SKILL.md +79 -79
  112. package/templates/skills/feature-full/SKILL.md +38 -38
  113. package/templates/skills/gitflow/SKILL.md +277 -0
  114. package/templates/{commands → skills}/gitflow/_shared.md +20 -20
  115. package/templates/skills/gitflow/phases/abort.md +173 -0
  116. package/templates/skills/gitflow/phases/cleanup.md +226 -0
  117. package/templates/skills/gitflow/phases/status.md +178 -0
  118. package/templates/skills/gitflow/steps/step-commit.md +255 -0
  119. package/templates/skills/gitflow/steps/step-finish.md +255 -0
  120. package/templates/skills/gitflow/steps/step-init.md +209 -0
  121. package/templates/skills/gitflow/steps/step-merge.md +225 -0
  122. package/templates/skills/gitflow/steps/step-plan.md +208 -0
  123. package/templates/skills/gitflow/steps/step-pr.md +235 -0
  124. package/templates/skills/gitflow/steps/step-start.md +234 -0
  125. package/templates/skills/gitflow/steps/step-sync.md +200 -0
  126. package/templates/skills/gitflow/templates/config.json +53 -0
  127. package/templates/skills/notification/SKILL.md +51 -51
  128. package/templates/skills/ralph-loop/SKILL.md +228 -0
  129. package/templates/skills/ralph-loop/steps/step-00-init.md +201 -0
  130. package/templates/skills/ralph-loop/steps/step-01-task.md +169 -0
  131. package/templates/skills/ralph-loop/steps/step-02-execute.md +173 -0
  132. package/templates/skills/ralph-loop/steps/step-03-commit.md +170 -0
  133. package/templates/skills/ralph-loop/steps/step-04-check.md +162 -0
  134. package/templates/skills/ralph-loop/steps/step-05-report.md +181 -0
  135. package/templates/skills/review-code/SKILL.md +219 -0
  136. package/templates/skills/review-code/references/clean-code-principles.md +140 -0
  137. package/templates/skills/review-code/references/code-quality-metrics.md +174 -0
  138. package/templates/skills/review-code/references/feedback-patterns.md +149 -0
  139. package/templates/skills/review-code/references/security-checklist.md +127 -0
  140. package/templates/skills/ui-components/SKILL.md +54 -54
  141. package/templates/skills/workflow/SKILL.md +46 -46
  142. package/templates/commands/ai-prompt.md +0 -315
  143. package/templates/commands/apex/1-analyze.md +0 -100
  144. package/templates/commands/apex/2-plan.md +0 -145
  145. package/templates/commands/apex/3-execute.md +0 -171
  146. package/templates/commands/apex/4-examine.md +0 -116
  147. package/templates/commands/apex/5-tasks.md +0 -209
  148. package/templates/commands/apex.md +0 -76
  149. package/templates/commands/application/create.md +0 -362
  150. package/templates/commands/application/templates-backend.md +0 -463
  151. package/templates/commands/application/templates-frontend.md +0 -517
  152. package/templates/commands/application/templates-i18n.md +0 -478
  153. package/templates/commands/application/templates-seed.md +0 -362
  154. package/templates/commands/application.md +0 -303
  155. package/templates/commands/business-analyse/0-orchestrate.md +0 -156
  156. package/templates/commands/business-analyse/1-init.md +0 -99
  157. package/templates/commands/business-analyse/2-discover.md +0 -143
  158. package/templates/commands/business-analyse/3-analyse.md +0 -106
  159. package/templates/commands/business-analyse/4-specify.md +0 -133
  160. package/templates/commands/business-analyse/5-validate.md +0 -132
  161. package/templates/commands/business-analyse/6-handoff.md +0 -157
  162. package/templates/commands/business-analyse/7-doc-html.md +0 -103
  163. package/templates/commands/business-analyse/_shared.md +0 -176
  164. package/templates/commands/business-analyse/bug.md +0 -118
  165. package/templates/commands/business-analyse/change-request.md +0 -144
  166. package/templates/commands/business-analyse/hotfix.md +0 -116
  167. package/templates/commands/business-analyse.md +0 -121
  168. package/templates/commands/controller/create.md +0 -216
  169. package/templates/commands/controller/postman-templates.md +0 -528
  170. package/templates/commands/controller/templates.md +0 -600
  171. package/templates/commands/controller.md +0 -337
  172. package/templates/commands/create/agent.md +0 -138
  173. package/templates/commands/create/command.md +0 -166
  174. package/templates/commands/create/hook.md +0 -234
  175. package/templates/commands/create/plugin.md +0 -329
  176. package/templates/commands/create/project.md +0 -508
  177. package/templates/commands/create/skill.md +0 -199
  178. package/templates/commands/create.md +0 -220
  179. package/templates/commands/documentation/module.md +0 -202
  180. package/templates/commands/documentation/templates.md +0 -432
  181. package/templates/commands/documentation.md +0 -190
  182. package/templates/commands/epct.md +0 -69
  183. package/templates/commands/explain.md +0 -186
  184. package/templates/commands/feature-full.md +0 -267
  185. package/templates/commands/gitflow/1-init.md +0 -188
  186. package/templates/commands/gitflow/10-start.md +0 -190
  187. package/templates/commands/gitflow/11-finish.md +0 -382
  188. package/templates/commands/gitflow/12-cleanup.md +0 -103
  189. package/templates/commands/gitflow/13-sync.md +0 -216
  190. package/templates/commands/gitflow/14-rebase.md +0 -251
  191. package/templates/commands/gitflow/2-status.md +0 -122
  192. package/templates/commands/gitflow/3-commit.md +0 -209
  193. package/templates/commands/gitflow/4-plan.md +0 -174
  194. package/templates/commands/gitflow/5-exec.md +0 -202
  195. package/templates/commands/gitflow/6-abort.md +0 -121
  196. package/templates/commands/gitflow/7-pull-request.md +0 -176
  197. package/templates/commands/gitflow/8-review.md +0 -113
  198. package/templates/commands/gitflow/9-merge.md +0 -157
  199. package/templates/commands/gitflow.md +0 -128
  200. package/templates/commands/implement.md +0 -663
  201. package/templates/commands/init.md +0 -567
  202. package/templates/commands/mcp-integration.md +0 -330
  203. package/templates/commands/notification.md +0 -129
  204. package/templates/commands/oneshot.md +0 -57
  205. package/templates/commands/quickstart.md +0 -154
  206. package/templates/commands/ralph-loop/cancel-ralph.md +0 -18
  207. package/templates/commands/ralph-loop/help.md +0 -126
  208. package/templates/commands/ralph-loop/ralph-loop.md +0 -120
  209. package/templates/commands/review.md +0 -106
  210. package/templates/commands/workflow.md +0 -193
@@ -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,234 @@
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 DB Config (.NET)
156
+
157
+ **If `appsettings.json` detected:**
158
+ ```bash
159
+ PROJECT_NAME=$(basename $(pwd) | tr '[:upper:]' '[:lower:]')
160
+ DB_NAME="${PROJECT_NAME}_${branch_type}_${BRANCH_NAME}" | cut -c1-63
161
+
162
+ cat > "$WORKTREE_PATH/appsettings.Local.json" << EOF
163
+ {
164
+ "ConnectionStrings": {
165
+ "DefaultConnection": "Server=localhost;Database=${DB_NAME};Trusted_Connection=true;TrustServerCertificate=true"
166
+ }
167
+ }
168
+ EOF
169
+ ```
170
+
171
+ ### 8. Store State
172
+
173
+ ```bash
174
+ # Save to state for next steps
175
+ {
176
+ "branch_type": "{branch_type}",
177
+ "branch_name": "{FULL_BRANCH}",
178
+ "base_branch": "{BASE_BRANCH}",
179
+ "target_branch": "{TARGET}",
180
+ "worktree_path": "{WORKTREE_PATH}",
181
+ "version_current": "{VERSION}"
182
+ }
183
+ ```
184
+
185
+ ### 9. Summary
186
+
187
+ ```
188
+ ╔══════════════════════════════════════════════════════════════════╗
189
+ ║ {BRANCH_TYPE} CREATED ║
190
+ ╠══════════════════════════════════════════════════════════════════╣
191
+ ║ Branch: {FULL_BRANCH} ║
192
+ ║ Base: {BASE_BRANCH} ║
193
+ ║ Target: {TARGET} ║
194
+ ║ Worktree: {WORKTREE_PATH} ║
195
+ ╠══════════════════════════════════════════════════════════════════╣
196
+ ║ NEXT STEPS: ║
197
+ ║ ║
198
+ ║ 1. Go to worktree: ║
199
+ ║ cd {WORKTREE_PATH} ║
200
+ ║ ║
201
+ ║ 2. Make changes and commit: ║
202
+ ║ /gitflow commit ║
203
+ ║ ║
204
+ ║ 3. Create pull request: ║
205
+ ║ /gitflow pr ║
206
+ ║ ║
207
+ ║ 4. After PR merged, finalize: ║
208
+ ║ /gitflow finish ║
209
+ ╚══════════════════════════════════════════════════════════════════╝
210
+ ```
211
+
212
+ ---
213
+
214
+ ## ERROR HANDLING:
215
+
216
+ | Error | Solution |
217
+ |-------|----------|
218
+ | Branch exists | Offer: rename, checkout, or delete |
219
+ | Dirty working directory | Offer: stash, commit, or continue |
220
+ | Worktree path exists | Remove orphan or use different path |
221
+ | Base branch behind remote | Pull before creating |
222
+
223
+ ---
224
+
225
+ ## SUCCESS CRITERIA:
226
+
227
+ - Branch created from correct base
228
+ - Worktree set up (if enabled)
229
+ - Local config created (if .NET)
230
+ - State stored for subsequent steps
231
+
232
+ ## NEXT STEP:
233
+
234
+ User works on code, then runs `/gitflow commit`.
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: step-sync
3
+ description: Sync with remote and rebase if behind
4
+ next_step: null
5
+ ---
6
+
7
+ # Step: SYNC - Synchronize with Remote
8
+
9
+ ## YOUR TASK:
10
+
11
+ Fetch from remote, detect divergence, push local commits, and rebase if behind base branch.
12
+
13
+ **ULTRA THINK about merge conflicts.**
14
+
15
+ ---
16
+
17
+ ## EXECUTION SEQUENCE:
18
+
19
+ ### 1. Fetch Remote State
20
+
21
+ ```bash
22
+ git fetch origin --quiet
23
+ CURRENT=$(git rev-parse --abbrev-ref HEAD)
24
+
25
+ # Determine base branch
26
+ case "$CURRENT" in
27
+ feature/*) BASE_BRANCH="develop" ;;
28
+ release/*) BASE_BRANCH="develop" ;;
29
+ hotfix/*) BASE_BRANCH="main" ;;
30
+ *) BASE_BRANCH="develop" ;;
31
+ esac
32
+ ```
33
+
34
+ ### 2. Analyze Divergence
35
+
36
+ ```bash
37
+ # Current branch vs remote
38
+ AHEAD=$(git rev-list --count origin/$CURRENT..HEAD 2>/dev/null || echo "0")
39
+ BEHIND=$(git rev-list --count HEAD..origin/$CURRENT 2>/dev/null || echo "0")
40
+
41
+ # Current branch vs base branch
42
+ BASE_AHEAD=$(git rev-list --count origin/$BASE_BRANCH..HEAD 2>/dev/null || echo "0")
43
+ BASE_BEHIND=$(git rev-list --count HEAD..origin/$BASE_BRANCH 2>/dev/null || echo "0")
44
+ ```
45
+
46
+ **State matrix:**
47
+
48
+ | Ahead | Behind | State | Action |
49
+ |-------|--------|-------|--------|
50
+ | 0 | 0 | Synced | Nothing to do |
51
+ | >0 | 0 | Ahead | Push |
52
+ | 0 | >0 | Behind | Pull |
53
+ | >0 | >0 | Diverged | Pull --rebase + Push |
54
+
55
+ ### 3. Display Status
56
+
57
+ ```
58
+ Sync Status: {CURRENT}
59
+
60
+ | Remote | Ahead | Behind | Status |
61
+ |--------|-------|--------|--------|
62
+ | origin/{CURRENT} | {AHEAD} | {BEHIND} | {state} |
63
+ | origin/{BASE_BRANCH} | {BASE_AHEAD} | {BASE_BEHIND} | {state} |
64
+ ```
65
+
66
+ ### 4. Push Local Commits
67
+
68
+ ```bash
69
+ [ "$AHEAD" -gt 0 ] && {
70
+ echo "Pushing $AHEAD commit(s) to origin/$CURRENT..."
71
+ git push origin $CURRENT
72
+ }
73
+ ```
74
+
75
+ ### 5. Pull Remote Commits
76
+
77
+ ```bash
78
+ [ "$BEHIND" -gt 0 ] && {
79
+ echo "Pulling $BEHIND commit(s) from origin/$CURRENT..."
80
+
81
+ # Check for uncommitted changes
82
+ DIRTY=$(git status --porcelain | wc -l)
83
+ [ "$DIRTY" -gt 0 ] && {
84
+ git stash push -m "sync-stash-$(date +%s)"
85
+ STASHED=true
86
+ }
87
+
88
+ git pull --rebase origin $CURRENT
89
+
90
+ [ "$STASHED" = true ] && git stash pop
91
+ }
92
+ ```
93
+
94
+ ### 6. Rebase on Base Branch (if behind)
95
+
96
+ ```bash
97
+ [ "$BASE_BEHIND" -gt 0 ] && {
98
+ echo "Branch is $BASE_BEHIND commits behind $BASE_BRANCH"
99
+
100
+ if [ "$auto_mode" = true ]; then
101
+ # Auto rebase
102
+ git rebase origin/$BASE_BRANCH
103
+ else
104
+ # Ask user
105
+ AskUserQuestion:
106
+ header: "Rebase"
107
+ question: "Rebase on $BASE_BRANCH? ($BASE_BEHIND commits behind)"
108
+ options:
109
+ - label: "Yes (Recommended)"
110
+ description: "Rebase to include latest changes"
111
+ - label: "No"
112
+ description: "Keep current base"
113
+ fi
114
+ }
115
+ ```
116
+
117
+ ### 7. Handle Rebase Conflicts
118
+
119
+ ```bash
120
+ # If rebase has conflicts
121
+ if [ -d ".git/rebase-merge" ] || [ -d ".git/rebase-apply" ]; then
122
+ echo "⚠️ REBASE CONFLICT DETECTED"
123
+
124
+ CONFLICTS=$(git diff --name-only --diff-filter=U)
125
+ echo "Conflicting files:"
126
+ echo "$CONFLICTS"
127
+
128
+ # Check for migration conflicts
129
+ MIGRATION_CONFLICTS=$(echo "$CONFLICTS" | grep "Migrations/")
130
+ [ -n "$MIGRATION_CONFLICTS" ] && {
131
+ echo "⚠️ Migration conflicts detected!"
132
+ echo "Recommend: /efcore:rebase-snapshot"
133
+ }
134
+
135
+ # Options
136
+ AskUserQuestion:
137
+ header: "Conflict"
138
+ question: "How to handle conflicts?"
139
+ options:
140
+ - label: "Resolve manually"
141
+ description: "I'll fix conflicts and continue"
142
+ - label: "Abort rebase"
143
+ description: "Cancel and return to previous state"
144
+ - label: "Accept theirs (migrations)"
145
+ description: "Use base branch migrations, regenerate ours"
146
+ fi
147
+ ```
148
+
149
+ ### 8. Force Push After Rebase
150
+
151
+ ```bash
152
+ # After successful rebase
153
+ if [ "$REBASED" = true ]; then
154
+ echo "Rebase complete. Force pushing..."
155
+ git push --force-with-lease origin $CURRENT
156
+ fi
157
+ ```
158
+
159
+ ### 9. Summary
160
+
161
+ ```
162
+ ╔══════════════════════════════════════════════════════════════════╗
163
+ ║ SYNC COMPLETE ║
164
+ ╠══════════════════════════════════════════════════════════════════╣
165
+ ║ Branch: {CURRENT} ║
166
+ ╠══════════════════════════════════════════════════════════════════╣
167
+ ║ Actions: ║
168
+ ║ {✅ Pushed {N} commits | ⬜ Nothing to push} ║
169
+ ║ {✅ Pulled {N} commits | ⬜ Nothing to pull} ║
170
+ ║ {✅ Rebased on {BASE_BRANCH} | ⬜ No rebase needed} ║
171
+ ╠══════════════════════════════════════════════════════════════════╣
172
+ ║ Status: In sync with remote ║
173
+ ╠══════════════════════════════════════════════════════════════════╣
174
+ ║ NEXT: /gitflow pr ║
175
+ ╚══════════════════════════════════════════════════════════════════╝
176
+ ```
177
+
178
+ ---
179
+
180
+ ## ERROR HANDLING:
181
+
182
+ | Error | Solution |
183
+ |-------|----------|
184
+ | Push rejected | Pull first, then push |
185
+ | Rebase conflict | Resolve or abort |
186
+ | Migration conflict | Use /efcore:rebase-snapshot |
187
+ | Force push blocked | Check branch protection |
188
+
189
+ ---
190
+
191
+ ## SUCCESS CRITERIA:
192
+
193
+ - All local commits pushed
194
+ - All remote commits pulled
195
+ - Rebased on base branch (if needed)
196
+ - No conflicts remaining
197
+
198
+ ## NEXT STEP:
199
+
200
+ User runs `/gitflow pr` to create pull request.