@zimezone/z-command 1.0.1 → 1.1.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 (217) hide show
  1. package/README.md +57 -38
  2. package/dist/cli.js +14 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/init.d.ts +1 -7
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +101 -23
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/update.d.ts +11 -0
  9. package/dist/commands/update.d.ts.map +1 -0
  10. package/dist/commands/update.js +88 -0
  11. package/dist/commands/update.js.map +1 -0
  12. package/dist/platforms.d.ts +21 -0
  13. package/dist/platforms.d.ts.map +1 -0
  14. package/dist/platforms.js +137 -0
  15. package/dist/platforms.js.map +1 -0
  16. package/dist/types.d.ts +44 -0
  17. package/dist/types.d.ts.map +1 -0
  18. package/dist/types.js +6 -0
  19. package/dist/types.js.map +1 -0
  20. package/package.json +13 -5
  21. package/templates/agents/api-documenter.agent.md +161 -0
  22. package/templates/agents/architect-review.agent.md +146 -0
  23. package/templates/agents/arm-cortex-expert.agent.md +288 -0
  24. package/templates/agents/backend-architect.agent.md +309 -0
  25. package/templates/agents/backend-security-coder.agent.md +152 -0
  26. package/templates/agents/bash-pro.agent.md +285 -0
  27. package/templates/agents/c-pro.agent.md +35 -0
  28. package/templates/agents/c4-code.agent.md +320 -0
  29. package/templates/agents/c4-component.agent.md +227 -0
  30. package/templates/agents/c4-container.agent.md +248 -0
  31. package/templates/agents/c4-context.agent.md +235 -0
  32. package/templates/agents/conductor-validator.agent.md +245 -0
  33. package/templates/agents/csharp-pro.agent.md +38 -0
  34. package/templates/agents/customer-support.agent.md +148 -0
  35. package/templates/agents/database-admin.agent.md +142 -0
  36. package/templates/agents/database-architect.agent.md +238 -0
  37. package/templates/agents/database-optimizer.agent.md +144 -0
  38. package/templates/agents/debugger.agent.md +30 -0
  39. package/templates/agents/deployment-engineer.agent.md +0 -0
  40. package/templates/agents/devops-troubleshooter.agent.md +138 -0
  41. package/templates/agents/django-pro.agent.md +159 -0
  42. package/templates/agents/docs-architect.agent.md +77 -0
  43. package/templates/agents/dotnet-architect.agent.md +175 -0
  44. package/templates/agents/dx-optimizer.agent.md +63 -0
  45. package/templates/agents/elixir-pro.agent.md +38 -0
  46. package/templates/agents/error-detective.agent.md +32 -0
  47. package/templates/agents/event-sourcing-architect.agent.md +42 -0
  48. package/templates/agents/fastapi-pro.agent.md +171 -0
  49. package/templates/agents/firmware-analyst.agent.md +330 -0
  50. package/templates/agents/frontend-security-coder.agent.md +149 -0
  51. package/templates/agents/haskell-pro.agent.md +37 -0
  52. package/templates/agents/hr-pro.agent.md +105 -0
  53. package/templates/agents/incident-responder.agent.md +190 -0
  54. package/templates/agents/ios-developer.agent.md +198 -0
  55. package/templates/agents/java-pro.agent.md +156 -0
  56. package/templates/agents/javascript-pro.agent.md +35 -0
  57. package/templates/agents/julia-pro.agent.md +187 -0
  58. package/templates/agents/legal-advisor.agent.md +49 -0
  59. package/templates/agents/malware-analyst.agent.md +272 -0
  60. package/templates/agents/mermaid-expert.agent.md +39 -0
  61. package/templates/agents/minecraft-bukkit-pro.agent.md +104 -0
  62. package/templates/agents/mobile-security-coder.agent.md +163 -0
  63. package/templates/agents/monorepo-architect.agent.md +44 -0
  64. package/templates/agents/observability-engineer.agent.md +228 -0
  65. package/templates/agents/performance-engineer.agent.md +167 -0
  66. package/templates/agents/php-pro.agent.md +43 -0
  67. package/templates/agents/posix-shell-pro.agent.md +284 -0
  68. package/templates/agents/quant-analyst.agent.md +32 -0
  69. package/templates/agents/reference-builder.agent.md +167 -0
  70. package/templates/agents/reverse-engineer.agent.md +202 -0
  71. package/templates/agents/risk-manager.agent.md +41 -0
  72. package/templates/agents/ruby-pro.agent.md +35 -0
  73. package/templates/agents/rust-pro.agent.md +156 -0
  74. package/templates/agents/sales-automator.agent.md +35 -0
  75. package/templates/agents/scala-pro.agent.md +60 -0
  76. package/templates/agents/search-specialist.agent.md +59 -0
  77. package/templates/agents/security-auditor.agent.md +138 -0
  78. package/templates/agents/seo-authority-builder.agent.md +116 -0
  79. package/templates/agents/seo-cannibalization-detector.agent.md +103 -0
  80. package/templates/agents/seo-content-auditor.agent.md +63 -0
  81. package/templates/agents/seo-content-planner.agent.md +88 -0
  82. package/templates/agents/seo-content-refresher.agent.md +98 -0
  83. package/templates/agents/seo-content-writer.agent.md +76 -0
  84. package/templates/agents/seo-keyword-strategist.agent.md +75 -0
  85. package/templates/agents/seo-meta-optimizer.agent.md +72 -0
  86. package/templates/agents/seo-snippet-hunter.agent.md +94 -0
  87. package/templates/agents/seo-structure-architect.agent.md +88 -0
  88. package/templates/agents/service-mesh-expert.agent.md +41 -0
  89. package/templates/agents/sql-pro.agent.md +146 -0
  90. package/templates/agents/tdd-orchestrator.agent.md +183 -0
  91. package/templates/agents/temporal-python-pro.agent.md +349 -0
  92. package/templates/agents/terraform-specialist.agent.md +137 -0
  93. package/templates/agents/test-automator.agent.md +203 -0
  94. package/templates/agents/threat-modeling-expert.agent.md +44 -0
  95. package/templates/agents/tutorial-engineer.agent.md +118 -0
  96. package/templates/agents/ui-ux-designer.agent.md +188 -0
  97. package/templates/agents/ui-visual-validator.agent.md +192 -0
  98. package/templates/agents/vector-database-engineer.agent.md +43 -0
  99. package/templates/skills/angular-migration/SKILL.md +410 -0
  100. package/templates/skills/api-design-principles/SKILL.md +528 -0
  101. package/templates/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  102. package/templates/skills/api-design-principles/assets/rest-api-template.py +182 -0
  103. package/templates/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  104. package/templates/skills/api-design-principles/references/rest-best-practices.md +408 -0
  105. package/templates/skills/architecture-decision-records/SKILL.md +428 -0
  106. package/templates/skills/architecture-patterns/SKILL.md +494 -0
  107. package/templates/skills/async-python-patterns/SKILL.md +694 -0
  108. package/templates/skills/auth-implementation-patterns/SKILL.md +634 -0
  109. package/templates/skills/changelog-automation/SKILL.md +552 -0
  110. package/templates/skills/code-review-excellence/SKILL.md +520 -0
  111. package/templates/skills/competitive-landscape/SKILL.md +479 -0
  112. package/templates/skills/context-driven-development/SKILL.md +385 -0
  113. package/templates/skills/cost-optimization/SKILL.md +274 -0
  114. package/templates/skills/cqrs-implementation/SKILL.md +554 -0
  115. package/templates/skills/data-quality-frameworks/SKILL.md +587 -0
  116. package/templates/skills/data-storytelling/SKILL.md +453 -0
  117. package/templates/skills/database-migration/SKILL.md +424 -0
  118. package/templates/skills/dbt-transformation-patterns/SKILL.md +561 -0
  119. package/templates/skills/debugging-strategies/SKILL.md +527 -0
  120. package/templates/skills/defi-protocol-templates/SKILL.md +454 -0
  121. package/templates/skills/dependency-upgrade/SKILL.md +409 -0
  122. package/templates/skills/deployment-pipeline-design/SKILL.md +359 -0
  123. package/templates/skills/distributed-tracing/SKILL.md +438 -0
  124. package/templates/skills/dotnet-backend-patterns/SKILL.md +815 -0
  125. package/templates/skills/dotnet-backend-patterns/assets/repository-template.cs +523 -0
  126. package/templates/skills/dotnet-backend-patterns/assets/service-template.cs +336 -0
  127. package/templates/skills/dotnet-backend-patterns/references/dapper-patterns.md +544 -0
  128. package/templates/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +355 -0
  129. package/templates/skills/e2e-testing-patterns/SKILL.md +547 -0
  130. package/templates/skills/employment-contract-templates/SKILL.md +507 -0
  131. package/templates/skills/error-handling-patterns/SKILL.md +636 -0
  132. package/templates/skills/event-store-design/SKILL.md +437 -0
  133. package/templates/skills/fastapi-templates/SKILL.md +567 -0
  134. package/templates/skills/git-advanced-workflows/SKILL.md +400 -0
  135. package/templates/skills/github-actions-templates/SKILL.md +333 -0
  136. package/templates/skills/go-concurrency-patterns/SKILL.md +655 -0
  137. package/templates/skills/grafana-dashboards/SKILL.md +369 -0
  138. package/templates/skills/helm-chart-scaffolding/SKILL.md +544 -0
  139. package/templates/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
  140. package/templates/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
  141. package/templates/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
  142. package/templates/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
  143. package/templates/skills/javascript-testing-patterns/SKILL.md +1025 -0
  144. package/templates/skills/langchain-architecture/SKILL.md +338 -0
  145. package/templates/skills/llm-evaluation/SKILL.md +471 -0
  146. package/templates/skills/microservices-patterns/SKILL.md +595 -0
  147. package/templates/skills/modern-javascript-patterns/SKILL.md +911 -0
  148. package/templates/skills/monorepo-management/SKILL.md +622 -0
  149. package/templates/skills/nextjs-app-router-patterns/SKILL.md +544 -0
  150. package/templates/skills/nodejs-backend-patterns/SKILL.md +1020 -0
  151. package/templates/skills/nx-workspace-patterns/SKILL.md +452 -0
  152. package/templates/skills/openapi-spec-generation/SKILL.md +1028 -0
  153. package/templates/skills/paypal-integration/SKILL.md +467 -0
  154. package/templates/skills/pci-compliance/SKILL.md +466 -0
  155. package/templates/skills/postgresql/SKILL.md +204 -0
  156. package/templates/skills/projection-patterns/SKILL.md +490 -0
  157. package/templates/skills/prometheus-configuration/SKILL.md +392 -0
  158. package/templates/skills/prompt-engineering-patterns/SKILL.md +201 -0
  159. package/templates/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
  160. package/templates/skills/prompt-engineering-patterns/assets/prompt-template-library.md +246 -0
  161. package/templates/skills/prompt-engineering-patterns/references/chain-of-thought.md +399 -0
  162. package/templates/skills/prompt-engineering-patterns/references/few-shot-learning.md +369 -0
  163. package/templates/skills/prompt-engineering-patterns/references/prompt-optimization.md +414 -0
  164. package/templates/skills/prompt-engineering-patterns/references/prompt-templates.md +470 -0
  165. package/templates/skills/prompt-engineering-patterns/references/system-prompts.md +189 -0
  166. package/templates/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
  167. package/templates/skills/python-packaging/SKILL.md +870 -0
  168. package/templates/skills/python-performance-optimization/SKILL.md +869 -0
  169. package/templates/skills/python-testing-patterns/SKILL.md +907 -0
  170. package/templates/skills/rag-implementation/SKILL.md +403 -0
  171. package/templates/skills/react-modernization/SKILL.md +513 -0
  172. package/templates/skills/react-native-architecture/SKILL.md +671 -0
  173. package/templates/skills/react-state-management/SKILL.md +429 -0
  174. package/templates/skills/risk-metrics-calculation/SKILL.md +555 -0
  175. package/templates/skills/rust-async-patterns/SKILL.md +517 -0
  176. package/templates/skills/secrets-management/SKILL.md +346 -0
  177. package/templates/skills/security-requirement-extraction/SKILL.md +677 -0
  178. package/templates/skills/shellcheck-configuration/SKILL.md +454 -0
  179. package/templates/skills/similarity-search-patterns/SKILL.md +558 -0
  180. package/templates/skills/slo-implementation/SKILL.md +329 -0
  181. package/templates/skills/sql-optimization-patterns/SKILL.md +493 -0
  182. package/templates/skills/stripe-integration/SKILL.md +442 -0
  183. package/templates/skills/tailwind-design-system/SKILL.md +666 -0
  184. package/templates/skills/temporal-python-testing/SKILL.md +158 -0
  185. package/templates/skills/temporal-python-testing/resources/integration-testing.md +455 -0
  186. package/templates/skills/temporal-python-testing/resources/local-setup.md +553 -0
  187. package/templates/skills/temporal-python-testing/resources/replay-testing.md +462 -0
  188. package/templates/skills/temporal-python-testing/resources/unit-testing.md +328 -0
  189. package/templates/skills/terraform-module-library/SKILL.md +249 -0
  190. package/templates/skills/terraform-module-library/references/aws-modules.md +63 -0
  191. package/templates/skills/threat-mitigation-mapping/SKILL.md +745 -0
  192. package/templates/skills/track-management/SKILL.md +593 -0
  193. package/templates/skills/typescript-advanced-types/SKILL.md +717 -0
  194. package/templates/skills/ui-ux-pro-max/SKILL.md +352 -0
  195. package/templates/skills/ui-ux-pro-max/data/charts.csv +26 -0
  196. package/templates/skills/ui-ux-pro-max/data/colors.csv +97 -0
  197. package/templates/skills/ui-ux-pro-max/data/icons.csv +101 -0
  198. package/templates/skills/ui-ux-pro-max/data/landing.csv +31 -0
  199. package/templates/skills/ui-ux-pro-max/data/products.csv +97 -0
  200. package/templates/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  201. package/templates/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  202. package/templates/skills/ui-ux-pro-max/data/styles.csv +59 -0
  203. package/templates/skills/ui-ux-pro-max/data/typography.csv +58 -0
  204. package/templates/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  205. package/templates/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  206. package/templates/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  207. package/templates/skills/ui-ux-pro-max/scripts/core.py +258 -0
  208. package/templates/skills/ui-ux-pro-max/scripts/design_system.py +547 -0
  209. package/templates/skills/ui-ux-pro-max/scripts/search.py +76 -0
  210. package/templates/skills/uv-package-manager/SKILL.md +831 -0
  211. package/templates/skills/vector-index-tuning/SKILL.md +521 -0
  212. package/templates/skills/wcag-audit-patterns/SKILL.md +555 -0
  213. package/templates/skills/workflow-orchestration-patterns/SKILL.md +316 -0
  214. package/templates/skills/workflow-patterns/SKILL.md +623 -0
  215. package/templates/agents/game-developer.agent.md +0 -57
  216. package/templates/agents/kubernetes-specialist.agent.md +0 -56
  217. package/templates/agents/market-researcher.agent.md +0 -47
