cfsa-antigravity 2.19.0 → 2.19.2

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 (200) hide show
  1. package/package.json +1 -1
  2. package/template/.agent/kit-sync.md +3 -3
  3. package/template/.claude/commands/audit-ambiguity-execute.md +6 -0
  4. package/template/.claude/commands/audit-ambiguity-rubrics.md +6 -0
  5. package/template/.claude/commands/audit-ambiguity.md +6 -0
  6. package/template/.claude/commands/bootstrap-agents-fill.md +6 -0
  7. package/template/.claude/commands/bootstrap-agents-provision.md +6 -0
  8. package/template/.claude/commands/bootstrap-agents.md +6 -0
  9. package/template/.claude/commands/create-prd-architecture.md +6 -0
  10. package/template/.claude/commands/create-prd-compile.md +6 -0
  11. package/template/.claude/commands/create-prd-design-system.md +6 -0
  12. package/template/.claude/commands/create-prd-security.md +6 -0
  13. package/template/.claude/commands/create-prd-stack.md +6 -0
  14. package/template/.claude/commands/decompose-architecture-structure.md +6 -0
  15. package/template/.claude/commands/decompose-architecture-validate.md +6 -0
  16. package/template/.claude/commands/evolve-contract.md +6 -0
  17. package/template/.claude/commands/evolve-feature-cascade.md +6 -0
  18. package/template/.claude/commands/evolve-feature-classify.md +6 -0
  19. package/template/.claude/commands/evolve-feature.md +6 -0
  20. package/template/.claude/commands/ideate-discover.md +6 -0
  21. package/template/.claude/commands/ideate-extract.md +6 -0
  22. package/template/.claude/commands/ideate-validate.md +6 -0
  23. package/template/.claude/commands/implement-slice-setup.md +6 -0
  24. package/template/.claude/commands/implement-slice-tdd.md +6 -0
  25. package/template/.claude/commands/plan-phase-preflight.md +6 -0
  26. package/template/.claude/commands/plan-phase-write.md +6 -0
  27. package/template/.claude/commands/propagate-decision-apply.md +6 -0
  28. package/template/.claude/commands/propagate-decision-scan.md +6 -0
  29. package/template/.claude/commands/propagate-decision.md +6 -0
  30. package/template/.claude/commands/remediate-pipeline-assess.md +6 -0
  31. package/template/.claude/commands/remediate-pipeline-execute.md +6 -0
  32. package/template/.claude/commands/remediate-pipeline.md +6 -0
  33. package/template/.claude/commands/remediate-shard-split.md +6 -0
  34. package/template/.claude/commands/resolve-ambiguity.md +6 -0
  35. package/template/.claude/commands/setup-workspace-cicd.md +6 -0
  36. package/template/.claude/commands/setup-workspace-data.md +6 -0
  37. package/template/.claude/commands/setup-workspace-hosting.md +6 -0
  38. package/template/.claude/commands/setup-workspace-scaffold.md +6 -0
  39. package/template/.claude/commands/sync-kit.md +6 -0
  40. package/template/.claude/commands/update-architecture-map.md +6 -0
  41. package/template/.claude/commands/validate-phase-quality.md +6 -0
  42. package/template/.claude/commands/validate-phase-readiness.md +6 -0
  43. package/template/.claude/commands/verify-infrastructure.md +6 -0
  44. package/template/.claude/commands/write-architecture-spec-deepen.md +6 -0
  45. package/template/.claude/commands/write-architecture-spec-design.md +6 -0
  46. package/template/.claude/commands/write-be-spec-classify.md +6 -0
  47. package/template/.claude/commands/write-be-spec-write.md +6 -0
  48. package/template/.claude/commands/write-fe-spec-classify.md +6 -0
  49. package/template/.claude/commands/write-fe-spec-write.md +6 -0
  50. package/template/.claude/skills/accessibility/SKILL.md +522 -0
  51. package/template/.claude/skills/accessibility/references/WCAG.md +162 -0
  52. package/template/.claude/skills/accessibility/references/ia-spec-checklist.md +35 -0
  53. package/template/.claude/skills/adversarial-review/SKILL.md +90 -0
  54. package/template/.claude/skills/antigravity-workflows/SKILL.md +81 -0
  55. package/template/.claude/skills/antigravity-workflows/resources/implementation-playbook.md +36 -0
  56. package/template/.claude/skills/api-design-principles/SKILL.md +169 -0
  57. package/template/.claude/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  58. package/template/.claude/skills/api-design-principles/assets/rest-api-template.py +182 -0
  59. package/template/.claude/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  60. package/template/.claude/skills/api-design-principles/references/rest-best-practices.md +408 -0
  61. package/template/.claude/skills/api-design-principles/resources/implementation-playbook.md +513 -0
  62. package/template/.claude/skills/api-versioning/SKILL.md +166 -0
  63. package/template/.claude/skills/api-versioning/references/typescript.md +157 -0
  64. package/template/.claude/skills/architecture-mapping/SKILL.md +219 -0
  65. package/template/.claude/skills/bootstrap-agents/SKILL.md +258 -0
  66. package/template/.claude/skills/brainstorming/SKILL.md +177 -0
  67. package/template/.claude/skills/brand-guidelines/SKILL.md +44 -0
  68. package/template/.claude/skills/clean-code/SKILL.md +196 -0
  69. package/template/.claude/skills/clean-code/references/typescript.md +126 -0
  70. package/template/.claude/skills/code-review-pro/SKILL.md +152 -0
  71. package/template/.claude/skills/concise-planning/SKILL.md +107 -0
  72. package/template/.claude/skills/cross-layer-consistency/SKILL.md +117 -0
  73. package/template/.claude/skills/database-schema-design/SKILL.md +205 -0
  74. package/template/.claude/skills/database-schema-design/references/relational.md +228 -0
  75. package/template/.claude/skills/deployment-procedures/SKILL.md +241 -0
  76. package/template/.claude/skills/design-anti-cliche/SKILL.md +159 -0
  77. package/template/.claude/skills/design-direction/SKILL.md +45 -0
  78. package/template/.claude/skills/error-handling-patterns/SKILL.md +226 -0
  79. package/template/.claude/skills/error-handling-patterns/references/go.md +162 -0
  80. package/template/.claude/skills/error-handling-patterns/references/python.md +262 -0
  81. package/template/.claude/skills/error-handling-patterns/references/rust.md +112 -0
  82. package/template/.claude/skills/error-handling-patterns/references/typescript.md +178 -0
  83. package/template/.claude/skills/find-skills/SKILL.md +145 -0
  84. package/template/.claude/skills/git-advanced/SKILL.md +972 -0
  85. package/template/.claude/skills/git-workflow/SKILL.md +420 -0
  86. package/template/.claude/skills/idea-extraction/SKILL.md +644 -0
  87. package/template/.claude/skills/logging-best-practices/SKILL.md +192 -0
  88. package/template/.claude/skills/logging-best-practices/references/go.md +49 -0
  89. package/template/.claude/skills/logging-best-practices/references/python.md +52 -0
  90. package/template/.claude/skills/logging-best-practices/references/typescript.md +215 -0
  91. package/template/.claude/skills/migration-management/SKILL.md +200 -0
  92. package/template/.claude/skills/migration-management/references/relational.md +214 -0
  93. package/template/.claude/skills/minimalist-surgical-development/SKILL.md +135 -0
  94. package/template/.claude/skills/parallel-agents/SKILL.md +165 -0
  95. package/template/.claude/skills/parallel-debugging/SKILL.md +135 -0
  96. package/template/.claude/skills/parallel-feature-development/SKILL.md +157 -0
  97. package/template/.claude/skills/performance-budgeting/SKILL.md +144 -0
  98. package/template/.claude/skills/pipeline-rubrics/SKILL.md +51 -0
  99. package/template/.claude/skills/pipeline-rubrics/references/architecture-rubric.md +19 -0
  100. package/template/.claude/skills/pipeline-rubrics/references/be-rubric.md +21 -0
  101. package/template/.claude/skills/pipeline-rubrics/references/fe-rubric.md +20 -0
  102. package/template/.claude/skills/pipeline-rubrics/references/ia-rubric.md +19 -0
  103. package/template/.claude/skills/pipeline-rubrics/references/scoring.md +32 -0
  104. package/template/.claude/skills/pipeline-rubrics/references/vision-rubric.md +12 -0
  105. package/template/.claude/skills/prd-templates/SKILL.md +107 -0
  106. package/template/.claude/skills/prd-templates/references/architecture-completeness-checklist.md +28 -0
  107. package/template/.claude/skills/prd-templates/references/architecture-design-template.md +88 -0
  108. package/template/.claude/skills/prd-templates/references/be-spec-classification.md +41 -0
  109. package/template/.claude/skills/prd-templates/references/be-spec-template.md +107 -0
  110. package/template/.claude/skills/prd-templates/references/bootstrap-verification-protocol.md +50 -0
  111. package/template/.claude/skills/prd-templates/references/constraint-exploration.md +41 -0
  112. package/template/.claude/skills/prd-templates/references/data-placement-template.md +74 -0
  113. package/template/.claude/skills/prd-templates/references/decision-confirmation-protocol.md +68 -0
  114. package/template/.claude/skills/prd-templates/references/decision-propagation.md +121 -0
  115. package/template/.claude/skills/prd-templates/references/decomposition-templates.md +226 -0
  116. package/template/.claude/skills/prd-templates/references/deep-ideation-loading-protocol.md +114 -0
  117. package/template/.claude/skills/prd-templates/references/design-system-decisions.md +198 -0
  118. package/template/.claude/skills/prd-templates/references/design-system-prerequisite-check.md +18 -0
  119. package/template/.claude/skills/prd-templates/references/domain-exhaustion-criteria.md +37 -0
  120. package/template/.claude/skills/prd-templates/references/engagement-tier-protocol.md +58 -0
  121. package/template/.claude/skills/prd-templates/references/engineering-standards-template.md +126 -0
  122. package/template/.claude/skills/prd-templates/references/evolution-layer-guidance.md +91 -0
  123. package/template/.claude/skills/prd-templates/references/expansion-modes.md +27 -0
  124. package/template/.claude/skills/prd-templates/references/fe-classification-procedures.md +47 -0
  125. package/template/.claude/skills/prd-templates/references/fe-spec-template.md +90 -0
  126. package/template/.claude/skills/prd-templates/references/feature-ledger-protocol.md +149 -0
  127. package/template/.claude/skills/prd-templates/references/folder-seeding-protocol.md +77 -0
  128. package/template/.claude/skills/prd-templates/references/fractal-cx-template.md +58 -0
  129. package/template/.claude/skills/prd-templates/references/fractal-feature-template.md +93 -0
  130. package/template/.claude/skills/prd-templates/references/fractal-node-index-template.md +55 -0
  131. package/template/.claude/skills/prd-templates/references/gate-applicability.md +92 -0
  132. package/template/.claude/skills/prd-templates/references/ideation-crosscut-template.md +36 -0
  133. package/template/.claude/skills/prd-templates/references/ideation-index-template.md +111 -0
  134. package/template/.claude/skills/prd-templates/references/ideation-meta-template.md +126 -0
  135. package/template/.claude/skills/prd-templates/references/infrastructure-report-template.md +71 -0
  136. package/template/.claude/skills/prd-templates/references/input-classification.md +23 -0
  137. package/template/.claude/skills/prd-templates/references/map-guard-protocol.md +65 -0
  138. package/template/.claude/skills/prd-templates/references/operational-templates.md +116 -0
  139. package/template/.claude/skills/prd-templates/references/persona-completeness-gate.md +20 -0
  140. package/template/.claude/skills/prd-templates/references/placeholder-guard-template.md +21 -0
  141. package/template/.claude/skills/prd-templates/references/placeholder-workflow-mapping.md +50 -0
  142. package/template/.claude/skills/prd-templates/references/shard-boundary-analysis.md +103 -0
  143. package/template/.claude/skills/prd-templates/references/shard-split-remediation.md +157 -0
  144. package/template/.claude/skills/prd-templates/references/skill-loading-protocol.md +36 -0
  145. package/template/.claude/skills/prd-templates/references/slice-completion-gates.md +29 -0
  146. package/template/.claude/skills/prd-templates/references/spec-coverage-sweep.md +44 -0
  147. package/template/.claude/skills/prd-templates/references/surface-model.md +61 -0
  148. package/template/.claude/skills/prd-templates/references/tdd-testing-policy.md +39 -0
  149. package/template/.claude/skills/prd-templates/references/vision-template.md +57 -0
  150. package/template/.claude/skills/prd-templates/references/workflow-checkpoint-protocol.md +112 -0
  151. package/template/.claude/skills/prd-templates/references/write-verification-protocol.md +57 -0
  152. package/template/.claude/skills/prompt-engineer/SKILL.md +203 -0
  153. package/template/.claude/skills/regex-patterns/SKILL.md +333 -0
  154. package/template/.claude/skills/regex-patterns/references/go.md +44 -0
  155. package/template/.claude/skills/regex-patterns/references/javascript.md +63 -0
  156. package/template/.claude/skills/regex-patterns/references/python.md +77 -0
  157. package/template/.claude/skills/regex-patterns/references/rust.md +43 -0
  158. package/template/.claude/skills/resolve-ambiguity/SKILL.md +278 -0
  159. package/template/.claude/skills/security-scanning-security-hardening/SKILL.md +231 -0
  160. package/template/.claude/skills/session-continuity/SKILL.md +732 -0
  161. package/template/.claude/skills/session-continuity/protocols/01-session-resumption.md +38 -0
  162. package/template/.claude/skills/session-continuity/protocols/02-progress-generation.md +85 -0
  163. package/template/.claude/skills/session-continuity/protocols/03-progress-update.md +70 -0
  164. package/template/.claude/skills/session-continuity/protocols/04-pattern-extraction.md +60 -0
  165. package/template/.claude/skills/session-continuity/protocols/05-session-close.md +37 -0
  166. package/template/.claude/skills/session-continuity/protocols/06-decision-analysis.md +84 -0
  167. package/template/.claude/skills/session-continuity/protocols/07-spec-pipeline-generation.md +48 -0
  168. package/template/.claude/skills/session-continuity/protocols/08-spec-pipeline-update.md +55 -0
  169. package/template/.claude/skills/session-continuity/protocols/09-parallel-claim.md +122 -0
  170. package/template/.claude/skills/session-continuity/protocols/10-placeholder-verification-gate.md +83 -0
  171. package/template/.claude/skills/session-continuity/protocols/11-parallel-synthesis.md +21 -0
  172. package/template/.claude/skills/session-continuity/protocols/ambiguity-gates.md +48 -0
  173. package/template/.claude/skills/skill-creator/SKILL.md +203 -0
  174. package/template/.claude/skills/skill-creator/references/.gitkeep +0 -0
  175. package/template/.claude/skills/skill-creator/scripts/.gitkeep +0 -0
  176. package/template/.claude/skills/spec-writing/SKILL.md +110 -0
  177. package/template/.claude/skills/systematic-debugging/CREATION-LOG.md +119 -0
  178. package/template/.claude/skills/systematic-debugging/SKILL.md +297 -0
  179. package/template/.claude/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  180. package/template/.claude/skills/systematic-debugging/condition-based-waiting.md +115 -0
  181. package/template/.claude/skills/systematic-debugging/defense-in-depth.md +122 -0
  182. package/template/.claude/skills/systematic-debugging/find-polluter.sh +63 -0
  183. package/template/.claude/skills/systematic-debugging/root-cause-tracing.md +169 -0
  184. package/template/.claude/skills/systematic-debugging/test-academic.md +14 -0
  185. package/template/.claude/skills/systematic-debugging/test-pressure-1.md +58 -0
  186. package/template/.claude/skills/systematic-debugging/test-pressure-2.md +68 -0
  187. package/template/.claude/skills/systematic-debugging/test-pressure-3.md +69 -0
  188. package/template/.claude/skills/tdd-workflow/SKILL.md +186 -0
  189. package/template/.claude/skills/tdd-workflow/references/typescript.md +231 -0
  190. package/template/.claude/skills/tech-stack-catalog/SKILL.md +49 -0
  191. package/template/.claude/skills/tech-stack-catalog/references/constraint-questions.md +237 -0
  192. package/template/.claude/skills/tech-stack-catalog/references/dev-tooling-decisions.md +37 -0
  193. package/template/.claude/skills/tech-stack-catalog/references/surface-decision-tables.md +69 -0
  194. package/template/.claude/skills/technical-writer/SKILL.md +242 -0
  195. package/template/.claude/skills/testing-strategist/SKILL.md +319 -0
  196. package/template/.claude/skills/testing-strategist/references/typescript.md +328 -0
  197. package/template/.claude/skills/verification-before-completion/SKILL.md +97 -0
  198. package/template/.claude/skills/workflow-automation/SKILL.md +166 -0
  199. package/template/.claude/skills/workflow-automation/references/inngest.md +88 -0
  200. package/template/.claude/skills/workflow-automation/references/temporal.md +64 -0
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: logging-best-practices
3
+ description: Implement structured logging with JSON formats, log levels (DEBUG, INFO, WARN, ERROR), contextual logging, PII handling, and centralized logging. Use for logging, observability, log levels, structured logs, or debugging.
4
+ ---
5
+
6
+ # Logging Best Practices
7
+
8
+ ## Overview
9
+
10
+ Comprehensive guide to implementing structured, secure, and performant logging across applications. Covers log levels, structured logging formats, contextual information, PII protection, and centralized logging systems.
11
+
12
+ ## When to Use
13
+
14
+ - Setting up application logging infrastructure
15
+ - Implementing structured logging
16
+ - Configuring log levels for different environments
17
+ - Managing sensitive data in logs
18
+ - Setting up centralized logging
19
+ - Implementing distributed tracing
20
+ - Debugging production issues
21
+ - Compliance with logging regulations
22
+
23
+ ## Stack-Specific References
24
+
25
+ After reading the methodology below, read the reference matching your surface's Languages column:
26
+
27
+ | Language | Reference |
28
+ |----------|-----------|
29
+ | TypeScript / JavaScript | `references/typescript.md` |
30
+ | Python | `references/python.md` |
31
+ | Go | `references/go.md` |
32
+
33
+ ---
34
+
35
+ ## 1. Log Levels
36
+
37
+ | Level | When to Use | Production Default |
38
+ |-------|------------|-------------------|
39
+ | **DEBUG** | Detailed info for debugging — request payloads, intermediate values | OFF |
40
+ | **INFO** | General operational events — user actions, transactions, startup | ON |
41
+ | **WARN** | Potentially harmful — rate limits approaching, retry, deprecations | ON |
42
+ | **ERROR** | Failures the app can recover from — failed request, DB timeout | ON |
43
+ | **FATAL** | Critical failures — the app must stop | ON (triggers alerts) |
44
+
45
+ **Environment rules:**
46
+ - Development: DEBUG and above
47
+ - Staging: INFO and above
48
+ - Production: INFO and above (DEBUG only via feature flag for specific modules)
49
+
50
+ ---
51
+
52
+ ## 2. Structured Logging (JSON)
53
+
54
+ All production logs MUST be structured (JSON format), not free-text. Structured logs enable:
55
+ - Machine-parseable log aggregation
56
+ - Field-based search and filtering
57
+ - Dashboards and alerting
58
+
59
+ **Every log entry must include:**
60
+ - `timestamp` — ISO 8601 format
61
+ - `level` — log level string
62
+ - `message` — human-readable description
63
+ - `service` — service name
64
+ - `environment` — deployment environment
65
+
66
+ **Example output (any language):**
67
+ ```json
68
+ {
69
+ "timestamp": "2024-01-15T10:30:00.000Z",
70
+ "level": "INFO",
71
+ "message": "User created",
72
+ "service": "user-service",
73
+ "environment": "production",
74
+ "userId": "abc-123",
75
+ "requestId": "req-456"
76
+ }
77
+ ```
78
+
79
+ ---
80
+
81
+ ## 3. Contextual Logging
82
+
83
+ ### Request Context
84
+ Attach request metadata to every log within a request lifecycle:
85
+ - **Request ID** — unique identifier for correlating logs from one request
86
+ - **Correlation ID** — propagated across service boundaries in distributed systems
87
+ - **User ID** — authenticated user (if available)
88
+ - **HTTP method/path** — what was requested
89
+
90
+ ### Correlation IDs
91
+ In distributed systems, propagate a correlation ID via headers (`X-Correlation-Id`) so that logs from multiple services can be traced together.
92
+
93
+ ---
94
+
95
+ ## 4. PII and Sensitive Data Handling
96
+
97
+ **CRITICAL:** PII must NEVER appear in plaintext in logs.
98
+
99
+ ### Sensitive Fields (always redact or mask)
100
+ - Passwords, tokens, API keys
101
+ - SSN, credit card numbers
102
+ - Email addresses (depending on regulation)
103
+ - Phone numbers (depending on regulation)
104
+
105
+ ### Strategies
106
+ | Strategy | When to Use |
107
+ |----------|-------------|
108
+ | **Redaction** — replace with `[REDACTED]` | Passwords, API keys, tokens |
109
+ | **Masking** — partial reveal (`u***r@example.com`) | Email, phone, credit card |
110
+ | **Hashing** — one-way hash | When you need to correlate without revealing |
111
+ | **Omission** — don't log the field at all | When the field serves no diagnostic purpose |
112
+
113
+ ---
114
+
115
+ ## 5. Performance Logging
116
+
117
+ Track operation timing for performance monitoring:
118
+ - **Start timer** before operation
119
+ - **End timer** after operation
120
+ - **Log duration** with context
121
+ - **Alert on threshold** if operation exceeds expected time
122
+
123
+ Key operations to time:
124
+ - Database queries
125
+ - External API calls
126
+ - File I/O operations
127
+ - Complex computations
128
+
129
+ ---
130
+
131
+ ## 6. Centralized Logging
132
+
133
+ For distributed systems, aggregate logs to a central system:
134
+
135
+ | Tool | Type |
136
+ |------|------|
137
+ | **ELK Stack** | Elasticsearch + Logstash + Kibana (self-hosted) |
138
+ | **Grafana + Loki** | Lightweight log aggregation (self-hosted) |
139
+ | **Datadog** | Cloud monitoring and logging |
140
+ | **AWS CloudWatch** | AWS-native log management |
141
+ | **Splunk** | Enterprise log management |
142
+
143
+ ---
144
+
145
+ ## 7. Distributed Tracing
146
+
147
+ For microservice architectures, use OpenTelemetry (or similar) to trace requests across services:
148
+ - Create spans for each operation
149
+ - Propagate trace context via headers
150
+ - Export to Jaeger, Zipkin, or Datadog
151
+
152
+ ---
153
+
154
+ ## 8. Log Sampling (High-Volume Services)
155
+
156
+ For high-volume services, sample INFO/DEBUG logs to reduce volume:
157
+ - **Random sampling** — log N% of requests
158
+ - **Consistent sampling** — hash user ID so same user always gets logged (or not)
159
+ - **Always log** WARN and ERROR — never sample these
160
+
161
+ ---
162
+
163
+ ## Best Practices
164
+
165
+ ### ✅ DO
166
+ - Use structured logging (JSON) in production
167
+ - Include correlation/request IDs in all logs
168
+ - Log at appropriate levels (don't overuse DEBUG)
169
+ - Redact sensitive data (PII, passwords, tokens)
170
+ - Include context (userId, requestId, etc.)
171
+ - Log errors with full stack traces
172
+ - Use centralized logging in distributed systems
173
+ - Set up log rotation to manage disk space
174
+ - Monitor log volume and costs
175
+ - Use async logging for performance
176
+ - Include timestamps in ISO 8601 format
177
+ - Log business events (user actions, transactions)
178
+ - Set up alerts for error patterns
179
+
180
+ ### ❌ DON'T
181
+ - Log passwords, tokens, or sensitive data
182
+ - Use print/console.log in production
183
+ - Log at DEBUG level in production by default
184
+ - Log inside tight loops (use sampling)
185
+ - Include PII without anonymization
186
+ - Ignore log rotation (disk will fill up)
187
+ - Use synchronous logging in hot paths
188
+ - Log to multiple transports without need
189
+ - Forget to include error stack traces
190
+ - Log binary data or large objects
191
+ - Use string concatenation (use structured fields)
192
+ - Log every single request in high-volume APIs
@@ -0,0 +1,49 @@
1
+ # Go Logging Patterns
2
+
3
+ Language-specific patterns for the `logging-best-practices` skill. Read `SKILL.md` first for universal methodology.
4
+
5
+ ---
6
+
7
+ ## Libraries
8
+
9
+ | Library | Use Case |
10
+ |---------|----------|
11
+ | **zap** | High-performance structured logging |
12
+ | **zerolog** | Zero-allocation JSON logger |
13
+
14
+ ## zap Setup
15
+
16
+ ```go
17
+ package main
18
+
19
+ import "go.uber.org/zap"
20
+
21
+ func main() {
22
+ // Production config (JSON output)
23
+ logger, _ := zap.NewProduction()
24
+ defer logger.Sync()
25
+
26
+ // Development config (human-readable)
27
+ // logger, _ := zap.NewDevelopment()
28
+
29
+ logger.Info("User created",
30
+ zap.String("userId", user.ID),
31
+ zap.String("email", user.Email),
32
+ zap.String("requestId", req.ID),
33
+ )
34
+
35
+ logger.Error("Payment processing failed",
36
+ zap.Error(err),
37
+ zap.String("orderId", order.ID),
38
+ zap.Float64("amount", order.Total),
39
+ zap.String("userId", user.ID),
40
+ )
41
+
42
+ // Sugared logger for convenience (slightly slower)
43
+ sugar := logger.Sugar()
44
+ sugar.Infow("User login",
45
+ "userId", user.ID,
46
+ "ip", req.IP,
47
+ )
48
+ }
49
+ ```
@@ -0,0 +1,52 @@
1
+ # Python Logging Patterns
2
+
3
+ Language-specific patterns for the `logging-best-practices` skill. Read `SKILL.md` first for universal methodology.
4
+
5
+ ---
6
+
7
+ ## Libraries
8
+
9
+ | Library | Use Case |
10
+ |---------|----------|
11
+ | **structlog** | Structured logging with processors |
12
+ | **logging** | Standard library (structlog wraps it) |
13
+
14
+ ## structlog Setup
15
+
16
+ ```python
17
+ import structlog
18
+ import logging
19
+
20
+ structlog.configure(
21
+ processors=[
22
+ structlog.stdlib.filter_by_level,
23
+ structlog.stdlib.add_logger_name,
24
+ structlog.stdlib.add_log_level,
25
+ structlog.stdlib.PositionalArgumentsFormatter(),
26
+ structlog.processors.TimeStamper(fmt="iso"),
27
+ structlog.processors.StackInfoRenderer(),
28
+ structlog.processors.format_exc_info,
29
+ structlog.processors.UnicodeDecoder(),
30
+ structlog.processors.JSONRenderer()
31
+ ],
32
+ context_class=dict,
33
+ logger_factory=structlog.stdlib.LoggerFactory(),
34
+ cache_logger_on_first_use=True,
35
+ )
36
+
37
+ logger = structlog.get_logger()
38
+
39
+ # Usage
40
+ logger.info("user_created",
41
+ user_id=user.id,
42
+ email=user.email,
43
+ request_id=request.id
44
+ )
45
+
46
+ logger.error("payment_failed",
47
+ error=str(error),
48
+ order_id=order.id,
49
+ amount=order.total,
50
+ user_id=user.id
51
+ )
52
+ ```
@@ -0,0 +1,215 @@
1
+ # TypeScript Logging Patterns
2
+
3
+ Language-specific patterns for the `logging-best-practices` skill. Read `SKILL.md` first for universal methodology.
4
+
5
+ ---
6
+
7
+ ## Libraries
8
+
9
+ | Library | Use Case |
10
+ |---------|----------|
11
+ | **Winston** | Versatile, multi-transport, production-ready |
12
+ | **Pino** | High-performance JSON logger |
13
+ | **OpenTelemetry SDK** | Distributed tracing |
14
+
15
+ ## Winston Setup
16
+
17
+ ```typescript
18
+ import winston from 'winston';
19
+
20
+ const logger = winston.createLogger({
21
+ level: process.env.LOG_LEVEL || 'info',
22
+ format: winston.format.combine(
23
+ winston.format.timestamp(),
24
+ winston.format.errors({ stack: true }),
25
+ winston.format.json()
26
+ ),
27
+ defaultMeta: {
28
+ service: 'user-service',
29
+ environment: process.env.NODE_ENV
30
+ },
31
+ transports: [
32
+ new winston.transports.Console({
33
+ format: winston.format.combine(
34
+ winston.format.colorize(),
35
+ winston.format.simple()
36
+ )
37
+ }),
38
+ new winston.transports.File({
39
+ filename: 'logs/error.log',
40
+ level: 'error',
41
+ maxsize: 5242880, maxFiles: 5
42
+ }),
43
+ new winston.transports.File({
44
+ filename: 'logs/combined.log',
45
+ maxsize: 5242880, maxFiles: 5
46
+ })
47
+ ]
48
+ });
49
+
50
+ logger.info('User created', { userId: user.id, requestId: req.id });
51
+ logger.error('Payment failed', { error: error.message, stack: error.stack, orderId: order.id });
52
+ ```
53
+
54
+ ## Request Context Middleware
55
+
56
+ ```typescript
57
+ import { v4 as uuidv4 } from 'uuid';
58
+ import { AsyncLocalStorage } from 'async_hooks';
59
+
60
+ const asyncLocalStorage = new AsyncLocalStorage();
61
+
62
+ export function requestLogger(req, res, next) {
63
+ const requestId = req.headers['x-request-id'] || uuidv4();
64
+ const context = {
65
+ requestId, method: req.method, path: req.path,
66
+ ip: req.ip, userId: req.user?.id
67
+ };
68
+
69
+ asyncLocalStorage.run(context, () => {
70
+ logger.info('Request started', context);
71
+ res.on('finish', () => {
72
+ logger.info('Request completed', {
73
+ ...context, statusCode: res.statusCode,
74
+ duration: Date.now() - req.startTime
75
+ });
76
+ });
77
+ req.startTime = Date.now();
78
+ next();
79
+ });
80
+ }
81
+
82
+ export function getLogger() {
83
+ const context = asyncLocalStorage.getStore();
84
+ return {
85
+ info: (message: string, meta?: object) =>
86
+ logger.info(message, { ...context, ...meta }),
87
+ error: (message: string, error: Error, meta?: object) =>
88
+ logger.error(message, { ...context, error, ...meta }),
89
+ warn: (message: string, meta?: object) =>
90
+ logger.warn(message, { ...context, ...meta }),
91
+ debug: (message: string, meta?: object) =>
92
+ logger.debug(message, { ...context, ...meta })
93
+ };
94
+ }
95
+ ```
96
+
97
+ ## PII Sanitization
98
+
99
+ ```typescript
100
+ const SENSITIVE_FIELDS = ['password', 'token', 'apiKey', 'ssn', 'creditCard', 'email', 'phone'];
101
+
102
+ function sanitize(obj: any): any {
103
+ if (typeof obj !== 'object' || obj === null) return obj;
104
+ if (Array.isArray(obj)) return obj.map(sanitize);
105
+
106
+ const sanitized = {};
107
+ for (const [key, value] of Object.entries(obj)) {
108
+ if (SENSITIVE_FIELDS.some(f => key.toLowerCase().includes(f.toLowerCase()))) {
109
+ sanitized[key] = '[REDACTED]';
110
+ } else if (typeof value === 'object') {
111
+ sanitized[key] = sanitize(value);
112
+ } else {
113
+ sanitized[key] = value;
114
+ }
115
+ }
116
+ return sanitized;
117
+ }
118
+
119
+ function maskEmail(email: string): string {
120
+ const [local, domain] = email.split('@');
121
+ return `${local[0]}${'*'.repeat(local.length - 2)}${local[local.length - 1]}@${domain}`;
122
+ }
123
+ ```
124
+
125
+ ## Performance Logger
126
+
127
+ ```typescript
128
+ class PerformanceLogger {
129
+ private timers = new Map<string, number>();
130
+
131
+ start(op: string) { this.timers.set(op, Date.now()); }
132
+
133
+ end(op: string, meta?: object) {
134
+ const start = this.timers.get(op);
135
+ if (!start) return;
136
+ const duration = Date.now() - start;
137
+ this.timers.delete(op);
138
+ logger.info(`Performance: ${op}`, { operation: op, durationMs: duration, ...meta });
139
+ if (duration > 1000) {
140
+ logger.warn(`Slow operation: ${op}`, { operation: op, durationMs: duration, threshold: 1000, ...meta });
141
+ }
142
+ }
143
+
144
+ async measure<T>(op: string, fn: () => Promise<T>, meta?: object): Promise<T> {
145
+ this.start(op);
146
+ try { return await fn(); } finally { this.end(op, meta); }
147
+ }
148
+ }
149
+ ```
150
+
151
+ ## Distributed Tracing (OpenTelemetry)
152
+
153
+ ```typescript
154
+ import opentelemetry from '@opentelemetry/api';
155
+ import { NodeTracerProvider } from '@opentelemetry/node';
156
+ import { SimpleSpanProcessor } from '@opentelemetry/tracing';
157
+ import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
158
+
159
+ const provider = new NodeTracerProvider();
160
+ provider.addSpanProcessor(
161
+ new SimpleSpanProcessor(new JaegerExporter({
162
+ serviceName: 'user-service',
163
+ endpoint: 'http://jaeger:14268/api/traces'
164
+ }))
165
+ );
166
+ provider.register();
167
+
168
+ const tracer = opentelemetry.trace.getTracer('user-service');
169
+
170
+ app.get('/api/users/:id', async (req, res) => {
171
+ const span = tracer.startSpan('get-user', {
172
+ attributes: { 'http.method': req.method, 'http.url': req.url }
173
+ });
174
+ try {
175
+ const user = await fetchUser(req.params.id);
176
+ span.setStatus({ code: opentelemetry.SpanStatusCode.OK });
177
+ res.json(user);
178
+ } catch (error) {
179
+ span.setStatus({ code: opentelemetry.SpanStatusCode.ERROR, message: error.message });
180
+ res.status(500).json({ error: 'Internal server error' });
181
+ } finally {
182
+ span.end();
183
+ }
184
+ });
185
+ ```
186
+
187
+ ## Centralized Logging (ELK + Winston)
188
+
189
+ ```typescript
190
+ import 'winston-logstash';
191
+
192
+ const elkLogger = winston.createLogger({
193
+ transports: [
194
+ new winston.transports.Logstash({
195
+ port: 5000, host: 'logstash',
196
+ node_name: 'user-service', max_connect_retries: -1
197
+ })
198
+ ]
199
+ });
200
+ ```
201
+
202
+ ## Log Sampling
203
+
204
+ ```typescript
205
+ class SamplingLogger {
206
+ constructor(private logger: Logger, private sampleRate = 0.1) {}
207
+
208
+ info(message: string, meta?: object) {
209
+ if (Math.random() < this.sampleRate) this.logger.info(message, meta);
210
+ }
211
+
212
+ warn(message: string, meta?: object) { this.logger.warn(message, meta); }
213
+ error(message: string, error: Error, meta?: object) { this.logger.error(message, error, meta); }
214
+ }
215
+ ```
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: database-migration-management
3
+ description: Manage database migrations and schema versioning. Use when planning migrations, version control, rollback strategies, or data transformations for any database paradigm.
4
+ ---
5
+
6
+ # Database Migration Management
7
+
8
+ ## Overview
9
+
10
+ Implement robust database migration systems with version control, rollback capabilities, and data transformation strategies. This skill covers universal migration methodology. For paradigm-specific tooling, see references.
11
+
12
+ ## When to Use
13
+
14
+ - Schema versioning and evolution
15
+ - Data transformations and cleanup
16
+ - Adding/removing tables, columns, collections, or fields
17
+ - Index creation and optimization
18
+ - Migration testing and validation
19
+ - Rollback planning and execution
20
+ - Multi-environment deployments
21
+
22
+ ## Paradigm-Specific References
23
+
24
+ After reading the methodology below, read the reference matching your surface's Databases column in the surface stack map (`.agent/instructions/tech-stack.md`):
25
+
26
+ | Paradigm | Reference | Example Stores |
27
+ |----------|-----------|----------------|
28
+ | Relational | `references/relational.md` | PostgreSQL, MySQL, SQLite |
29
+ | Document | `references/document.md` | MongoDB, Firestore, CouchDB |
30
+ | Graph | `references/graph.md` | SurrealDB, Neo4j, ArangoDB |
31
+
32
+ ---
33
+
34
+ ## Universal Migration Principles
35
+
36
+ ### 1. Bidirectional Migrations
37
+
38
+ Every migration must have both directions:
39
+ - **UP** — applies the change
40
+ - **DOWN** — reverses the change
41
+
42
+ If a migration cannot be reversed (e.g., data deletion), document this explicitly and require a backup before execution.
43
+
44
+ ### 2. Migration Ordering
45
+
46
+ Migrations are **sequentially ordered** by timestamp or version number:
47
+ - Timestamp format: `YYYYMMDD_NNN_description` (e.g., `20240115_001_add_phone_to_users`)
48
+ - Never reorder or renumber existing migrations
49
+ - Never modify an already-executed migration — create a new one
50
+
51
+ ### 3. Idempotency
52
+
53
+ Migrations should be idempotent where possible:
54
+ - Use "IF NOT EXISTS" / "IF EXISTS" guards
55
+ - Check for the presence of the change before applying it
56
+ - Run pre-flight checks before destructive operations
57
+
58
+ ### 4. Atomic Migrations
59
+
60
+ Each migration should be a single logical change:
61
+ - One migration = one purpose (add column, create table, transform data)
62
+ - Don't combine unrelated changes
63
+ - Use transactions for multi-statement migrations where supported
64
+
65
+ ---
66
+
67
+ ## Common Migration Patterns
68
+
69
+ ### Safe Schema Changes
70
+
71
+ | Operation | Safe? | Strategy |
72
+ |-----------|-------|----------|
73
+ | Add nullable column | ✅ Always safe | Add with default or NULL |
74
+ | Add NOT NULL column | ⚠️ Requires backfill | Add nullable → backfill → add constraint |
75
+ | Rename column | ⚠️ Requires coordination | Add new → copy data → update app → drop old |
76
+ | Drop column | ⚠️ Requires coordination | Stop reading → deploy → drop column |
77
+ | Add index | ⚠️ Can lock table | Use concurrent/online index creation |
78
+ | Drop table | 🔴 Destructive | Backup first, confirm no references |
79
+
80
+ ### Multi-Phase Migrations
81
+
82
+ For non-trivial schema changes (rename, type change, restructure):
83
+
84
+ 1. **Phase 1: Expand** — Add new structure alongside old
85
+ 2. **Phase 2: Migrate** — Copy/transform data to new structure
86
+ 3. **Phase 3: Contract** — Remove old structure after verification
87
+
88
+ This pattern prevents downtime and allows rollback at any phase.
89
+
90
+ ### Data Transformation Migrations
91
+
92
+ When transforming data (normalization, cleanup, format changes):
93
+
94
+ 1. **Verify source data** — Count records, check constraints
95
+ 2. **Apply transformation** — Batch for large datasets
96
+ 3. **Validate results** — Compare counts, spot-check values
97
+ 4. **Document irreversibility** — If rollback requires backup restore, say so
98
+
99
+ ---
100
+
101
+ ## Rollback Strategies
102
+
103
+ ### Per-Migration Rollback
104
+
105
+ Every migration has a DOWN direction. Execute in reverse order:
106
+ - Migration 5 DOWN
107
+ - Migration 4 DOWN
108
+ - Migration 3 DOWN
109
+ - ... until target version reached
110
+
111
+ ### Point-in-Time Recovery
112
+
113
+ For data-destructive migrations:
114
+ - Require backup before execution
115
+ - Document the backup location
116
+ - Test restore procedure before migration
117
+
118
+ ### Blue-Green Schema Changes
119
+
120
+ For zero-downtime migrations:
121
+ - Run new schema alongside old
122
+ - Application supports both schemas during transition
123
+ - Cut over when new schema is verified
124
+ - Drop old schema after observation period
125
+
126
+ ---
127
+
128
+ ## Testing Migrations
129
+
130
+ ### Local Testing
131
+
132
+ 1. **Fresh database** — Run all migrations from scratch (empty → current)
133
+ 2. **Incremental** — Run only new migrations on a copy of production
134
+ 3. **Rollback** — Test DOWN migration after UP
135
+ 4. **Data integrity** — Verify constraints hold after migration
136
+
137
+ ### Staging Validation
138
+
139
+ 1. Restore production backup to staging
140
+ 2. Run migrations on staging
141
+ 3. Verify application works against migrated schema
142
+ 4. Run automated tests against staging
143
+ 5. Record migration timing for capacity planning
144
+
145
+ ### Pre-Production Checklist
146
+
147
+ - [ ] Tested on local database
148
+ - [ ] Tested on staging with production data copy
149
+ - [ ] Rollback procedure tested
150
+ - [ ] Backup verified before migration
151
+ - [ ] Application code compatible with both old and new schema
152
+ - [ ] Migration timing measured (acceptable for maintenance window?)
153
+ - [ ] Long-running query impact assessed
154
+
155
+ ---
156
+
157
+ ## Production Deployment
158
+
159
+ ### Safe Migration Checklist
160
+
161
+ - [ ] Test migration on production-like database
162
+ - [ ] Verify backup exists before migration
163
+ - [ ] Schedule during low-traffic window
164
+ - [ ] Monitor locks and long-running queries
165
+ - [ ] Have rollback plan ready and tested
166
+ - [ ] Document all changes
167
+ - [ ] Run in transaction when possible
168
+ - [ ] Verify data integrity after migration
169
+ - [ ] Coordinate application code deployment with migration
170
+ - [ ] Notify team of migration window
171
+
172
+ ### Post-Migration Verification
173
+
174
+ 1. **Schema check** — Verify new structures exist
175
+ 2. **Data check** — Verify data integrity constraints
176
+ 3. **Application check** — Verify application reads/writes correctly
177
+ 4. **Performance check** — Verify query performance hasn't degraded
178
+ 5. **Monitoring** — Watch error rates for 24 hours post-migration
179
+
180
+ ---
181
+
182
+ ## Migration Tracking
183
+
184
+ Maintain a migration history table (or equivalent) that records:
185
+ - Migration version/ID
186
+ - Migration name/description
187
+ - Execution timestamp
188
+ - Duration
189
+ - Checksum (to detect tampering)
190
+ - Status (applied, rolled back, failed)
191
+
192
+ ---
193
+
194
+ ## Resources
195
+
196
+ - [Flyway](https://flywaydb.org/) — Java/JVM migration tool
197
+ - [Liquibase](https://www.liquibase.org/) — Database changelog management
198
+ - [Alembic](https://alembic.sqlalchemy.org/) — Python/SQLAlchemy migrations
199
+ - [Knex.js](https://knexjs.org/) — Node.js query builder with migrations
200
+ - [golang-migrate](https://github.com/golang-migrate/migrate) — Go migration tool