git 4.3.2 → 5.0.0.beta.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 (280) hide show
  1. checksums.yaml +4 -4
  2. data/.github/copilot-instructions.md +67 -2705
  3. data/.github/pull_request_template.md +3 -1
  4. data/.github/skills/breaking-change-analysis/SKILL.md +102 -0
  5. data/.github/skills/ci-cd-troubleshooting/SKILL.md +264 -0
  6. data/.github/skills/command-implementation/REFERENCE.md +993 -0
  7. data/.github/skills/command-implementation/SKILL.md +229 -0
  8. data/.github/skills/command-test-conventions/SKILL.md +660 -0
  9. data/.github/skills/command-yard-documentation/SKILL.md +426 -0
  10. data/.github/skills/dependency-management/SKILL.md +72 -0
  11. data/.github/skills/development-workflow/SKILL.md +506 -0
  12. data/.github/skills/extract-command-from-lib/SKILL.md +487 -0
  13. data/.github/skills/extract-facade-from-base-lib/SKILL.md +586 -0
  14. data/.github/skills/facade-implementation/REFERENCE.md +840 -0
  15. data/.github/skills/facade-implementation/SKILL.md +260 -0
  16. data/.github/skills/facade-test-conventions/SKILL.md +380 -0
  17. data/.github/skills/facade-yard-documentation/SKILL.md +429 -0
  18. data/.github/skills/make-skill-template/SKILL.md +176 -0
  19. data/.github/skills/pr-readiness-review/SKILL.md +185 -0
  20. data/.github/skills/project-context/SKILL.md +313 -0
  21. data/.github/skills/pull-request-review/SKILL.md +168 -0
  22. data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +131 -0
  23. data/.github/skills/release-management/SKILL.md +125 -0
  24. data/.github/skills/review-arguments-dsl/CHECKLIST.md +788 -0
  25. data/.github/skills/review-arguments-dsl/SKILL.md +214 -0
  26. data/.github/skills/review-backward-compatibility/SKILL.md +275 -0
  27. data/.github/skills/review-cross-command-consistency/SKILL.md +139 -0
  28. data/.github/skills/reviewing-skills/SKILL.md +189 -0
  29. data/.github/skills/rspec-unit-testing-standards/SKILL.md +639 -0
  30. data/.github/skills/tdd-refactor-step/SKILL.md +236 -0
  31. data/.github/skills/test-debugging/SKILL.md +160 -0
  32. data/.github/skills/yard-documentation/SKILL.md +793 -0
  33. data/.github/workflows/continuous_integration.yml +3 -2
  34. data/.github/workflows/enforce_conventional_commits.yml +1 -1
  35. data/.github/workflows/experimental_continuous_integration.yml +2 -2
  36. data/.github/workflows/release.yml +3 -4
  37. data/.gitignore +8 -0
  38. data/.husky/pre-commit +13 -0
  39. data/.release-please-manifest.json +1 -1
  40. data/.rspec +3 -0
  41. data/.rubocop.yml +7 -3
  42. data/.rubocop_todo.yml +23 -5
  43. data/.yardopts +1 -0
  44. data/CHANGELOG.md +0 -40
  45. data/CONTRIBUTING.md +694 -53
  46. data/README.md +17 -5
  47. data/Rakefile +61 -9
  48. data/commitlint.test +4 -0
  49. data/git.gemspec +14 -8
  50. data/lib/git/args_builder.rb +0 -8
  51. data/lib/git/base.rb +486 -410
  52. data/lib/git/branch.rb +380 -43
  53. data/lib/git/branch_delete_failure.rb +31 -0
  54. data/lib/git/branch_delete_result.rb +63 -0
  55. data/lib/git/branch_info.rb +178 -0
  56. data/lib/git/branches.rb +130 -24
  57. data/lib/git/command_line/base.rb +245 -0
  58. data/lib/git/command_line/capturing.rb +249 -0
  59. data/lib/git/command_line/result.rb +96 -0
  60. data/lib/git/command_line/streaming.rb +194 -0
  61. data/lib/git/command_line.rb +43 -322
  62. data/lib/git/command_line_result.rb +4 -88
  63. data/lib/git/commands/add.rb +131 -0
  64. data/lib/git/commands/am/abort.rb +43 -0
  65. data/lib/git/commands/am/apply.rb +252 -0
  66. data/lib/git/commands/am/continue.rb +43 -0
  67. data/lib/git/commands/am/quit.rb +43 -0
  68. data/lib/git/commands/am/retry.rb +47 -0
  69. data/lib/git/commands/am/show_current_patch.rb +64 -0
  70. data/lib/git/commands/am/skip.rb +42 -0
  71. data/lib/git/commands/am.rb +33 -0
  72. data/lib/git/commands/apply.rb +237 -0
  73. data/lib/git/commands/archive/list_formats.rb +46 -0
  74. data/lib/git/commands/archive.rb +140 -0
  75. data/lib/git/commands/arguments.rb +3510 -0
  76. data/lib/git/commands/base.rb +403 -0
  77. data/lib/git/commands/branch/copy.rb +94 -0
  78. data/lib/git/commands/branch/create.rb +173 -0
  79. data/lib/git/commands/branch/delete.rb +80 -0
  80. data/lib/git/commands/branch/list.rb +162 -0
  81. data/lib/git/commands/branch/move.rb +94 -0
  82. data/lib/git/commands/branch/set_upstream.rb +86 -0
  83. data/lib/git/commands/branch/show_current.rb +49 -0
  84. data/lib/git/commands/branch/unset_upstream.rb +57 -0
  85. data/lib/git/commands/branch.rb +34 -0
  86. data/lib/git/commands/cat_file/batch.rb +364 -0
  87. data/lib/git/commands/cat_file/filtered.rb +105 -0
  88. data/lib/git/commands/cat_file/raw.rb +210 -0
  89. data/lib/git/commands/cat_file.rb +49 -0
  90. data/lib/git/commands/checkout/branch.rb +151 -0
  91. data/lib/git/commands/checkout/files.rb +115 -0
  92. data/lib/git/commands/checkout.rb +38 -0
  93. data/lib/git/commands/checkout_index.rb +105 -0
  94. data/lib/git/commands/clean.rb +100 -0
  95. data/lib/git/commands/clone.rb +240 -0
  96. data/lib/git/commands/commit.rb +272 -0
  97. data/lib/git/commands/commit_tree.rb +100 -0
  98. data/lib/git/commands/config_option_syntax/add.rb +83 -0
  99. data/lib/git/commands/config_option_syntax/get.rb +117 -0
  100. data/lib/git/commands/config_option_syntax/get_all.rb +115 -0
  101. data/lib/git/commands/config_option_syntax/get_color.rb +91 -0
  102. data/lib/git/commands/config_option_syntax/get_color_bool.rb +93 -0
  103. data/lib/git/commands/config_option_syntax/get_regexp.rb +115 -0
  104. data/lib/git/commands/config_option_syntax/get_urlmatch.rb +102 -0
  105. data/lib/git/commands/config_option_syntax/list.rb +107 -0
  106. data/lib/git/commands/config_option_syntax/remove_section.rb +74 -0
  107. data/lib/git/commands/config_option_syntax/rename_section.rb +78 -0
  108. data/lib/git/commands/config_option_syntax/replace_all.rb +104 -0
  109. data/lib/git/commands/config_option_syntax/set.rb +114 -0
  110. data/lib/git/commands/config_option_syntax/unset.rb +89 -0
  111. data/lib/git/commands/config_option_syntax/unset_all.rb +89 -0
  112. data/lib/git/commands/config_option_syntax.rb +56 -0
  113. data/lib/git/commands/describe.rb +155 -0
  114. data/lib/git/commands/diff.rb +656 -0
  115. data/lib/git/commands/diff_files.rb +518 -0
  116. data/lib/git/commands/diff_index.rb +496 -0
  117. data/lib/git/commands/fetch.rb +352 -0
  118. data/lib/git/commands/fsck.rb +136 -0
  119. data/lib/git/commands/gc.rb +132 -0
  120. data/lib/git/commands/grep.rb +338 -0
  121. data/lib/git/commands/init.rb +99 -0
  122. data/lib/git/commands/log.rb +632 -0
  123. data/lib/git/commands/ls_files.rb +191 -0
  124. data/lib/git/commands/ls_remote.rb +155 -0
  125. data/lib/git/commands/ls_tree.rb +131 -0
  126. data/lib/git/commands/maintenance/register.rb +75 -0
  127. data/lib/git/commands/maintenance/run.rb +104 -0
  128. data/lib/git/commands/maintenance/start.rb +66 -0
  129. data/lib/git/commands/maintenance/stop.rb +55 -0
  130. data/lib/git/commands/maintenance/unregister.rb +79 -0
  131. data/lib/git/commands/maintenance.rb +31 -0
  132. data/lib/git/commands/merge/abort.rb +44 -0
  133. data/lib/git/commands/merge/continue.rb +44 -0
  134. data/lib/git/commands/merge/quit.rb +46 -0
  135. data/lib/git/commands/merge/start.rb +245 -0
  136. data/lib/git/commands/merge.rb +28 -0
  137. data/lib/git/commands/merge_base.rb +86 -0
  138. data/lib/git/commands/mv.rb +77 -0
  139. data/lib/git/commands/name_rev.rb +114 -0
  140. data/lib/git/commands/pull.rb +377 -0
  141. data/lib/git/commands/push.rb +246 -0
  142. data/lib/git/commands/read_tree.rb +149 -0
  143. data/lib/git/commands/remote/add.rb +91 -0
  144. data/lib/git/commands/remote/get_url.rb +66 -0
  145. data/lib/git/commands/remote/list.rb +54 -0
  146. data/lib/git/commands/remote/prune.rb +61 -0
  147. data/lib/git/commands/remote/remove.rb +52 -0
  148. data/lib/git/commands/remote/rename.rb +69 -0
  149. data/lib/git/commands/remote/set_branches.rb +63 -0
  150. data/lib/git/commands/remote/set_head.rb +82 -0
  151. data/lib/git/commands/remote/set_url.rb +71 -0
  152. data/lib/git/commands/remote/set_url_add.rb +61 -0
  153. data/lib/git/commands/remote/set_url_delete.rb +64 -0
  154. data/lib/git/commands/remote/show.rb +71 -0
  155. data/lib/git/commands/remote/update.rb +72 -0
  156. data/lib/git/commands/remote.rb +42 -0
  157. data/lib/git/commands/repack.rb +277 -0
  158. data/lib/git/commands/reset.rb +147 -0
  159. data/lib/git/commands/rev_parse.rb +297 -0
  160. data/lib/git/commands/revert/abort.rb +45 -0
  161. data/lib/git/commands/revert/continue.rb +57 -0
  162. data/lib/git/commands/revert/quit.rb +47 -0
  163. data/lib/git/commands/revert/skip.rb +44 -0
  164. data/lib/git/commands/revert/start.rb +153 -0
  165. data/lib/git/commands/revert.rb +29 -0
  166. data/lib/git/commands/rm.rb +114 -0
  167. data/lib/git/commands/show.rb +632 -0
  168. data/lib/git/commands/show_ref/exclude_existing.rb +120 -0
  169. data/lib/git/commands/show_ref/exists.rb +78 -0
  170. data/lib/git/commands/show_ref/list.rb +145 -0
  171. data/lib/git/commands/show_ref/verify.rb +120 -0
  172. data/lib/git/commands/show_ref.rb +42 -0
  173. data/lib/git/commands/stash/apply.rb +75 -0
  174. data/lib/git/commands/stash/branch.rb +65 -0
  175. data/lib/git/commands/stash/clear.rb +41 -0
  176. data/lib/git/commands/stash/create.rb +58 -0
  177. data/lib/git/commands/stash/drop.rb +67 -0
  178. data/lib/git/commands/stash/list.rb +39 -0
  179. data/lib/git/commands/stash/pop.rb +78 -0
  180. data/lib/git/commands/stash/push.rb +103 -0
  181. data/lib/git/commands/stash/show.rb +149 -0
  182. data/lib/git/commands/stash/store.rb +63 -0
  183. data/lib/git/commands/stash.rb +38 -0
  184. data/lib/git/commands/status.rb +169 -0
  185. data/lib/git/commands/symbolic_ref/delete.rb +68 -0
  186. data/lib/git/commands/symbolic_ref/read.rb +95 -0
  187. data/lib/git/commands/symbolic_ref/update.rb +76 -0
  188. data/lib/git/commands/symbolic_ref.rb +38 -0
  189. data/lib/git/commands/tag/create.rb +139 -0
  190. data/lib/git/commands/tag/delete.rb +55 -0
  191. data/lib/git/commands/tag/list.rb +143 -0
  192. data/lib/git/commands/tag/verify.rb +71 -0
  193. data/lib/git/commands/tag.rb +26 -0
  194. data/lib/git/commands/update_ref/batch.rb +140 -0
  195. data/lib/git/commands/update_ref/delete.rb +92 -0
  196. data/lib/git/commands/update_ref/update.rb +106 -0
  197. data/lib/git/commands/update_ref.rb +42 -0
  198. data/lib/git/commands/version.rb +52 -0
  199. data/lib/git/commands/worktree/add.rb +140 -0
  200. data/lib/git/commands/worktree/list.rb +64 -0
  201. data/lib/git/commands/worktree/lock.rb +58 -0
  202. data/lib/git/commands/worktree/management_base.rb +51 -0
  203. data/lib/git/commands/worktree/move.rb +66 -0
  204. data/lib/git/commands/worktree/prune.rb +67 -0
  205. data/lib/git/commands/worktree/remove.rb +63 -0
  206. data/lib/git/commands/worktree/repair.rb +76 -0
  207. data/lib/git/commands/worktree/unlock.rb +47 -0
  208. data/lib/git/commands/worktree.rb +43 -0
  209. data/lib/git/commands/write_tree.rb +68 -0
  210. data/lib/git/commands.rb +89 -0
  211. data/lib/git/detached_head_info.rb +54 -0
  212. data/lib/git/diff.rb +297 -7
  213. data/lib/git/diff_file_numstat_info.rb +29 -0
  214. data/lib/git/diff_file_patch_info.rb +134 -0
  215. data/lib/git/diff_file_raw_info.rb +127 -0
  216. data/lib/git/diff_info.rb +169 -0
  217. data/lib/git/diff_path_status.rb +78 -19
  218. data/lib/git/diff_result.rb +32 -0
  219. data/lib/git/diff_stats.rb +59 -14
  220. data/lib/git/dirstat_info.rb +86 -0
  221. data/lib/git/errors.rb +65 -2
  222. data/lib/git/execution_context/global.rb +56 -0
  223. data/lib/git/execution_context/repository.rb +147 -0
  224. data/lib/git/execution_context.rb +482 -0
  225. data/lib/git/file_ref.rb +74 -0
  226. data/lib/git/fsck_object.rb +9 -9
  227. data/lib/git/fsck_result.rb +1 -1
  228. data/lib/git/lib.rb +1606 -1028
  229. data/lib/git/log.rb +15 -2
  230. data/lib/git/object.rb +92 -22
  231. data/lib/git/parsers/branch.rb +224 -0
  232. data/lib/git/parsers/cat_file.rb +111 -0
  233. data/lib/git/parsers/diff.rb +585 -0
  234. data/lib/git/parsers/fsck.rb +133 -0
  235. data/lib/git/parsers/grep.rb +42 -0
  236. data/lib/git/parsers/ls_tree.rb +58 -0
  237. data/lib/git/parsers/stash.rb +208 -0
  238. data/lib/git/parsers/tag.rb +257 -0
  239. data/lib/git/remote.rb +133 -9
  240. data/lib/git/repository/branching.rb +572 -0
  241. data/lib/git/repository/committing.rb +191 -0
  242. data/lib/git/repository/configuring.rb +156 -0
  243. data/lib/git/repository/diffing.rb +775 -0
  244. data/lib/git/repository/inspecting.rb +153 -0
  245. data/lib/git/repository/logging.rb +247 -0
  246. data/lib/git/repository/merging.rb +295 -0
  247. data/lib/git/repository/object_operations.rb +1101 -0
  248. data/lib/git/repository/path_resolver.rb +207 -0
  249. data/lib/git/repository/remote_operations.rb +753 -0
  250. data/lib/git/repository/shared_private.rb +51 -0
  251. data/lib/git/repository/staging.rb +390 -0
  252. data/lib/git/repository/stashing.rb +107 -0
  253. data/lib/git/repository/status_operations.rb +180 -0
  254. data/lib/git/repository/worktree_operations.rb +159 -0
  255. data/lib/git/repository.rb +264 -1
  256. data/lib/git/stash.rb +85 -4
  257. data/lib/git/stash_info.rb +104 -0
  258. data/lib/git/stashes.rb +130 -13
  259. data/lib/git/status.rb +224 -18
  260. data/lib/git/tag_delete_failure.rb +31 -0
  261. data/lib/git/tag_delete_result.rb +63 -0
  262. data/lib/git/tag_info.rb +105 -0
  263. data/lib/git/version.rb +109 -2
  264. data/lib/git/version_constraint.rb +81 -0
  265. data/lib/git/worktree.rb +120 -5
  266. data/lib/git/worktrees.rb +107 -7
  267. data/lib/git.rb +114 -18
  268. data/redesign/1_architecture_existing.md +54 -18
  269. data/redesign/2_architecture_redesign.md +365 -46
  270. data/redesign/3_architecture_implementation.md +1451 -54
  271. data/tasks/gem_tasks.rake +4 -0
  272. data/tasks/npm_tasks.rake +7 -0
  273. data/tasks/rspec.rake +48 -0
  274. data/tasks/test.rake +13 -1
  275. data/tasks/yard.rake +34 -7
  276. metadata +349 -20
  277. data/lib/git/index.rb +0 -6
  278. data/lib/git/path.rb +0 -38
  279. data/lib/git/working_directory.rb +0 -6
  280. /data/{release-please-config.json → .release-please-config.json} +0 -0
