/ai-analyst-plus:archaeologyfrom ai-analyst-plus
Retrieves proven SQL patterns, table cheatsheets, and join patterns from a local knowledge store so past work is reused before writing new SQL. Automatically fires as a pre-flight step.
Ships in ai-analyst-plus. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Retrieve proven SQL patterns, table cheatsheets, and join patterns from the query archaeology store so agents reuse validated work instead of writing SQL from scratch. The skill also defines the store's local write path: after a validated analysis, the final SQL is curated back into the store (the Writer Convention below), which is what makes the retrieval loop close.
Read .knowledge/query-archaeology/curated/index.yaml. Parse counters:
cookbook_entries, table_cheatsheets, join_patterns.
If all three are zero (or the file is missing), stop here. Return nothing and do not mention archaeology to the user.
From the current analysis context, extract:
orders, events)funnel, retention, revenue, cohort)Search each store that has entries (per index counts). Match using
case-insensitive substring -- order matches orders, order_items.
curated/cookbook/*.yaml)For each file, check:
tables array -- any element contains a search table name as substring?tags array -- any element matches a query intent tag?Extract on match: title, sql, tables, tags, and any caveats/notes.
curated/tables/*.yaml)For each file, check:
table_name contains a search table name as substring?Extract on match: table_name, grain, primary_key, common_filters,
gotchas, common_joins.
curated/joins/*.yaml)For each file, check:
tables array -- at least two elements match search table names?tables contains it as substring.Extract on match: tables, join_sql, cardinality, notes, validated.
Return matched entries as a fenced context block. Omit sections with no matches.
--- QUERY ARCHAEOLOGY CONTEXT ---
## Cookbook Patterns
### {title}
Tables: {tables} | Tags: {tags}
```sql
{sql}
Caveats: {caveats or "none"}
Cardinality: {cardinality} | Validated: {validated}
{join_sql}
Notes: {notes}
--- END ARCHAEOLOGY CONTEXT ---
### Step 5: Agent Handoff
Pass the formatted block as additional context to the analysis agent. The
agent should prefer archaeology SQL over writing from scratch, respect any
gotchas listed, and note in working files when an archaeology pattern was used.
## Writer Convention: Curate After a Validated Analysis
Retrieval only pays off if something writes. After an analysis is validated
(the triangulation checks pass and the finding ships), curate the final proven
SQL into the store:
1. Allocate the next entry id `CK-{NNN}`: scan
`.knowledge/query-archaeology/curated/cookbook/` for the highest existing
number and increment (start at `CK-001` for an empty store).
2. Write `.knowledge/query-archaeology/curated/cookbook/{entry_id}.yaml` with:
`id`, `title` (what the query answers), `description`, `sql` (the final
validated SQL), `dataset`, `tables`, `tags` (query intent tags such as
`funnel`, `retention`, `revenue`), `source_analysis` (the analysis brief or
`.knowledge/analyses/` run-record filename), `created_at` and `last_used`
(today), `use_count: 0`. This is the same cookbook format notion-ingest
writes, so imported and locally curated entries live side by side.
3. Create `curated/index.yaml` if it is missing (counters `cookbook_entries`,
`table_cheatsheets`, `join_patterns`, all starting at 0), then increment
`cookbook_entries`.
Curate one entry per validated headline query, not every intermediate query.
Skip exploratory SQL and one-off sanity checks.
## Anti-Patterns
1. **Never mention archaeology when the store is empty** -- silent skip
2. **Never require exact matches** -- always substring so `order` finds `orders`
3. **Never load all files eagerly** -- check index counts first, skip zero stores
4. **Retrieval never modifies archaeology files** -- the pre-flight path is
read-only; only the Writer Convention appends entries, and only after
validation
5. **Never block analysis if retrieval fails** -- archaeology is additive, not a gate
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ai-analyst-lab/ai-analyst-plugin --plugin ai-analyst-plus47 skills in this plugin
/always-compareNever present a metric or number in isolation; anchor every number to a comparison (prior period, benchmark, or another segment) or state that none is available. Use every time you show a number: rates, counts, revenue, averages, query results, chart labels, summary stats. Trigger on output containing "the rate is", "we saw", "total", "average", "conversion", "revenue", "users", "sessions", "churn", "AOV", "NPS", or any figure pulled from data./analysis-designTurn a vague hunch or stakeholder request into a rigorous analysis plan via a staged pipeline (hypothesis sharpening, confound scan, V1, feedback, V2 redesign). Trigger on "I think X caused Y", "design an analysis for", "what's driving", "V2 after feedback", "stakeholder comments", "redesign the analysis". Vs question-framing (the lightweight framing gate before every analysis): use THIS only for a real hunch, confound scan, or V1 to V2 redesign./analyst-coreOperating rules for every data analysis. Apply for ANY data-analysis intent: "analyze", "investigate", "why did X change", "compare", "report on", "dashboard", "metrics", "funnel", "retention", "revenue", "conversion", "trend", "segment", "forecast", "how are we doing", "dig into", "break down", or any question about data, a metric, a CSV, or a table. Sets the method and routes to the other skills; load before any analytical question./businessBrowse and search the organization's business context in .knowledge/organizations/: glossary terms, product catalog, metric definitions, OKRs, team structure. Trigger on "/business", "show me our glossary", "what metrics are defined?", "what products do we have?", "show me our OKRs", "who's on which team?", "look up [business term]", "what's the meaning of [term]?". Use this instead of reading the files directly./causalCausal inference toolkit for when experiments are not possible: estimate treatment effects from observational data with assumption checks and mandatory caveats. Invoke as /causal. Trigger on "causal", "caused", "impact of", "effect of", "attribution", "counterfactual", "difference-in-differences", "DiD", "propensity matching", "pre-post". If randomization IS possible, route to /experiment design instead./close-the-loopEnd every analysis that makes a recommendation with an actionable follow-up plan. Use ONLY AFTER a specific recommendation ("we should...", "I recommend..."); add the checklist automatically even if not asked. DO NOT use for pre-recommendation exploratory questions like "should we investigate this?" or "what's causing this pattern?"; skip pure exploration with no recommendations.Other plugins' skills for the same job