@overscore/cli 0.11.6 → 0.11.10

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.
package/dist/index.js CHANGED
@@ -1171,6 +1171,9 @@ async function syncHubManagedRules(targetDir, baseUrl, projectSlug, apiKey) {
1171
1171
  catch {
1172
1172
  // Non-fatal
1173
1173
  }
1174
+ // Platform rules (skills, capabilities) — same sync that dashboard pull/deploy gets.
1175
+ await syncPlatformRules(targetDir, baseUrl, apiKey);
1176
+ syncClaudeMdImports(targetDir);
1174
1177
  }
1175
1178
  /**
1176
1179
  * Sync the project knowledge base from the Hub into .claude/knowledge/.
@@ -1269,6 +1272,41 @@ async function uploadKnowledgeBase(targetDir, baseUrl, projectSlug, apiKey) {
1269
1272
  * User-owned files (company-context.md, this-dashboard.md, knowledge/)
1270
1273
  * are NOT touched — those sync via separate mechanisms.
1271
1274
  */
1275
+ const DASHBOARD_IMPORTS = [
1276
+ "@.claude/rules/this-dashboard.md",
1277
+ "@.claude/knowledge/INDEX.md",
1278
+ "@.claude/platform-capabilities.md",
1279
+ ];
1280
+ const ANALYSIS_IMPORTS = [
1281
+ "@this-analysis.md",
1282
+ "@.claude/knowledge/INDEX.md",
1283
+ "@.claude/platform-capabilities.md",
1284
+ ];
1285
+ /**
1286
+ * Ensures the project's CLAUDE.md has the standard @import lines at the top.
1287
+ * Detects dashboard vs analysis by file presence. Injects only what's missing —
1288
+ * never overwrites existing content. Returns true if CLAUDE.md was modified.
1289
+ */
1290
+ function syncClaudeMdImports(targetDir) {
1291
+ const claudeMdPath = path.join(targetDir, ".claude", "CLAUDE.md");
1292
+ if (!fs.existsSync(claudeMdPath))
1293
+ return false;
1294
+ const isAnalysis = fs.existsSync(path.join(targetDir, "analysis-log.md"));
1295
+ const requiredImports = isAnalysis ? ANALYSIS_IMPORTS : DASHBOARD_IMPORTS;
1296
+ let content = fs.readFileSync(claudeMdPath, "utf-8");
1297
+ const missing = requiredImports.filter((imp) => !content.includes(imp));
1298
+ if (missing.length === 0)
1299
+ return false;
1300
+ // Inject missing imports right after the first # heading line
1301
+ const lines = content.split("\n");
1302
+ const headingIdx = lines.findIndex((l) => l.startsWith("# "));
1303
+ if (headingIdx === -1)
1304
+ return false;
1305
+ lines.splice(headingIdx + 1, 0, "", ...missing);
1306
+ const updated = lines.join("\n").replace(/\n{3,}/g, "\n\n");
1307
+ fs.writeFileSync(claudeMdPath, updated);
1308
+ return true;
1309
+ }
1272
1310
  async function syncPlatformRules(targetDir, baseUrl, apiKey) {
1273
1311
  try {
1274
1312
  const res = await fetch(`${baseUrl}/api/projects/platform-rules`, {
@@ -1286,14 +1324,85 @@ async function syncPlatformRules(targetDir, baseUrl, apiKey) {
1286
1324
  fs.writeFileSync(fullPath, content);
1287
1325
  count++;
1288
1326
  }
1289
- if (count > 0) {
1290
- console.log(` Platform rules synced (${count} files).`);
1327
+ const claudeUpdated = syncClaudeMdImports(targetDir);
1328
+ const total = count + (claudeUpdated ? 1 : 0);
1329
+ if (total > 0) {
1330
+ console.log(` Platform rules synced (${count} files${claudeUpdated ? " + CLAUDE.md updated" : ""}).`);
1291
1331
  }
1292
1332
  }
1293
1333
  catch {
1294
1334
  // Non-fatal — existing rules stay in place
1295
1335
  }
1296
1336
  }
1337
+ /**
1338
+ * Explicit on-demand platform rules sync. Reports what changed so Claude
1339
+ * can tell the user what's new. Called by `npx @overscore/cli platform update`.
1340
+ */
1341
+ async function platformUpdate() {
1342
+ const { apiUrl, apiKey } = await loadEnv();
1343
+ const baseUrl = apiUrl.replace(/\/api$/, "");
1344
+ console.log("\n Syncing platform rules from Hub...\n");
1345
+ const capPath = path.resolve(process.cwd(), ".claude", "platform-capabilities.md");
1346
+ const prevContent = fs.existsSync(capPath) ? fs.readFileSync(capPath, "utf-8") : null;
1347
+ const prevVersion = prevContent?.match(/^version:\s*(.+)$/m)?.[1]?.trim() ?? null;
1348
+ const res = await fetch(`${baseUrl}/api/projects/platform-rules`, {
1349
+ headers: { Authorization: `Bearer ${apiKey}` },
1350
+ });
1351
+ if (!res.ok) {
1352
+ console.error(`\n Error: Could not reach Hub (HTTP ${res.status})\n`);
1353
+ process.exit(1);
1354
+ }
1355
+ const data = (await res.json());
1356
+ if (!data.files) {
1357
+ console.error("\n Error: No files in platform-rules response.\n");
1358
+ process.exit(1);
1359
+ }
1360
+ const updated = [];
1361
+ for (const [relPath, content] of Object.entries(data.files)) {
1362
+ const fullPath = path.join(process.cwd(), ".claude", relPath);
1363
+ const existing = fs.existsSync(fullPath) ? fs.readFileSync(fullPath, "utf-8") : null;
1364
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
1365
+ fs.writeFileSync(fullPath, content);
1366
+ if (existing !== content)
1367
+ updated.push(relPath);
1368
+ }
1369
+ const claudeUpdated = syncClaudeMdImports(process.cwd());
1370
+ if (claudeUpdated)
1371
+ updated.push(".claude/CLAUDE.md (@imports updated)");
1372
+ if (updated.length === 0) {
1373
+ console.log(" Already up to date — no changes.\n");
1374
+ return;
1375
+ }
1376
+ console.log(` Updated ${updated.length} file${updated.length === 1 ? "" : "s"}:\n`);
1377
+ for (const f of updated)
1378
+ console.log(` ${f}`);
1379
+ if (updated.includes("platform-capabilities.md")) {
1380
+ const newContent = data.files["platform-capabilities.md"];
1381
+ const newVersion = newContent.match(/^version:\s*(.+)$/m)?.[1]?.trim() ?? "unknown";
1382
+ if (prevVersion && prevVersion !== newVersion) {
1383
+ console.log(`\n Capabilities updated: ${prevVersion} → ${newVersion}`);
1384
+ const changelog = extractChangelogSince(newContent, prevVersion);
1385
+ if (changelog)
1386
+ console.log(`\n What's new:\n\n${changelog}`);
1387
+ }
1388
+ else if (!prevVersion) {
1389
+ console.log(`\n Platform capabilities synced (v${newVersion}).`);
1390
+ console.log(` Re-read .claude/platform-capabilities.md in your Claude session to see available commands.`);
1391
+ }
1392
+ }
1393
+ console.log();
1394
+ }
1395
+ function extractChangelogSince(content, sinceVersion) {
1396
+ const match = content.match(/## Changelog\n([\s\S]*?)(?=\n## |\s*$)/);
1397
+ if (!match)
1398
+ return null;
1399
+ const blocks = match[1].split(/(?=### )/);
1400
+ const newer = blocks.filter((b) => {
1401
+ const v = b.match(/### (\d{4}-\d{2}-\d{2})/)?.[1];
1402
+ return v && v > sinceVersion;
1403
+ });
1404
+ return newer.length ? newer.join("").trim() : null;
1405
+ }
1297
1406
  /**
1298
1407
  * Recursively copies a template directory to a target directory, substituting
1299
1408
  * `{{KEY}}` placeholders in text files. Mirrors directory structure.
@@ -1616,6 +1725,9 @@ async function analysisPublish() {
1616
1725
  console.log(`\n URL: ${data.url}\n`);
1617
1726
  // Upload knowledge base so insights from this analysis persist
1618
1727
  await uploadKnowledgeBase(process.cwd(), baseUrl, meta.project_slug, cfg.apiKey);
1728
+ // Sync platform rules so skills and capabilities stay current
1729
+ await syncPlatformRules(process.cwd(), baseUrl, cfg.apiKey);
1730
+ syncClaudeMdImports(process.cwd());
1619
1731
  }
1620
1732
  /**
1621
1733
  * Ensure analysis.json has a valid id by fetching from the Hub.
@@ -2281,6 +2393,22 @@ else if (command === "analysis") {
2281
2393
  `);
2282
2394
  }
2283
2395
  }
2396
+ else if (command === "platform") {
2397
+ if (subcommand === "update") {
2398
+ platformUpdate();
2399
+ }
2400
+ else {
2401
+ console.log(`
2402
+ overscore platform — Manage platform rules and capabilities
2403
+
2404
+ Commands:
2405
+ update Sync latest platform rules, skills, and capabilities from Hub
2406
+
2407
+ Example:
2408
+ npx @overscore/cli platform update
2409
+ `);
2410
+ }
2411
+ }
2284
2412
  else if (command === "query") {
2285
2413
  if (subcommand === "list") {
2286
2414
  queryList();
@@ -2339,6 +2467,7 @@ else {
2339
2467
  pull <slug> Pull source code from the hub
2340
2468
  versions List deploy history
2341
2469
  query <subcommand> Manage dashboard queries
2470
+ platform <subcommand> Sync platform rules and capabilities
2342
2471
  analysis <subcommand> Manage analyses (frozen investigations)
2343
2472
  install-skills Install the Overscore skill library into ~/.claude/skills/
2344
2473
 
@@ -2350,6 +2479,7 @@ else {
2350
2479
  npx @overscore/cli pull <slug>
2351
2480
  npx @overscore/cli pull <slug> --version 3
2352
2481
  npx @overscore/cli versions
2482
+ npx @overscore/cli platform update
2353
2483
  npx @overscore/cli query list
2354
2484
  npx @overscore/cli query add <name> "<sql>"
2355
2485
  npx @overscore/cli query update <name> "<sql>"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overscore/cli",
3
- "version": "0.11.6",
3
+ "version": "0.11.10",
4
4
  "description": "CLI for deploying Overscore dashboards and publishing analyses",
5
5
  "bin": {
6
6
  "overscore": "dist/index.js"
@@ -1,27 +1,26 @@
1
1
  # Overscore Analysis: {{TITLE}}
2
2
 
3
+ @this-analysis.md
4
+ @.claude/knowledge/INDEX.md
5
+ @.claude/platform-capabilities.md
6
+
3
7
  This is an **Overscore Analysis** — a one-off, frozen investigation that produces a single self-contained `report.html` you can share in Slack and reopen later to refresh.
4
8
 
5
9
  Analyses are NOT dashboards. No React, no `package.json`, no `useQuery`, no scheduled refreshes. The numbers are baked into `report.html` at publish time.
6
10
 
7
11
  ## First steps — interview before you query
8
12
 
9
- **Before running any SQL, check `analysis-log.md`.** If it has no queries logged yet and the user hasn't already provided specific tables, questions, and context in their message, invoke the **`start-analysis`** skill to interview them first. If the user has already given you detailed context (tables, time windows, hypotheses), skip the interviewsummarize what they told you in the Key Findings section and propose a query plan directly.
13
+ **Before running any SQL, check `this-analysis.md`.** If it's empty (just the stub), invoke the **`start-analysis`** skill to interview the user first — then check `analysis-log.md` to see what's already been tried. If `this-analysis.md` is filled in, you have the context you need read `analysis-log.md` to pick up where the last session left off.
10
14
 
11
- The interview takes 2 minutes and gives you:
12
- - The real question (often different from the title)
13
- - Which BigQuery tables matter (so you don't probe them all)
14
- - What success looks like (a number? a chart? a go/no-go?)
15
- - 1–3 hypotheses to test
16
- - Time window and filters
15
+ If the user has already given you detailed context in their message (tables, time windows, hypotheses), skip the interview write `this-analysis.md` from what they told you and propose a query plan directly.
17
16
 
18
- After the interview, draft an initial entry in `analysis-log.md` and propose a query plan for the user to approve.
17
+ ## Two files, two purposes
19
18
 
20
- ## Always maintain analysis-log.md
19
+ **`this-analysis.md`** is the **context file** — loaded automatically every session. It answers: what question is this analysis trying to answer, for whom, using what data, with what hypotheses. Written once after the interview, updated only if scope changes. Keep it short and stable.
21
20
 
22
- `analysis-log.md` is the **recoverable session state** for this analysis. Future sessions (including yourself, weeks from now, after the user runs `analysis pull`) read it to know what's been done. **Append to it as you work**, not at the end.
21
+ **`analysis-log.md`** is the **work journal** append-only record of every query run, every observation, every conclusion. Future sessions read this to know what's already been tried. **Append to it as you work**, not at the end.
23
22
 
24
- Every meaningful exploration step is a new entry: the question being investigated, the SQL you ran (paste it verbatim), what you observed, the conclusion you drew, and any open questions for the next pass.
23
+ Every meaningful exploration step in the log is a new entry: the question being investigated, the SQL you ran (paste it verbatim), what you observed, the conclusion you drew, and any open questions for the next pass.
25
24
 
26
25
  ## How to run BigQuery queries
27
26
 
@@ -57,12 +56,17 @@ The `queries/` directory is for SQL files you want to keep around — the canoni
57
56
  business logic, metric formulas, data quirks. **Read INDEX.md before starting any data work.**
58
57
  Only read the specific files relevant to your current task.
59
58
 
60
- When you discover something non-obvious (a timezone gotcha, a dedup rule, a column that means
61
- something unexpected), **propose adding it to the knowledge base**:
59
+ When you learn something worth keeping anything about how the business works, how their data is structured, or what they care about — add it to the knowledge base. The test: **is this a reusable fact, or is it specific to this session?**
60
+
61
+ Save it: business context ("Dam Filters is a drop shipping company"), table quirks, metric definitions, join rules, data quality issues, stakeholder preferences. Skip it: session decisions ("I used a 30-day window"), analysis conclusions ("revenue was up 20%"), transient states ("migration is running").
62
+
62
63
  - Create a new `.claude/knowledge/{topic}.md` file (one topic per file, 20-80 lines)
63
64
  - Or append to an existing file if the topic matches
65
+ - Surgically edit specific lines to correct wrong facts — never overwrite a file wholesale
64
66
  - Update INDEX.md when you add or remove a file
65
67
 
68
+ Write to the knowledge base during the session, not only at publish time. If the session ends before publishing, context written only to `analysis-log.md` won't make it to the Hub.
69
+
66
70
  Knowledge files sync to the Hub on `analysis publish` and are shared with every artifact
67
71
  in this project. Good knowledge notes help every future session.
68
72
 
@@ -95,6 +99,8 @@ npx @overscore/cli analysis publish
95
99
 
96
100
  This uploads `report.html` and the entire bundle (this CLAUDE.md, `analysis-log.md`, the `.claude/` tree, etc.) to Overscore. The analysis becomes available at `https://<project>.overscore.dev/analysis/{{SLUG}}`. Re-publishing overwrites the previous version. **Always preview `report.html` in a browser and get the user's approval before publishing.**
97
101
 
102
+ After publish succeeds and you've shared the link, invoke the **`save-knowledge`** skill. It shows what's already in the context files, proposes specific additions from this session, and lets the user accept or adjust before anything is written. Don't skip it — it's a short conversation, and it's what makes the next session start informed instead of blank.
103
+
98
104
  ## When the user wants to turn this into a dashboard
99
105
 
100
106
  Analyses are static. If the user asks to "make this a real dashboard" or "turn this into something that updates," **do NOT add React code to this folder** — it would corrupt the artifact. Use the global `scaffold-overscore-artifact` skill to route them to a fresh dashboard scaffold that lives as a sibling of this analysis.
@@ -107,4 +113,4 @@ The following files in `.claude/rules/` load automatically when you touch matchi
107
113
  - **`report-html.md`** — Self-contained HTML rules and dark-theme spec (loads when editing `report.html`)
108
114
  - **`report-components.md`** — Copy-paste HTML/SVG component snippets: KPI cards, charts, tables, heatmaps (loads when editing `report.html`)
109
115
  - **`analysis-methodology.md`** — Investigation loop, when to ask vs query (loads when editing `analysis-log.md`)
110
- - **`knowledge/INDEX.md`** — Project knowledge base catalog (read before data work)
116
+ - **`knowledge/INDEX.md`** — Project knowledge base catalog (auto-loaded every session via @import above)
@@ -1,41 +1,79 @@
1
1
  ---
2
2
  name: save-knowledge
3
- description: Reviews data insights discovered during analysis work and proposes additions to the project knowledge base. Use before publishing an analysis, when the user says "save what you learned", or after discovering non-obvious data facts like timezone quirks, column semantics, dedup rules, or metric definitions.
3
+ description: Collaborative debrief after publishing an analysis. Reviews what was learned this session, shows what's already in the knowledge base and analysis context, proposes specific additions and edits, and waits for the user to accept or adjust before writing anything. Run after publishing, or when the user says "save what we learned".
4
4
  ---
5
5
 
6
6
  # Save Knowledge
7
7
 
8
- Run before publishing an analysis or whenever you discover something non-obvious about the data.
8
+ A short debrief after publishing. The goal is to make sure what you learned this session doesn't disappear when the conversation ends.
9
9
 
10
- ## Process
10
+ ## The flow
11
11
 
12
- 1. Review `analysis-log.md` look for non-obvious data facts you discovered:
13
- - Column semantics that weren't obvious from the name
14
- - Timezone, dedup, or join gotchas
15
- - Metric definitions or business rules
16
- - Data quality issues or known gaps
12
+ ### 1. Review what's already documented
17
13
 
18
- 2. **Read the existing knowledge files before proposing anything.** Read `.claude/knowledge/INDEX.md`, then read the specific files relevant to what you discovered. You need to know what's already there before you can know what's new.
14
+ Read the current state of the context files before proposing anything:
15
+ - `this-analysis.md` — already in context via @import, but re-read with fresh eyes for gaps or things that changed
16
+ - `.claude/knowledge/INDEX.md` — what knowledge files exist
17
+ - Any knowledge files relevant to what you worked on this session
19
18
 
20
- 3. For each insight, decide what action to take:
19
+ ### 2. Identify what's new from this session
21
20
 
22
- | Situation | Action |
23
- |---|---|
24
- | New topic, no existing file covers it | Create a new `.claude/knowledge/{topic}.md`; add entry to INDEX.md |
25
- | New fact that belongs in an existing knowledge file | Append a new line or section to that file — do not rewrite what's there |
26
- | Fact that refines or corrects something already documented | Edit that specific line/section only — do not duplicate it |
27
- | Already documented accurately | Skip entirely |
28
- | Analysis-specific (only relevant to this investigation) | Leave in analysis-log.md — don't promote to project knowledge |
21
+ Think through the queries you ran, what the user told you, what you discovered about the data. Cross-reference against what's already in the files. Look for:
22
+ - Things the user mentioned that aren't written down anywhere
23
+ - Data facts that would save a future session from re-discovering them
24
+ - Join logic, dedup rules, timezone quirks, schema surprises
25
+ - Anything that corrects or refines what's already documented
29
26
 
30
- **Never overwrite a file wholesale. Never duplicate a fact that's already accurate. Only write what's genuinely new or changed.**
27
+ ### 3. Show existing context and propose additions
31
28
 
32
- 4. Present proposed changes to the user. Show the exact text you'd add or the exact edit you'd make not a summary of what you intend to write.
29
+ Lead with what's already there, then show exactly what you'd change. Use file links so the user can open them:
33
30
 
34
- 5. After approval, write the files and update INDEX.md.
31
+ > Here's what's already saved:
32
+ > - [this-analysis.md](this-analysis.md) — question, hypotheses, data sources, known quirks
33
+ > - [company.md](.claude/knowledge/company.md) — company context
34
+ >
35
+ > Based on this session, here's what I'd suggest adding:
36
+ >
37
+ > **[this-analysis.md](this-analysis.md)** — under Known Quirks:
38
+ > _"Shopify order_id and QuickBooks invoice_id join via the orders_bridge table, not directly"_
39
+ >
40
+ > **[company.md](.claude/knowledge/company.md)** — new file:
41
+ > _"Dam Filters sells pool filters via drop shipping. Primary sales channel is Shopify; QuickBooks handles accounting."_
42
+ >
43
+ > Accept these, or want to change anything?
35
44
 
36
- ## What qualifies as project knowledge
37
- - "unique_page_views is already COUNT(DISTINCT domain_userid)" → YES
38
- - "date_az is America/Phoenix UTC-7, no DST" → YES
39
- - "affiliate_id = 0 is unattributed, usually exclude" → YES
40
- - "Q1 churn spiked because of the pricing change" → NO (analysis conclusion, not a data fact)
41
- - "I used a 90-day window for this analysis" → NO (analysis-specific decision)
45
+ Show the exact text you'd write — not a description of what you intend to write. Keep it tight. If there's nothing worth adding, say so.
46
+
47
+ ### 4. Let the user respond
48
+
49
+ - "Looks good" → write everything as proposed
50
+ - "Also note that we exclude test orders" → incorporate and confirm
51
+ - "That's not right, it's actually..." → update the proposal, confirm before writing
52
+ - "Don't bother with that one" → drop it
53
+
54
+ Don't write anything until you have confirmation on the full set of changes.
55
+
56
+ ### 5. Write the files
57
+
58
+ Once confirmed, write exactly what was agreed:
59
+ - Append new sections or lines — never overwrite a file wholesale
60
+ - Surgically edit specific lines to correct wrong facts
61
+ - Create new knowledge files if needed, update INDEX.md
62
+ - Skip anything already accurately documented
63
+
64
+ ## What's worth saving
65
+
66
+ **Save it** — reusable facts about the business or data:
67
+ - "Dam Filters sells pool filters via drop shipping" — business context, Claude starts blank every session
68
+ - "Shopify order_id joins to QuickBooks invoice_id via orders_bridge" — saves re-discovering this join
69
+ - "unique_page_views is COUNT(DISTINCT domain_userid)" — saves re-discovering this
70
+ - "date_az is America/Phoenix, UTC-7, no DST" — prevents timezone mistakes
71
+ - "affiliate_id = 0 is unattributed, usually exclude" — prevents wrong counts
72
+ - "fiscal year ends March 31" — affects every period comparison
73
+ - "orders table has one row per line item, not per order" — would produce wrong counts without this
74
+
75
+ **Skip it** — session-specific decisions and transient states:
76
+ - "Q1 churn spiked because of the pricing change" — analysis conclusion, belongs in the report
77
+ - "I used a 90-day window for this analysis" — session decision, not a reusable fact
78
+ - "The migration is still running" — transient state, will be wrong tomorrow
79
+ - "I ran 3 queries to explore this" — process note, not a fact about the data
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: start-analysis
3
- description: Interviews the user before querying data at the start of a new Overscore analysis. Captures the real question, known tables, success criteria, hypotheses, time window, and data quirks, then writes an initial analysis-log.md entry and proposes a query plan for approval. Use when analysis-log.md has no queries logged yet, or when the user says "investigate", "look into", or "analyze" something for the first time.
3
+ description: Interviews the user before querying data at the start of a new Overscore analysis. Captures the real question, known tables, success criteria, hypotheses, time window, and data quirks, then writes this-analysis.md and proposes a query plan for approval. Use when this-analysis.md is empty, or when the user says "investigate", "look into", or "analyze" something for the first time.
4
4
  allowed-tools:
5
5
  - Read
6
6
  - Write
@@ -38,15 +38,23 @@ Ask these one or two at a time conversationally — don't dump all 6 at once lik
38
38
  ## After the interview
39
39
 
40
40
  1. **Read `.claude/knowledge/INDEX.md`** and any relevant knowledge files to understand what previous sessions have already documented about this project's data. Cross-reference what the user said against what's already known.
41
- 2. **Draft an initial entry in `analysis-log.md`** with:
42
- - The clarified question (not the original title)
43
- - The tables the user named, with what each contains
44
- - The success criteria (literally quote the user)
45
- - The hypotheses (numbered)
46
- - The time window and any filters
47
- - Any quirks the user mentioned
48
- 3. **Propose a prioritized query plan** — 3-5 queries that test the highest-priority hypothesis first. For each query, write the SQL, what hypothesis it tests, and what result would confirm or refute it. Do NOT run any of them yet.
49
- 4. **Get approval.** Show the user the plan and ask them to confirm or revise before you run anything.
41
+
42
+ 2. **Write `this-analysis.md` immediately** before proposing a query plan. Fill in every section:
43
+ - **Question** the clarified question, not the original title
44
+ - **Audience** who asked and what they'll do with the answer
45
+ - **Data Sources** — the tables the user named, with what each contains
46
+ - **Hypotheses** numbered list of what they suspect is true
47
+ - **Success Criteria** — quote the user on what "done" looks like
48
+ - **Time Window & Filters** — the date range, cohort, what to include/exclude
49
+ - **Known Quirks** anything about the data the user flagged upfront
50
+
51
+ This is the context file that loads automatically every future session. Don't skip it.
52
+
53
+ 3. **Write business context to the knowledge base** — if the user told you anything about the company, their business model, or their data sources that would help any future artifact in this project, write it to `.claude/knowledge/company.md` (create it if it doesn't exist, add to INDEX.md). This is separate from `this-analysis.md` — it's project-wide, not analysis-specific.
54
+
55
+ 4. **Propose a prioritized query plan** — 3-5 queries that test the highest-priority hypothesis first. For each query, write the SQL, what hypothesis it tests, and what result would confirm or refute it. Do NOT run any of them yet.
56
+
57
+ 5. **Get approval.** Show the user the plan and ask them to confirm or revise before you run anything.
50
58
 
51
59
  ## What this skill does NOT do
52
60
 
@@ -1,4 +1,4 @@
1
- # {{TITLE}}
1
+ # {{TITLE}} — Query Log
2
2
 
3
3
  ## Key Findings
4
4
  _(Updated as the analysis progresses — this is what the report is built from)_
@@ -12,9 +12,4 @@ _(Updated as the analysis progresses — this is what the report is built from)_
12
12
 
13
13
  ## Query Log
14
14
 
15
- ### {{DATE}} Initial exploration
16
-
17
- **Tables identified:**
18
- - _(see `.claude/rules/company-context.md`)_
19
-
20
- <!-- Append new query entries below this line -->
15
+ <!-- Append new entries below. Format: Q1, Q2, Q3... cross-referenced with Key Findings above. -->
@@ -0,0 +1,17 @@
1
+ # {{TITLE}}
2
+
3
+ <!-- Written by Claude after the start-analysis interview. Update if scope changes. -->
4
+
5
+ ## Question
6
+
7
+ ## Audience
8
+
9
+ ## Data Sources
10
+
11
+ ## Hypotheses
12
+
13
+ ## Success Criteria
14
+
15
+ ## Time Window & Filters
16
+
17
+ ## Known Quirks