Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .claude/mcp.json.example

This file was deleted.

100 changes: 100 additions & 0 deletions .claude/skills/archaeology/skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Skill: Query Archaeology Retrieval

## Purpose
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.

## When to Use
- **Automatically** before any analysis agent writes SQL (pre-flight step)
- **Manually** when the user asks about known patterns for a table or join

## Instructions

### Step 1: Check the Index

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.

### Step 2: Identify Search Terms

From the current analysis context, extract:
- **Table names** the agent is about to query (e.g., `orders`, `events`)
- **Query intent tags** (e.g., `funnel`, `retention`, `revenue`, `cohort`)

### Step 3: Search the Three Stores

Search each store that has entries (per index counts). Match using
**case-insensitive substring** -- `order` matches `orders`, `order_items`.

#### 3a. Cookbook (`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`.

#### 3b. Table Cheatsheets (`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`.

#### 3c. Join Patterns (`curated/joins/*.yaml`)
For each file, check:
- `tables` array -- at least two elements match search table names?
- If only one search table, match if `tables` contains it as substring.

Extract on match: `tables`, `join_sql`, `cardinality`, `notes`, `validated`.

### Step 4: Format Results

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"}

## Table Cheatsheets
### {table_name}
- Grain: {grain}
- Primary key: {primary_key}
- Common filters: {common_filters}
- Gotchas: {gotchas}
- Common joins: {common_joins summary}

## Join Patterns
### {tables[0]} <-> {tables[1]}
Cardinality: {cardinality} | Validated: {validated}
```sql
{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.

## 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. **Never modify archaeology files** -- this skill is read-only
5. **Never block analysis if retrieval fails** -- archaeology is additive, not a gate
2 changes: 1 addition & 1 deletion .claude/skills/architect/skill.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If the brief is too vague (under 20 words, no clear deliverable), ask one clarif
### 2. Determine output directory

Look for context clues:
- If the brief mentions a specific project (podcast, bootcamp, evals, etc.), use that project's directory
- If the brief mentions a specific project (podcast, analytics, evals, etc.), use that project's directory
- If a `working/plans/` directory already exists nearby, use it
- Otherwise, create `working/plans/` in the most relevant project directory
- If truly ambiguous, ask the user
Expand Down
23 changes: 23 additions & 0 deletions .claude/skills/archive-analysis/skill.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,29 @@ Findings: {count} key findings captured
Use `/history` to browse past analyses.
```

### Step 6: Capture to Query Archaeology (Optional)

After archiving, check if the analysis produced reusable patterns worth saving
to `.knowledge/query-archaeology/curated/` via `helpers/archaeology_helpers.py`.

1. **SQL patterns** — If validated SQL queries could be reused for future analyses:
- Offer to capture via `capture_cookbook_entry(title, sql, dataset, tables, tags)`
- Only capture queries that passed tie-out or validation checks

2. **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

3. **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 capture patterns from analyses with confidence grade B or better
- Never auto-capture without user confirmation

## Rules
1. Never overwrite an existing archive entry — always append
2. Key findings should be one sentence each, factual, with numbers
Expand Down
156 changes: 156 additions & 0 deletions .claude/skills/business/skill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# /business — Business Context Browser

> Interactive browser for your organization's knowledge system. Explore terms,
> products, metrics, objectives, and team structure.

## Trigger
Invoked as `/business` or `/business {subcommand}`

## Prerequisites
- Organization context must exist at `.knowledge/organizations/{org}/`
- Read `.knowledge/setup-state.yaml` to find active organization
- If no org configured: "No organization context found. Run `/setup` Phase 3 to configure business context, or create one manually at `.knowledge/organizations/{name}/`."

## Subcommands

### `/business` (no args) — Overview
Display a summary of available business context:

```
📊 Business Context: {org_name}

Glossary: {n} terms defined
Products: {n} products cataloged
Metrics: {n} metrics specified
Objectives: {n} OKRs/goals tracked
Teams: {n} teams mapped

Type /business {category} for details.
```

**Implementation:**
1. Read `.knowledge/organizations/{org}/manifest.yaml` for org name
2. Use `helpers/business_context.py` → `load_business_context(org_path)`
3. Count entries in each category
4. Display summary table

### `/business glossary` — Browse Terms
Display all business term definitions:

