Skill: Archive Analysis
Purpose
Save a completed analysis to the knowledge system's analysis archive for
future recall. Captures key findings, metrics used, agents invoked, and
output file paths so that past work can be referenced in future sessions.
When to Use
- After completing an L3+ analysis (post-validation)
- After
/run-pipeline completes successfully
- User says "save this analysis" or "archive this"
- Automatically triggered at the end of Step 18 (Close the Loop)
- VERIFICATION MODE: User says "verify the archive" or "show me what was captured" — read existing entry, don't create new
Instructions
Step 0: Determine Mode
Check if this is an archive request (create new entry) or a verification request (read existing entry).
Verification signals:
- User says "verify", "check", "show me what was captured", "did it save", "was it archived"
- User mentions pipeline "auto-saved" or "already completed"
- No new findings mentioned — just wants to see what's already there
If verification: Skip to Verification Mode (below). Otherwise, proceed to Step 1.
Step 1: Gather Analysis Metadata from Session Context
Record only what exists: findings, metrics, agents, and files come from the files and session
history listed below, or from what the user stated. Anything not found is null or [], never
invented.
Where to look:
- Pipeline state — Read
working/session_state.yaml if it exists (contains pipeline progress, agents run, resume instructions)
- Active dataset — Read
.knowledge/active.yaml for dataset ID
- Output files — Scan
outputs/ and working/ directories for artifacts created in this session (use ls -lt to find recent files)
- Validation report — Look for
working/validation_report.md or working/validation_summary.json for confidence grade
- User's stated findings — If user provides key findings in their request, use those verbatim
What to extract:
- Title: Derive from the original question or business context (check session history for the initial analytical question)
- Question: The original user question (look back in conversation for the first analytical request)
- Question level: From the Question Router classification (L1-L5) — check if router was invoked
- Dataset ID: From
.knowledge/active.yaml
- Key findings:
- If validation report exists, extract from there
- Otherwise, check
working/analysis_summary.md or outputs/narrative.md
- If nothing exists, use findings the user mentioned in their archive request
- Format as single-sentence bullets with numbers
- Metrics used:
- Check validation report or analysis summary for metric references
- Scan SQL queries in
working/*.sql for column names
- Match against
.knowledge/metrics/index.yaml if available
- Agents used:
- Read
working/session_state.yaml if pipeline was used
- Check conversation history for agent invocations (look for "Task" tool uses)
- List in execution order
- Output files:
- Run
ls -lt outputs/ working/ | head -20 to find recent files
- Filter for files created during this session (check timestamps)
- Include both deliverables (outputs/) and working files (working/)
- ONLY list files that actually exist — check the directory before listing
- If no files exist or user didn't mention any outputs, set
output_files: []
- Tags: Auto-generate from:
- Keywords in the original question (mobile, checkout, seasonal, etc.)
- Metric names used
- Dataset name
- Analysis type (funnel, root-cause, segmentation, etc.)
- Confidence:
- Read from
working/validation_report.md or working/validation_summary.json
- If validation was not run, set to
null and note it
If actual files don't exist: Create the archive with whatever metadata is available. Mark it as partial: true if deliverables are missing.
Step 2: Create Archive Entry
- Read the schema:
.knowledge/analyses/_schema.yaml to understand required/optional fields
- Generate a unique ID:
analysis_{YYYYMMDD}_{HHMMSS} (use current timestamp)
- Build the entry dict following the schema structure
Example entry format:
- id: analysis_20260403_232623
title: "Mobile checkout conversion drop investigation"
date: "2026-04-03"
dataset: {active_dataset}
question: "What caused the conversion rate drop and how does it relate to the mobile checkout flow?"
question_level: L4
findings:
- "Mobile checkout conversion fell 2.1pp (5.4% → 3.3%) in March; desktop was flat"
- "82% of the drop is concentrated at the payment step on iOS"
- "Sessions with a payment error retry at 11% vs. 64% baseline"
metrics:
- conversion_rate
- checkout_completion
- funnel_drop_off
- device_segmentation
agents:
- question-framing
- data-explorer
- descriptive-analytics
- root-cause-investigator
- validation
- chart-maker
output_files:
- outputs/checkout_conversion_analysis.png
- outputs/conversion_funnel_chart.png
- working/checkout_funnel_analysis.png
tags:
- conversion
- mobile
- checkout
- funnel-analysis
- root-cause
confidence: B
partial: false
Step 3: Append to Index
- Read
.knowledge/analyses/index.yaml
- If file doesn't exist, create it from template:
analyses: []
total_analyses: 0
last_updated: null
- Append the new entry to the
analyses list
- Increment
total_analyses
- Update
last_updated to current date (YYYY-MM-DD)
- Write back to
index.yaml
Step 4: Update Dataset Stats
- Read
.knowledge/datasets/{active}/manifest.yaml
- Increment
analysis_count
- Update
last_used to current date
- Write back
Step 5: Confirm
Report to user:
Analysis archived: {title}
ID: {id}
Findings: {count} key findings captured
Use `/history` to browse past analyses.
Step 6: Capture to Query Archaeology (Optional)
When to apply: Only for completed analyses (not partial) with confidence grade B or better.
After archiving, check if the analysis produced reusable patterns worth saving
to .knowledge/query-archaeology/curated/ via helpers/knowledge/archaeology_helpers.py.
SQL patterns — If validated SQL queries exist in working/*.sql:
- Ask: "Would you like to save any SQL patterns from this analysis?"
- Offer to capture via
capture_cookbook_entry(title, sql, dataset, tables, tags)
- Only capture queries that passed tie-out or validation checks
Table knowledge — If the analysis revealed useful table metadata:
- Offer to capture/update via
capture_table_cheatsheet(table_name, dataset, grain, primary_key, common_filters, gotchas, common_joins)
- Include grain, primary key, common filters, gotchas, and common joins
Join patterns — If the analysis used non-obvious joins:
- Offer to capture via
capture_join_pattern(tables, join_sql, cardinality, validated, dataset)
- Record cardinality and whether the join was validated
Rules for this step:
- Ask the user: "Would you like to save any SQL patterns from this analysis?"
- If the user declines or there are no reusable patterns, skip silently
- Only offer for analyses with confidence grade B or better
- Never auto-capture without user confirmation
Verification Mode
When user wants to verify an existing archive (not create a new one):
- Read
.knowledge/analyses/index.yaml
- Find the most recent entry (highest index, latest date)
- Display what was captured:
- Analysis ID and title
- Date archived
- Key findings (list them)
- Metrics used
- Agents invoked
- Output files preserved
- Tags
- Confidence grade
- Confirm dataset manifest was updated
- Report archive stats (total analyses, last updated)
Do NOT create a new archive entry in verification mode.
Report format:
Archive verified: {title}
ID: {id}
Status: Successfully archived on {date}
Captured:
- {count} key findings
- {count} metrics tracked
- {count} agents used
- {count} output files preserved
Use `/history` to browse all past analyses.
Rules
- Never overwrite an existing archive entry — always append
- Key findings should be one sentence each, factual, with numbers where possible
- Tags should be lowercase, no spaces (use hyphens)
- If validation was not run, set confidence to null and note it
- Archive even partial analyses — mark as
partial: true
- Verification requests don't create new entries — read and report existing archives
- DO NOT create standalone analysis markdown files or archive directories — the archive system stores metadata in
index.yaml only. Output files remain in their original locations (outputs/, working/) and are referenced by path in the output_files array. DO NOT copy or duplicate artifacts.
Edge Cases
- No outputs exist: Set
output_files: [], do not invent file names. Archive with metadata only.
- Pipeline was interrupted: Archive what's available, mark as
partial: true, document reason in a reason_incomplete field
- Duplicate question: Still archive — different runs may find different things
- Analysis index doesn't exist: Create it from template
- User says 'verify' but no archive exists: Report "No archive found. Would you like to create one?" and proceed to archive mode if confirmed
- Session state files don't exist: Use conversation history and user-provided metadata to build the archive entry
- User mentioned files but they don't exist: Only list files that actually exist in outputs/ or working/. If the user mentioned output files but they're not present, note in confirmation: "Files mentioned but not found: {list}"
1---2name: archive-analysis3description: Save completed analyses to the knowledge system's analysis archive for future reference. Use this skill after completing any L3+ analysis, when `/run-pipeline` completes, when the user explicitly says "save this analysis" or "archive this", or automatically at the end of Step 18 (Close the Loop) in the analysis workflow. This skill captures key findings, metrics used, agents invoked, and output file paths so past work can be referenced in future sessions. Trigger whenever you finish validation on a multi-step analysis, complete an analytical deck, wrap up a root cause investigation, finish an opportunity sizing exercise, or close any analysis that produced deliverables worth preserving. Also apply when the user mentions saving work, archiving results, preserving findings, or wants to ensure an analysis can be recalled later. This is your analytical memory system — use it proactively to build institutional knowledge.4---56# Skill: Archive Analysis78## Purpose9Save a completed analysis to the knowledge system's analysis archive for10future recall. Captures key findings, metrics used, agents invoked, and11output file paths so that past work can be referenced in future sessions.1213## When to Use14- After completing an L3+ analysis (post-validation)15- After `/run-pipeline` completes successfully16- User says "save this analysis" or "archive this"17- Automatically triggered at the end of Step 18 (Close the Loop)18- **VERIFICATION MODE:** User says "verify the archive" or "show me what was captured" — read existing entry, don't create new1920## Instructions2122### Step 0: Determine Mode2324Check if this is an **archive request** (create new entry) or a **verification request** (read existing entry).2526**Verification signals:**27- User says "verify", "check", "show me what was captured", "did it save", "was it archived"28- User mentions pipeline "auto-saved" or "already completed"29- No new findings mentioned — just wants to see what's already there3031**If verification:** Skip to Verification Mode (below). Otherwise, proceed to Step 1.3233### Step 1: Gather Analysis Metadata from Session Context3435Record only what exists: findings, metrics, agents, and files come from the files and session36history listed below, or from what the user stated. Anything not found is `null` or `[]`, never37invented.3839**Where to look:**40411. **Pipeline state** — Read `working/session_state.yaml` if it exists (contains pipeline progress, agents run, resume instructions)422. **Active dataset** — Read `.knowledge/active.yaml` for dataset ID433. **Output files** — Scan `outputs/` and `working/` directories for artifacts created in this session (use `ls -lt` to find recent files)444. **Validation report** — Look for `working/validation_report.md` or `working/validation_summary.json` for confidence grade455. **User's stated findings** — If user provides key findings in their request, use those verbatim4647**What to extract:**48491. **Title:** Derive from the original question or business context (check session history for the initial analytical question)502. **Question:** The original user question (look back in conversation for the first analytical request)513. **Question level:** From the Question Router classification (L1-L5) — check if router was invoked524. **Dataset ID:** From `.knowledge/active.yaml`535. **Key findings:**54 - If validation report exists, extract from there55 - Otherwise, check `working/analysis_summary.md` or `outputs/narrative.md`56 - If nothing exists, use findings the user mentioned in their archive request57 - Format as single-sentence bullets with numbers586. **Metrics used:**59 - Check validation report or analysis summary for metric references60 - Scan SQL queries in `working/*.sql` for column names61 - Match against `.knowledge/metrics/index.yaml` if available627. **Agents used:**63 - Read `working/session_state.yaml` if pipeline was used64 - Check conversation history for agent invocations (look for "Task" tool uses)65 - List in execution order668. **Output files:**67 - Run `ls -lt outputs/ working/ | head -20` to find recent files68 - Filter for files created during this session (check timestamps)69 - Include both deliverables (outputs/) and working files (working/)70 - **ONLY list files that actually exist** — check the directory before listing71 - If no files exist or user didn't mention any outputs, set `output_files: []`729. **Tags:** Auto-generate from:73 - Keywords in the original question (mobile, checkout, seasonal, etc.)74 - Metric names used75 - Dataset name76 - Analysis type (funnel, root-cause, segmentation, etc.)7710. **Confidence:**78 - Read from `working/validation_report.md` or `working/validation_summary.json`79 - If validation was not run, set to `null` and note it8081**If actual files don't exist:** Create the archive with whatever metadata is available. Mark it as `partial: true` if deliverables are missing.8283### Step 2: Create Archive Entry84851. **Read the schema:** `.knowledge/analyses/_schema.yaml` to understand required/optional fields862. Generate a unique ID: `analysis_{YYYYMMDD}_{HHMMSS}` (use current timestamp)873. Build the entry dict following the schema structure8889Example entry format:9091```yaml92- id: analysis_20260403_23262393 title: "Mobile checkout conversion drop investigation"94 date: "2026-04-03"95 dataset: {active_dataset}96 question: "What caused the conversion rate drop and how does it relate to the mobile checkout flow?"97 question_level: L498 findings:99 - "Mobile checkout conversion fell 2.1pp (5.4% → 3.3%) in March; desktop was flat"100 - "82% of the drop is concentrated at the payment step on iOS"101 - "Sessions with a payment error retry at 11% vs. 64% baseline"102 metrics:103 - conversion_rate104 - checkout_completion105 - funnel_drop_off106 - device_segmentation107 agents:108 - question-framing109 - data-explorer110 - descriptive-analytics111 - root-cause-investigator112 - validation113 - chart-maker114 output_files:115 - outputs/checkout_conversion_analysis.png116 - outputs/conversion_funnel_chart.png117 - working/checkout_funnel_analysis.png118 tags:119 - conversion120 - mobile121 - checkout122 - funnel-analysis123 - root-cause124 confidence: B125 partial: false126```127128### Step 3: Append to Index1291. Read `.knowledge/analyses/index.yaml`1302. If file doesn't exist, create it from template:131 ```yaml132 analyses: []133 total_analyses: 0134 last_updated: null135 ```1363. Append the new entry to the `analyses` list1374. Increment `total_analyses`1385. Update `last_updated` to current date (YYYY-MM-DD)1396. Write back to `index.yaml`140141### Step 4: Update Dataset Stats1421. Read `.knowledge/datasets/{active}/manifest.yaml`1432. Increment `analysis_count`1443. Update `last_used` to current date1454. Write back146147### Step 5: Confirm148Report to user:149```150Analysis archived: {title}151ID: {id}152Findings: {count} key findings captured153Use `/history` to browse past analyses.154```155156### Step 6: Capture to Query Archaeology (Optional)157158**When to apply:** Only for completed analyses (not partial) with confidence grade B or better.159160After archiving, check if the analysis produced reusable patterns worth saving161to `.knowledge/query-archaeology/curated/` via `helpers/knowledge/archaeology_helpers.py`.1621631. **SQL patterns** — If validated SQL queries exist in `working/*.sql`:164 - Ask: "Would you like to save any SQL patterns from this analysis?"165 - Offer to capture via `capture_cookbook_entry(title, sql, dataset, tables, tags)`166 - Only capture queries that passed tie-out or validation checks1671682. **Table knowledge** — If the analysis revealed useful table metadata:169 - Offer to capture/update via `capture_table_cheatsheet(table_name, dataset, grain, primary_key, common_filters, gotchas, common_joins)`170 - Include grain, primary key, common filters, gotchas, and common joins1711723. **Join patterns** — If the analysis used non-obvious joins:173 - Offer to capture via `capture_join_pattern(tables, join_sql, cardinality, validated, dataset)`174 - Record cardinality and whether the join was validated175176**Rules for this step:**177- Ask the user: "Would you like to save any SQL patterns from this analysis?"178- If the user declines or there are no reusable patterns, skip silently179- Only offer for analyses with confidence grade B or better180- Never auto-capture without user confirmation181182## Verification Mode183184**When user wants to verify an existing archive (not create a new one):**1851861. Read `.knowledge/analyses/index.yaml`1872. Find the most recent entry (highest index, latest date)1883. Display what was captured:189 - Analysis ID and title190 - Date archived191 - Key findings (list them)192 - Metrics used193 - Agents invoked194 - Output files preserved195 - Tags196 - Confidence grade1974. Confirm dataset manifest was updated1985. Report archive stats (total analyses, last updated)199200**Do NOT create a new archive entry in verification mode.**201202Report format:203```204Archive verified: {title}205ID: {id}206Status: Successfully archived on {date}207208Captured:209- {count} key findings210- {count} metrics tracked211- {count} agents used212- {count} output files preserved213214Use `/history` to browse all past analyses.215```216217## Rules2181. **Never overwrite an existing archive entry** — always append2192. Key findings should be one sentence each, factual, with numbers where possible2203. Tags should be lowercase, no spaces (use hyphens)2214. If validation was not run, set confidence to null and note it2225. Archive even partial analyses — mark as `partial: true`2236. **Verification requests don't create new entries** — read and report existing archives2247. **DO NOT create standalone analysis markdown files or archive directories** — the archive system stores metadata in `index.yaml` only. Output files remain in their original locations (`outputs/`, `working/`) and are referenced by path in the `output_files` array. DO NOT copy or duplicate artifacts.225226## Edge Cases227- **No outputs exist:** Set `output_files: []`, do not invent file names. Archive with metadata only.228- **Pipeline was interrupted:** Archive what's available, mark as `partial: true`, document reason in a `reason_incomplete` field229- **Duplicate question:** Still archive — different runs may find different things230- **Analysis index doesn't exist:** Create it from template231- **User says 'verify' but no archive exists:** Report "No archive found. Would you like to create one?" and proceed to archive mode if confirmed232- **Session state files don't exist:** Use conversation history and user-provided metadata to build the archive entry233- **User mentioned files but they don't exist:** Only list files that actually exist in outputs/ or working/. If the user mentioned output files but they're not present, note in confirmation: "Files mentioned but not found: {list}"