codeforge-dev 1.5.8 → 1.8.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 (176) hide show
  1. package/.devcontainer/.env +4 -5
  2. package/.devcontainer/.env.example +29 -0
  3. package/.devcontainer/.gitignore +8 -0
  4. package/.devcontainer/.secrets.example +12 -0
  5. package/.devcontainer/CHANGELOG.md +186 -0
  6. package/.devcontainer/CLAUDE.md +108 -21
  7. package/.devcontainer/README.md +173 -57
  8. package/.devcontainer/config/defaults/keybindings.json +5 -0
  9. package/.devcontainer/config/{main-system-prompt.md → defaults/main-system-prompt.md} +135 -2
  10. package/.devcontainer/config/{settings.json → defaults/settings.json} +25 -6
  11. package/.devcontainer/config/file-manifest.json +20 -0
  12. package/.devcontainer/devcontainer.json +38 -2
  13. package/.devcontainer/docs/configuration-reference.md +90 -0
  14. package/.devcontainer/docs/keybindings.md +100 -0
  15. package/.devcontainer/docs/optional-features.md +129 -0
  16. package/.devcontainer/docs/plugins.md +154 -0
  17. package/.devcontainer/docs/troubleshooting.md +128 -0
  18. package/.devcontainer/features/README.md +21 -7
  19. package/.devcontainer/features/agent-browser/install.sh +6 -0
  20. package/.devcontainer/features/ast-grep/install.sh +6 -0
  21. package/.devcontainer/features/biome/README.md +27 -0
  22. package/.devcontainer/features/biome/install.sh +6 -0
  23. package/.devcontainer/features/ccburn/README.md +60 -0
  24. package/.devcontainer/features/ccburn/devcontainer-feature.json +38 -0
  25. package/.devcontainer/features/ccburn/install.sh +180 -0
  26. package/.devcontainer/features/ccstatusline/README.md +22 -21
  27. package/.devcontainer/features/ccstatusline/devcontainer-feature.json +6 -1
  28. package/.devcontainer/features/ccstatusline/install.sh +55 -16
  29. package/.devcontainer/features/ccusage/install.sh +6 -0
  30. package/.devcontainer/features/claude-monitor/install.sh +6 -0
  31. package/.devcontainer/features/dprint/README.md +30 -0
  32. package/.devcontainer/features/dprint/devcontainer-feature.json +18 -0
  33. package/.devcontainer/features/dprint/install.sh +131 -0
  34. package/.devcontainer/features/hadolint/README.md +35 -0
  35. package/.devcontainer/features/hadolint/devcontainer-feature.json +13 -0
  36. package/.devcontainer/features/hadolint/install.sh +86 -0
  37. package/.devcontainer/features/lsp-servers/devcontainer-feature.json +5 -0
  38. package/.devcontainer/features/lsp-servers/install.sh +7 -0
  39. package/.devcontainer/features/mcp-qdrant/devcontainer-feature.json +6 -1
  40. package/.devcontainer/features/mcp-qdrant/install.sh +13 -6
  41. package/.devcontainer/features/mcp-reasoner/devcontainer-feature.json +6 -1
  42. package/.devcontainer/features/mcp-reasoner/install.sh +8 -1
  43. package/.devcontainer/features/notify-hook/devcontainer-feature.json +5 -0
  44. package/.devcontainer/features/notify-hook/install.sh +7 -0
  45. package/.devcontainer/features/ruff/README.md +26 -0
  46. package/.devcontainer/features/ruff/devcontainer-feature.json +21 -0
  47. package/.devcontainer/features/ruff/install.sh +74 -0
  48. package/.devcontainer/features/shellcheck/README.md +38 -0
  49. package/.devcontainer/features/shellcheck/devcontainer-feature.json +13 -0
  50. package/.devcontainer/features/shellcheck/install.sh +24 -0
  51. package/.devcontainer/features/shfmt/README.md +37 -0
  52. package/.devcontainer/features/shfmt/devcontainer-feature.json +13 -0
  53. package/.devcontainer/features/shfmt/install.sh +85 -0
  54. package/.devcontainer/features/splitrail/devcontainer-feature.json +5 -0
  55. package/.devcontainer/features/splitrail/install.sh +7 -0
  56. package/.devcontainer/features/tmux/install.sh +8 -0
  57. package/.devcontainer/features/tree-sitter/install.sh +6 -0
  58. package/.devcontainer/plugins/devs-marketplace/.claude-plugin/marketplace.json +3 -10
  59. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/.claude-plugin/plugin.json +1 -1
  60. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/__pycache__/format-on-stop.cpython-314.pyc +0 -0
  61. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/format-on-stop.py +133 -13
  62. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/.claude-plugin/plugin.json +1 -1
  63. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/hooks/hooks.json +4 -5
  64. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/__pycache__/lint-file.cpython-314.pyc +0 -0
  65. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/lint-file.py +477 -78
  66. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/.claude-plugin/plugin.json +1 -1
  67. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/AGENT-REDIRECTION.md +226 -0
  68. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/REVIEW-RUBRIC.md +440 -0
  69. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/architect.md +207 -0
  70. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/bash-exec.md +173 -0
  71. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/claude-guide.md +146 -0
  72. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/debug-logs.md +2 -0
  73. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/dependency-analyst.md +250 -0
  74. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/doc-writer.md +246 -0
  75. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/explorer.md +237 -0
  76. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/generalist.md +134 -0
  77. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/git-archaeologist.md +242 -0
  78. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/migrator.md +201 -0
  79. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/perf-profiler.md +265 -0
  80. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/refactorer.md +213 -0
  81. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/researcher.md +195 -0
  82. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/security-auditor.md +289 -0
  83. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/spec-writer.md +297 -0
  84. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/statusline-config.md +188 -0
  85. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/test-writer.md +248 -0
  86. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/hooks/hooks.json +51 -0
  87. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/advisory-test-runner.cpython-314.pyc +0 -0
  88. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/collect-edited-files.cpython-314.pyc +0 -0
  89. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/commit-reminder.cpython-314.pyc +0 -0
  90. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/git-state-injector.cpython-314.pyc +0 -0
  91. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/guard-readonly-bash.cpython-314.pyc +0 -0
  92. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/redirect-builtin-agents.cpython-314.pyc +0 -0
  93. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/skill-suggester.cpython-314.pyc +0 -0
  94. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/syntax-validator.cpython-314.pyc +0 -0
  95. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/ticket-linker.cpython-314.pyc +0 -0
  96. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/todo-harvester.cpython-314.pyc +0 -0
  97. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/verify-no-regression.cpython-314.pyc +0 -0
  98. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/verify-tests-pass.cpython-314.pyc +0 -0
  99. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/advisory-test-runner.py +174 -0
  100. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/collect-edited-files.py +8 -6
  101. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/commit-reminder.py +90 -0
  102. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/git-state-injector.py +114 -0
  103. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/guard-readonly-bash.py +611 -0
  104. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/redirect-builtin-agents.py +83 -0
  105. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/skill-suggester.py +146 -2
  106. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/syntax-validator.py +9 -4
  107. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/ticket-linker.py +137 -0
  108. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/todo-harvester.py +130 -0
  109. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/verify-no-regression.py +221 -0
  110. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/verify-tests-pass.py +176 -0
  111. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/SKILL.md +224 -0
  112. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/references/error-handling.md +166 -0
  113. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/references/rest-conventions.md +215 -0
  114. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/ast-grep-patterns/SKILL.md +211 -0
  115. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/ast-grep-patterns/references/language-patterns.md +327 -0
  116. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/claude-agent-sdk/SKILL.md +599 -0
  117. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/claude-agent-sdk/references/sdk-typescript-reference.md +954 -0
  118. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/SKILL.md +134 -0
  119. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/references/ecosystem-commands.md +264 -0
  120. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/references/license-compliance.md +80 -0
  121. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/SKILL.md +153 -0
  122. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/references/api-doc-templates.md +221 -0
  123. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/references/docstring-formats.md +296 -0
  124. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/git-forensics/SKILL.md +276 -0
  125. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/git-forensics/references/advanced-commands.md +332 -0
  126. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/git-forensics/references/investigation-playbooks.md +319 -0
  127. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/SKILL.md +150 -0
  128. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/references/javascript-migrations.md +179 -0
  129. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/references/python-migrations.md +141 -0
  130. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/performance-profiling/SKILL.md +341 -0
  131. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/performance-profiling/references/interpreting-results.md +235 -0
  132. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/performance-profiling/references/tool-commands.md +395 -0
  133. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/refactoring-patterns/SKILL.md +344 -0
  134. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/refactoring-patterns/references/safe-transformations.md +247 -0
  135. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/refactoring-patterns/references/smell-catalog.md +332 -0
  136. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/security-checklist/SKILL.md +277 -0
  137. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/security-checklist/references/owasp-patterns.md +269 -0
  138. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/security-checklist/references/secrets-patterns.md +253 -0
  139. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/specification-writing/SKILL.md +320 -0
  140. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/specification-writing/references/criteria-patterns.md +245 -0
  141. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/specification-writing/references/ears-templates.md +239 -0
  142. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/__pycache__/block-dangerous.cpython-314.pyc +0 -0
  143. package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/hooks/hooks.json +1 -1
  144. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/__pycache__/guard-protected.cpython-314.pyc +0 -0
  145. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/guard-protected.py +40 -39
  146. package/.devcontainer/scripts/check-setup.sh +72 -0
  147. package/.devcontainer/scripts/setup-aliases.sh +51 -6
  148. package/.devcontainer/scripts/setup-auth.sh +74 -0
  149. package/.devcontainer/scripts/setup-config.sh +112 -20
  150. package/.devcontainer/scripts/setup-plugins.sh +38 -46
  151. package/.devcontainer/scripts/setup-projects.sh +175 -0
  152. package/.devcontainer/scripts/setup-symlink-claude.sh +36 -0
  153. package/.devcontainer/scripts/setup-update-claude.sh +19 -8
  154. package/.devcontainer/scripts/setup.sh +49 -14
  155. package/README.md +23 -190
  156. package/package.json +1 -1
  157. package/setup.js +245 -71
  158. package/.devcontainer/features/claude-code/README.md +0 -498
  159. package/.devcontainer/features/claude-code/config/settings.json +0 -36
  160. package/.devcontainer/features/claude-code/config/system-prompt.md +0 -118
  161. package/.devcontainer/features/claude-code/config/world-building-sp.md +0 -1432
  162. package/.devcontainer/features/claude-code/devcontainer-feature.json +0 -42
  163. package/.devcontainer/features/claude-code/install.sh +0 -466
  164. package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/.claude-plugin/plugin.json +0 -7
  165. package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/hooks/hooks.json +0 -17
  166. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/.claude-plugin/plugin.json +0 -6
  167. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/config/planning-instructions.md +0 -14
  168. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/functional-conjuring-map.md +0 -989
  169. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/hooks/hooks.json +0 -33
  170. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/__pycache__/post-enhance-task.cpython-314.pyc +0 -0
  171. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhance-planning.py +0 -71
  172. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-plan.sh +0 -68
  173. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-task.sh +0 -120
  174. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-plan.py +0 -133
  175. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-task.py +0 -253
  176. package/.devcontainer/scripts/setup-irie-claude.sh +0 -32
