codeforge-dev 1.7.0 → 1.9.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 (158) hide show
  1. package/.devcontainer/.env +4 -6
  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 +181 -0
  6. package/.devcontainer/CLAUDE.md +57 -20
  7. package/.devcontainer/README.md +111 -56
  8. package/.devcontainer/config/{main-system-prompt.md → defaults/main-system-prompt.md} +72 -0
  9. package/.devcontainer/config/defaults/rules/spec-workflow.md +67 -0
  10. package/.devcontainer/config/defaults/rules/workspace-scope.md +7 -0
  11. package/.devcontainer/config/defaults/settings.json +67 -0
  12. package/.devcontainer/config/file-manifest.json +32 -0
  13. package/.devcontainer/devcontainer.json +20 -0
  14. package/.devcontainer/docs/configuration-reference.md +90 -0
  15. package/.devcontainer/docs/keybindings.md +100 -0
  16. package/.devcontainer/docs/optional-features.md +129 -0
  17. package/.devcontainer/docs/plugins.md +154 -0
  18. package/.devcontainer/docs/troubleshooting.md +128 -0
  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/install.sh +6 -0
  24. package/.devcontainer/features/ccstatusline/devcontainer-feature.json +5 -0
  25. package/.devcontainer/features/ccstatusline/install.sh +7 -0
  26. package/.devcontainer/features/ccusage/install.sh +6 -0
  27. package/.devcontainer/features/claude-monitor/install.sh +6 -0
  28. package/.devcontainer/features/dprint/README.md +30 -0
  29. package/.devcontainer/features/dprint/devcontainer-feature.json +18 -0
  30. package/.devcontainer/features/dprint/install.sh +131 -0
  31. package/.devcontainer/features/hadolint/README.md +35 -0
  32. package/.devcontainer/features/hadolint/devcontainer-feature.json +13 -0
  33. package/.devcontainer/features/hadolint/install.sh +86 -0
  34. package/.devcontainer/features/lsp-servers/devcontainer-feature.json +5 -0
  35. package/.devcontainer/features/lsp-servers/install.sh +7 -0
  36. package/.devcontainer/features/mcp-qdrant/devcontainer-feature.json +5 -0
  37. package/.devcontainer/features/mcp-qdrant/install.sh +13 -6
  38. package/.devcontainer/features/mcp-reasoner/devcontainer-feature.json +5 -0
  39. package/.devcontainer/features/mcp-reasoner/install.sh +8 -1
  40. package/.devcontainer/features/notify-hook/devcontainer-feature.json +5 -0
  41. package/.devcontainer/features/notify-hook/install.sh +7 -0
  42. package/.devcontainer/features/ruff/README.md +26 -0
  43. package/.devcontainer/features/ruff/devcontainer-feature.json +21 -0
  44. package/.devcontainer/features/ruff/install.sh +74 -0
  45. package/.devcontainer/features/shellcheck/README.md +38 -0
  46. package/.devcontainer/features/shellcheck/devcontainer-feature.json +13 -0
  47. package/.devcontainer/features/shellcheck/install.sh +24 -0
  48. package/.devcontainer/features/shfmt/README.md +37 -0
  49. package/.devcontainer/features/shfmt/devcontainer-feature.json +13 -0
  50. package/.devcontainer/features/shfmt/install.sh +85 -0
  51. package/.devcontainer/features/splitrail/devcontainer-feature.json +5 -0
  52. package/.devcontainer/features/splitrail/install.sh +7 -0
  53. package/.devcontainer/features/tmux/install.sh +8 -0
  54. package/.devcontainer/features/tree-sitter/install.sh +6 -0
  55. package/.devcontainer/plugins/devs-marketplace/.claude-plugin/marketplace.json +104 -104
  56. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/.claude-plugin/plugin.json +7 -0
  57. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/README.md +158 -0
  58. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/hooks/hooks.json +39 -0
  59. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/collect-edited-files.py +47 -0
  60. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/format-on-stop.py +297 -0
  61. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/lint-file.py +536 -0
  62. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/syntax-validator.py +146 -0
  63. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/.claude-plugin/plugin.json +1 -1
  64. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/__pycache__/format-on-stop.cpython-314.pyc +0 -0
  65. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/format-on-stop.py +114 -9
  66. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/.claude-plugin/plugin.json +1 -1
  67. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/hooks/hooks.json +4 -5
  68. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/__pycache__/lint-file.cpython-314.pyc +0 -0
  69. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/lint-file.py +478 -76
  70. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/.claude-plugin/plugin.json +1 -1
  71. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/AGENT-REDIRECTION.md +226 -0
  72. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/architect.md +94 -1
  73. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/bash-exec.md +4 -4
  74. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/claude-guide.md +14 -23
  75. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/debug-logs.md +20 -0
  76. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/dependency-analyst.md +20 -0
  77. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/doc-writer.md +99 -1
  78. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/explorer.md +20 -0
  79. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/generalist.md +152 -9
  80. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/git-archaeologist.md +18 -0
  81. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/migrator.md +114 -1
  82. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/perf-profiler.md +24 -0
  83. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/refactorer.md +101 -1
  84. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/researcher.md +33 -1
  85. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/security-auditor.md +24 -0
  86. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/spec-writer.md +65 -24
  87. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/statusline-config.md +3 -3
  88. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/test-writer.md +99 -1
  89. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/hooks/hooks.json +100 -56
  90. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/advisory-test-runner.cpython-314.pyc +0 -0
  91. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/collect-edited-files.cpython-314.pyc +0 -0
  92. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/commit-reminder.cpython-314.pyc +0 -0
  93. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/git-state-injector.cpython-314.pyc +0 -0
  94. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/redirect-builtin-agents.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/advisory-test-runner.py +174 -0
  98. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/collect-edited-files.py +8 -6
  99. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/commit-reminder.py +90 -0
  100. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/git-state-injector.py +114 -0
  101. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/skill-suggester.py +61 -0
  102. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/spec-reminder.py +121 -0
  103. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/ticket-linker.py +137 -0
  104. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/todo-harvester.py +130 -0
  105. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/SKILL.md +224 -0
  106. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/references/error-handling.md +166 -0
  107. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/references/rest-conventions.md +215 -0
  108. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/ast-grep-patterns/SKILL.md +211 -0
  109. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/ast-grep-patterns/references/language-patterns.md +327 -0
  110. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/SKILL.md +134 -0
  111. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/references/ecosystem-commands.md +264 -0
  112. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/references/license-compliance.md +80 -0
  113. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/SKILL.md +153 -0
  114. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/references/api-doc-templates.md +221 -0
  115. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/references/docstring-formats.md +296 -0
  116. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/SKILL.md +150 -0
  117. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/references/javascript-migrations.md +179 -0
  118. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/references/python-migrations.md +141 -0
  119. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-check/SKILL.md +86 -0
  120. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-init/SKILL.md +97 -0
  121. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-init/references/backlog-template.md +7 -0
  122. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-init/references/roadmap-template.md +13 -0
  123. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-new/SKILL.md +101 -0
  124. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-new/references/template.md +110 -0
  125. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-update/SKILL.md +124 -0
  126. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/specification-writing/SKILL.md +32 -0
  127. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/__pycache__/block-dangerous.cpython-314.pyc +0 -0
  128. package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/hooks/hooks.json +1 -1
  129. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/__pycache__/guard-protected.cpython-314.pyc +0 -0
  130. package/.devcontainer/scripts/check-setup.sh +72 -0
  131. package/.devcontainer/scripts/setup-aliases.sh +43 -3
  132. package/.devcontainer/scripts/setup-auth.sh +74 -0
  133. package/.devcontainer/scripts/setup-config.sh +117 -24
  134. package/.devcontainer/scripts/setup-update-claude.sh +8 -0
  135. package/.devcontainer/scripts/setup.sh +46 -13
  136. package/README.md +23 -190
  137. package/package.json +42 -42
  138. package/setup.js +245 -71
  139. package/.devcontainer/config/settings.json +0 -70
  140. package/.devcontainer/features/claude-code/README.md +0 -498
  141. package/.devcontainer/features/claude-code/config/settings.json +0 -72
  142. package/.devcontainer/features/claude-code/config/system-prompt.md +0 -118
  143. package/.devcontainer/features/claude-code/config/world-building-sp.md +0 -1432
  144. package/.devcontainer/features/claude-code/devcontainer-feature.json +0 -42
  145. package/.devcontainer/features/claude-code/install.sh +0 -466
  146. package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/.claude-plugin/plugin.json +0 -7
  147. package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/hooks/hooks.json +0 -17
  148. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/.claude-plugin/plugin.json +0 -6
  149. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/config/planning-instructions.md +0 -14
  150. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/functional-conjuring-map.md +0 -989
  151. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/hooks/hooks.json +0 -33
  152. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/__pycache__/post-enhance-task.cpython-314.pyc +0 -0
  153. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhance-planning.py +0 -71
  154. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-plan.sh +0 -68
  155. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-task.sh +0 -120
  156. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-plan.py +0 -133
  157. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-task.py +0 -253
  158. /package/.devcontainer/config/{keybindings.json → defaults/keybindings.json} +0 -0
