@caddis/cli 0.0.0 → 0.1.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 (153) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -1
  3. package/bundles/antigravity-plugin/agents/code-reviewer.md +47 -0
  4. package/bundles/antigravity-plugin/agents/preflight.md +53 -0
  5. package/bundles/antigravity-plugin/guard_agy.py +338 -0
  6. package/bundles/antigravity-plugin/hooks.json +36 -0
  7. package/bundles/antigravity-plugin/mcp_config.json +8 -0
  8. package/bundles/antigravity-plugin/mcp_ping_server.py +55 -0
  9. package/bundles/antigravity-plugin/plugin.json +5 -0
  10. package/bundles/antigravity-plugin/session_end_agy.py +57 -0
  11. package/bundles/antigravity-plugin/skills/_registry.md +115 -0
  12. package/bundles/antigravity-plugin/skills/add-rules/SKILL.md +45 -0
  13. package/bundles/antigravity-plugin/skills/api-design/SKILL.md +249 -0
  14. package/bundles/antigravity-plugin/skills/backend-development/SKILL.md +305 -0
  15. package/bundles/antigravity-plugin/skills/best-practices/SKILL.md +500 -0
  16. package/bundles/antigravity-plugin/skills/best-practices/agents/best-practices-referencer.md +263 -0
  17. package/bundles/antigravity-plugin/skills/best-practices/agents/codebase-context-builder.md +326 -0
  18. package/bundles/antigravity-plugin/skills/best-practices/agents/task-intent-analyzer.md +245 -0
  19. package/bundles/antigravity-plugin/skills/best-practices/references/anti-patterns.md +571 -0
  20. package/bundles/antigravity-plugin/skills/best-practices/references/before-after-examples.md +1114 -0
  21. package/bundles/antigravity-plugin/skills/best-practices/references/best-practices-guide.md +513 -0
  22. package/bundles/antigravity-plugin/skills/best-practices/references/common-workflows.md +692 -0
  23. package/bundles/antigravity-plugin/skills/best-practices/references/prompt-patterns.md +547 -0
  24. package/bundles/antigravity-plugin/skills/brainstorming/SKILL.md +57 -0
  25. package/bundles/antigravity-plugin/skills/ci-cd-pipeline/SKILL.md +315 -0
  26. package/bundles/antigravity-plugin/skills/code-documentation/SKILL.md +271 -0
  27. package/bundles/antigravity-plugin/skills/code-review/SKILL.md +122 -0
  28. package/bundles/antigravity-plugin/skills/codebase-audit/SKILL.md +204 -0
  29. package/bundles/antigravity-plugin/skills/context-curator/SKILL.md +157 -0
  30. package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +40 -0
  31. package/bundles/antigravity-plugin/skills/css-architecture/SKILL.md +305 -0
  32. package/bundles/antigravity-plugin/skills/css-architecture/references/RESPONSIVE-DESIGN.md +604 -0
  33. package/bundles/antigravity-plugin/skills/database-design/SKILL.md +177 -0
  34. package/bundles/antigravity-plugin/skills/db-diagram/SKILL.md +148 -0
  35. package/bundles/antigravity-plugin/skills/db-diagram/scripts/sql_to_graph.py +1212 -0
  36. package/bundles/antigravity-plugin/skills/digress/SKILL.md +61 -0
  37. package/bundles/antigravity-plugin/skills/draw-io/SKILL.md +162 -0
  38. package/bundles/antigravity-plugin/skills/draw-io/references/aws-icons.md +677 -0
  39. package/bundles/antigravity-plugin/skills/draw-io/references/layout-guidelines.md +142 -0
  40. package/bundles/antigravity-plugin/skills/draw-io/references/troubleshooting.md +118 -0
  41. package/bundles/antigravity-plugin/skills/draw-io/references/workflows.md +103 -0
  42. package/bundles/antigravity-plugin/skills/draw-io/scripts/convert-drawio-to-png.sh +25 -0
  43. package/bundles/antigravity-plugin/skills/draw-io/scripts/find_aws_icon.py +79 -0
  44. package/bundles/antigravity-plugin/skills/error-handling/SKILL.md +260 -0
  45. package/bundles/antigravity-plugin/skills/excalidraw-db/SKILL.md +38 -0
  46. package/bundles/antigravity-plugin/skills/fastapi-dev/SKILL.md +300 -0
  47. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +198 -0
  48. package/bundles/antigravity-plugin/skills/frontend-design/SKILL.md +193 -0
  49. package/bundles/antigravity-plugin/skills/frontend-design/references/my-tech-stack.md +127 -0
  50. package/bundles/antigravity-plugin/skills/gh-cli/SKILL.md +195 -0
  51. package/bundles/antigravity-plugin/skills/git-commit/SKILL.md +285 -0
  52. package/bundles/antigravity-plugin/skills/golden-plan/SKILL.md +577 -0
  53. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +100 -0
  54. package/bundles/antigravity-plugin/skills/implement/SKILL.md +114 -0
  55. package/bundles/antigravity-plugin/skills/javascript-typescript/SKILL.md +142 -0
  56. package/bundles/antigravity-plugin/skills/kb/SKILL.md +60 -0
  57. package/bundles/antigravity-plugin/skills/mermaid-db/SKILL.md +33 -0
  58. package/bundles/antigravity-plugin/skills/mermaid-diagrams/SKILL.md +236 -0
  59. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/ENHANCEMENTS.md +264 -0
  60. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/MERMAID-SUMMARY.md +137 -0
  61. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/advanced-features.md +556 -0
  62. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/architecture-diagrams.md +192 -0
  63. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/c4-diagrams.md +410 -0
  64. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/class-diagrams.md +361 -0
  65. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/erd-diagrams.md +510 -0
  66. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/flowcharts.md +450 -0
  67. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/sequence-diagrams.md +394 -0
  68. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/troubleshooting.md +335 -0
  69. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/workflows.md +418 -0
  70. package/bundles/antigravity-plugin/skills/migrate-dir/SKILL.md +68 -0
  71. package/bundles/antigravity-plugin/skills/mockup/SKILL.md +242 -0
  72. package/bundles/antigravity-plugin/skills/particle-art/SKILL.md +243 -0
  73. package/bundles/antigravity-plugin/skills/particle-art/references/canvas-utils.ts +171 -0
  74. package/bundles/antigravity-plugin/skills/particle-art/references/dot-field.template.tsx +203 -0
  75. package/bundles/antigravity-plugin/skills/particle-art/references/flow-field.template.tsx +263 -0
  76. package/bundles/antigravity-plugin/skills/particle-art/references/node-shape.template.tsx +261 -0
  77. package/bundles/antigravity-plugin/skills/particle-art/references/shape-sampler.ts +281 -0
  78. package/bundles/antigravity-plugin/skills/particle-art/references/stipple-morph.template.tsx +167 -0
  79. package/bundles/antigravity-plugin/skills/particle-art/references/stipple.template.tsx +175 -0
  80. package/bundles/antigravity-plugin/skills/particle-art/references/trail-ghost.template.tsx +266 -0
  81. package/bundles/antigravity-plugin/skills/particle-art/references/usage-examples.md +320 -0
  82. package/bundles/antigravity-plugin/skills/playwright/API_REFERENCE.md +653 -0
  83. package/bundles/antigravity-plugin/skills/playwright/SKILL.md +454 -0
  84. package/bundles/antigravity-plugin/skills/playwright/lib/helpers.js +441 -0
  85. package/bundles/antigravity-plugin/skills/playwright/package.json +26 -0
  86. package/bundles/antigravity-plugin/skills/playwright/run.js +228 -0
  87. package/bundles/antigravity-plugin/skills/prd/SKILL.md +107 -0
  88. package/bundles/antigravity-plugin/skills/preflight/SKILL.md +435 -0
  89. package/bundles/antigravity-plugin/skills/python/SKILL.md +388 -0
  90. package/bundles/antigravity-plugin/skills/react-best-practices/SKILL.md +269 -0
  91. package/bundles/antigravity-plugin/skills/react-dev/README.md +404 -0
  92. package/bundles/antigravity-plugin/skills/react-dev/SKILL.md +459 -0
  93. package/bundles/antigravity-plugin/skills/react-dev/examples/generic-components.md +579 -0
  94. package/bundles/antigravity-plugin/skills/react-dev/examples/server-components.md +579 -0
  95. package/bundles/antigravity-plugin/skills/react-dev/references/event-handlers.md +574 -0
  96. package/bundles/antigravity-plugin/skills/react-dev/references/hooks.md +456 -0
  97. package/bundles/antigravity-plugin/skills/react-dev/references/react-19-patterns.md +638 -0
  98. package/bundles/antigravity-plugin/skills/react-dev/references/react-router.md +1002 -0
  99. package/bundles/antigravity-plugin/skills/react-dev/references/tanstack-router.md +587 -0
  100. package/bundles/antigravity-plugin/skills/refactoring/SKILL.md +486 -0
  101. package/bundles/antigravity-plugin/skills/resume/SKILL.md +36 -0
  102. package/bundles/antigravity-plugin/skills/security-review/SKILL.md +196 -0
  103. package/bundles/antigravity-plugin/skills/setup-project-ai/SKILL.md +61 -0
  104. package/bundles/antigravity-plugin/skills/ship/SKILL.md +107 -0
  105. package/bundles/antigravity-plugin/skills/ship-merge/SKILL.md +103 -0
  106. package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +102 -0
  107. package/bundles/antigravity-plugin/skills/skill-creator/LICENSE.txt +202 -0
  108. package/bundles/antigravity-plugin/skills/skill-creator/SKILL.md +491 -0
  109. package/bundles/antigravity-plugin/skills/skill-creator/agents/analyzer.md +274 -0
  110. package/bundles/antigravity-plugin/skills/skill-creator/agents/comparator.md +202 -0
  111. package/bundles/antigravity-plugin/skills/skill-creator/agents/grader.md +223 -0
  112. package/bundles/antigravity-plugin/skills/skill-creator/assets/eval_review.html +146 -0
  113. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  114. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  115. package/bundles/antigravity-plugin/skills/skill-creator/references/schemas.md +430 -0
  116. package/bundles/antigravity-plugin/skills/skill-creator/scripts/__init__.py +0 -0
  117. package/bundles/antigravity-plugin/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  118. package/bundles/antigravity-plugin/skills/skill-creator/scripts/generate_report.py +326 -0
  119. package/bundles/antigravity-plugin/skills/skill-creator/scripts/improve_description.py +247 -0
  120. package/bundles/antigravity-plugin/skills/skill-creator/scripts/package_skill.py +136 -0
  121. package/bundles/antigravity-plugin/skills/skill-creator/scripts/quick_validate.py +103 -0
  122. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_eval.py +310 -0
  123. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_loop.py +328 -0
  124. package/bundles/antigravity-plugin/skills/skill-creator/scripts/utils.py +47 -0
  125. package/bundles/antigravity-plugin/skills/sql/SKILL.md +321 -0
  126. package/bundles/antigravity-plugin/skills/tdd/SKILL.md +37 -0
  127. package/bundles/antigravity-plugin/skills/tdd-workflow/SKILL.md +188 -0
  128. package/bundles/antigravity-plugin/skills/technical-writing/SKILL.md +286 -0
  129. package/bundles/antigravity-plugin/skills/test-strategy/SKILL.md +155 -0
  130. package/bundles/antigravity-plugin/skills/ui-brief/SKILL.md +84 -0
  131. package/bundles/antigravity-plugin/skills/ui-review/SKILL.md +176 -0
  132. package/bundles/antigravity-plugin/skills/ui-review/references/framework-fixes.md +471 -0
  133. package/bundles/antigravity-plugin/skills/ui-review/references/visual-checklist.md +236 -0
  134. package/bundles/antigravity-plugin/skills/usage-review/SKILL.md +77 -0
  135. package/bundles/antigravity-plugin/skills/use-model/SKILL.md +64 -0
  136. package/bundles/antigravity-plugin/skills/using-git-worktrees/SKILL.md +217 -0
  137. package/bundles/antigravity-plugin/skills/version/SKILL.md +18 -0
  138. package/bundles/antigravity-plugin/skills/warm-editorial-ui/DESIGN_TOKENS.md +487 -0
  139. package/bundles/antigravity-plugin/skills/warm-editorial-ui/IMPLEMENTATION_GUIDE.md +177 -0
  140. package/bundles/antigravity-plugin/skills/warm-editorial-ui/SKILL.md +732 -0
  141. package/bundles/antigravity-plugin/skills/webapp-testing/LICENSE.txt +202 -0
  142. package/bundles/antigravity-plugin/skills/webapp-testing/SKILL.md +97 -0
  143. package/bundles/antigravity-plugin/skills/webapp-testing/examples/console_logging.py +35 -0
  144. package/bundles/antigravity-plugin/skills/webapp-testing/examples/element_discovery.py +40 -0
  145. package/bundles/antigravity-plugin/skills/webapp-testing/examples/static_html_automation.py +33 -0
  146. package/bundles/antigravity-plugin/skills/webapp-testing/scripts/with_server.py +106 -0
  147. package/bundles/antigravity-plugin/skills/windows-deployment/SKILL.md +880 -0
  148. package/bundles/antigravity-plugin/skills/writing-plans/SKILL.md +384 -0
  149. package/bundles/antigravity-plugin/statusline-command-agy.sh +91 -0
  150. package/bundles/antigravity-plugin/warm_start_agy.py +149 -0
  151. package/bundles/manifest.json +6 -0
  152. package/dist/cli.js +5363 -0
  153. package/package.json +61 -4