@@ -0,0 +1,506 @@
1
+ ---
2
+ name: development-workflow
3
+ description: "Follows a strict Test-Driven Development (TDD) workflow with four phases: triage, prepare, execute, and finalize. Use for bug fixes, feature implementation, refactoring, maintenance tasks, and issue triage / diagnosis (triage phase only for diagnosis without implementation)."
4
+ ---
5
+
6
+ # Development Workflow
7
+
8
+ This skill implements a strict Test-Driven Development (TDD) workflow.
9
+
10
+ **This project strictly follows TDD practices. All production code MUST be
11
+ written using the TDD process described below.**
12
+
13
+ ## Contents
14
+
15
+ - [Contents](#contents)
16
+ - [How to use this skill](#how-to-use-this-skill)
17
+ - [Workflow Overview](#workflow-overview)
18
+ - [Core TDD Principles](#core-tdd-principles)
19
+ - [Phase 0: TRIAGE](#phase-0-triage)
20
+ - [Phase 1: PREPARE](#phase-1-prepare)
21
+ - [Phase 2: EXECUTE](#phase-2-execute)
22
+ - [RED-GREEN Step](#red-green-step)
23
+ - [REFACTOR Step](#refactor-step)
24
+ - [VERIFY Step](#verify-step)
25
+ - [COMMIT Step](#commit-step)
26
+ - [REPLAN Step](#replan-step)
27
+ - [Phase 3: FINALIZE](#phase-3-finalize)
28
+ - [Per-Task Commits](#per-task-commits)
29
+ - [Related skills](#related-skills)
30
+ - [Additional Guidelines](#additional-guidelines)
31
+ - [Example TDD Cycle](#example-tdd-cycle)
32
+
33
+ ## How to use this skill
34
+
35
+ Attach this file to your Copilot Chat context, then invoke it when implementing
36
+ features, fixing bugs, refactoring, or maintaining code. Follow phases in order
37
+ and stop after TRIAGE when the issue is non-actionable or needs clarification.
38
+
39
+ ## Workflow Overview
40
+
41
+ When assigned a task involving a GitHub issue, follow this workflow:
42
+
43
+ 1. **Phase 0: TRIAGE** - Understand the issue and determine if action is needed
44
+ 2. **Phase 1: PREPARE** - Set up the environment and plan the implementation
45
+ 3. **Phase 2: EXECUTE** - Implement the solution using TDD
46
+ 4. **Phase 3: FINALIZE** - Squash commits and create the PR
47
+
48
+ **Note:** Not all issues require implementation. Phase 0 may result in requesting
49
+ clarification, confirming the issue is a duplicate, or determining no changes are
50
+ needed.
51
+
52
+ ## Related skills
53
+
54
+ - [RSpec Unit Testing Standards](../rspec-unit-testing-standards/SKILL.md) — RSpec rules for test structure, naming,
55
+ setup patterns, stubbing, and coverage; apply when writing tests during TDD cycles
56
+ - [TDD Refactor Step](../tdd-refactor-step/SKILL.md) — detailed guidance for the
57
+ REFACTOR step: code smells, techniques, test cleanup, and rubocop integration
58
+ - [Test Debugging](../test-debugging/SKILL.md) — focused diagnosis for failing or
59
+ flaky tests
60
+ - [CI/CD Troubleshooting](../ci-cd-troubleshooting/SKILL.md) — workflow for CI
61
+ failures and environment-specific issues
62
+ - [PR Readiness Review](../pr-readiness-review/SKILL.md) — final quality gate
63
+ before opening a pull request
64
+ - [Command Implementation](../command-implementation/SKILL.md) — scaffolding and
65
+ reviewing `Git::Commands::*` classes during implementation
66
+ - [Facade Implementation](../facade-implementation/SKILL.md) — scaffolding and
67
+ reviewing `Git::Repository::*` facade methods during implementation
68
+ - [Extract Command from Lib](../extract-command-from-lib/SKILL.md) — migrating a
69
+ `#command` call in `Git::Lib` into a `Git::Commands::*` class
70
+ - [Extract Facade from Base/Lib](../extract-facade-from-base-lib/SKILL.md) —
71
+ migrating a public method from `Git::Base` / `Git::Lib` into a
72
+ `Git::Repository::*` facade method
73
+
74
+ ## Core TDD Principles
75
+
76
+ Adhere to the following fundamental principles to ensure high code quality and test
77
+ coverage:
78
+
79
+ - **Never Write Production Code without a Failing Test**
80
+ - **Bug Fixes Start with Tests:** Before fixing any bug, write a failing test that
81
+ demonstrates the bug and fails in the expected way. Only then fix the code to make
82
+ the test pass.
83
+ - **Tests Drive Design:** Let the test dictate the API and architecture. If the test
84
+ is hard to write, the design is likely wrong. When this happens, stop and suggest
85
+ one or more design alternatives. Offer to stash any current changes and work on the
86
+ design improvements first before continuing with the original task.
87
+ - **Write Tests Incrementally:** Build tests in small steps, writing just enough to
88
+ get the next expected failure. For example, first write a test that references a
89
+ class that doesn't exist (fails), then define the empty class (passes), then extend
90
+ the test to call a method (fails), then define the method (passes), etc.
91
+ - **Tests Should Be Atomic:** Each test should verify exactly one logical behavior,
92
+ making failures easy to diagnose and understand.
93
+ - **Prefer the Simplest Solution:** Choose the simplest implementation that could
94
+ possibly work, even if it seems naive. Complexity should only be added when driven
95
+ by actual requirements in tests.
96
+ - **No Implementation in Advance:** Only write the code strictly needed to pass the
97
+ current test.
98
+
99
+ ## Phase 0: TRIAGE
100
+
101
+ The purpose of this phase is to understand what the issue is asking for, investigate
102
+ the current state of the codebase, and determine whether implementation is needed.
103
+
104
+ **Use this phase when the user references a GitHub issue number** (e.g., "Fix issue
105
+ \#999", "Implement \#999", "Diagnose issue \#999").
106
+
107
+ 1. **Fetch the Issue:** Use `gh issue view #999` to read the full issue content,
108
+ including description, comments, and labels.
109
+
110
+ 2. **Understand the Request:** Analyze what is being asked:
111
+ - Is this a bug report? Feature request? Question? Documentation issue?
112
+ - Is the issue clear and actionable, or does it need clarification?
113
+ - Are there reproduction steps or examples provided?
114
+
115
+ 3. **Search for Context:** Investigate the codebase to understand the area affected:
116
+ - Use `grep_search` or `semantic_search` to find relevant code
117
+ - Read related test files to understand existing behavior
118
+ - Check if similar functionality already exists
119
+ - Look for related issues or PRs that might be relevant
120
+
121
+ 4. **Reproduce (if applicable):** For bug reports:
122
+ - Try to reproduce the issue based on the provided steps
123
+ - Run existing tests to see if they catch the issue
124
+ - Verify the issue still exists in the current codebase
125
+
126
+ 5. **Determine Next Steps and Report Findings:**
127
+
128
+ **Option A: Issue needs clarification**
129
+ - Comment on the issue using `gh issue comment #999 --body "..."`
130
+ - Ask specific questions about reproduction steps, expected behavior, or use case
131
+ - **STOP here** - wait for user/reporter response before proceeding
132
+
133
+ **Option B: Issue is not actionable (duplicate, won't-fix, already resolved)**
134
+ - Comment on the issue explaining your findings
135
+ - Suggest closing the issue or linking to related issues
136
+ - **STOP here** - no implementation needed
137
+
138
+ **Option C: Issue is clear and actionable**
139
+ - Comment on the issue confirming you understand the request and plan to implement
140
+ - Summarize your understanding and proposed approach
141
+ - **Proceed to Phase 1: PREPARE** to begin implementation
142
+
143
+ **Option D: User asked only to diagnose (not implement)**
144
+ - Comment on the issue with your diagnostic findings
145
+ - Explain what you discovered (root cause, affected code, potential solutions)
146
+ - **STOP here** - wait for confirmation to proceed with implementation
147
+
148
+ **GitHub CLI Commands for Phase 0:**
149
+
150
+ - View issue: `gh issue view #999`
151
+ - View with comments: `gh issue view #999 --comments`
152
+ - Comment on issue: `gh issue comment #999 --body "Your comment here"`
153
+ - Search issues: `gh issue list --search "keyword"`
154
+
155
+ ## Phase 1: PREPARE
156
+
157
+ The purpose of this phase is to ensure the project environment is ready, establish a
158
+ clean baseline, and create a clear implementation plan before writing any code.
159
+
160
+ **Only proceed to this phase if Phase 0 determined that implementation is needed.**
161
+
162
+ 1. **Check Uncommitted Changes:** If there are any uncommitted changes in the
163
+ project, ask the user what to do with them before continuing: include them in the
164
+ current implementation plan, ignore them, or stash them before continuing.
165
+ 2. **Create Feature Branch:** Create a new branch from `origin/main` using the naming
166
+ convention `<type>/<short-description>` (e.g., `fix/issue-999`).
167
+ 3. **Verify Project Setup:** Run `bin/setup` to ensure that the project is ready
168
+ for development.
169
+ 4. **Verify Clean Baseline:** Ensure that all existing tests and linters pass by
170
+ running `bundle exec rake default`.
171
+ 5. **Analyze and Plan:** Understand the requirements, identify edge cases and
172
+ potential challenges, and break the work into small, isolated tasks. Consider what
173
+ tests will be needed and in what order they should be written.
174
+ 6. **Consider Refactoring:** Look for ways to make the implementation of the feature
175
+ or bug fix easier by performing one or more refactorings. If any are found,
176
+ suggest them to the user. If the user confirms the refactoring, do the refactoring
177
+ in a separate TDD process. Only once the refactoring is completed should the
178
+ current feature or bug fix be worked on.
179
+ 7. **Review Implementation Guidelines:** When implementing or modifying git command
180
+ wrappers, read the "Wrapping a git command" section in CONTRIBUTING.md before
181
+ proceeding. This ensures consistent API design
182
+ for method placement, naming, parameters, and output processing.
183
+
184
+ ## Phase 2: EXECUTE
185
+
186
+ The purpose of this phase is to implement each planned task using strict TDD cycles,
187
+ ensuring every line of production code is driven by a failing test.
188
+
189
+ Execute each task by repeating the following cycle of steps until all tasks are
190
+ complete:
191
+
192
+ 1. **RED-GREEN:** Write failing tests and implement code to make them pass
193
+ 2. **REFACTOR:** Improve code quality and design without changing behavior
194
+ 3. **VERIFY:** Confirm the task is complete and code meets quality standards
195
+ 4. **COMMIT:** Create a commit for the completed task
196
+ 5. **REPLAN:** Review the implementation plan, then return to step 1 for the next
197
+ task
198
+
199
+ When all tasks are complete, proceed to **Phase 3: FINALIZE**.
200
+
201
+ ### RED-GREEN Step
202
+
203
+ 1. **RED Substep**
204
+
205
+ The purpose of this substep is to write a failing test that you hypothesize will
206
+ pass with the next incremental bit of task implementation.
207
+
208
+ - **Write the Test:** Write a single, focused, failing test or extend an existing
209
+ test for the current task.
210
+ - **Keep It Minimal:** Only write enough of a test to get an expected, failing
211
+ result (the test should fail for the *right* reason).
212
+ - **Execute and Analyze:** Run the specific test file (e.g.,
213
+ `bundle exec rspec spec/unit/git/commands/<command>_spec.rb` for RSpec or
214
+ `bundle exec bin/test <test_file>` for TestUnit) and analyze the output.
215
+ - **Confirm Expected Failure:** Confirm it fails with an expected error (e.g.,
216
+ assertion failure or missing definition).
217
+ - **Validate:** If the test passes without implementation, the test is invalid or
218
+ the logic already exists. When that happens, revise or skip.
219
+
220
+ 2. **GREEN Substep**
221
+
222
+ The purpose of this substep is to write just enough production code to make the
223
+ failing test(s) pass.
224
+
225
+ - **Write Minimal Code:** Write the minimum amount of code required to make the
226
+ test pass.
227
+ - **Use Simple Solutions:** It is acceptable to use hardcoded values or "quick and
228
+ dirty" logic here just to get to green, even if this means intentionally writing
229
+ clearly suboptimal code that you will improve during the REFACTOR step.
230
+ - **No Premature Optimization:** Do NOT optimize, clean up, or improve code style
231
+ during GREEN—that work belongs in the REFACTOR step.
232
+ - **Execute and Verify:** Run the specific test file
233
+ - **If the test passes**, proceed to the REFACTOR step
234
+ - **If the test fails**, read the FULL error output including the stack trace.
235
+ Identify the exact failing line and assertion before modifying any code. Fix
236
+ only what the error indicates, then re-run. Repeat until the test passes.
237
+ - **Rollback on Repeated Failure:** If the test cannot be made to pass within 3
238
+ attempts, revert all changes from this RED-GREEN cycle, report the issue to the
239
+ user, and ask for guidance before proceeding.
240
+ - **Stay Focused:** Do not implement future features or optimizations yet.
241
+
242
+ ### REFACTOR Step
243
+
244
+ The purpose of this step is to improve code quality and design without changing
245
+ behavior, ensuring the codebase remains clean and maintainable.
246
+
247
+ **You must consider refactoring before starting the next task.** Remove duplication,
248
+ improve variable names, and apply design patterns. Skip this step only if the code is
249
+ already clean and simple—avoid over-engineering.
250
+
251
+ For detailed guidance on code smells, refactoring techniques, test cleanup, and
252
+ rubocop integration, see the
253
+ [TDD Refactor Step](../tdd-refactor-step/SKILL.md) skill.
254
+
255
+ - **Generalize the Implementation:** Ensure the code solves the general case, not
256
+ just the specific test case. Replace hardcoded values used to pass the test with
257
+ actual logic.
258
+ - **Limit Scope:** Do not perform refactorings that affect files outside the
259
+ immediate scope of the current task. If a broader refactor is needed, add it to the
260
+ task list during the REPLAN step as a separate task.
261
+ - **Execute All Tests:** Run `bundle exec rake default` and verify they still pass.
262
+ - **Verify Test Independence:** Verify tests can run independently in any order.
263
+ - **Confirm Improvement:** Ensure the refactoring made the code clearer, simpler, or
264
+ more maintainable.
265
+
266
+ ### VERIFY Step
267
+
268
+ The purpose of this step is to confirm that the current task is fully complete before
269
+ moving to the next task.
270
+
271
+ - **Confirm Implementation Complete:** Verify all functionality for the task is
272
+ implemented.
273
+ - **Run All Tests:** Run `bundle exec rspec` and `bundle exec rake test` to ensure
274
+ all tests pass.
275
+ - **Run Linters:** Run `bundle exec rubocop` and `bundle exec rake yard` to verify
276
+ code style and documentation standards.
277
+ - **Check Code Quality:** Confirm the code is clean and well-factored.
278
+ - **Audit Command Tests (command tasks only):** If this task added or modified tests
279
+ for any `Git::Commands::*` class, apply the
280
+ [Command Test Conventions](../command-test-conventions/SKILL.md) skill to every new or
281
+ changed spec file before committing. Fix any violations found before moving to the
282
+ COMMIT step.
283
+ - **Audit Command YARD Docs (command tasks only):** If this task added or modified
284
+ any `Git::Commands::*` source file, apply the
285
+ [Command YARD Documentation](../command-yard-documentation/SKILL.md)
286
+ skill to each changed source file. Fix any documentation gaps before committing.
287
+ - **STOP on Unexpected Failure:** If any test unexpectedly fails during VERIFY, STOP
288
+ immediately and report the failure to the user. Do not attempt to fix the failure
289
+ without first explaining what went wrong and getting confirmation to proceed.
290
+
291
+ ### COMMIT Step
292
+
293
+ The purpose of this step is to create a checkpoint after successfully completing a
294
+ task, providing a safe rollback point.
295
+
296
+ - **Create Commit:** Commit all changes from this task using the appropriate
297
+ conventional commit type (see the **Per-Task Commits** section below for guidance).
298
+ - **Keep Commits Atomic:** Each commit should represent one completed task with all
299
+ tests passing and linters clean.
300
+
301
+ ### REPLAN Step
302
+
303
+ The purpose of this step is to review progress and adjust the implementation plan
304
+ based on what was learned during the current task.
305
+
306
+ - **Review Implementation Plan:** Assess whether the remaining tasks are still valid
307
+ and appropriately scoped based on what was learned.
308
+ - **Identify New Tasks:** If the implementation revealed new requirements, edge
309
+ cases, or necessary refactorings, add them to the task list.
310
+ - **Reprioritize if Needed:** Adjust task order if dependencies or priorities have
311
+ changed.
312
+ - **Sync Redesign Tracker (required for command migrations):** If the task adds,
313
+ migrates, or rewires any `Git::Commands::*` usage, update
314
+ `redesign/3_architecture_implementation.md` in the same task commit:
315
+ - mark migrated command checklist entries (`[ ]` → `[x]`)
316
+ - update Phase 2 migrated count in the Progress Tracker
317
+ - update "Next Task" to the next unchecked command in list order
318
+ - ensure command spec paths use `spec/unit/...` or `spec/integration/...` (never
319
+ stale `spec/git/...` paths)
320
+ - run a stale-doc sanity check by comparing unchecked `Git::Commands::*` entries
321
+ against files under `lib/git/commands/`; resolve any mismatches before moving on
322
+ - **Report Progress:** Briefly summarize what was completed and what remains.
323
+ **ALWAYS** print the updated task list with status (e.g., `[x] Task 1`, `[ ] Task
324
+ 2`).
325
+ - **Continue or Complete:** If tasks remain, return to RED-GREEN for the next task.
326
+ If all tasks are complete, proceed to **Phase 3: FINALIZE**.
327
+
328
+ ## Phase 3: FINALIZE
329
+
330
+ The purpose of this phase is to consolidate all task commits into a single, clean
331
+ commit and complete the feature or bug fix.
332
+
333
+ 1. **Run Final Verification:** Run `bundle exec rake default` one final time to
334
+ ensure everything passes.
335
+ 2. **Safety Check:** Run `git log --oneline HEAD~N..HEAD` (where N is the number of
336
+ task commits) to list the commits included in the squash. Verify these are
337
+ strictly the commits generated during the current session. If unexpected commits
338
+ appear, STOP and ask the user for the correct value of N.
339
+ 3. **Capture Commit Messages:** Run `git log --format="- %s" HEAD~N..HEAD` to capture
340
+ individual commit messages for inclusion in the final commit body.
341
+ 4. **Draft the Squash Message:** Prepare a commit message with:
342
+ - **Subject:** A single line summarizing the entire feature or fix (e.g.,
343
+ `feat(branch): add Branch#create method`)
344
+ - **Body:** A summary of what was implemented, the captured commit messages from
345
+ step 2, key decisions made, and any relevant context. Wrap lines at 100
346
+ characters.
347
+ 5. **Propose the Squash:** Present the drafted message and the commands to squash to
348
+ the user:
349
+ - `git reset --soft HEAD~N` (where N is the number of task commits)
350
+ - `git commit -m "<drafted message>"`
351
+ 6. **Wait for Confirmation:** Do NOT execute the squash until the user reviews the
352
+ commits and confirms. The user may want to adjust the message or keep some commits
353
+ separate.
354
+ 7. **Execute on Confirmation:** Once confirmed, run `git reset --soft HEAD~N` to
355
+ unstage the task commits while preserving all changes, then commit with the
356
+ approved message.
357
+ 8. **Handle Commit Hook Failure:** If the commit fails due to a `commit-msg` hook
358
+ rejection (e.g., commitlint error):
359
+ - Read the error message carefully to identify the formatting issue.
360
+ - To validate a message file before committing:
361
+ ```bash
362
+ npx commitlint --format @commitlint/format < commit_msg.txt
363
+ ```
364
+ - To diagnose *why* a message is rejected (e.g., unexpected body/footer split),
365
+ inspect how the parser tokenizes it:
366
+ ```bash
367
+ cat commit_msg.txt | node -e "
368
+ const parse = require('@commitlint/parse');
369
+ let msg = '';
370
+ process.stdin.on('data', d => msg += d);
371
+ process.stdin.on('end', () =>
372
+ parse.default(msg.trim()).then(r => console.log(JSON.stringify(r, null, 2)))
373
+ );
374
+ " | jq
375
+ ```
376
+ - Fix the commit message to comply with the project's commit conventions.
377
+ - Retry the commit. The changes remain staged after a hook failure, so only the
378
+ `git commit` command needs to be re-run.
379
+ - If the commit fails 3 times, STOP and report the issue to the user with the
380
+ exact error message.
381
+ 9. **Create the Pull Request:** Push the branch and open the PR. **CRITICAL:** The
382
+ terminal tool mangles multi-line markdown (backticks, asterisks, newlines) in any
383
+ shell command — including heredocs and inline `--body "..."` arguments. Always
384
+ write the PR body using the **`create_file` tool** (not the terminal), then
385
+ reference that file:
386
+ - Use `create_file` to write the body to `./pr_body.md` (repo-relative path,
387
+ works on all platforms)
388
+ - Then run in the terminal: `git push origin <branch>`
389
+ - Then run in the terminal: `gh pr create --title "<title>" --base <target-branch> --body-file ./pr_body.md`
390
+ (choose `main` or `4.x` per the [branch strategy](/CONTRIBUTING.md))
391
+
392
+ After creating the PR, verify the stored body with
393
+ `gh pr view <number> --json body --jq '.body'`. If it is garbled, rewrite
394
+ `./pr_body.md` with `create_file` and fix with
395
+ `gh pr edit <number> --body-file ./pr_body.md`.
396
+
397
+
398
+ ### Per-Task Commits
399
+
400
+ In the COMMIT step, create a commit for the completed task following these
401
+ guidelines:
402
+
403
+ - **Use Appropriate Types:**
404
+ - `test:` for adding or modifying tests (RED step)
405
+ - `feat:` for new **user-facing** functionality (triggers MINOR version bump)
406
+ - `fix:` for bug fixes (GREEN step for bugs)
407
+ - `refactor:` for code improvements without behavior change
408
+ - `chore:` for internal tooling or maintenance
409
+ - **Use Scope When Relevant:** Include a scope to indicate the affected component
410
+ (e.g., `feat(branch):`, `test(remote):`).
411
+ - **Write Clear Subjects:** Use imperative mood, lowercase, no period (e.g.,
412
+ `feat(branch): add create method`).
413
+ - **Issue and PR References in the Body:** Do not use `#<number>` in the commit
414
+ body — write `issue 1000` not `issue #1000`. A commitlint parser flaw treats
415
+ any line containing `#<number>` as a footer token, permanently breaking the
416
+ body/footer split for all subsequent lines.
417
+ - To **close** an issue/PR, use `Closes`/`Fixes`/`Resolves` with `#` in the
418
+ footer — e.g. `Closes #1000`.
419
+ - To **mention** an issue for context only, omit the `#` in the body and no
420
+ footer line is needed.
421
+
422
+ ## Additional Guidelines
423
+
424
+ These guidelines supplement the TDD process:
425
+
426
+ - **Justify Test Modifications:** If an existing test needs to be modified, STOP and
427
+ report to the user before making the change. Explain which test needs modification,
428
+ why the expected behavior is changing, and whether this represents a breaking
429
+ change. Wait for user confirmation before proceeding.
430
+ - **Unrelated Test Failures:** If you need to modify a test file that is not related
431
+ to the current task to make the build pass, STOP and report to the user. This
432
+ usually indicates a deeper regression, environment issue, or flawed assumption. Do
433
+ not attempt to fix unrelated tests without user guidance.
434
+ - **Handle Discovered Complexity:** If the implementation reveals a complex logic
435
+ gap, add it to your task list but finish the current cycle first.
436
+ - **Test Names Describe Behavior:** Name tests to clearly describe what behavior they
437
+ verify (e.g., `test_creates_new_branch` not `test_branch`).
438
+ - **Ask for Clarification:** Stop and ask for clarification if requirements or
439
+ expectations are ambiguous.
440
+ - **Do NOT Update CHANGELOG.md:** The CHANGELOG is auto-generated from commit
441
+ messages. Never edit it manually.
442
+ - **Bulk File Text Substitutions:** When renaming classes, methods, or files across
443
+ many files simultaneously, avoid complex chained `sed` commands — the terminal tool
444
+ can mangle multi-pattern substitutions with non-trivial quoting or multi-line
445
+ heredocs. Instead, write the substitution logic to a temporary Ruby script and
446
+ execute it:
447
+
448
+ ```ruby
449
+ # tmp_rename.rb
450
+ files = Dir.glob('lib/**/*.rb') +
451
+ Dir.glob('spec/**/*.rb') +
452
+ Dir.glob('tests/**/*.rb')
453
+ files.each do |f|
454
+ src = File.read(f)
455
+ # Apply most-specific patterns first to avoid partial matches
456
+ new_src = src
457
+ .gsub('OldClassName', 'NewClassName')
458
+ .gsub("require_relative 'old_path'", "require_relative 'new_path'")
459
+ File.write(f, new_src) if new_src != src
460
+ end
461
+ ```
462
+
463
+ Run the script, then delete it:
464
+
465
+ ```
466
+ ruby tmp_rename.rb
467
+ rm tmp_rename.rb # macOS/Linux
468
+ del tmp_rename.rb # Windows (cmd)
469
+ Remove-Item tmp_rename.rb # Windows (PowerShell)
470
+ ```
471
+
472
+ Apply substitutions from most-specific to least-specific to prevent partial
473
+ matches (e.g., replace `FooBarBaz` before `FooBar`).
474
+
475
+ ## Example TDD Cycle
476
+
477
+ Each task follows this cycle: **RED → GREEN → REFACTOR → VERIFY → COMMIT → REPLAN**
478
+
479
+ **RED:** Write a failing test that describes the desired behavior.
480
+
481
+ ```ruby
482
+ def test_creates_new_branch
483
+ @git.branch('feature').create
484
+ assert @git.branches.local.map(&:name).include?('feature')
485
+ end
486
+ # Run: bundle exec bin/test test_branch → fails with NoMethodError
487
+ ```
488
+
489
+ **GREEN:** Write minimal code to make the test pass.
490
+
491
+ ```ruby
492
+ def create
493
+ @base.lib.branch_new(@name)
494
+ end
495
+ # Run: bundle exec bin/test test_branch → passes
496
+ ```
497
+
498
+ **REFACTOR:** Improve code quality without changing behavior, then run all tests.
499
+
500
+ **VERIFY:** Run `bundle exec rake default` to confirm tests and linters pass.
501
+
502
+ **COMMIT:** `git commit -m "feat(branch): add Branch#create method"`
503
+
504
+ **REPLAN:** Report progress, update task list, proceed to next task or FINALIZE.
505
+
506
+ **FINALIZE (after all tasks):** Propose squash commit with captured messages, wait