@@ -0,0 +1,319 @@
1
+ # Git Investigation Playbooks
2
+
3
+ Step-by-step playbooks for common git forensic investigations.
4
+
5
+ ## Contents
6
+
7
+ - [Playbook 1: Finding When a Bug Was Introduced](#playbook-1-finding-when-a-bug-was-introduced)
8
+ - [Playbook 2: Finding Deleted Code](#playbook-2-finding-deleted-code)
9
+ - [Playbook 3: Tracing a Line's History](#playbook-3-tracing-a-lines-history)
10
+ - [Playbook 4: Recovering Lost Work](#playbook-4-recovering-lost-work)
11
+ - [Playbook 5: Identifying Hot Spots and Code Ownership](#playbook-5-identifying-hot-spots-and-code-ownership)
12
+ - [Playbook 6: Understanding a Complex Merge Conflict](#playbook-6-understanding-a-complex-merge-conflict)
13
+
14
+ ---
15
+
16
+ ## Playbook 1: Finding When a Bug Was Introduced
17
+
18
+ **Scenario:** A feature that used to work is now broken. You need to find the exact commit that introduced the regression.
19
+
20
+ ### Step 1: Establish the boundary
21
+
22
+ ```bash
23
+ # Find a known-good commit (e.g., last release tag)
24
+ git tag --list "v*" --sort=-version:refname | head -5
25
+
26
+ # Verify the good commit is actually good
27
+ git stash # save current work
28
+ git checkout v2.1.0
29
+ # run the failing test or reproduce the bug manually
30
+ # if it passes, this is your good commit
31
+ ```
32
+
33
+ ### Step 2: Start bisect
34
+
35
+ ```bash
36
+ git bisect start
37
+ git bisect bad HEAD # current commit is bad
38
+ git bisect good v2.1.0 # last known good commit
39
+ ```
40
+
41
+ ### Step 3: Test each checkout
42
+
43
+ Git will check out a commit roughly in the middle. Test it:
44
+
45
+ ```bash
46
+ # Option A: Manual testing
47
+ pytest tests/test_feature.py -x
48
+ # If it passes: git bisect good
49
+ # If it fails: git bisect bad
50
+
51
+ # Option B: Automated
52
+ git bisect run pytest tests/test_feature.py -x
53
+ ```
54
+
55
+ ### Step 4: Analyze the result
56
+
57
+ ```bash
58
+ # Git outputs the first bad commit
59
+ # Example: abc1234 is the first bad commit
60
+
61
+ # Examine the commit
62
+ git show abc1234
63
+ git show abc1234 --stat
64
+
65
+ # Understand the context
66
+ git log --oneline abc1234~5..abc1234
67
+ ```
68
+
69
+ ### Step 5: Clean up
70
+
71
+ ```bash
72
+ git bisect reset
73
+ git stash pop # restore your work
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Playbook 2: Finding Deleted Code
79
+
80
+ **Scenario:** A function or class that used to exist has been deleted. You need to find when it was removed and why.
81
+
82
+ ### Step 1: Search for when the code was last present
83
+
84
+ ```bash
85
+ # Find commits that changed the count of the string
86
+ git log -S "def calculate_tax" --oneline
87
+
88
+ # Output shows commits where the function was added or removed
89
+ # The LAST commit in the list removed it; the FIRST added it
90
+ ```
91
+
92
+ ### Step 2: Examine the removal commit
93
+
94
+ ```bash
95
+ # Show the commit that removed the function
96
+ git show abc1234
97
+
98
+ # See the full file at the commit BEFORE removal
99
+ git show abc1234^:path/to/file.py
100
+
101
+ # See the diff to understand what replaced it
102
+ git diff abc1234^..abc1234 -- path/to/file.py
103
+ ```
104
+
105
+ ### Step 3: Find the file if it was renamed or moved
106
+
107
+ ```bash
108
+ # If the file itself was deleted, find when
109
+ git log --diff-filter=D --summary | grep "path/to/file.py"
110
+
111
+ # If the function moved to another file, search with -G
112
+ git log -G "def calculate_tax" --oneline --all
113
+ ```
114
+
115
+ ### Step 4: Recover the deleted code
116
+
117
+ ```bash
118
+ # Get the file content from before the deletion
119
+ git show abc1234^:path/to/file.py > recovered_file.py
120
+
121
+ # Or cherry-pick just the function (manual extraction)
122
+ git show abc1234^:path/to/file.py | grep -A 50 "def calculate_tax"
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Playbook 3: Tracing a Line's History
128
+
129
+ **Scenario:** You need to understand why a specific line of code exists -- who wrote it, when, and in what context.
130
+
131
+ ### Step 1: Initial blame
132
+
133
+ ```bash
134
+ # Blame with whitespace and move detection
135
+ git blame -w -M -C path/to/file.py
136
+
137
+ # Focus on the specific line range
138
+ git blame -w -M -C -L 42,42 path/to/file.py
139
+ ```
140
+
141
+ ### Step 2: Go deeper if the blame shows a bulk change
142
+
143
+ If blame points to a formatting or refactoring commit:
144
+
145
+ ```bash
146
+ # Blame at the commit BEFORE the bulk change
147
+ git blame -w -M -C abc1234^ -- path/to/file.py -L 42,42
148
+
149
+ # Or use .git-blame-ignore-revs to skip bulk commits automatically
150
+ git blame --ignore-revs-file .git-blame-ignore-revs path/to/file.py
151
+ ```
152
+
153
+ ### Step 3: Read the full commit context
154
+
155
+ ```bash
156
+ # See the full commit that introduced the line
157
+ git show def5678
158
+
159
+ # See the PR/issue if the commit message references one
160
+ # e.g., "Fix #123" or "Closes #456"
161
+ git log --format="%H %s" | grep "#123"
162
+ ```
163
+
164
+ ### Step 4: See all changes to this line over time
165
+
166
+ ```bash
167
+ # Log of all commits that touched this line range
168
+ git log -L 42,42:path/to/file.py
169
+
170
+ # This shows the line's evolution across commits, including the diff at each step
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Playbook 4: Recovering Lost Work
176
+
177
+ **Scenario:** You accidentally ran `git reset --hard`, deleted a branch, or lost commits.
178
+
179
+ ### Step 1: Don't panic -- check the reflog
180
+
181
+ ```bash
182
+ # See recent HEAD movements
183
+ git reflog
184
+
185
+ # Look for the commit you lost
186
+ # Example output:
187
+ # abc1234 HEAD@{0}: reset: moving to HEAD~3 ← the reset that lost your work
188
+ # def5678 HEAD@{1}: commit: add user validation ← your lost commit
189
+ # 789abcd HEAD@{2}: commit: fix login bug ← another lost commit
190
+ ```
191
+
192
+ ### Step 2: Verify the lost commit
193
+
194
+ ```bash
195
+ # Check the commit contents
196
+ git show def5678
197
+ git show def5678 --stat
198
+ ```
199
+
200
+ ### Step 3: Recover
201
+
202
+ ```bash
203
+ # Option A: Create a branch at the lost commit (safest)
204
+ git branch recovery def5678
205
+
206
+ # Option B: Cherry-pick the commit onto your current branch
207
+ git cherry-pick def5678
208
+
209
+ # Option C: Reset to the lost commit (if you want to restore the full state)
210
+ git reset --hard def5678
211
+ ```
212
+
213
+ ### Step 4: If reflog doesn't help
214
+
215
+ ```bash
216
+ # Find unreachable objects (last resort)
217
+ git fsck --unreachable --no-reflogs
218
+
219
+ # This lists dangling commits, blobs, and trees
220
+ # Look for "dangling commit" entries
221
+ # Examine them with git show
222
+ ```
223
+
224
+ ---
225
+
226
+ ## Playbook 5: Identifying Hot Spots and Code Ownership
227
+
228
+ **Scenario:** You're new to a codebase and need to understand which files change most and who knows them best.
229
+
230
+ ### Step 1: Find frequently changed files
231
+
232
+ ```bash
233
+ # Most changed files in the last 6 months
234
+ git log --since="6 months ago" --pretty=format: --name-only | sort | uniq -c | sort -rn | head -20
235
+ ```
236
+
237
+ ### Step 2: Find who knows each area
238
+
239
+ ```bash
240
+ # Top contributors overall
241
+ git shortlog -sn --no-merges --since="6 months ago"
242
+
243
+ # Top contributors for a specific directory
244
+ git shortlog -sn --no-merges -- src/auth/
245
+
246
+ # Who last touched each file in a directory
247
+ for f in src/auth/*.py; do
248
+ echo "$f: $(git log -1 --format='%an (%ar)' -- "$f")"
249
+ done
250
+ ```
251
+
252
+ ### Step 3: Find coupling (files that change together)
253
+
254
+ ```bash
255
+ # Files that frequently appear in the same commit
256
+ git log --pretty=format: --name-only | sort | uniq -c | sort -rn | head -30
257
+
258
+ # Look for pairs: if file A and file B always change together,
259
+ # they may have hidden coupling that should be made explicit
260
+ ```
261
+
262
+ ### Step 4: Identify aging code
263
+
264
+ ```bash
265
+ # Files not modified in over a year
266
+ git log --diff-filter=M --since="1 year ago" --pretty=format: --name-only | sort -u > recent.txt
267
+ git ls-files | sort > all.txt
268
+ comm -23 all.txt recent.txt | head -30
269
+ rm recent.txt all.txt
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Playbook 6: Understanding a Complex Merge Conflict
275
+
276
+ **Scenario:** You have a merge conflict and need to understand the history of both sides before resolving.
277
+
278
+ ### Step 1: See what both branches changed
279
+
280
+ ```bash
281
+ # Changes on your branch since diverging from main
282
+ git log --oneline main..HEAD
283
+
284
+ # Changes on main since your branch diverged
285
+ git log --oneline HEAD..main
286
+
287
+ # The common ancestor
288
+ git merge-base HEAD main
289
+ ```
290
+
291
+ ### Step 2: Understand the conflicting file's history
292
+
293
+ ```bash
294
+ # History on your branch
295
+ git log --oneline main..HEAD -- path/to/conflicted/file.py
296
+
297
+ # History on main
298
+ git log --oneline HEAD..main -- path/to/conflicted/file.py
299
+ ```
300
+
301
+ ### Step 3: See the three-way diff
302
+
303
+ ```bash
304
+ # During a merge conflict, git stores three versions:
305
+ # :1: = common ancestor (base)
306
+ # :2: = your version (ours)
307
+ # :3: = their version (theirs)
308
+
309
+ git show :1:path/to/file.py > base.py
310
+ git show :2:path/to/file.py > ours.py
311
+ git show :3:path/to/file.py > theirs.py
312
+
313
+ # Compare
314
+ diff3 ours.py base.py theirs.py
315
+ ```
316
+
317
+ ### Step 4: Resolve with context
318
+
319
+ Understanding both sides' intent (from the commit messages in Step 1) helps you resolve the conflict correctly rather than just picking one side.
@@ -0,0 +1,150 @@
1
+ ---
2
+ name: migration-patterns
3
+ description: >-
4
+ This skill should be used when the user asks to "migrate from X to Y",
5
+ "upgrade to version N", "bump Python version", "upgrade pydantic",
6
+ "migrate express to fastify", "framework migration", "version upgrade",
7
+ "modernize the codebase", or discusses code migration, framework upgrades,
8
+ API version bumps, or dependency migration strategies.
9
+ version: 0.1.0
10
+ ---
11
+
12
+ # Migration Patterns
13
+
14
+ ## Mental Model
15
+
16
+ Migrations are a sequence of **small, verifiable, rollback-safe transformations**. Each step must independently compile, pass tests, and leave the system in a valid state. The moment you batch changes or skip verification, you create a state that is harder to debug than the original problem.
17
+
18
+ **Key principles:**
19
+ - **One thing at a time.** Each migration step changes one category of code (imports, API calls, configuration, types). Mixing categories makes failures hard to isolate.
20
+ - **Verify after every step.** Build → Test → Lint after each transformation. A broken intermediate state that goes undetected compounds into an undebuggable mess.
21
+ - **Rollback is always an option.** Git checkpoints after each successful step. If step N fails, you can revert to step N-1 cleanly.
22
+ - **Import mapping first.** Most framework migrations change import paths. Map all imports before modifying call sites — this gives you a complete inventory of affected code.
23
+ - **Official guides are the source of truth.** Always fetch and read the official migration guide before planning. Community blog posts may be outdated or incomplete.
24
+
25
+ ---
26
+
27
+ ## Migration Planning Framework
28
+
29
+ Follow this sequence for every migration:
30
+
31
+ ### 1. Assess Current State
32
+
33
+ - Read manifest files to identify current version and all dependencies.
34
+ - Use `Glob` and `Grep` to inventory usage of the APIs being migrated.
35
+ - Count occurrences of each deprecated pattern to estimate effort.
36
+
37
+ ### 2. Read Official Guides
38
+
39
+ - Use `WebFetch` to pull the official migration guide, changelog, and breaking changes list.
40
+ - Note every breaking change that applies to the project.
41
+ - Identify changes with no direct replacement — these need special handling.
42
+
43
+ ### 3. Inventory Affected Files
44
+
45
+ - Map every file that uses a deprecated API or pattern.
46
+ - Group files by change type (imports, API calls, configuration, types).
47
+ - Count total changes per group to estimate per-step effort.
48
+
49
+ ### 4. Order Steps
50
+
51
+ Sequence changes so each step is independently buildable:
52
+
53
+ 1. **Configuration** — Manifest files, build configs, tool configs
54
+ 2. **Core utilities and shared modules** — Changes here propagate to dependents
55
+ 3. **Business logic** — Module by module, starting with lowest dependency count
56
+ 4. **Route handlers / controllers** — Often the most numerous changes
57
+ 5. **Tests** — Updated last to match migrated source
58
+
59
+ ### 5. Risk Assessment
60
+
61
+ Flag high-risk changes:
62
+ - Behavioral changes (same API, different default behavior)
63
+ - Removed APIs with no direct replacement
64
+ - Database schema changes
65
+ - Serialization format changes (affects stored data)
66
+
67
+ ### 6. Present Plan
68
+
69
+ Output numbered steps with:
70
+ - File count per step
71
+ - Risk level (low / medium / high)
72
+ - Verification command
73
+ - Rollback command
74
+
75
+ ---
76
+
77
+ ## Step Verification Protocol
78
+
79
+ After each migration step, run these checks in order:
80
+
81
+ | Check | Command Examples | Purpose |
82
+ |-------|-----------------|---------|
83
+ | **Syntax** | `python -m py_compile`, `npx tsc --noEmit`, `node --check` | Code parses correctly |
84
+ | **Build** | `npm run build`, `cargo build`, `go build ./...` | Project compiles |
85
+ | **Tests** | `pytest`, `npm test`, `cargo test`, `go test ./...` | Behavior preserved |
86
+ | **Lint** | `ruff check`, `npm run lint`, `cargo clippy` | Style and correctness |
87
+
88
+ If any check fails:
89
+ 1. Identify which change in this step caused the failure.
90
+ 2. Fix within the current step — do not proceed to the next.
91
+ 3. If the fix is unclear, report the failure with full error output.
92
+ 4. Never fix forward by making changes intended for later steps.
93
+
94
+ ---
95
+
96
+ ## Rollback Strategy
97
+
98
+ - **Before starting**: Verify the user has committed or stashed current work.
99
+ - **After each step**: Suggest a commit checkpoint: "Step N complete — recommend committing now."
100
+ - **On failure**: Provide exact `git checkout -- <files>` commands to revert to the last good state.
101
+ - **Database migrations**: Always plan the down-migration alongside the up-migration.
102
+ - **Feature flags**: For gradual migrations, consider feature flags to run old and new code paths in parallel.
103
+
104
+ ---
105
+
106
+ ## Import-First Strategy
107
+
108
+ Most framework migrations change import paths. Map imports before modifying call sites:
109
+
110
+ 1. **Inventory**: `Grep` for all imports from the old framework/library.
111
+ 2. **Map**: Create a mapping of old import → new import.
112
+ 3. **Transform**: Change all imports in a single step.
113
+ 4. **Verify**: Build and test after import changes (some imports may have side effects).
114
+ 5. **Proceed**: With imports correct, modify call sites knowing the right modules are loaded.
115
+
116
+ This approach gives you a complete inventory of affected code before making any behavioral changes.
117
+
118
+ ---
119
+
120
+ ## Common Pitfalls
121
+
122
+ | Pitfall | Why It Fails | Prevention |
123
+ |---------|-------------|------------|
124
+ | Batching all changes | One failure breaks everything; can't isolate cause | One category per step |
125
+ | Skipping verification | Errors compound silently | Build + test after every step |
126
+ | Fixing forward | New changes mask existing failures | Fix in current step or revert |
127
+ | Ignoring transitive deps | A dependency may not support the target version | Check compatibility first |
128
+ | Mixing migration with refactoring | Two concerns, double the failure modes | Migrate first, refactor later |
129
+ | Not reading the migration guide | Miss non-obvious behavioral changes | Official guide before planning |
130
+
131
+ ---
132
+
133
+ ## Ambiguity Policy
134
+
135
+ | Ambiguity | Default |
136
+ |-----------|---------|
137
+ | **Verification depth** | Full suite: build + test + lint after every step |
138
+ | **Step granularity** | One file category per step (imports, then API calls, then config) |
139
+ | **Unknown migration path** | Fetch docs, analyze both APIs, present mapping for review |
140
+ | **Partial migration requested** | Warn about inconsistency; verify the module's own tests pass |
141
+ | **Target version not specified** | Migrate to the latest stable release |
142
+
143
+ ---
144
+
145
+ ## Reference Files
146
+
147
+ | File | Contents |
148
+ |------|----------|
149
+ | [Python Migrations](references/python-migrations.md) | Python version upgrades (3.8→3.12), Pydantic v1→v2 API mapping, Django and SQLAlchemy migration patterns |
150
+ | [JavaScript Migrations](references/javascript-migrations.md) | Express→Fastify mapping, React upgrade patterns, TypeScript version upgrades, CommonJS→ESM migration |
@@ -0,0 +1,179 @@
1
+ # JavaScript / TypeScript Migration Patterns
2
+
3
+ ## Express → Fastify
4
+
5
+ ### Route Mapping
6
+
7
+ | Express | Fastify | Notes |
8
+ |---------|---------|-------|
9
+ | `app.get('/path', handler)` | `fastify.get('/path', handler)` | Similar signature |
10
+ | `app.post('/path', handler)` | `fastify.post('/path', handler)` | Similar signature |
11
+ | `app.use(middleware)` | `fastify.register(plugin)` | Middleware → plugin model |
12
+ | `app.use('/prefix', router)` | `fastify.register(plugin, { prefix: '/prefix' })` | Router → registered plugin |
13
+
14
+ ### Request / Response API
15
+
16
+ | Express | Fastify | Notes |
17
+ |---------|---------|-------|
18
+ | `req.body` | `request.body` | Same concept, different naming convention |
19
+ | `req.params.id` | `request.params.id` | Same |
20
+ | `req.query.page` | `request.query.page` | Same |
21
+ | `req.headers` | `request.headers` | Same |
22
+ | `res.status(200).json(data)` | `reply.code(200).send(data)` | `status` → `code`, `json` → `send` |
23
+ | `res.send('text')` | `reply.send('text')` | Same |
24
+ | `res.redirect('/url')` | `reply.redirect('/url')` | Same |
25
+ | `res.set('header', 'value')` | `reply.header('header', 'value')` | `set` → `header` |
26
+
27
+ ### Middleware → Plugin Conversion
28
+
29
+ ```javascript
30
+ // Express middleware
31
+ app.use((req, res, next) => {
32
+ req.startTime = Date.now();
33
+ next();
34
+ });
35
+
36
+ // Fastify equivalent (using hooks)
37
+ fastify.addHook('onRequest', async (request, reply) => {
38
+ request.startTime = Date.now();
39
+ });
40
+ ```
41
+
42
+ ### Error Handling
43
+
44
+ ```javascript
45
+ // Express error handler
46
+ app.use((err, req, res, next) => {
47
+ res.status(err.status || 500).json({ error: err.message });
48
+ });
49
+
50
+ // Fastify error handler
51
+ fastify.setErrorHandler((error, request, reply) => {
52
+ reply.code(error.statusCode || 500).send({ error: error.message });
53
+ });
54
+ ```
55
+
56
+ ### Migration Steps
57
+
58
+ 1. Install Fastify: `npm install fastify`
59
+ 2. Create Fastify app instance to replace Express app
60
+ 3. Convert middleware to Fastify plugins/hooks
61
+ 4. Convert route handlers (update request/response API calls)
62
+ 5. Convert error handling
63
+ 6. Update tests to use `fastify.inject()` instead of `supertest`
64
+ 7. Remove Express: `npm uninstall express`
65
+
66
+ ---
67
+
68
+ ## React Version Upgrades
69
+
70
+ ### React 17 → 18
71
+
72
+ | Change | Action |
73
+ |--------|--------|
74
+ | `ReactDOM.render()` | Replace with `createRoot().render()` |
75
+ | `ReactDOM.hydrate()` | Replace with `hydrateRoot()` |
76
+ | Automatic batching | No code change — now batches all state updates by default |
77
+ | `useId()` hook | New — use for accessible server/client IDs |
78
+ | Strict Mode double-rendering | Now also double-invokes effects in dev mode |
79
+
80
+ ```javascript
81
+ // React 17
82
+ import ReactDOM from 'react-dom';
83
+ ReactDOM.render(<App />, document.getElementById('root'));
84
+
85
+ // React 18
86
+ import { createRoot } from 'react-dom/client';
87
+ const root = createRoot(document.getElementById('root'));
88
+ root.render(<App />);
89
+ ```
90
+
91
+ ### React 18 → 19
92
+
93
+ | Change | Action |
94
+ |--------|--------|
95
+ | `forwardRef` | No longer needed — `ref` is a regular prop |
96
+ | `React.lazy` | Now supports server components |
97
+ | Context | `<Context>` replaces `<Context.Provider>` |
98
+ | `use()` hook | New — reads resources (promises, context) during render |
99
+ | `ref` callbacks | Now support cleanup functions (return from callback) |
100
+ | Metadata tags | `<title>`, `<meta>`, `<link>` in components hoist to `<head>` |
101
+
102
+ ---
103
+
104
+ ## TypeScript Version Upgrades
105
+
106
+ ### Key Changes by Version
107
+
108
+ | Version | Notable Changes |
109
+ |---------|----------------|
110
+ | 4.7 → 4.8 | Stricter type narrowing in `in` operator |
111
+ | 4.8 → 4.9 | `satisfies` operator |
112
+ | 4.9 → 5.0 | Decorators (TC39 standard), `bundler` module resolution |
113
+ | 5.0 → 5.1 | Easier implicit returns for `undefined`, linked cursors |
114
+ | 5.1 → 5.2 | `using` declarations (explicit resource management) |
115
+ | 5.2 → 5.3 | Import attributes, narrowing in `switch(true)` |
116
+ | 5.3 → 5.4 | `NoInfer<T>` utility type, improved narrowing in closures |
117
+ | 5.4 → 5.5 | Inferred type predicates, regex syntax checking |
118
+
119
+ ### tsconfig Changes
120
+
121
+ | Old Option | New Option | Version |
122
+ |-----------|-----------|---------|
123
+ | `moduleResolution: "node"` | `moduleResolution: "bundler"` | 5.0+ (for bundled apps) |
124
+ | `target: "es2020"` | `target: "es2022"` | 5.0+ (enables native decorators) |
125
+ | `importsNotUsedAsValues` | `verbatimModuleSyntax` | 5.0 (consolidates 3 flags into 1) |
126
+
127
+ ---
128
+
129
+ ## CommonJS → ESM Migration
130
+
131
+ ### Step-by-Step
132
+
133
+ 1. **Update `package.json`**: Add `"type": "module"`
134
+ 2. **Rename if needed**: `.js` files become ESM by default; use `.cjs` for files that must stay CommonJS
135
+ 3. **Convert imports**:
136
+
137
+ | CommonJS | ESM |
138
+ |----------|-----|
139
+ | `const x = require('pkg')` | `import x from 'pkg'` |
140
+ | `const { a, b } = require('pkg')` | `import { a, b } from 'pkg'` |
141
+ | `module.exports = x` | `export default x` |
142
+ | `module.exports = { a, b }` | `export { a, b }` |
143
+ | `exports.a = x` | `export const a = x` |
144
+
145
+ 4. **Fix path imports**: ESM requires file extensions in relative imports: `import x from './utils.js'` (not `'./utils'`)
146
+ 5. **Replace `__dirname` / `__filename`**:
147
+
148
+ ```javascript
149
+ // CommonJS
150
+ const dir = __dirname;
151
+ const file = __filename;
152
+
153
+ // ESM
154
+ import { fileURLToPath } from 'url';
155
+ import { dirname } from 'path';
156
+ const __filename = fileURLToPath(import.meta.url);
157
+ const __dirname = dirname(__filename);
158
+ ```
159
+
160
+ 6. **Replace `require.resolve`**:
161
+
162
+ ```javascript
163
+ // CommonJS
164
+ const resolved = require.resolve('pkg');
165
+
166
+ // ESM
167
+ import { createRequire } from 'module';
168
+ const require = createRequire(import.meta.url);
169
+ const resolved = require.resolve('pkg');
170
+ ```
171
+
172
+ 7. **Update tooling configs**: Jest, ESLint, and other tools may need config changes for ESM support.
173
+
174
+ ### Common Gotchas
175
+
176
+ - JSON imports require import assertions: `import data from './data.json' with { type: 'json' }`
177
+ - Dynamic imports (`import()`) return a module namespace object with a `.default` property
178
+ - Top-level `await` is available in ESM (not in CommonJS)
179
+ - Some packages only export CommonJS — use `import pkg from 'pkg'` (default import) or dynamic `import()`