@@ -0,0 +1,315 @@
1
+ ---
2
+ name: ci-cd-pipeline
3
+ context: fork
4
+ description: CI/CD pipeline design and implementation for GitHub Actions, Azure DevOps, and general pipeline architecture. Use when creating build pipelines, deployment workflows, quality gates, environment promotion strategies, or automating release processes.
5
+ ---
6
+
7
+ # CI/CD Pipeline Skill
8
+
9
+ Automate the path from commit to production. Every merge should be deployable.
10
+
11
+ ## 1. When to Apply This Skill
12
+
13
+ **Trigger conditions:**
14
+ - Setting up CI/CD for a new project
15
+ - "Create a build and deploy pipeline"
16
+ - Adding quality gates to an existing pipeline
17
+ - Designing environment promotion strategy
18
+ - Troubleshooting pipeline failures or slow builds
19
+
20
+ ## 2. Pipeline Architecture
21
+
22
+ ### Standard Flow
23
+
24
+ ```
25
+ Commit → Lint → Test → Build → [Quality Gate] → Deploy Staging → [Approval] → Deploy Production
26
+ ```
27
+
28
+ ### Pipeline Stages
29
+
30
+ | Stage | Purpose | Fail = Block? |
31
+ |-------|---------|--------------|
32
+ | **Lint** | Code style, formatting | Yes |
33
+ | **Type Check** | Static type errors | Yes |
34
+ | **Unit Test** | Logic correctness | Yes |
35
+ | **Integration Test** | Service interactions | Yes |
36
+ | **Build** | Compile, bundle, containerise | Yes |
37
+ | **Security Scan** | Vulnerabilities, secrets | Yes (critical), Warn (medium) |
38
+ | **Deploy Staging** | Validate in staging env | Yes |
39
+ | **Smoke Test** | Basic health check post-deploy | Yes |
40
+ | **Deploy Production** | Ship to users | Manual approval required |
41
+
42
+ ## 3. GitHub Actions — Python Project
43
+
44
+ ```yaml
45
+ name: CI
46
+ context: fork
47
+
48
+ on:
49
+ push:
50
+ branches: [main]
51
+ pull_request:
52
+ branches: [main]
53
+
54
+ concurrency:
55
+ group: ${{ github.workflow }}-${{ github.ref }}
56
+ cancel-in-progress: true
57
+
58
+ jobs:
59
+ lint:
60
+ runs-on: ubuntu-latest
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+ - uses: actions/setup-python@v5
64
+ with:
65
+ python-version: "3.12"
66
+ cache: pip
67
+ - run: pip install ruff
68
+ - run: ruff check .
69
+ - run: ruff format --check .
70
+
71
+ test:
72
+ runs-on: ubuntu-latest
73
+ needs: lint
74
+ steps:
75
+ - uses: actions/checkout@v4
76
+ - uses: actions/setup-python@v5
77
+ with:
78
+ python-version: "3.12"
79
+ cache: pip
80
+ - run: pip install -e ".[test]"
81
+ - run: pytest --cov=src --cov-report=xml -q
82
+ - uses: codecov/codecov-action@v4
83
+ with:
84
+ file: coverage.xml
85
+
86
+ build:
87
+ runs-on: ubuntu-latest
88
+ needs: test
89
+ steps:
90
+ - uses: actions/checkout@v4
91
+ - uses: docker/setup-buildx-action@v3
92
+ - uses: docker/build-push-action@v5
93
+ with:
94
+ context: .
95
+ push: false
96
+ tags: app:${{ github.sha }}
97
+ cache-from: type=gha
98
+ cache-to: type=gha,mode=max
99
+ ```
100
+
101
+ ## 4. GitHub Actions — Node.js/TypeScript Project
102
+
103
+ ```yaml
104
+ name: CI
105
+ context: fork
106
+
107
+ on:
108
+ push:
109
+ branches: [main]
110
+ pull_request:
111
+ branches: [main]
112
+
113
+ concurrency:
114
+ group: ${{ github.workflow }}-${{ github.ref }}
115
+ cancel-in-progress: true
116
+
117
+ jobs:
118
+ quality:
119
+ runs-on: ubuntu-latest
120
+ steps:
121
+ - uses: actions/checkout@v4
122
+ - uses: pnpm/action-setup@v4
123
+ - uses: actions/setup-node@v4
124
+ with:
125
+ node-version: 22
126
+ cache: pnpm
127
+ - run: pnpm install --frozen-lockfile
128
+ - run: pnpm lint
129
+ - run: pnpm typecheck
130
+ - run: pnpm test -- --coverage
131
+ - run: pnpm build
132
+ ```
133
+
134
+ ## 5. Quality Gates
135
+
136
+ Define pass/fail criteria for each stage.
137
+
138
+ ```yaml
139
+ # quality-gates.yml (reference document)
140
+ gates:
141
+ lint:
142
+ ruff_errors: 0
143
+ format_diff: 0
144
+ test:
145
+ min_coverage: 80
146
+ max_test_duration_seconds: 120
147
+ allowed_failures: 0
148
+ security:
149
+ critical_vulnerabilities: 0
150
+ high_vulnerabilities: 0
151
+ build:
152
+ max_image_size_mb: 500
153
+ max_build_time_minutes: 10
154
+ deploy:
155
+ smoke_test_pass: true
156
+ health_check_pass: true
157
+ rollback_on_error_rate: 5 # percent
158
+ ```
159
+
160
+ ## 6. Environment Promotion Strategy
161
+
162
+ ```
163
+ Feature Branch → PR Review → Main → Staging → Production
164
+ │ │ │
165
+ │ │ └── Manual approval
166
+ │ └── Auto-deploy on main merge
167
+ └── CI runs on every PR
168
+ ```
169
+
170
+ | Environment | Deploy Trigger | Approval | Data |
171
+ |-------------|---------------|----------|------|
172
+ | **Dev** | Every push to branch | None | Synthetic/mock |
173
+ | **Staging** | Merge to main | Automatic | Production-like (anonymised) |
174
+ | **Production** | Tag or manual | Required (2 reviewers) | Real |
175
+
176
+ ## 7. Secrets Management
177
+
178
+ ```yaml
179
+ # ✅ GOOD: Use GitHub Actions secrets
180
+ env:
181
+ DATABASE_URL: ${{ secrets.DATABASE_URL }}
182
+ API_KEY: ${{ secrets.API_KEY }}
183
+
184
+ # ✅ GOOD: Use OIDC for cloud auth (no long-lived credentials)
185
+ - uses: aws-actions/configure-aws-credentials@v4
186
+ with:
187
+ role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
188
+ aws-region: eu-west-1
189
+
190
+ # ❌ BAD: Hardcoded secrets in workflow
191
+ env:
192
+ API_KEY: "sk-abc123" # NEVER DO THIS
193
+ ```
194
+
195
+ **Rules:**
196
+ - Never commit secrets to the repository
197
+ - Use environment-scoped secrets (staging secrets ≠ production secrets)
198
+ - Rotate secrets on a schedule (90 days max)
199
+ - Use OIDC federation over long-lived credentials where possible
200
+
201
+ ## 8. Caching Strategy
202
+
203
+ ```yaml
204
+ # Python pip cache
205
+ - uses: actions/setup-python@v5
206
+ with:
207
+ cache: pip
208
+
209
+ # Node.js pnpm cache
210
+ - uses: actions/setup-node@v4
211
+ with:
212
+ cache: pnpm
213
+
214
+ # Docker layer cache
215
+ - uses: docker/build-push-action@v5
216
+ with:
217
+ cache-from: type=gha
218
+ cache-to: type=gha,mode=max
219
+
220
+ # Custom cache (e.g., test fixtures)
221
+ - uses: actions/cache@v4
222
+ with:
223
+ path: .test-cache
224
+ key: test-fixtures-${{ hashFiles('tests/fixtures/**') }}
225
+ ```
226
+
227
+ ## 9. Pipeline Performance
228
+
229
+ Keep CI fast. Developers won't wait for slow pipelines.
230
+
231
+ | Target | Goal |
232
+ |--------|------|
233
+ | Lint + type check | < 2 minutes |
234
+ | Unit tests | < 5 minutes |
235
+ | Full pipeline (PR) | < 15 minutes |
236
+ | Deploy to staging | < 5 minutes |
237
+
238
+ **Optimisation techniques:**
239
+ - Run lint and test in parallel (separate jobs)
240
+ - Cache dependencies aggressively
241
+ - Use `concurrency` to cancel outdated runs
242
+ - Split slow test suites with `pytest -x --dist=loadgroup`
243
+ - Use Docker layer caching for builds
244
+
245
+ ## 10. Rollback Strategy
246
+
247
+ | Approach | Speed | Complexity |
248
+ |----------|-------|------------|
249
+ | **Revert commit** | Fast (minutes) | Low — git revert + re-deploy |
250
+ | **Blue-green deploy** | Instant (seconds) | Medium — swap traffic target |
251
+ | **Canary rollback** | Instant | High — requires traffic splitting |
252
+ | **Database rollback** | Slow, risky | High — only if migration is reversible |
253
+
254
+ **Rule:** Always prefer forward-fix (deploy a fix) over rollback. Rollback is the escape hatch, not the default.
255
+
256
+ ## 11. Anti-Patterns
257
+
258
+ | Anti-Pattern | Problem | Fix |
259
+ |---|---|---|
260
+ | No CI on PRs | Bugs merge to main | Run full pipeline on every PR |
261
+ | Deploy from local machine | "Works on my machine" | Deploy only from CI/CD |
262
+ | Single mega-job | Slow, hard to debug | Split into parallel stages |
263
+ | No caching | 10-min installs every run | Cache deps, Docker layers |
264
+ | Manual production deploy | Human error, inconsistent | Automated with approval gate |
265
+ | Secrets in code | Compromised on push | Use secrets manager + OIDC |
266
+ | No rollback plan | Broken deploy = downtime | Blue-green or revert strategy |
267
+ | Build passes but output is wrong | Config error baked into assets | Post-build output validation gate (§12) |
268
+
269
+ ## 12. Frontend Build Output Validation
270
+
271
+ A successful build (exit code 0) does not guarantee correct output. Configuration errors — especially wrong asset path prefixes — produce valid bundles that break at runtime. Add a **post-build validation step** in CI:
272
+
273
+ ### 12.1 Subpath Base-Path Check
274
+
275
+ When a frontend is deployed under a URL subpath (e.g. `/my-app/`), the built `index.html` must reference assets with that prefix. Vite's `base` config controls this, and it can be accidentally changed.
276
+
277
+ ```yaml
278
+ # GitHub Actions / Gitea Actions example
279
+ jobs:
280
+ frontend-checks:
281
+ runs-on: ubuntu-latest
282
+ steps:
283
+ - uses: actions/checkout@v4
284
+ - uses: actions/setup-node@v4
285
+ with:
286
+ node-version: 22
287
+ - run: npm ci
288
+ working-directory: frontend
289
+ # Build with production mode to activate conditional base path
290
+ - run: npx vite build --mode production
291
+ working-directory: frontend
292
+ - name: Validate production base path
293
+ working-directory: frontend
294
+ run: |
295
+ if ! grep -q '/my-app/assets/' dist/index.html; then
296
+ echo "FAIL: Built index.html does not reference /my-app/assets/"
297
+ echo "Check vite.config.ts base setting"
298
+ exit 1
299
+ fi
300
+ echo 'Base-path guard passed'
301
+ ```
302
+
303
+ **Key points:**
304
+ - Build with `--mode production` — without it, mode-conditional `base` stays as `"/"` and the guard always fails
305
+ - This catches the exact scenario where someone changes `base: mode === "production" ? "/my-app/" : "/"` to `base: "/"`
306
+ - The same check should also run in the deploy script as a belt-and-suspenders guard (abort before service restart)
307
+
308
+ ### 12.2 General Output Validation Patterns
309
+
310
+ | Check | Command | When to use |
311
+ |-------|---------|-------------|
312
+ | Subpath prefix | `grep -q '/{subpath}/assets/' dist/index.html` | Subpath deployments |
313
+ | Non-empty dist | `test -d dist/assets && ls dist/assets/*.js` | Always |
314
+ | Bundle size budget | `du -sh dist/ \| awk '{print $1}'` | When size regressions matter |
315
+ | No source maps in prod | `! ls dist/assets/*.map 2>/dev/null` | Production builds |
@@ -0,0 +1,271 @@
1
+ ---
2
+ name: code-documentation
3
+ description: Writing effective code documentation - API docs, README files, inline comments, and technical guides. Use for documenting codebases, APIs, or writing developer guides.
4
+ source: wshobson/agents
5
+ license: MIT
6
+ ---
7
+
8
+ # Code Documentation
9
+
10
+ ## Document Metadata
11
+
12
+ For standalone Markdown docs such as README files, guides, ADRs, and API reference pages, apply `.github/instructions/document-frontmatter.instructions.md` before the first heading.
13
+
14
+ - **New docs**: add `Original Author`, `Creation Date`, and `Creating Model`.
15
+ - **Updated docs**: preserve the original fields and add or update `Last Author`, `Last Updated`, and `Last Model Used`.
16
+ - Use full ISO 8601 UTC timestamps for `Creation Date` and `Last Updated` values.
17
+
18
+ ## README Structure
19
+
20
+ ### Standard README Template
21
+ ```markdown
22
+ # Project Name
23
+
24
+ Brief description of what this project does.
25
+
26
+ ## Quick Start
27
+
28
+ \`\`\`bash
29
+ npm install
30
+ npm run dev
31
+ \`\`\`
32
+
33
+ ## Installation
34
+
35
+ Detailed installation instructions...
36
+
37
+ ## Usage
38
+
39
+ \`\`\`typescript
40
+ import { something } from 'project';
41
+
42
+ // Example usage
43
+ const result = something.doThing();
44
+ \`\`\`
45
+
46
+ ## API Reference
47
+
48
+ ### `functionName(param: Type): ReturnType`
49
+
50
+ Description of what the function does.
51
+
52
+ **Parameters:**
53
+ - `param` - Description of parameter
54
+
55
+ **Returns:** Description of return value
56
+
57
+ **Example:**
58
+ \`\`\`typescript
59
+ const result = functionName('value');
60
+ \`\`\`
61
+
62
+ ## Configuration
63
+
64
+ | Option | Type | Default | Description |
65
+ |--------|------|---------|-------------|
66
+ | `option1` | `string` | `'default'` | What it does |
67
+
68
+ ## Contributing
69
+
70
+ How to contribute...
71
+
72
+ ## License
73
+
74
+ MIT
75
+ ```
76
+
77
+ ## API Documentation
78
+
79
+ ### JSDoc/TSDoc Style
80
+ ```typescript
81
+ /**
82
+ * Creates a new user account.
83
+ *
84
+ * @param userData - The user data for account creation
85
+ * @param options - Optional configuration
86
+ * @returns The created user object
87
+ * @throws {ValidationError} If email is invalid
88
+ * @example
89
+ * ```ts
90
+ * const user = await createUser({
91
+ * email: 'user@example.com',
92
+ * name: 'John'
93
+ * });
94
+ * ```
95
+ */
96
+ async function createUser(
97
+ userData: UserInput,
98
+ options?: CreateOptions
99
+ ): Promise<User> {
100
+ // Implementation
101
+ }
102
+
103
+ /**
104
+ * Configuration options for the API client.
105
+ */
106
+ interface ClientConfig {
107
+ /** The API base URL */
108
+ baseUrl: string;
109
+ /** Request timeout in milliseconds @default 5000 */
110
+ timeout?: number;
111
+ /** Custom headers to include in requests */
112
+ headers?: Record<string, string>;
113
+ }
114
+ ```
115
+
116
+ ### OpenAPI/Swagger
117
+ ```yaml
118
+ openapi: 3.0.0
119
+ info:
120
+ title: My API
121
+ version: 1.0.0
122
+
123
+ paths:
124
+ /users:
125
+ post:
126
+ summary: Create a user
127
+ description: Creates a new user account
128
+ requestBody:
129
+ required: true
130
+ content:
131
+ application/json:
132
+ schema:
133
+ $ref: '#/components/schemas/UserInput'
134
+ responses:
135
+ '201':
136
+ description: User created successfully
137
+ content:
138
+ application/json:
139
+ schema:
140
+ $ref: '#/components/schemas/User'
141
+ '400':
142
+ description: Invalid input
143
+
144
+ components:
145
+ schemas:
146
+ UserInput:
147
+ type: object
148
+ required:
149
+ - email
150
+ - name
151
+ properties:
152
+ email:
153
+ type: string
154
+ format: email
155
+ name:
156
+ type: string
157
+ User:
158
+ type: object
159
+ properties:
160
+ id:
161
+ type: string
162
+ email:
163
+ type: string
164
+ name:
165
+ type: string
166
+ createdAt:
167
+ type: string
168
+ format: date-time
169
+ ```
170
+
171
+ ## Inline Comments
172
+
173
+ ### When to Comment
174
+ ```typescript
175
+ // GOOD: Explain WHY, not WHAT
176
+
177
+ // Use binary search because the list is always sorted and
178
+ // can contain millions of items - O(log n) vs O(n)
179
+ const index = binarySearch(items, target);
180
+
181
+ // GOOD: Explain complex business logic
182
+ // Users get 20% discount if they've been members for 2+ years
183
+ // AND have made 10+ purchases (per marketing team decision Q4 2024)
184
+ if (user.memberYears >= 2 && user.purchaseCount >= 10) {
185
+ applyDiscount(0.2);
186
+ }
187
+
188
+ // GOOD: Document workarounds
189
+ // HACK: Safari doesn't support this API, fallback to polling
190
+ // TODO: Remove when Safari adds support (tracking: webkit.org/b/12345)
191
+ if (!window.IntersectionObserver) {
192
+ startPolling();
193
+ }
194
+ ```
195
+
196
+ ### When NOT to Comment
197
+ ```typescript
198
+ // BAD: Stating the obvious
199
+ // Increment counter by 1
200
+ counter++;
201
+
202
+ // BAD: Explaining clear code
203
+ // Check if user is admin
204
+ if (user.role === 'admin') { ... }
205
+
206
+ // BAD: Outdated comments (worse than no comment)
207
+ // Returns the user's full name <-- Actually returns email now!
208
+ function getUserIdentifier(user) {
209
+ return user.email;
210
+ }
211
+ ```
212
+
213
+ ## Architecture Documentation
214
+
215
+ ### ADR (Architecture Decision Record)
216
+ ```markdown
217
+ # ADR-001: Use PostgreSQL for Primary Database
218
+
219
+ ## Status
220
+ Accepted
221
+
222
+ ## Context
223
+ We need a database for storing user data and transactions.
224
+ Options considered: PostgreSQL, MySQL, MongoDB, DynamoDB.
225
+
226
+ ## Decision
227
+ Use PostgreSQL with Supabase hosting.
228
+
229
+ ## Rationale
230
+ - Strong ACID compliance needed for financial data
231
+ - Team has PostgreSQL experience
232
+ - Supabase provides auth and realtime features
233
+ - pgvector extension for future AI features
234
+
235
+ ## Consequences
236
+ - Need to manage schema migrations
237
+ - May need read replicas for scale
238
+ - Team needs to learn Supabase-specific features
239
+ ```
240
+
241
+ ### Component Documentation
242
+ ```markdown
243
+ ## Authentication Module
244
+
245
+ ### Overview
246
+ Handles user authentication using JWT tokens with refresh rotation.
247
+
248
+ ### Flow
249
+ 1. User submits credentials to `/auth/login`
250
+ 2. Server validates and returns access + refresh tokens
251
+ 3. Access token used for API requests (15min expiry)
252
+ 4. Refresh token used to get new access token (7d expiry)
253
+
254
+ ### Dependencies
255
+ - `jsonwebtoken` - Token generation/validation
256
+ - `bcrypt` - Password hashing
257
+ - `redis` - Refresh token storage
258
+
259
+ ### Configuration
260
+ - `JWT_SECRET` - Secret for signing tokens
261
+ - `ACCESS_TOKEN_EXPIRY` - Access token lifetime
262
+ - `REFRESH_TOKEN_EXPIRY` - Refresh token lifetime
263
+ ```
264
+
265
+ ## Documentation Principles
266
+
267
+ 1. **Write for your audience** - New devs vs API consumers
268
+ 2. **Keep it close to code** - Docs in same repo, near relevant code
269
+ 3. **Update with code** - Stale docs are worse than none
270
+ 4. **Examples over explanations** - Show, don't just tell
271
+ 5. **Progressive disclosure** - Quick start first, details later
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: code-review
3
+ context: fork
4
+ description: Automated code review for pull requests using specialized review patterns. Analyzes code for quality, security, performance, and best practices. Use when reviewing code changes, PRs, or doing code audits.
5
+ source: anthropics/claude-code
6
+ license: Apache-2.0
7
+ ---
8
+
9
+ # Code Review
10
+
11
+ ## Review Categories
12
+
13
+ ### 1. Security Review
14
+ Check for:
15
+ - SQL injection vulnerabilities
16
+ - XSS (Cross-Site Scripting)
17
+ - Command injection
18
+ - Insecure deserialization
19
+ - Hardcoded secrets/credentials
20
+ - Improper authentication/authorization
21
+ - Insecure direct object references
22
+
23
+ ### 2. Performance Review
24
+ Check for:
25
+ - N+1 queries
26
+ - Missing database indexes
27
+ - Unnecessary re-renders (React)
28
+ - Memory leaks
29
+ - Blocking operations in async code
30
+ - Missing caching opportunities
31
+ - Large bundle sizes
32
+
33
+ ### 3. Code Quality Review
34
+ Check for:
35
+ - Code duplication (DRY violations)
36
+ - Functions doing too much (SRP violations)
37
+ - Deep nesting / complex conditionals
38
+ - Magic numbers/strings
39
+ - Poor naming
40
+ - Missing error handling
41
+ - Incomplete type coverage
42
+
43
+ ### 4. Testing Review
44
+ Check for:
45
+ - Missing test coverage for new code
46
+ - Tests that don't test behavior
47
+ - Flaky test patterns
48
+ - Missing edge cases
49
+ - Mocked external dependencies
50
+
51
+ ## Review Output Format
52
+
53
+ ```markdown
54
+ ## Code Review Summary
55
+
56
+ ### 🔴 Critical (Must Fix)
57
+ - **[File:Line]** [Issue description]
58
+ - **Why:** [Explanation]
59
+ - **Fix:** [Suggested fix]
60
+
61
+ ### 🟡 Suggestions (Should Consider)
62
+ - **[File:Line]** [Issue description]
63
+ - **Why:** [Explanation]
64
+ - **Fix:** [Suggested fix]
65
+
66
+ ### 🟢 Nits (Optional)
67
+ - **[File:Line]** [Minor suggestion]
68
+
69
+ ### ✅ What's Good
70
+ - [Positive feedback on good patterns]
71
+ ```
72
+
73
+ ## Common Patterns to Flag
74
+
75
+ ### Security
76
+ ```javascript
77
+ // BAD: SQL injection
78
+ const query = `SELECT * FROM users WHERE id = ${userId}`;
79
+
80
+ // GOOD: Parameterized query
81
+ const query = 'SELECT * FROM users WHERE id = $1';
82
+ await db.query(query, [userId]);
83
+ ```
84
+
85
+ ### Performance
86
+ ```javascript
87
+ // BAD: N+1 query
88
+ users.forEach(async user => {
89
+ const posts = await getPosts(user.id);
90
+ });
91
+
92
+ // GOOD: Batch query
93
+ const userIds = users.map(u => u.id);
94
+ const posts = await getPostsForUsers(userIds);
95
+ ```
96
+
97
+ ### Error Handling
98
+ ```javascript
99
+ // BAD: Swallowing errors
100
+ try {
101
+ await riskyOperation();
102
+ } catch (e) {}
103
+
104
+ // GOOD: Handle or propagate
105
+ try {
106
+ await riskyOperation();
107
+ } catch (e) {
108
+ logger.error('Operation failed', { error: e });
109
+ throw new AppError('Operation failed', { cause: e });
110
+ }
111
+ ```
112
+
113
+ ## Review Checklist
114
+
115
+ - [ ] No hardcoded secrets
116
+ - [ ] Input validation present
117
+ - [ ] Error handling complete
118
+ - [ ] Types/interfaces defined
119
+ - [ ] Tests added for new code
120
+ - [ ] No obvious performance issues
121
+ - [ ] Code is readable and documented
122
+ - [ ] Breaking changes documented