```
📖 Glossary ({n} terms)

Term | Definition | Category
──────────────────|─────────────────────────────────────|──────────
Active User | User with ≥1 session in last 30d | Engagement
Churn | No activity for 60+ days | Retention
...
```

**Implementation:**
1. Load from `business/glossary/terms.yaml`
2. Sort alphabetically
3. Show first 20 terms; offer "Show all" if more
4. If empty: "No glossary terms defined. Add terms to `.knowledge/organizations/{org}/business/glossary/terms.yaml`."

### `/business products` — View Product Catalog
Display product hierarchy:

```
📦 Products ({n} total)

Product | Category | Status | Key Metrics
──────────────────|─────────────|───────────|────────────
Core Platform | SaaS | Active | MAU, Revenue
Mobile App | Mobile | Active | DAU, Retention
...
```

**Implementation:**
1. Load from `business/products/index.yaml`
2. Display in table format
3. If empty: "No products defined. Add products to `.knowledge/organizations/{org}/business/products/index.yaml`."

### `/business metrics` — Inspect Metric Definitions
Display metric dictionary:

```
📏 Metrics ({n} defined)

Metric | Type | Formula/Definition | Owner
──────────────────|─────────────|───────────────────────────|──────
Conversion Rate | Ratio | signups / visitors | Growth
MRR | Currency | SUM(active_subscriptions) | Finance
...
```

**Implementation:**
1. Load from `business/metrics/index.yaml`
2. Cross-reference with `.knowledge/datasets/{active}/metrics/` if available
3. Show definition, type, owner
4. If empty: "No metrics defined. Use `/metrics add` to define metrics, or add to `.knowledge/organizations/{org}/business/metrics/index.yaml`."

### `/business objectives` — Review OKRs/Goals
Display current objectives:

```
🎯 Objectives ({n} active)

Objective | Key Results | Status
───────────────────────────────|──────────────────────────|────────
Increase activation rate | +15% by Q2 | On Track
Reduce churn | <5% monthly by Q3 | At Risk
...
```

**Implementation:**
1. Load from `business/objectives/index.yaml`
2. Show status indicators (On Track / At Risk / Behind)
3. If empty: "No objectives defined. Add OKRs to `.knowledge/organizations/{org}/business/objectives/index.yaml`."

### `/business teams` — Show Team Structure
Display team organization:

```
👥 Teams ({n} mapped)

Team | Lead | Focus Area | Analysts
──────────────────|─────────────|───────────────────|──────────
Growth | Jane D. | Acquisition | 2
Product | John S. | Core Experience | 3
...
```

**Implementation:**
1. Load from `business/teams/index.yaml`
2. Show team summary
3. If empty: "No teams defined. Add team structure to `.knowledge/organizations/{org}/business/teams/index.yaml`."

### `/business lookup {term}` — Search
Search across all categories for a term:

1. Search glossary terms (exact + fuzzy match)
2. Search product names
3. Search metric names
4. Search objective text
5. Display all matches with category labels

If no match: "No results for '{term}'. Try a different search term or browse categories with `/business`."

**Implementation:**
1. Use `helpers/business_context.py` → `get_glossary()`, `get_products()`, etc.
2. Case-insensitive substring match across all categories
3. Rank: exact match > starts-with > contains
4. Show top 10 results with category badge

## Error Handling
- Missing org directory → suggest `/setup` Phase 3
- Empty categories → show helpful "how to add" message with file path
- Malformed YAML → show parse error, suggest checking file syntax
- Partial context (some categories empty) → show what exists, note gaps

## Display Rules
- Use tables for structured data (align columns)
- Limit initial display to 20 rows; offer pagination
- Always show file paths so users know where to edit
- Adapt detail level: summary for `/business`, detail for subcommands
6 changes: 3 additions & 3 deletions .claude/skills/datasets/skill.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ For each registered source, check if `.knowledge/datasets/{name}/manifest.yaml`
```
Connected Datasets:

* novamart (active)
NovaMart E-Commerce — 13 tables, 2024-01-01 to 2024-12-31
Connection: motherduck (novamart)
* your_dataset (active)
Your Dataset Name — {table_count} tables, {date_range}
Connection: {type} ({database})
Analyses: 0

- {other_dataset}
Expand Down
Loading
Loading