baldart 3.6.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 (230) hide show
  1. package/CHANGELOG.md +599 -0
  2. package/README.md +566 -0
  3. package/VERSION +1 -0
  4. package/bin/baldart.js +143 -0
  5. package/framework/.claude/agents/REGISTRY.md +169 -0
  6. package/framework/.claude/agents/api-perf-cost-auditor.md +291 -0
  7. package/framework/.claude/agents/code-reviewer.md +350 -0
  8. package/framework/.claude/agents/codebase-architect.md +391 -0
  9. package/framework/.claude/agents/coder.md +291 -0
  10. package/framework/.claude/agents/deep-human-insight.md +198 -0
  11. package/framework/.claude/agents/doc-reviewer.md +440 -0
  12. package/framework/.claude/agents/email-deliverability-architect.md +193 -0
  13. package/framework/.claude/agents/hybrid-ml-architect.md +285 -0
  14. package/framework/.claude/agents/hyper-gamification-designer.md +149 -0
  15. package/framework/.claude/agents/legal-counsel-gdpr.md +179 -0
  16. package/framework/.claude/agents/marketing-conversion-strategist.md +162 -0
  17. package/framework/.claude/agents/motion-expert.md +108 -0
  18. package/framework/.claude/agents/onboarding-architect-lead.md +230 -0
  19. package/framework/.claude/agents/plan-auditor.md +546 -0
  20. package/framework/.claude/agents/prd-card-writer.md +372 -0
  21. package/framework/.claude/agents/prd.md +744 -0
  22. package/framework/.claude/agents/qa-sentinel.md +305 -0
  23. package/framework/.claude/agents/remotion-animator-orchestrator.md +218 -0
  24. package/framework/.claude/agents/security-reviewer.md +276 -0
  25. package/framework/.claude/agents/senior-researcher.md +175 -0
  26. package/framework/.claude/agents/seo-analytics-strategist.md +156 -0
  27. package/framework/.claude/agents/skill-improver.md +61 -0
  28. package/framework/.claude/agents/ui-expert.md +191 -0
  29. package/framework/.claude/agents/visual-designer.md +190 -0
  30. package/framework/.claude/agents/website-orchestrator.md +118 -0
  31. package/framework/.claude/agents/wiki-curator.md +145 -0
  32. package/framework/.claude/commands/baldart-push.md +15 -0
  33. package/framework/.claude/commands/check.md +237 -0
  34. package/framework/.claude/commands/codexreview.md +203 -0
  35. package/framework/.claude/commands/design-review.md +11 -0
  36. package/framework/.claude/commands/issue-review.md +34 -0
  37. package/framework/.claude/commands/new.md +331 -0
  38. package/framework/.claude/commands/qa.md +257 -0
  39. package/framework/.claude/hooks/framework-edit-gate.js +208 -0
  40. package/framework/.claude/hooks/lint-before-commit.sh.template +66 -0
  41. package/framework/.claude/settings.local.json.example +32 -0
  42. package/framework/.claude/skills/api-design-principles/SKILL.md +567 -0
  43. package/framework/.claude/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  44. package/framework/.claude/skills/api-design-principles/assets/rest-api-template.py +182 -0
  45. package/framework/.claude/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  46. package/framework/.claude/skills/api-design-principles/references/rest-best-practices.md +408 -0
  47. package/framework/.claude/skills/baldart-push/SKILL.md +222 -0
  48. package/framework/.claude/skills/bug/SKILL.md +200 -0
  49. package/framework/.claude/skills/bug/references/logging-patterns.md +174 -0
  50. package/framework/.claude/skills/capture/SKILL.md +125 -0
  51. package/framework/.claude/skills/capture/references/synthesis-template.md +42 -0
  52. package/framework/.claude/skills/context-primer/SKILL.md +189 -0
  53. package/framework/.claude/skills/copywriting/SKILL.md +273 -0
  54. package/framework/.claude/skills/copywriting/references/copy-frameworks.md +338 -0
  55. package/framework/.claude/skills/copywriting/references/natural-transitions.md +252 -0
  56. package/framework/.claude/skills/doc-writing-for-rag/SKILL.md +119 -0
  57. package/framework/.claude/skills/doc-writing-for-rag/references/before-after-examples.md +291 -0
  58. package/framework/.claude/skills/doc-writing-for-rag/references/compact-templates.md +183 -0
  59. package/framework/.claude/skills/doc-writing-for-rag/references/frontmatter-minimal.md +112 -0
  60. package/framework/.claude/skills/doc-writing-for-rag/references/line-count-targets.md +110 -0
  61. package/framework/.claude/skills/doc-writing-for-rag/references/schemas-and-errors.md +129 -0
  62. package/framework/.claude/skills/find-skills/SKILL.md +133 -0
  63. package/framework/.claude/skills/frontend-design/LICENSE.txt +177 -0
  64. package/framework/.claude/skills/frontend-design/SKILL.md +84 -0
  65. package/framework/.claude/skills/gamification-design/SKILL.md +130 -0
  66. package/framework/.claude/skills/issue-review/SKILL.md +45 -0
  67. package/framework/.claude/skills/kie-ai/SKILL.md +262 -0
  68. package/framework/.claude/skills/kie-ai/references/models-catalog.md +272 -0
  69. package/framework/.claude/skills/kie-ai/scripts/kie_api.sh +209 -0
  70. package/framework/.claude/skills/kie-ai/scripts/remove_greenscreen.py +69 -0
  71. package/framework/.claude/skills/kie-ai/scripts/setup_api_key.sh +77 -0
  72. package/framework/.claude/skills/motion-design/LICENSE +21 -0
  73. package/framework/.claude/skills/motion-design/README.md +82 -0
  74. package/framework/.claude/skills/motion-design/SKILL.md +336 -0
  75. package/framework/.claude/skills/motion-design/director/choreography.md +93 -0
  76. package/framework/.claude/skills/motion-design/director/context-adaptation.md +83 -0
  77. package/framework/.claude/skills/motion-design/director/core-philosophy.md +53 -0
  78. package/framework/.claude/skills/motion-design/director/decision-framework.md +91 -0
  79. package/framework/.claude/skills/motion-design/director/disney-principles.md +102 -0
  80. package/framework/.claude/skills/motion-design/director/emotion-mapping.md +71 -0
  81. package/framework/.claude/skills/motion-design/director/motion-personality.md +89 -0
  82. package/framework/.claude/skills/motion-design/director/narrative-structure.md +62 -0
  83. package/framework/.claude/skills/motion-design/patterns/ambient-continuous.md +81 -0
  84. package/framework/.claude/skills/motion-design/patterns/entrance-exit.md +82 -0
  85. package/framework/.claude/skills/motion-design/patterns/multi-element.md +69 -0
  86. package/framework/.claude/skills/motion-design/patterns/state-feedback.md +96 -0
  87. package/framework/.claude/skills/motion-design/reference/property-selection.md +95 -0
  88. package/framework/.claude/skills/motion-design/reference/quality-checklist.md +67 -0
  89. package/framework/.claude/skills/motion-design/reference/timing-easing-tables.md +106 -0
  90. package/framework/.claude/skills/motion-design/reference/troubleshooting.md +73 -0
  91. package/framework/.claude/skills/new/SKILL.md +1687 -0
  92. package/framework/.claude/skills/playwright-skill/API_REFERENCE.md +652 -0
  93. package/framework/.claude/skills/playwright-skill/SKILL.md +157 -0
  94. package/framework/.claude/skills/playwright-skill/package.json +26 -0
  95. package/framework/.claude/skills/prd/SKILL.md +228 -0
  96. package/framework/.claude/skills/prd/assets/card-template.yml +232 -0
  97. package/framework/.claude/skills/prd/assets/epic-template.yml +190 -0
  98. package/framework/.claude/skills/prd/assets/prd-template.md +230 -0
  99. package/framework/.claude/skills/prd/assets/state-template.md +78 -0
  100. package/framework/.claude/skills/prd/references/api-perf-gate.md +152 -0
  101. package/framework/.claude/skills/prd/references/audit-phase.md +478 -0
  102. package/framework/.claude/skills/prd/references/backlog-phase.md +145 -0
  103. package/framework/.claude/skills/prd/references/discovery-phase.md +359 -0
  104. package/framework/.claude/skills/prd/references/impact-analysis.md +233 -0
  105. package/framework/.claude/skills/prd/references/prd-add-phase.md +214 -0
  106. package/framework/.claude/skills/prd/references/prd-writing-phase.md +145 -0
  107. package/framework/.claude/skills/prd/references/research-phase.md +216 -0
  108. package/framework/.claude/skills/prd/references/ui-design-phase.md +61 -0
  109. package/framework/.claude/skills/prd/references/validation-phase.md +72 -0
  110. package/framework/.claude/skills/prd-add/SKILL.md +222 -0
  111. package/framework/.claude/skills/prd-add/references/impact-analysis.md +233 -0
  112. package/framework/.claude/skills/remotion-best-practices/SKILL.md +48 -0
  113. package/framework/.claude/skills/remotion-best-practices/rules/3d.md +86 -0
  114. package/framework/.claude/skills/remotion-best-practices/rules/animations.md +29 -0
  115. package/framework/.claude/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
  116. package/framework/.claude/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
  117. package/framework/.claude/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
  118. package/framework/.claude/skills/remotion-best-practices/rules/assets.md +78 -0
  119. package/framework/.claude/skills/remotion-best-practices/rules/audio.md +169 -0
  120. package/framework/.claude/skills/remotion-best-practices/rules/calculate-metadata.md +104 -0
  121. package/framework/.claude/skills/remotion-best-practices/rules/can-decode.md +75 -0
  122. package/framework/.claude/skills/remotion-best-practices/rules/charts.md +58 -0
  123. package/framework/.claude/skills/remotion-best-practices/rules/compositions.md +141 -0
  124. package/framework/.claude/skills/remotion-best-practices/rules/display-captions.md +184 -0
  125. package/framework/.claude/skills/remotion-best-practices/rules/extract-frames.md +229 -0
  126. package/framework/.claude/skills/remotion-best-practices/rules/fonts.md +152 -0
  127. package/framework/.claude/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
  128. package/framework/.claude/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
  129. package/framework/.claude/skills/remotion-best-practices/rules/get-video-duration.md +58 -0
  130. package/framework/.claude/skills/remotion-best-practices/rules/gifs.md +141 -0
  131. package/framework/.claude/skills/remotion-best-practices/rules/images.md +130 -0
  132. package/framework/.claude/skills/remotion-best-practices/rules/import-srt-captions.md +69 -0
  133. package/framework/.claude/skills/remotion-best-practices/rules/light-leaks.md +73 -0
  134. package/framework/.claude/skills/remotion-best-practices/rules/lottie.md +67 -0
  135. package/framework/.claude/skills/remotion-best-practices/rules/maps.md +401 -0
  136. package/framework/.claude/skills/remotion-best-practices/rules/measuring-dom-nodes.md +34 -0
  137. package/framework/.claude/skills/remotion-best-practices/rules/measuring-text.md +143 -0
  138. package/framework/.claude/skills/remotion-best-practices/rules/parameters.md +98 -0
  139. package/framework/.claude/skills/remotion-best-practices/rules/sequencing.md +118 -0
  140. package/framework/.claude/skills/remotion-best-practices/rules/subtitles.md +36 -0
  141. package/framework/.claude/skills/remotion-best-practices/rules/tailwind.md +11 -0
  142. package/framework/.claude/skills/remotion-best-practices/rules/text-animations.md +20 -0
  143. package/framework/.claude/skills/remotion-best-practices/rules/timing.md +179 -0
  144. package/framework/.claude/skills/remotion-best-practices/rules/transcribe-captions.md +70 -0
  145. package/framework/.claude/skills/remotion-best-practices/rules/transitions.md +197 -0
  146. package/framework/.claude/skills/remotion-best-practices/rules/transparent-videos.md +106 -0
  147. package/framework/.claude/skills/remotion-best-practices/rules/trimming.md +52 -0
  148. package/framework/.claude/skills/remotion-best-practices/rules/videos.md +171 -0
  149. package/framework/.claude/skills/seo-audit/SKILL.md +394 -0
  150. package/framework/.claude/skills/seo-audit/references/aeo-geo-patterns.md +279 -0
  151. package/framework/.claude/skills/seo-audit/references/ai-writing-detection.md +190 -0
  152. package/framework/.claude/skills/simplify/SKILL.md +137 -0
  153. package/framework/.claude/skills/skill-creator/LICENSE.txt +202 -0
  154. package/framework/.claude/skills/skill-creator/SKILL.md +356 -0
  155. package/framework/.claude/skills/skill-creator/references/output-patterns.md +82 -0
  156. package/framework/.claude/skills/skill-creator/references/workflows.md +28 -0
  157. package/framework/.claude/skills/skill-creator/scripts/init_skill.py +303 -0
  158. package/framework/.claude/skills/skill-creator/scripts/package_skill.py +110 -0
  159. package/framework/.claude/skills/skill-creator/scripts/quick_validate.py +95 -0
  160. package/framework/.claude/skills/ui-design/SKILL.md +199 -0
  161. package/framework/.claude/skills/ui-design/references/component-discovery.md +54 -0
  162. package/framework/.claude/skills/ui-design/references/evaluation.md +171 -0
  163. package/framework/.claude/skills/ui-design/references/generation.md +109 -0
  164. package/framework/.claude/skills/ui-design/references/inventory.md +59 -0
  165. package/framework/.claude/skills/webapp-testing/LICENSE.txt +202 -0
  166. package/framework/.claude/skills/webapp-testing/SKILL.md +123 -0
  167. package/framework/.claude/skills/webapp-testing/examples/console_logging.py +35 -0
  168. package/framework/.claude/skills/webapp-testing/examples/element_discovery.py +40 -0
  169. package/framework/.claude/skills/webapp-testing/examples/static_html_automation.py +33 -0
  170. package/framework/.claude/skills/webapp-testing/scripts/with_server.py +106 -0
  171. package/framework/.claude/skills/worktree-manager/SKILL.md +680 -0
  172. package/framework/AGENTS.md +240 -0
  173. package/framework/agents/api-contracts.md +137 -0
  174. package/framework/agents/architecture.md +145 -0
  175. package/framework/agents/coding-standards.md +148 -0
  176. package/framework/agents/data-model.md +110 -0
  177. package/framework/agents/deployment-protocol.md +232 -0
  178. package/framework/agents/design-review.md +172 -0
  179. package/framework/agents/env-reference.md +171 -0
  180. package/framework/agents/github-issue-subagent.md +252 -0
  181. package/framework/agents/index.md +261 -0
  182. package/framework/agents/llm-wiki-methodology.md +216 -0
  183. package/framework/agents/maintenance-protocol.md +305 -0
  184. package/framework/agents/observability.md +162 -0
  185. package/framework/agents/performance.md +155 -0
  186. package/framework/agents/project-context.md +145 -0
  187. package/framework/agents/runbook.md +208 -0
  188. package/framework/agents/security.md +168 -0
  189. package/framework/agents/skills-mapping.md +286 -0
  190. package/framework/agents/testing.md +111 -0
  191. package/framework/agents/workflows.md +215 -0
  192. package/framework/docs/PROJECT-CONFIGURATION.md +336 -0
  193. package/framework/docs/references/brand-guidelines.md +170 -0
  194. package/framework/docs/references/ui-guidelines.template.md +182 -0
  195. package/framework/routines/code-review.routine.yml +46 -0
  196. package/framework/routines/doc-review.routine.yml +45 -0
  197. package/framework/routines/ds-drift.routine.yml +52 -0
  198. package/framework/routines/full-sweep.routine.yml +51 -0
  199. package/framework/routines/index.yml +70 -0
  200. package/framework/routines/skill-improve.routine.yml +50 -0
  201. package/framework/routines/wiki-review.routine.yml +45 -0
  202. package/framework/templates/baldart.config.template.yml +113 -0
  203. package/framework/templates/breaking-change-checklist.md +484 -0
  204. package/framework/templates/feature-card.template.yml +125 -0
  205. package/framework/templates/overlays/README.md +44 -0
  206. package/framework/templates/overlays/copywriting.fidelity-example.md +62 -0
  207. package/framework/templates/overlays/ui-design.fidelity-example.md +75 -0
  208. package/framework/templates/skill-project-context.snippet.md +19 -0
  209. package/framework/templates/spec.template.md +208 -0
  210. package/package.json +51 -0
  211. package/src/commands/add.js +229 -0
  212. package/src/commands/configure.js +385 -0
  213. package/src/commands/doctor.js +486 -0
  214. package/src/commands/migrate.js +185 -0
  215. package/src/commands/push.js +0 -0
  216. package/src/commands/routines.js +269 -0
  217. package/src/commands/status.js +130 -0
  218. package/src/commands/update.js +419 -0
  219. package/src/commands/version.js +88 -0
  220. package/src/utils/contamination.js +400 -0
  221. package/src/utils/git.js +181 -0
  222. package/src/utils/hooks.js +152 -0
  223. package/src/utils/routine-adapters/claude-code-cloud.js +78 -0
  224. package/src/utils/routine-adapters/cron.js +138 -0
  225. package/src/utils/routine-adapters/github-actions.js +141 -0
  226. package/src/utils/routine-adapters/index.js +21 -0
  227. package/src/utils/routines.js +166 -0
  228. package/src/utils/state.js +143 -0
  229. package/src/utils/symlinks.js +425 -0
  230. package/src/utils/ui.js +133 -0
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: bug
3
+ description: >
4
+ Structured bug investigation and resolution workflow (framework-agnostic; project-specific entry points are loaded from `.baldart/overlays/bug.md`).
5
+ Use when: the user says /bug, 'debug', 'c e un bug', 'non funziona', 'errore', 'broken',
6
+ 'investigate', or reports unexpected behavior. Accepts optional bug description as argument.
7
+ Enforces a disciplined 5-phase debugging protocol that prevents blind guessing:
8
+ (1) Reproduce & observe, (2) Enhanced logging if stuck, (3) Data-driven analysis,
9
+ (4) Hypothesis & minimal fix, (5) Verify. Leverages Playwright MCP for browser capture,
10
+ codebase-architect for code path tracing, doc-rag for known patterns, git bisect for regressions.
11
+ ---
12
+
13
+ # /bug — Structured Bug Investigation
14
+
15
+ Argument: optional bug description (e.g., `/bug feature X is not saving`).
16
+
17
+ ## Project Context
18
+
19
+ **Reads from `baldart.config.yml`:** `paths.design_system`, `paths.references_dir`.
20
+ **Gated by features:** `features.has_design_system` (when `true`, Phase 4's design-system reads become BLOCKING for UI-touching bugs).
21
+ **Overlay:** loads `.baldart/overlays/bug.md` if present — project-specific debug entry points (e.g. SWR debug switches, env summary helpers, error-code modules). The base skill stays generic; project-specific code paths live in the overlay.
22
+ **On missing/empty keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.
23
+
24
+ ## ANTI-PATTERNS (NEVER DO)
25
+
26
+ - NEVER change code before reproducing the bug
27
+ - NEVER guess the root cause — form hypotheses from evidence only
28
+ - NEVER skip logging escalation when first pass finds nothing
29
+ - NEVER fix symptoms — trace to root cause
30
+ - NEVER remove temporary debug code without grep verification
31
+
32
+ ## PHASE 0: TRIAGE (< 2 min)
33
+
34
+ 1. Parse the bug description from args (or ask user if missing)
35
+ 2. Classify the bug domain:
36
+ - **UI/Client** → Playwright MCP is primary tool
37
+ - **API/Server** → dev server logs + route handler analysis
38
+ - **Data/Firestore** → MCP Firestore tools + transaction tracing
39
+ - **Auth** → authMiddleware.ts + auth error codes
40
+ - **Build/Deploy** → Vercel logs + build output
41
+ 3. Launch `codebase-architect` agent to map the affected code paths — do NOT start debugging blind
42
+ 4. Search doc-rag for related patterns: `mcp__doc-rag__search_docs` with bug keywords
43
+ - always use `mode="hybrid"` (vector + knowledge graph) for richer context retrieval
44
+ - if results come from Obsidian, treat them as context only and verify runtime behavior against repo docs/code before fixing
45
+ 5. Check git history for recent changes in affected area:
46
+ ```
47
+ git log --oneline -20 --all -- <affected-files>
48
+ git log --oneline -10 --grep="<related-keyword>"
49
+ ```
50
+
51
+ ## PHASE 1: REPRODUCE & OBSERVE (mandatory before any code change)
52
+
53
+ Goal: get a reliable reproduction that you can re-run after fixing.
54
+
55
+ **For UI bugs:**
56
+ 1. Navigate with Playwright MCP: `browser_navigate` to the affected page
57
+ 2. Capture baseline: `browser_take_screenshot`
58
+ 3. Capture console state: `browser_console_messages`
59
+ 4. Capture network: `browser_network_requests`
60
+ 5. Reproduce the bug step-by-step, capturing after each action
61
+ 6. Record the exact sequence that triggers the bug
62
+
63
+ **For API bugs:**
64
+ 1. Identify the route handler file from the URL pattern
65
+ 2. Read the handler code — understand the full flow before anything else
66
+ 3. Check the error propagation pattern: look for `throw new Error(JSON.stringify({code, status, message}))` — this is the domain error contract
67
+ 4. Test the endpoint directly if possible (curl or Playwright network capture)
68
+
69
+ **For data bugs:**
70
+ 1. Use `mcp__plugin_firebase_firebase__firestore_get_document` to inspect the document state
71
+ 2. Check field values, timestamps, missing fields
72
+ 3. If collection query: use `firestore_query_collection` to verify query results
73
+
74
+ **Outcome:** a clear, repeatable reproduction OR evidence that the bug is intermittent (in which case, skip to Phase 2 immediately).
75
+
76
+ ## PHASE 2: ENHANCED LOGGING (escalate if Phase 1 didn't reveal root cause)
77
+
78
+ **This is the critical phase.** If you don't see the root cause within 5 minutes of Phase 1, escalate to enhanced logging IMMEDIATELY. Do NOT keep reading code hoping to find it.
79
+
80
+ ### Server-side logging injection
81
+
82
+ Add temporary debug logs to suspected route handlers. ALL temporary logs MUST:
83
+ - Use prefix `[DEBUG:<module>]` for easy grep
84
+ - End the line with comment `// DEBUG:` marker
85
+ - Include timestamps: `new Date().toISOString()`
86
+
87
+ ```typescript
88
+ console.log(`[DEBUG:reservations] PATCH entry`, { // DEBUG:
89
+ id: params.id,
90
+ body: JSON.stringify(body).slice(0, 500),
91
+ user: req.user?.uid,
92
+ ts: new Date().toISOString(),
93
+ }); // DEBUG:
94
+ ```
95
+
96
+ For Firestore operations, wrap reads/writes:
97
+ ```typescript
98
+ const t0 = Date.now(); // DEBUG:
99
+ const snap = await firestore.collection('X').doc(id).get();
100
+ console.log(`[DEBUG:fs] READ ${snap.ref.path} ${Date.now()-t0}ms exists=${snap.exists}`, snap.exists ? Object.keys(snap.data()!) : 'N/A'); // DEBUG:
101
+ ```
102
+
103
+ For transactions, log attempt count:
104
+ ```typescript
105
+ let attempt = 0; // DEBUG:
106
+ await firestore.runTransaction(async (tx) => {
107
+ attempt++; // DEBUG:
108
+ console.log(`[DEBUG:tx] attempt=${attempt}`); // DEBUG:
109
+ // ... existing code
110
+ });
111
+ console.log(`[DEBUG:tx] done in ${attempt} attempts`); // DEBUG:
112
+ ```
113
+
114
+ ### Client-side logging (via Playwright MCP — zero code changes)
115
+
116
+ Use `browser_evaluate` to inject runtime instrumentation:
117
+ ```javascript
118
+ // Intercept all fetch calls
119
+ const origFetch = window.fetch;
120
+ window.fetch = async (...args) => {
121
+ const url = typeof args[0] === 'string' ? args[0] : args[0]?.url;
122
+ console.log('[DEBUG:fetch]', args[1]?.method || 'GET', url);
123
+ try {
124
+ const res = await origFetch(...args);
125
+ if (!res.ok) {
126
+ const clone = res.clone();
127
+ const text = await clone.text().catch(() => '');
128
+ console.error('[DEBUG:fetch] error', res.status, url, text.slice(0, 500));
129
+ }
130
+ return res;
131
+ } catch(e) {
132
+ console.error('[DEBUG:fetch] network error', url, e.message);
133
+ throw e;
134
+ }
135
+ };
136
+ ```
137
+ Then capture everything: `browser_console_messages` after reproducing.
138
+
139
+ ### Cache/data-fetch debug mode
140
+
141
+ If the bug involves stale data and the project ships a cache provider with a debug switch (see `.baldart/overlays/bug.md` for the project-specific entry point — e.g. SWR/React Query/Apollo provider, env summary helper), enable it temporarily. Mark every temporary line with `// DEBUG:` so it can be grepped and reverted in Phase 5.
142
+
143
+ ### Environment check
144
+
145
+ If the project exposes an env-summary helper (listed in `.baldart/overlays/bug.md`), call it to confirm env state. Otherwise, manually inspect the relevant `process.env` keys for the failing flow.
146
+
147
+ ## PHASE 3: DATA-DRIVEN ANALYSIS
148
+
149
+ 1. Reproduce the bug AGAIN with enhanced logging active
150
+ 2. Collect ALL output:
151
+ - Server terminal (grep for `[DEBUG:`)
152
+ - `browser_console_messages` from Playwright
153
+ - `browser_network_requests` from Playwright
154
+ - Screenshots before/after
155
+ 3. Analyze:
156
+ - **Timeline**: what happened in what order?
157
+ - **Divergence**: where does expected flow differ from actual?
158
+ - **Error codes**: match against the project's error-code module (listed in `.baldart/overlays/bug.md`).
159
+ - **Database state**: correct data returned? Transaction retries? (Storage tech depends on project.)
160
+ - **Network**: status codes? Request bodies?
161
+ 4. If regression, use git bisect:
162
+ ```
163
+ git bisect start HEAD <last-known-good> --
164
+ git bisect run sh -c "npx tsc --noEmit 2>/dev/null || exit 125; <test-command>"
165
+ ```
166
+ 5. Form a specific hypothesis: "The bug occurs because X at line Y in file Z causes W"
167
+
168
+ ## PHASE 4: HYPOTHESIS & FIX
169
+
170
+ 1. State hypothesis explicitly
171
+ 2. Verify consistency with ALL collected evidence
172
+ 3. **Design System SSOT (MANDATORY for UI/styling bugs, when `features.has_design_system: true`)**: if the bug is visual (layout, spacing, color, motion, theming, overlay z-index) or the fix touches a UI component, you MUST read `${paths.design_system}/INDEX.md` and the relevant `${paths.design_system}/components/<Name>.md` BEFORE proposing the fix. This prevents patching symptoms with hardcoded hex/shadow values while the real fix is a token or component prop. Theming bugs (when `features.multi_tenant_theming: true`) → read the project's theming pattern doc; motion/animation bugs → read the project's motion pattern doc (both listed in `.baldart/overlays/bug.md` and `.baldart/overlays/ui-design.md`).
173
+ 4. Implement MINIMAL fix — fewest lines possible
174
+ 5. Do NOT refactor, add features, or "improve" surrounding code
175
+
176
+ ## PHASE 5: VERIFY & CLEAN UP
177
+
178
+ 1. Reproduce original scenario — confirm fix
179
+ 2. Check regressions: `npx tsc --noEmit` + `npx eslint --max-warnings=0 <changed-files>`
180
+ 3. If tests exist: `npm run test`
181
+ 4. **REMOVE ALL DEBUG LOGGING:**
182
+ ```bash
183
+ grep -rn '// DEBUG:' src/ --include='*.ts' --include='*.tsx'
184
+ ```
185
+ Remove every line found. Run grep again to confirm zero results.
186
+ 5. Revert any temporary cache/data-fetch debug switches enabled in Phase 2
187
+ 6. Final Playwright screenshot to confirm visually
188
+
189
+ ## TOOLS QUICK REFERENCE
190
+
191
+ | Tool | When | Purpose |
192
+ |------|------|---------|
193
+ | `codebase-architect` agent | Phase 0 | Map affected code paths |
194
+ | `mcp__doc-rag__search_docs` | Phase 0 | Search known patterns/errors (`hybrid` mode — vector + knowledge graph; if MCP available) |
195
+ | `mcp__playwright__browser_*` | Phase 1-5 | Navigate, screenshot, console, network |
196
+ | Project DB MCP (if available) | Phase 1 | Inspect storage state (e.g. firestore/postgres tools) |
197
+ | `git log/blame/bisect` | Phase 0, 3 | Find regression commits |
198
+ | Project-specific entry points | various | Listed in `.baldart/overlays/bug.md` — error-code module, env-summary helper, cache debug switch |
199
+
200
+ For detailed logging patterns, env vars, and storage debugging: see [references/logging-patterns.md](references/logging-patterns.md).
@@ -0,0 +1,174 @@
1
+ # Logging Patterns & Debug Environment Reference
2
+
3
+ ## Next.js 16 Built-In Logging (next.config.ts)
4
+
5
+ Add these to `next.config.ts` during debug sessions:
6
+
7
+ ```typescript
8
+ logging: {
9
+ fetches: { fullUrl: true }, // logs all server-side fetch() with cache HIT/MISS
10
+ serverFunctions: true, // logs Server Actions with name + args + duration
11
+ browserToTerminal: true, // forwards ALL client console.* to terminal with [browser] prefix
12
+ incomingRequests: {
13
+ ignore: [/\/api\/v1\/ping/, /\/_next/], // filter noise
14
+ },
15
+ },
16
+ ```
17
+
18
+ `browserToTerminal` (v16.2+) is the most powerful: it streams client-side `console.*` to the dev server terminal with file:line:col source location. No code changes needed.
19
+
20
+ ## Environment Variables for Debug Sessions
21
+
22
+ Set in `.env.local` during investigation, remove after:
23
+
24
+ ```bash
25
+ DEBUG_MODULES=reservations.patch,booking.schedule # server-side module filter
26
+ DEBUG_FIRESTORE=true # Firestore op tracing
27
+ DEBUG_NETWORK=true # request/response logging
28
+ DEBUG_PROXY=true # proxy/middleware logging
29
+ NEXT_PUBLIC_DEBUG_COMPONENTS=booking.form,planner # client component logs (rebuild required)
30
+ NEXT_OTEL_VERBOSE=1 # verbose OpenTelemetry spans
31
+ NEXT_TURBOPACK_TRACING=1 # Turbopack bundler trace → .next/dev/trace-turbopack
32
+ ```
33
+
34
+ ## Debug Log Convention
35
+
36
+ ALL temporary log lines MUST end with `// DEBUG:` comment marker.
37
+
38
+ Cleanup command:
39
+ ```bash
40
+ grep -rn '// DEBUG:' src/ --include='*.ts' --include='*.tsx'
41
+ ```
42
+
43
+ Remove every line found. Run grep again. Zero results = clean.
44
+
45
+ ## Firestore-Specific Debugging
46
+
47
+ ### Transaction contention
48
+ Firestore retries transactions silently up to 5 times. Only explicit attempt counting surfaces this:
49
+ ```typescript
50
+ let attempt = 0; // DEBUG:
51
+ await firestore.runTransaction(async (tx) => {
52
+ attempt++; // DEBUG:
53
+ console.log(`[DEBUG:tx] attempt=${attempt} path=${ref.path}`); // DEBUG:
54
+ });
55
+ ```
56
+
57
+ ### Snapshot ambiguity
58
+ `snapshot.empty === true` is AMBIGUOUS — could be security rules denial OR genuinely no documents. Check:
59
+ - `snapshot.metadata.fromCache` — `true` = offline/cached, `false` = network response
60
+ - `snapshot.metadata.hasPendingWrites` — pending optimistic writes
61
+
62
+ ### Query Explain (firebase-admin)
63
+ ```typescript
64
+ // PLAN mode: no reads, just execution plan
65
+ const plan = await query.explain({ analyze: false });
66
+ // ANALYZE mode: runs query, returns stats
67
+ const analysis = await query.explain({ analyze: true });
68
+ // RED FLAG: readOperations >> resultsReturned = missing composite index
69
+ ```
70
+
71
+ ### Security Rules debugging
72
+ `debug()` in Firestore rules works ONLY in the emulator, no-op in production.
73
+ Use `@firebase/rules-unit-testing` (already in devDeps) for rule testing.
74
+
75
+ ## Playwright MCP Debug Patterns
76
+
77
+ ### Inject fetch interceptor (zero code changes)
78
+ ```javascript
79
+ // browser_evaluate:
80
+ const origFetch = window.fetch;
81
+ window.fetch = async (...args) => {
82
+ const url = typeof args[0] === 'string' ? args[0] : args[0]?.url;
83
+ const method = args[1]?.method || 'GET';
84
+ console.log(`[DEBUG:fetch] ${method} ${url}`);
85
+ const start = Date.now();
86
+ try {
87
+ const res = await origFetch(...args);
88
+ console.log(`[DEBUG:fetch] ${res.status} ${url} ${Date.now()-start}ms`);
89
+ if (!res.ok) {
90
+ const clone = res.clone();
91
+ console.error(`[DEBUG:fetch] body:`, await clone.text().catch(() => ''));
92
+ }
93
+ return res;
94
+ } catch(e) {
95
+ console.error(`[DEBUG:fetch] FAIL ${url}`, e.message);
96
+ throw e;
97
+ }
98
+ };
99
+ ```
100
+
101
+ ### Inject SWR mutation tracker
102
+ ```javascript
103
+ // browser_evaluate:
104
+ const origMutate = window.__SWR_MUTATE__;
105
+ if (origMutate) {
106
+ window.__SWR_MUTATE__ = (...args) => {
107
+ console.log('[DEBUG:swr] mutate', args[0]);
108
+ return origMutate(...args);
109
+ };
110
+ }
111
+ ```
112
+
113
+ ### HAR recording (for complex network analysis)
114
+ In Playwright test context:
115
+ ```typescript
116
+ const context = await browser.newContext({ recordHar: { path: 'debug.har', mode: 'full' } });
117
+ ```
118
+
119
+ ## CDP (Chrome DevTools Protocol) via Playwright
120
+
121
+ For deep debugging beyond MCP tools:
122
+ ```typescript
123
+ const session = await context.newCDPSession(page);
124
+ await session.send('Runtime.enable');
125
+ session.on('Runtime.consoleAPICalled', (event) => { /* raw console events */ });
126
+ session.on('Runtime.exceptionThrown', (event) => { /* uncaught exceptions */ });
127
+ await session.send('Network.enable');
128
+ session.on('Network.requestWillBeSent', (event) => { /* all network + headers */ });
129
+ ```
130
+
131
+ ## Git Bisect Workflow
132
+
133
+ ```bash
134
+ # Find the commit that introduced a regression
135
+ git bisect start HEAD <last-known-good-tag> --
136
+ git bisect run sh -c "npx tsc --noEmit 2>/dev/null || exit 125; <test-command>"
137
+ git bisect reset
138
+
139
+ # Tips:
140
+ # - exit 125 = skip (untestable commit, e.g. npm install fails)
141
+ # - --first-parent avoids false positives from broken merge branches
142
+ # - Save session: git bisect log > session.log / replay: git bisect replay session.log
143
+ # - Skip if deps fail: npm ci --silent 2>/dev/null || exit 125
144
+ ```
145
+
146
+ ## instrumentation.ts Hooks
147
+
148
+ Next.js `instrumentation.ts` provides:
149
+ - `onRequestError(error, request, context)` — fires on server errors
150
+ - `context.routeType`: `'render' | 'route' | 'action' | 'proxy'` — distinguishes RSC vs handler vs Server Action
151
+ - `error.digest` — stable error ID for Sentry correlation
152
+
153
+ ## Project Codebase Debug Tools
154
+
155
+ The base skill is generic; project-specific debug entry points are listed in `.baldart/overlays/bug.md`. Typical entries:
156
+
157
+ | Tool | Location | Purpose |
158
+ |------|----------|---------|
159
+ | Sandbox / write-interceptor | (project-specific) | Intercept writes during walkthrough/testing |
160
+ | Sentry test endpoint | (project-specific) | Validate Sentry pipeline |
161
+ | Env summary helper | (project-specific) | Safe env snapshot |
162
+ | Auth bypass env var | (project-specific) | Emergency auth bypass |
163
+ | Cache debug provider | (project-specific) | Cache/fetch logging (SWR / React Query / Apollo) |
164
+ | Error boundaries | (project-specific) | Client error capture + Sentry |
165
+ | Auth error map | (project-specific) | Auth-provider errors → typed codes |
166
+
167
+ ## Zustand State Debugging
168
+
169
+ ```typescript
170
+ // In browser console:
171
+ store.getState() // point-in-time snapshot
172
+ store.subscribe((state) => console.log('[DEBUG:zustand]', state)) // live changes
173
+ // Zustand devtools (if enabled): visible in Redux DevTools extension
174
+ ```
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: capture
3
+ description: Distilla una sintesi cross-document della conversazione recente in una synthesis page riusabile del wiki overlay (path da `paths.wiki_dir`/syntheses/ in `baldart.config.yml`). Usare quando l'utente invoca `/capture`, dice "capture synthesis", "salva sintesi", "distilla conversazione", "save this as wiki", "questa conversazione in wiki", o quando chiede di trasformare un ragionamento cross-document appena fatto in una pagina stabile. Due modalità — manual (sempre funzionante) e proactive (conditional sui candidati in `.claude/capture-queue/`). Implementa il loop query→wiki file-back di Karpathy.
4
+ version: 0.1.0
5
+ ---
6
+
7
+ # /capture — Synthesis Capture Skill
8
+
9
+ Turns a recent multi-turn synthesis (cross-document reasoning done by the assistant) into a durable **synthesis page** under `${paths.wiki_dir}/syntheses/<slug>.md`. Part of the LLM wiki auto-learning loop — weak RAG queries and recurring synthesis patterns feed back into stable wiki pages so future agents can retrieve consolidated context instead of re-deriving it every time.
10
+
11
+ ## Project Context
12
+
13
+ **Reads from `baldart.config.yml`:** `paths.wiki_dir`, `paths.references_dir`.
14
+ **Gated by features:** `features.has_wiki_overlay` (skill REFUSES to run when `false` — the wiki overlay infrastructure must exist).
15
+ **Overlay:** loads `.baldart/overlays/capture.md` if present — project-specific wiki-log helper path, domain vocabulary for the `domain:` frontmatter field.
16
+ **On missing/empty keys:** ask the user; do not assume defaults. See `framework/agents/project-context.md` § 3.
17
+
18
+ ## Two Modes
19
+
20
+ | Mode | When | How |
21
+ |---|---|---|
22
+ | **Manual** | User runs `/capture` explicitly | Skill reads pending queue (if any) + recent turns, proposes a synthesis. |
23
+ | **Proactive** | `.claude/hooks/capture-detect.sh` triggers on `Stop` event and queues a candidate | Next `/capture` invocation surfaces the candidate first. |
24
+
25
+ Manual mode always works. Proactive mode is a convenience layer.
26
+
27
+ ## Workflow
28
+
29
+ Run these steps in order every time `/capture` is invoked.
30
+
31
+ ### Step 1 — Kill-switch check (soft)
32
+
33
+ ```bash
34
+ if [ -f .claude/capture-queue/.disabled ]; then
35
+ echo "Proactive capture disabled (sentinel present). Running in manual-only mode for this turn."
36
+ fi
37
+ ```
38
+
39
+ Manual flow continues even when the sentinel exists; only proactive suggestion
40
+ is suppressed.
41
+
42
+ ### Step 2 — Read pending candidates
43
+
44
+ List up to **5** candidate files in `.claude/capture-queue/`:
45
+
46
+ ```bash
47
+ ls -1 .claude/capture-queue/*.json 2>/dev/null | head -5
48
+ ```
49
+
50
+ Ignore the sentinels: `.disabled`, `.gitkeep`, `.ingest-pending`. If the
51
+ glob finds files, read the top 5 as JSON, extract `trigger`, `refs_mentioned`,
52
+ and a short excerpt, and present them as numbered options:
53
+
54
+ ```
55
+ 1. [2026-04-23 14:02 UTC] Cross-doc reasoning on <topic>
56
+ refs: <path-to-source-1>, ${paths.references_dir}/<doc>.md
57
+ [Accept] [Reject] [Refine]
58
+ 2. ...
59
+ ```
60
+
61
+ If no candidates AND the user did not provide an explicit synthesis hint, ask:
62
+
63
+ > "What synthesis should I capture? Briefly describe the topic."
64
+
65
+ ### Step 3 — Draft the synthesis page
66
+
67
+ 1. Pick a short kebab-case slug (e.g., `<domain>-<topic>-rules`).
68
+ 2. Target path: `${paths.wiki_dir}/syntheses/<slug>.md`.
69
+ 3. Load the template: `references/synthesis-template.md`.
70
+ 4. Fill in each placeholder. Required frontmatter fields:
71
+
72
+ - `doc_type: synthesis`
73
+ - `domain: <inferred>` — choose from the project's domain vocabulary listed in `.baldart/overlays/capture.md`. If no overlay, infer a free-form short slug.
74
+ - `canonicality: derived`
75
+ - `owner: capture-skill`
76
+ - `source_refs: [<paths from conversation>]`
77
+ - `canonical_refs: [<SSOT paths this synthesis points back to>]`
78
+ - `freshness_status: fresh`
79
+ - `confidence: low | medium | high`
80
+ - `last_verified_from_code: YYYY-MM-DD` (today)
81
+
82
+ 5. Keep the body compact (≤120 lines). Prefer short sections:
83
+ Context → Synthesis → Caveats → See also.
84
+
85
+ ### Step 4 — Diff + confirm
86
+
87
+ Show the user the proposed file (full content) and ask for explicit approval
88
+ before writing. On rejection, skip Step 5 and go to Step 6 with the rejection
89
+ reason.
90
+
91
+ ### Step 5 — Write + log (accepted)
92
+
93
+ If the project ships a wiki-log helper, call it with an `entry_type='capture'` entry referencing the new synthesis file and the source refs. The exact import path is listed in `.baldart/overlays/capture.md` (typically `tools/<rag-impl>/wiki_log.py`). If no helper exists, append a markdown bullet to `${paths.wiki_dir}/log.md` by hand. Example:
94
+
95
+ ```bash
96
+ python3 -c "import sys; sys.path.insert(0, 'tools/<rag-impl>'); \
97
+ from wiki_log import append_entry; \
98
+ append_entry(entry_type='capture', title='<slug>', \
99
+ agent='capture-skill', \
100
+ context={'mode': '<manual|proactive>', 'confidence': '<low|medium|high>'}, \
101
+ refs=['${paths.wiki_dir}/syntheses/<slug>.md', '<source ref 1>', '<source ref 2>'], \
102
+ outcome='created')"
103
+ ```
104
+
105
+ If the synthesis was surfaced from the queue, delete (or move to
106
+ `.processed/`) the candidate file after write.
107
+
108
+ ### Step 6 — Rejection
109
+
110
+ Log the rejection (same helper as Step 5 with `outcome='rejected'`). Also
111
+ delete the candidate file from the queue so it does not resurface.
112
+
113
+ ## Notes
114
+
115
+ - **Queue hygiene**: unprocessed candidates older than ~7 days should be pruned
116
+ manually. (A future enhancement can add automatic expiry.)
117
+ - **Kill switch**: `touch .claude/capture-queue/.disabled` stops proactive writes.
118
+ See `.claude/capture-queue/.disabled.example`.
119
+ - **Anti-spam**: the detection hook refuses to write when ≥10 unprocessed
120
+ candidates already exist. See `.claude/hooks/capture-detect.sh`.
121
+
122
+ ## Related
123
+
124
+ - Existing synthesis style: `${paths.wiki_dir}/syntheses/<slug>.md` examples in your project.
125
+ - Template: `references/synthesis-template.md`
@@ -0,0 +1,42 @@
1
+ ---
2
+ doc_type: synthesis
3
+ domain: <pick from project's domain vocabulary in `.baldart/overlays/capture.md`>
4
+ canonicality: derived
5
+ owner: capture-skill
6
+ status: active
7
+ freshness_status: fresh
8
+ confidence: <low|medium|high>
9
+ last_verified_from_code: <YYYY-MM-DD>
10
+ source_refs:
11
+ - <path/to/conversation/source/1>
12
+ - <path/to/conversation/source/2>
13
+ canonical_refs:
14
+ - <${paths.references_dir}/...>
15
+ ---
16
+
17
+ # <Synthesis Title>
18
+
19
+ <One-sentence purpose of this page. Why does it exist, who benefits?>
20
+
21
+ ## Context
22
+
23
+ <2–6 lines. What question or recurring topic triggered this synthesis?
24
+ What prior knowledge is assumed? Link to the conversation or card.>
25
+
26
+ ## Synthesis
27
+
28
+ <The reusable insight. Prefer short paragraphs, bullet lists, or a compact
29
+ table. Keep it declarative — decisions, rules, or stable mappings that will
30
+ not change on every run. Cite canonical sources inline when claiming runtime
31
+ behavior.>
32
+
33
+ ## Caveats
34
+
35
+ <When does this synthesis NOT apply? What assumptions is it built on?
36
+ Note any freshness risks: "verified against <file> at <date>".>
37
+
38
+ ## See also
39
+
40
+ - <canonical ref 1 — the SSOT this points back to>
41
+ - <related synthesis page(s)>
42
+ - <ADR or PRD, if any>