@@ -0,0 +1,400 @@
1
+ ---
2
+ name: git-advanced-workflows
3
+ description: Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.
4
+ ---
5
+
6
+ # Git Advanced Workflows
7
+
8
+ Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.
9
+
10
+ ## When to Use This Skill
11
+
12
+ - Cleaning up commit history before merging
13
+ - Applying specific commits across branches
14
+ - Finding commits that introduced bugs
15
+ - Working on multiple features simultaneously
16
+ - Recovering from Git mistakes or lost commits
17
+ - Managing complex branch workflows
18
+ - Preparing clean PRs for review
19
+ - Synchronizing diverged branches
20
+
21
+ ## Core Concepts
22
+
23
+ ### 1. Interactive Rebase
24
+
25
+ Interactive rebase is the Swiss Army knife of Git history editing.
26
+
27
+ **Common Operations:**
28
+ - `pick`: Keep commit as-is
29
+ - `reword`: Change commit message
30
+ - `edit`: Amend commit content
31
+ - `squash`: Combine with previous commit
32
+ - `fixup`: Like squash but discard message
33
+ - `drop`: Remove commit entirely
34
+
35
+ **Basic Usage:**
36
+ ```bash
37
+ # Rebase last 5 commits
38
+ git rebase -i HEAD~5
39
+
40
+ # Rebase all commits on current branch
41
+ git rebase -i $(git merge-base HEAD main)
42
+
43
+ # Rebase onto specific commit
44
+ git rebase -i abc123
45
+ ```
46
+
47
+ ### 2. Cherry-Picking
48
+
49
+ Apply specific commits from one branch to another without merging entire branches.
50
+
51
+ ```bash
52
+ # Cherry-pick single commit
53
+ git cherry-pick abc123
54
+
55
+ # Cherry-pick range of commits (exclusive start)
56
+ git cherry-pick abc123..def456
57
+
58
+ # Cherry-pick without committing (stage changes only)
59
+ git cherry-pick -n abc123
60
+
61
+ # Cherry-pick and edit commit message
62
+ git cherry-pick -e abc123
63
+ ```
64
+
65
+ ### 3. Git Bisect
66
+
67
+ Binary search through commit history to find the commit that introduced a bug.
68
+
69
+ ```bash
70
+ # Start bisect
71
+ git bisect start
72
+
73
+ # Mark current commit as bad
74
+ git bisect bad
75
+
76
+ # Mark known good commit
77
+ git bisect good v1.0.0
78
+
79
+ # Git will checkout middle commit - test it
80
+ # Then mark as good or bad
81
+ git bisect good # or: git bisect bad
82
+
83
+ # Continue until bug found
84
+ # When done
85
+ git bisect reset
86
+ ```
87
+
88
+ **Automated Bisect:**
89
+ ```bash
90
+ # Use script to test automatically
91
+ git bisect start HEAD v1.0.0
92
+ git bisect run ./test.sh
93
+
94
+ # test.sh should exit 0 for good, 1-127 (except 125) for bad
95
+ ```
96
+
97
+ ### 4. Worktrees
98
+
99
+ Work on multiple branches simultaneously without stashing or switching.
100
+
101
+ ```bash
102
+ # List existing worktrees
103
+ git worktree list
104
+
105
+ # Add new worktree for feature branch
106
+ git worktree add ../project-feature feature/new-feature
107
+
108
+ # Add worktree and create new branch
109
+ git worktree add -b bugfix/urgent ../project-hotfix main
110
+
111
+ # Remove worktree
112
+ git worktree remove ../project-feature
113
+
114
+ # Prune stale worktrees
115
+ git worktree prune
116
+ ```
117
+
118
+ ### 5. Reflog
119
+
120
+ Your safety net - tracks all ref movements, even deleted commits.
121
+
122
+ ```bash
123
+ # View reflog
124
+ git reflog
125
+
126
+ # View reflog for specific branch
127
+ git reflog show feature/branch
128
+
129
+ # Restore deleted commit
130
+ git reflog
131
+ # Find commit hash
132
+ git checkout abc123
133
+ git branch recovered-branch
134
+
135
+ # Restore deleted branch
136
+ git reflog
137
+ git branch deleted-branch abc123
138
+ ```
139
+
140
+ ## Practical Workflows
141
+
142
+ ### Workflow 1: Clean Up Feature Branch Before PR
143
+
144
+ ```bash
145
+ # Start with feature branch
146
+ git checkout feature/user-auth
147
+
148
+ # Interactive rebase to clean history
149
+ git rebase -i main
150
+
151
+ # Example rebase operations:
152
+ # - Squash "fix typo" commits
153
+ # - Reword commit messages for clarity
154
+ # - Reorder commits logically
155
+ # - Drop unnecessary commits
156
+
157
+ # Force push cleaned branch (safe if no one else is using it)
158
+ git push --force-with-lease origin feature/user-auth
159
+ ```
160
+
161
+ ### Workflow 2: Apply Hotfix to Multiple Releases
162
+
163
+ ```bash
164
+ # Create fix on main
165
+ git checkout main
166
+ git commit -m "fix: critical security patch"
167
+
168
+ # Apply to release branches
169
+ git checkout release/2.0
170
+ git cherry-pick abc123
171
+
172
+ git checkout release/1.9
173
+ git cherry-pick abc123
174
+
175
+ # Handle conflicts if they arise
176
+ git cherry-pick --continue
177
+ # or
178
+ git cherry-pick --abort
179
+ ```
180
+
181
+ ### Workflow 3: Find Bug Introduction
182
+
183
+ ```bash
184
+ # Start bisect
185
+ git bisect start
186
+ git bisect bad HEAD
187
+ git bisect good v2.1.0
188
+
189
+ # Git checks out middle commit - run tests
190
+ npm test
191
+
192
+ # If tests fail
193
+ git bisect bad
194
+
195
+ # If tests pass
196
+ git bisect good
197
+
198
+ # Git will automatically checkout next commit to test
199
+ # Repeat until bug found
200
+
201
+ # Automated version
202
+ git bisect start HEAD v2.1.0
203
+ git bisect run npm test
204
+ ```
205
+
206
+ ### Workflow 4: Multi-Branch Development
207
+
208
+ ```bash
209
+ # Main project directory
210
+ cd ~/projects/myapp
211
+
212
+ # Create worktree for urgent bugfix
213
+ git worktree add ../myapp-hotfix hotfix/critical-bug
214
+
215
+ # Work on hotfix in separate directory
216
+ cd ../myapp-hotfix
217
+ # Make changes, commit
218
+ git commit -m "fix: resolve critical bug"
219
+ git push origin hotfix/critical-bug
220
+
221
+ # Return to main work without interruption
222
+ cd ~/projects/myapp
223
+ git fetch origin
224
+ git cherry-pick hotfix/critical-bug
225
+
226
+ # Clean up when done
227
+ git worktree remove ../myapp-hotfix
228
+ ```
229
+
230
+ ### Workflow 5: Recover from Mistakes
231
+
232
+ ```bash
233
+ # Accidentally reset to wrong commit
234
+ git reset --hard HEAD~5 # Oh no!
235
+
236
+ # Use reflog to find lost commits
237
+ git reflog
238
+ # Output shows:
239
+ # abc123 HEAD@{0}: reset: moving to HEAD~5
240
+ # def456 HEAD@{1}: commit: my important changes
241
+
242
+ # Recover lost commits
243
+ git reset --hard def456
244
+
245
+ # Or create branch from lost commit
246
+ git branch recovery def456
247
+ ```
248
+
249
+ ## Advanced Techniques
250
+
251
+ ### Rebase vs Merge Strategy
252
+
253
+ **When to Rebase:**
254
+ - Cleaning up local commits before pushing
255
+ - Keeping feature branch up-to-date with main
256
+ - Creating linear history for easier review
257
+
258
+ **When to Merge:**
259
+ - Integrating completed features into main
260
+ - Preserving exact history of collaboration
261
+ - Public branches used by others
262
+
263
+ ```bash
264
+ # Update feature branch with main changes (rebase)
265
+ git checkout feature/my-feature
266
+ git fetch origin
267
+ git rebase origin/main
268
+
269
+ # Handle conflicts
270
+ git status
271
+ # Fix conflicts in files
272
+ git add .
273
+ git rebase --continue
274
+
275
+ # Or merge instead
276
+ git merge origin/main
277
+ ```
278
+
279
+ ### Autosquash Workflow
280
+
281
+ Automatically squash fixup commits during rebase.
282
+
283
+ ```bash
284
+ # Make initial commit
285
+ git commit -m "feat: add user authentication"
286
+
287
+ # Later, fix something in that commit
288
+ # Stage changes
289
+ git commit --fixup HEAD # or specify commit hash
290
+
291
+ # Make more changes
292
+ git commit --fixup abc123
293
+
294
+ # Rebase with autosquash
295
+ git rebase -i --autosquash main
296
+
297
+ # Git automatically marks fixup commits
298
+ ```
299
+
300
+ ### Split Commit
301
+
302
+ Break one commit into multiple logical commits.
303
+
304
+ ```bash
305
+ # Start interactive rebase
306
+ git rebase -i HEAD~3
307
+
308
+ # Mark commit to split with 'edit'
309
+ # Git will stop at that commit
310
+
311
+ # Reset commit but keep changes
312
+ git reset HEAD^
313
+
314
+ # Stage and commit in logical chunks
315
+ git add file1.py
316
+ git commit -m "feat: add validation"
317
+
318
+ git add file2.py
319
+ git commit -m "feat: add error handling"
320
+
321
+ # Continue rebase
322
+ git rebase --continue
323
+ ```
324
+
325
+ ### Partial Cherry-Pick
326
+
327
+ Cherry-pick only specific files from a commit.
328
+
329
+ ```bash
330
+ # Show files in commit
331
+ git show --name-only abc123
332
+
333
+ # Checkout specific files from commit
334
+ git checkout abc123 -- path/to/file1.py path/to/file2.py
335
+
336
+ # Stage and commit
337
+ git commit -m "cherry-pick: apply specific changes from abc123"
338
+ ```
339
+
340
+ ## Best Practices
341
+
342
+ 1. **Always Use --force-with-lease**: Safer than --force, prevents overwriting others' work
343
+ 2. **Rebase Only Local Commits**: Don't rebase commits that have been pushed and shared
344
+ 3. **Descriptive Commit Messages**: Future you will thank present you
345
+ 4. **Atomic Commits**: Each commit should be a single logical change
346
+ 5. **Test Before Force Push**: Ensure history rewrite didn't break anything
347
+ 6. **Keep Reflog Aware**: Remember reflog is your safety net for 90 days
348
+ 7. **Branch Before Risky Operations**: Create backup branch before complex rebases
349
+
350
+ ```bash
351
+ # Safe force push
352
+ git push --force-with-lease origin feature/branch
353
+
354
+ # Create backup before risky operation
355
+ git branch backup-branch
356
+ git rebase -i main
357
+ # If something goes wrong
358
+ git reset --hard backup-branch
359
+ ```
360
+
361
+ ## Common Pitfalls
362
+
363
+ - **Rebasing Public Branches**: Causes history conflicts for collaborators
364
+ - **Force Pushing Without Lease**: Can overwrite teammate's work
365
+ - **Losing Work in Rebase**: Resolve conflicts carefully, test after rebase
366
+ - **Forgetting Worktree Cleanup**: Orphaned worktrees consume disk space
367
+ - **Not Backing Up Before Experiment**: Always create safety branch
368
+ - **Bisect on Dirty Working Directory**: Commit or stash before bisecting
369
+
370
+ ## Recovery Commands
371
+
372
+ ```bash
373
+ # Abort operations in progress
374
+ git rebase --abort
375
+ git merge --abort
376
+ git cherry-pick --abort
377
+ git bisect reset
378
+
379
+ # Restore file to version from specific commit
380
+ git restore --source=abc123 path/to/file
381
+
382
+ # Undo last commit but keep changes
383
+ git reset --soft HEAD^
384
+
385
+ # Undo last commit and discard changes
386
+ git reset --hard HEAD^
387
+
388
+ # Recover deleted branch (within 90 days)
389
+ git reflog
390
+ git branch recovered-branch abc123
391
+ ```
392
+
393
+ ## Resources
394
+
395
+ - **references/git-rebase-guide.md**: Deep dive into interactive rebase
396
+ - **references/git-conflict-resolution.md**: Advanced conflict resolution strategies
397
+ - **references/git-history-rewriting.md**: Safely rewriting Git history
398
+ - **assets/git-workflow-checklist.md**: Pre-PR cleanup checklist
399
+ - **assets/git-aliases.md**: Useful Git aliases for advanced workflows
400
+ - **scripts/git-clean-branches.sh**: Clean up merged and stale branches
@@ -0,0 +1,333 @@
1
+ ---
2
+ name: github-actions-templates
3
+ description: Create production-ready GitHub Actions workflows for automated testing, building, and deploying applications. Use when setting up CI/CD with GitHub Actions, automating development workflows, or creating reusable workflow templates.
4
+ ---
5
+
6
+ # GitHub Actions Templates
7
+
8
+ Production-ready GitHub Actions workflow patterns for testing, building, and deploying applications.
9
+
10
+ ## Purpose
11
+
12
+ Create efficient, secure GitHub Actions workflows for continuous integration and deployment across various tech stacks.
13
+
14
+ ## When to Use
15
+
16
+ - Automate testing and deployment
17
+ - Build Docker images and push to registries
18
+ - Deploy to Kubernetes clusters
19
+ - Run security scans
20
+ - Implement matrix builds for multiple environments
21
+
22
+ ## Common Workflow Patterns
23
+
24
+ ### Pattern 1: Test Workflow
25
+
26
+ ```yaml
27
+ name: Test
28
+
29
+ on:
30
+ push:
31
+ branches: [ main, develop ]
32
+ pull_request:
33
+ branches: [ main ]
34
+
35
+ jobs:
36
+ test:
37
+ runs-on: ubuntu-latest
38
+
39
+ strategy:
40
+ matrix:
41
+ node-version: [18.x, 20.x]
42
+
43
+ steps:
44
+ - uses: actions/checkout@v4
45
+
46
+ - name: Use Node.js ${{ matrix.node-version }}
47
+ uses: actions/setup-node@v4
48
+ with:
49
+ node-version: ${{ matrix.node-version }}
50
+ cache: 'npm'
51
+
52
+ - name: Install dependencies
53
+ run: npm ci
54
+
55
+ - name: Run linter
56
+ run: npm run lint
57
+
58
+ - name: Run tests
59
+ run: npm test
60
+
61
+ - name: Upload coverage
62
+ uses: codecov/codecov-action@v3
63
+ with:
64
+ files: ./coverage/lcov.info
65
+ ```
66
+
67
+ **Reference:** See `assets/test-workflow.yml`
68
+
69
+ ### Pattern 2: Build and Push Docker Image
70
+
71
+ ```yaml
72
+ name: Build and Push
73
+
74
+ on:
75
+ push:
76
+ branches: [ main ]
77
+ tags: [ 'v*' ]
78
+
79
+ env:
80
+ REGISTRY: ghcr.io
81
+ IMAGE_NAME: ${{ github.repository }}
82
+
83
+ jobs:
84
+ build:
85
+ runs-on: ubuntu-latest
86
+ permissions:
87
+ contents: read
88
+ packages: write
89
+
90
+ steps:
91
+ - uses: actions/checkout@v4
92
+
93
+ - name: Log in to Container Registry
94
+ uses: docker/login-action@v3
95
+ with:
96
+ registry: ${{ env.REGISTRY }}
97
+ username: ${{ github.actor }}
98
+ password: ${{ secrets.GITHUB_TOKEN }}
99
+
100
+ - name: Extract metadata
101
+ id: meta
102
+ uses: docker/metadata-action@v5
103
+ with:
104
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
105
+ tags: |
106
+ type=ref,event=branch
107
+ type=ref,event=pr
108
+ type=semver,pattern={{version}}
109
+ type=semver,pattern={{major}}.{{minor}}
110
+
111
+ - name: Build and push
112
+ uses: docker/build-push-action@v5
113
+ with:
114
+ context: .
115
+ push: true
116
+ tags: ${{ steps.meta.outputs.tags }}
117
+ labels: ${{ steps.meta.outputs.labels }}
118
+ cache-from: type=gha
119
+ cache-to: type=gha,mode=max
120
+ ```
121
+
122
+ **Reference:** See `assets/deploy-workflow.yml`
123
+
124
+ ### Pattern 3: Deploy to Kubernetes
125
+
126
+ ```yaml
127
+ name: Deploy to Kubernetes
128
+
129
+ on:
130
+ push:
131
+ branches: [ main ]
132
+
133
+ jobs:
134
+ deploy:
135
+ runs-on: ubuntu-latest
136
+
137
+ steps:
138
+ - uses: actions/checkout@v4
139
+
140
+ - name: Configure AWS credentials
141
+ uses: aws-actions/configure-aws-credentials@v4
142
+ with:
143
+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
144
+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
145
+ aws-region: us-west-2
146
+
147
+ - name: Update kubeconfig
148
+ run: |
149
+ aws eks update-kubeconfig --name production-cluster --region us-west-2
150
+
151
+ - name: Deploy to Kubernetes
152
+ run: |
153
+ kubectl apply -f k8s/
154
+ kubectl rollout status deployment/my-app -n production
155
+ kubectl get services -n production
156
+
157
+ - name: Verify deployment
158
+ run: |
159
+ kubectl get pods -n production
160
+ kubectl describe deployment my-app -n production
161
+ ```
162
+
163
+ ### Pattern 4: Matrix Build
164
+
165
+ ```yaml
166
+ name: Matrix Build
167
+
168
+ on: [push, pull_request]
169
+
170
+ jobs:
171
+ build:
172
+ runs-on: ${{ matrix.os }}
173
+
174
+ strategy:
175
+ matrix:
176
+ os: [ubuntu-latest, macos-latest, windows-latest]
177
+ python-version: ['3.9', '3.10', '3.11', '3.12']
178
+
179
+ steps:
180
+ - uses: actions/checkout@v4
181
+
182
+ - name: Set up Python
183
+ uses: actions/setup-python@v5
184
+ with:
185
+ python-version: ${{ matrix.python-version }}
186
+
187
+ - name: Install dependencies
188
+ run: |
189
+ python -m pip install --upgrade pip
190
+ pip install -r requirements.txt
191
+
192
+ - name: Run tests
193
+ run: pytest
194
+ ```
195
+
196
+ **Reference:** See `assets/matrix-build.yml`
197
+
198
+ ## Workflow Best Practices
199
+
200
+ 1. **Use specific action versions** (@v4, not @latest)
201
+ 2. **Cache dependencies** to speed up builds
202
+ 3. **Use secrets** for sensitive data
203
+ 4. **Implement status checks** on PRs
204
+ 5. **Use matrix builds** for multi-version testing
205
+ 6. **Set appropriate permissions**
206
+ 7. **Use reusable workflows** for common patterns
207
+ 8. **Implement approval gates** for production
208
+ 9. **Add notification steps** for failures
209
+ 10. **Use self-hosted runners** for sensitive workloads
210
+
211
+ ## Reusable Workflows
212
+
213
+ ```yaml
214
+ # .github/workflows/reusable-test.yml
215
+ name: Reusable Test Workflow
216
+
217
+ on:
218
+ workflow_call:
219
+ inputs:
220
+ node-version:
221
+ required: true
222
+ type: string
223
+ secrets:
224
+ NPM_TOKEN:
225
+ required: true
226
+
227
+ jobs:
228
+ test:
229
+ runs-on: ubuntu-latest
230
+ steps:
231
+ - uses: actions/checkout@v4
232
+ - uses: actions/setup-node@v4
233
+ with:
234
+ node-version: ${{ inputs.node-version }}
235
+ - run: npm ci
236
+ - run: npm test
237
+ ```
238
+
239
+ **Use reusable workflow:**
240
+ ```yaml
241
+ jobs:
242
+ call-test:
243
+ uses: ./.github/workflows/reusable-test.yml
244
+ with:
245
+ node-version: '20.x'
246
+ secrets:
247
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
248
+ ```
249
+
250
+ ## Security Scanning
251
+
252
+ ```yaml
253
+ name: Security Scan
254
+
255
+ on:
256
+ push:
257
+ branches: [ main ]
258
+ pull_request:
259
+ branches: [ main ]
260
+
261
+ jobs:
262
+ security:
263
+ runs-on: ubuntu-latest
264
+
265
+ steps:
266
+ - uses: actions/checkout@v4
267
+
268
+ - name: Run Trivy vulnerability scanner
269
+ uses: aquasecurity/trivy-action@master
270
+ with:
271
+ scan-type: 'fs'
272
+ scan-ref: '.'
273
+ format: 'sarif'
274
+ output: 'trivy-results.sarif'
275
+
276
+ - name: Upload Trivy results to GitHub Security
277
+ uses: github/codeql-action/upload-sarif@v2
278
+ with:
279
+ sarif_file: 'trivy-results.sarif'
280
+
281
+ - name: Run Snyk Security Scan
282
+ uses: snyk/actions/node@master
283
+ env:
284
+ SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
285
+ ```
286
+
287
+ ## Deployment with Approvals
288
+
289
+ ```yaml
290
+ name: Deploy to Production
291
+
292
+ on:
293
+ push:
294
+ tags: [ 'v*' ]
295
+
296
+ jobs:
297
+ deploy:
298
+ runs-on: ubuntu-latest
299
+ environment:
300
+ name: production
301
+ url: https://app.example.com
302
+
303
+ steps:
304
+ - uses: actions/checkout@v4
305
+
306
+ - name: Deploy application
307
+ run: |
308
+ echo "Deploying to production..."
309
+ # Deployment commands here
310
+
311
+ - name: Notify Slack
312
+ if: success()
313
+ uses: slackapi/slack-github-action@v1
314
+ with:
315
+ webhook-url: ${{ secrets.SLACK_WEBHOOK }}
316
+ payload: |
317
+ {
318
+ "text": "Deployment to production completed successfully!"
319
+ }
320
+ ```
321
+
322
+ ## Reference Files
323
+
324
+ - `assets/test-workflow.yml` - Testing workflow template
325
+ - `assets/deploy-workflow.yml` - Deployment workflow template
326
+ - `assets/matrix-build.yml` - Matrix build template
327
+ - `references/common-workflows.md` - Common workflow patterns
328
+
329
+ ## Related Skills
330
+
331
+ - `gitlab-ci-patterns` - For GitLab CI workflows
332
+ - `deployment-pipeline-design` - For pipeline architecture
333
+ - `secrets-management` - For secrets handling