@@ -0,0 +1,221 @@
1
+ # API Documentation Templates
2
+
3
+ ## REST Endpoint Documentation
4
+
5
+ Use this template for each API endpoint:
6
+
7
+ ### Template
8
+
9
+ ```markdown
10
+ ## [Method] [Path]
11
+
12
+ [One-sentence description of what this endpoint does.]
13
+
14
+ ### Request
15
+
16
+ **URL Parameters:**
17
+
18
+ | Name | Type | Required | Description |
19
+ |------|------|----------|-------------|
20
+ | `id` | string | Yes | The resource identifier |
21
+
22
+ **Query Parameters:**
23
+
24
+ | Name | Type | Required | Default | Description |
25
+ |------|------|----------|---------|-------------|
26
+ | `limit` | integer | No | 20 | Maximum results to return (1-100) |
27
+ | `cursor` | string | No | — | Pagination cursor from previous response |
28
+
29
+ **Request Body:**
30
+
31
+ | Field | Type | Required | Description | Constraints |
32
+ |-------|------|----------|-------------|-------------|
33
+ | `name` | string | Yes | Display name | 1-100 characters |
34
+ | `email` | string | Yes | Email address | Valid email format |
35
+
36
+ **Example Request:**
37
+
38
+ \```bash
39
+ curl -X POST https://api.example.com/v1/users \
40
+ -H "Authorization: Bearer sk-abc123" \
41
+ -H "Content-Type: application/json" \
42
+ -d '{
43
+ "name": "Jane Doe",
44
+ "email": "jane@example.com"
45
+ }'
46
+ \```
47
+
48
+ ### Response
49
+
50
+ **Success (201 Created):**
51
+
52
+ \```json
53
+ {
54
+ "id": "usr_abc123",
55
+ "name": "Jane Doe",
56
+ "email": "jane@example.com",
57
+ "created_at": "2024-01-15T10:30:00Z"
58
+ }
59
+ \```
60
+
61
+ **Error Responses:**
62
+
63
+ | Status | Type | When |
64
+ |--------|------|------|
65
+ | 400 | validation-error | Invalid request body |
66
+ | 401 | authentication-required | Missing or expired token |
67
+ | 409 | resource-conflict | Email already registered |
68
+ | 429 | rate-limit-exceeded | Too many requests |
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Parameter Table Format
74
+
75
+ Always include these columns for parameters:
76
+
77
+ | Column | Purpose |
78
+ |--------|---------|
79
+ | **Name** | Parameter name as it appears in code |
80
+ | **Type** | Data type (string, integer, boolean, array, object) |
81
+ | **Required** | Yes / No |
82
+ | **Default** | Default value if optional (— if none) |
83
+ | **Description** | What this parameter does |
84
+ | **Constraints** | Validation rules (min/max, regex, enum values) |
85
+
86
+ ### Example
87
+
88
+ | Name | Type | Required | Default | Description | Constraints |
89
+ |------|------|----------|---------|-------------|-------------|
90
+ | `page_size` | integer | No | 20 | Results per page | 1–100 |
91
+ | `status` | string | No | — | Filter by status | `active`, `inactive`, `pending` |
92
+ | `created_after` | string | No | — | Filter by creation date | ISO 8601 format |
93
+
94
+ ---
95
+
96
+ ## Request / Response Examples
97
+
98
+ ### curl
99
+
100
+ ```bash
101
+ curl -X GET "https://api.example.com/v1/users?status=active&limit=10" \
102
+ -H "Authorization: Bearer sk-abc123" \
103
+ -H "Accept: application/json"
104
+ ```
105
+
106
+ ### httpie
107
+
108
+ ```bash
109
+ http GET https://api.example.com/v1/users \
110
+ status==active limit==10 \
111
+ Authorization:"Bearer sk-abc123"
112
+ ```
113
+
114
+ ### Python (requests)
115
+
116
+ ```python
117
+ import requests
118
+
119
+ response = requests.get(
120
+ "https://api.example.com/v1/users",
121
+ params={"status": "active", "limit": 10},
122
+ headers={"Authorization": "Bearer sk-abc123"},
123
+ )
124
+ data = response.json()
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Error Response Documentation
130
+
131
+ Document every error code an endpoint can return:
132
+
133
+ ```markdown
134
+ ### Errors
135
+
136
+ | Status | Error Type | Description | Example Detail |
137
+ |--------|-----------|-------------|---------------|
138
+ | 400 | `validation-error` | Request body is malformed | "Missing required field: 'name'" |
139
+ | 401 | `authentication-required` | Token missing or expired | "Access token has expired" |
140
+ | 403 | `insufficient-permissions` | Valid token, wrong scope | "Requires 'admin' scope" |
141
+ | 404 | `resource-not-found` | Resource doesn't exist | "No user with ID 'usr_999'" |
142
+ | 409 | `resource-conflict` | Duplicate or state conflict | "Email already registered" |
143
+ | 422 | `unprocessable-entity` | Valid syntax, invalid data | "Age must be positive" |
144
+ | 429 | `rate-limit-exceeded` | Too many requests | "Retry after 30 seconds" |
145
+ ```
146
+
147
+ ---
148
+
149
+ ## OpenAPI / Swagger Annotations
150
+
151
+ ### Python (FastAPI)
152
+
153
+ ```python
154
+ @router.post(
155
+ "/users",
156
+ response_model=UserResponse,
157
+ status_code=201,
158
+ summary="Create a new user",
159
+ description="Registers a new user account with the provided details.",
160
+ responses={
161
+ 409: {"description": "Email already registered"},
162
+ 422: {"description": "Validation error"},
163
+ },
164
+ )
165
+ async def create_user(user: UserCreate) -> UserResponse:
166
+ ```
167
+
168
+ ### TypeScript (NestJS / Swagger)
169
+
170
+ ```typescript
171
+ @ApiOperation({ summary: 'Create a new user' })
172
+ @ApiResponse({ status: 201, description: 'User created', type: UserResponse })
173
+ @ApiResponse({ status: 409, description: 'Email already registered' })
174
+ @Post('users')
175
+ async createUser(@Body() dto: CreateUserDto): Promise<UserResponse> {
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Mermaid Diagram Quick Reference
181
+
182
+ ### Sequence Diagram
183
+
184
+ ```mermaid
185
+ sequenceDiagram
186
+ participant C as Client
187
+ participant A as API
188
+ participant D as Database
189
+ C->>A: POST /users
190
+ A->>D: INSERT user
191
+ D-->>A: user record
192
+ A-->>C: 201 Created
193
+ ```
194
+
195
+ ### Flowchart
196
+
197
+ ```mermaid
198
+ flowchart TD
199
+ A[Request] --> B{Authenticated?}
200
+ B -->|No| C[401 Unauthorized]
201
+ B -->|Yes| D{Valid Input?}
202
+ D -->|No| E[422 Validation Error]
203
+ D -->|Yes| F[Process Request]
204
+ F --> G[200 OK]
205
+ ```
206
+
207
+ ### Entity Relationship
208
+
209
+ ```mermaid
210
+ erDiagram
211
+ USER ||--o{ ORDER : places
212
+ ORDER ||--|{ LINE_ITEM : contains
213
+ PRODUCT ||--o{ LINE_ITEM : "ordered in"
214
+ ```
215
+
216
+ ### Tips
217
+
218
+ - Keep diagrams **under 10 nodes**. Split complex flows into multiple diagrams.
219
+ - Use descriptive labels on arrows (not just `-->` but `-->|description|`).
220
+ - Mermaid renders in GitHub, VS Code preview, and most documentation platforms.
221
+ - For architecture diagrams, prefer `flowchart` over `graph` (flowchart is the newer syntax).
@@ -0,0 +1,296 @@
1
+ # Docstring Format Reference
2
+
3
+ Complete templates for inline documentation across languages. Detect the project's existing style before adding new docstrings.
4
+
5
+ ---
6
+
7
+ ## Python
8
+
9
+ ### Google-Style (Recommended Default)
10
+
11
+ Detection pattern: `Grep: "Args:"` or `Grep: "Returns:"` in `.py` files.
12
+
13
+ ```python
14
+ def process_payment(amount: float, currency: str, customer_id: str) -> PaymentResult:
15
+ """Process a payment for the given customer.
16
+
17
+ Validates the amount, charges the customer's default payment method,
18
+ and records the transaction in the payment ledger.
19
+
20
+ Args:
21
+ amount: Payment amount in the smallest currency unit (e.g., cents).
22
+ Must be positive.
23
+ currency: ISO 4217 currency code (e.g., "usd", "eur").
24
+ customer_id: The unique customer identifier from the auth system.
25
+
26
+ Returns:
27
+ PaymentResult with transaction ID, status, and timestamp.
28
+
29
+ Raises:
30
+ InvalidAmountError: If amount is negative or zero.
31
+ CustomerNotFoundError: If customer_id doesn't match any customer.
32
+ PaymentGatewayError: If the external payment provider is unreachable.
33
+
34
+ Example:
35
+ >>> result = process_payment(1500, "usd", "cust_abc123")
36
+ >>> result.status
37
+ 'completed'
38
+ """
39
+ ```
40
+
41
+ ### NumPy-Style
42
+
43
+ Detection pattern: `Grep: "Parameters\n----------"` (multiline) or `Grep: "----------"` in docstrings.
44
+
45
+ ```python
46
+ def interpolate(x, y, method="linear"):
47
+ """Interpolate data points using the specified method.
48
+
49
+ Parameters
50
+ ----------
51
+ x : array_like
52
+ The x-coordinates of the data points.
53
+ y : array_like
54
+ The y-coordinates of the data points. Must have the same length as `x`.
55
+ method : str, optional
56
+ Interpolation method. One of 'linear', 'cubic', 'nearest'.
57
+ Default is 'linear'.
58
+
59
+ Returns
60
+ -------
61
+ callable
62
+ An interpolation function that accepts x values and returns
63
+ interpolated y values.
64
+
65
+ Raises
66
+ ------
67
+ ValueError
68
+ If `x` and `y` have different lengths.
69
+
70
+ Examples
71
+ --------
72
+ >>> f = interpolate([0, 1, 2], [0, 1, 4], method='cubic')
73
+ >>> f(1.5)
74
+ 2.25
75
+ """
76
+ ```
77
+
78
+ ### Sphinx / reStructuredText
79
+
80
+ Detection pattern: `Grep: ":param "` or `Grep: ":type "` in `.py` files.
81
+
82
+ ```python
83
+ def connect(host, port, timeout=30):
84
+ """Connect to the remote server.
85
+
86
+ Establishes a TCP connection with configurable timeout.
87
+
88
+ :param host: Server hostname or IP address.
89
+ :type host: str
90
+ :param port: Server port number (1-65535).
91
+ :type port: int
92
+ :param timeout: Connection timeout in seconds. Defaults to 30.
93
+ :type timeout: int
94
+ :returns: Active connection handle.
95
+ :rtype: Connection
96
+ :raises ConnectionError: If the server is unreachable.
97
+ :raises ValueError: If port is out of valid range.
98
+ """
99
+ ```
100
+
101
+ ### Module and Class Docstrings
102
+
103
+ ```python
104
+ """Payment processing module.
105
+
106
+ Handles payment creation, validation, and gateway communication.
107
+ Supports Stripe and PayPal providers via the adapter pattern.
108
+
109
+ See `src/payments/adapters/` for provider implementations.
110
+ """
111
+
112
+
113
+ class PaymentProcessor:
114
+ """Orchestrates payment workflows across multiple providers.
115
+
116
+ Manages provider selection, retry logic, and transaction recording.
117
+ Uses the strategy pattern to delegate provider-specific logic.
118
+
119
+ Attributes:
120
+ default_provider: Name of the fallback payment provider.
121
+ max_retries: Maximum retry attempts for failed transactions.
122
+ """
123
+ ```
124
+
125
+ ---
126
+
127
+ ## TypeScript / JavaScript
128
+
129
+ ### JSDoc
130
+
131
+ Detection pattern: `Grep: "@param "` or `Grep: "@returns"` in `.ts` or `.js` files.
132
+
133
+ ```typescript
134
+ /**
135
+ * Process a payment for the given customer.
136
+ *
137
+ * Validates the amount, charges the customer's default payment method,
138
+ * and records the transaction.
139
+ *
140
+ * @param amount - Payment amount in cents (must be positive)
141
+ * @param currency - ISO 4217 currency code (e.g., "usd", "eur")
142
+ * @param customerId - The unique customer identifier
143
+ * @returns Payment result with transaction ID and status
144
+ * @throws {InvalidAmountError} If amount is negative or zero
145
+ * @throws {CustomerNotFoundError} If customerId doesn't match any customer
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const result = await processPayment(1500, "usd", "cust_abc123");
150
+ * console.log(result.status); // "completed"
151
+ * ```
152
+ */
153
+ async function processPayment(
154
+ amount: number,
155
+ currency: string,
156
+ customerId: string
157
+ ): Promise<PaymentResult> {
158
+ ```
159
+
160
+ ### TSDoc
161
+
162
+ TSDoc is a stricter subset of JSDoc used by TypeScript-focused projects.
163
+
164
+ Key differences from JSDoc:
165
+ - Uses `{@link ClassName}` for references (not `{@see}`)
166
+ - `@param name -` format (with dash separator)
167
+ - `@throws` without type braces (types are in TypeScript)
168
+
169
+ ```typescript
170
+ /**
171
+ * Fetches user data from the API.
172
+ *
173
+ * @param userId - The user's unique identifier
174
+ * @param options - Request configuration
175
+ * @returns The user object, or `undefined` if not found
176
+ *
177
+ * @remarks
178
+ * This method caches results for 5 minutes. Use {@link invalidateCache}
179
+ * to force a fresh fetch.
180
+ */
181
+ ```
182
+
183
+ ### Module / File Headers
184
+
185
+ ```typescript
186
+ /**
187
+ * @module payments
188
+ *
189
+ * Payment processing module handling Stripe and PayPal integrations.
190
+ * Entry point: {@link PaymentProcessor.process}
191
+ */
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Go (godoc)
197
+
198
+ Detection pattern: Comments starting with the function/type name: `Grep: "^// [A-Z]"` before `func` or `type` declarations.
199
+
200
+ ```go
201
+ // ProcessPayment charges the customer's default payment method.
202
+ // Amount is in the smallest currency unit (e.g., cents for USD).
203
+ // Currency must be a valid ISO 4217 code.
204
+ //
205
+ // Returns the transaction result or an error if the charge fails.
206
+ // Possible errors: ErrInvalidAmount, ErrCustomerNotFound, ErrGatewayUnavailable.
207
+ func ProcessPayment(amount int64, currency string, customerID string) (*PaymentResult, error) {
208
+ ```
209
+
210
+ ### Package Comments
211
+
212
+ ```go
213
+ // Package payments provides payment processing across multiple providers.
214
+ //
215
+ // It supports Stripe and PayPal via pluggable adapters. Use NewProcessor
216
+ // to create a processor with the desired provider configuration.
217
+ //
218
+ // Example:
219
+ //
220
+ // p := payments.NewProcessor(payments.WithStripe(apiKey))
221
+ // result, err := p.Process(ctx, 1500, "usd", "cust_123")
222
+ package payments
223
+ ```
224
+
225
+ ### godoc Conventions
226
+
227
+ - First sentence starts with the name being documented: "ProcessPayment charges..."
228
+ - Use complete sentences with proper punctuation.
229
+ - Code examples use tab-indented blocks (no triple backticks).
230
+ - Document exported (capitalized) identifiers only.
231
+
232
+ ---
233
+
234
+ ## Rust (rustdoc)
235
+
236
+ Detection pattern: `Grep: "/// "` or `Grep: "//! "` in `.rs` files.
237
+
238
+ ```rust
239
+ /// Process a payment for the given customer.
240
+ ///
241
+ /// Validates the amount, charges the customer's default payment method,
242
+ /// and records the transaction in the payment ledger.
243
+ ///
244
+ /// # Arguments
245
+ ///
246
+ /// * `amount` - Payment amount in cents (must be positive)
247
+ /// * `currency` - ISO 4217 currency code (e.g., "usd", "eur")
248
+ /// * `customer_id` - The unique customer identifier
249
+ ///
250
+ /// # Returns
251
+ ///
252
+ /// A `PaymentResult` with transaction ID, status, and timestamp.
253
+ ///
254
+ /// # Errors
255
+ ///
256
+ /// Returns `PaymentError::InvalidAmount` if the amount is zero or negative.
257
+ /// Returns `PaymentError::CustomerNotFound` if the customer ID is invalid.
258
+ ///
259
+ /// # Examples
260
+ ///
261
+ /// ```
262
+ /// let result = process_payment(1500, "usd", "cust_abc123")?;
263
+ /// assert_eq!(result.status, PaymentStatus::Completed);
264
+ /// ```
265
+ ///
266
+ /// # Panics
267
+ ///
268
+ /// Panics if the payment gateway client is not initialized. Call
269
+ /// `init_gateway()` before using this function.
270
+ pub fn process_payment(amount: u64, currency: &str, customer_id: &str) -> Result<PaymentResult, PaymentError> {
271
+ ```
272
+
273
+ ### Module Documentation
274
+
275
+ ```rust
276
+ //! Payment processing module.
277
+ //!
278
+ //! Handles payment creation, validation, and gateway communication.
279
+ //! Supports Stripe and PayPal providers via the adapter pattern.
280
+ //!
281
+ //! # Overview
282
+ //!
283
+ //! Use [`PaymentProcessor::new`] to create a processor, then call
284
+ //! [`PaymentProcessor::process`] to execute a payment.
285
+ ```
286
+
287
+ ### Sections Convention
288
+
289
+ | Section | When to Use |
290
+ |---------|------------|
291
+ | `# Arguments` | All public functions with parameters |
292
+ | `# Returns` | Functions that return non-unit types |
293
+ | `# Errors` | Functions that return `Result` |
294
+ | `# Panics` | Functions that can panic |
295
+ | `# Safety` | Unsafe functions — document invariants |
296
+ | `# Examples` | Always for public API |
@@ -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 |