@quarri/claude-data-tools 1.0.2 → 1.1.1

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.
@@ -0,0 +1,335 @@
1
+ # Skill Chaining Demonstration
2
+
3
+ This document demonstrates how the Quarri skills chain together for complex requests, using simulated data to show the expected output flow.
4
+
5
+ ---
6
+
7
+ ## Demo 1: Full Analysis Request
8
+
9
+ **User Request**: "Analyze revenue trends by product category over the past quarter"
10
+
11
+ ### Skill Chain: `/quarri-analyze` → `/quarri-query` → `/quarri-insights` → `/quarri-chart`
12
+
13
+ ---
14
+
15
+ ### Stage 1: Query Generation (`/quarri-query`)
16
+
17
+ **Generated SQL:**
18
+ ```sql
19
+ SELECT
20
+ DATE_TRUNC('week', order_date) as week,
21
+ product_category,
22
+ COUNT(*) as order_count,
23
+ COUNT(DISTINCT customer_id) as customers,
24
+ SUM(revenue) as revenue,
25
+ AVG(revenue) as avg_order_value
26
+ FROM quarri.bridge
27
+ WHERE order_date >= CURRENT_DATE - INTERVAL '90 days'
28
+ GROUP BY week, product_category
29
+ ORDER BY week, product_category
30
+ ```
31
+
32
+ **Sample Results:**
33
+ | week | product_category | order_count | customers | revenue | avg_order_value |
34
+ |------|------------------|-------------|-----------|---------|-----------------|
35
+ | 2024-10-07 | Electronics | 156 | 142 | 45,200 | 289.74 |
36
+ | 2024-10-07 | Clothing | 234 | 198 | 18,720 | 80.00 |
37
+ | 2024-10-07 | Home | 89 | 82 | 12,460 | 140.00 |
38
+ | ... | ... | ... | ... | ... | ... |
39
+
40
+ ---
41
+
42
+ ### Stage 2: Statistical Analysis (`/quarri-insights`)
43
+
44
+ **Statistical Findings:**
45
+
46
+ #### Descriptive Statistics
47
+ | Metric | Electronics | Clothing | Home |
48
+ |--------|-------------|----------|------|
49
+ | Total Revenue | $542,400 | $224,640 | $149,520 |
50
+ | % of Total | 59.2% | 24.5% | 16.3% |
51
+ | Avg Weekly Growth | +3.2% | +1.8% | -0.5% |
52
+ | Volatility | 12.4% | 8.2% | 15.1% |
53
+
54
+ #### Key Patterns
55
+ - **Trend**: Electronics growing +3.2% weekly, Home declining -0.5%
56
+ - **Concentration**: Top category (Electronics) = 59% of revenue
57
+ - **Correlation**: Order count and revenue: r = 0.92 (strong positive)
58
+ - **Outlier**: Week of 2024-11-25 had 40% spike (Black Friday)
59
+
60
+ ---
61
+
62
+ ### Stage 3: Business Insights (`/quarri-insights` continued)
63
+
64
+ #### Key Finding
65
+ **Electronics drives 59% of total revenue and is growing 3.2% weekly, while Home category is declining 0.5% weekly - consider reallocating marketing investment.**
66
+
67
+ #### Insights
68
+
69
+ **1. Concentration Risk**
70
+ Electronics represents 59% of revenue from a single category.
71
+ - **Implication**: High dependency on one product line
72
+ - **Action**: Develop growth strategy for Clothing (24.5%) to diversify
73
+
74
+ **2. Growth Differential**
75
+ Electronics (+3.2%/week) outpacing Clothing (+1.8%) by 78%.
76
+ - **Implication**: Gap will widen without intervention
77
+ - **Action**: Analyze what's driving Electronics success, apply to other categories
78
+
79
+ **3. Home Decline**
80
+ Home category declining -0.5% weekly over 12 weeks.
81
+ - **Implication**: Potential market share loss or seasonal effect
82
+ - **Action**: Investigate: pricing, competition, product assortment
83
+
84
+ ---
85
+
86
+ ### Stage 4: Visualization (`/quarri-chart`)
87
+
88
+ **Recommended Chart**: Multi-line chart showing weekly revenue by category
89
+
90
+ **QuickChart URL**:
91
+ ```
92
+ https://quickchart.io/chart?c={type:'line',data:{labels:['Oct 7','Oct 14','Oct 21','Oct 28','Nov 4','Nov 11','Nov 18','Nov 25','Dec 2','Dec 9','Dec 16','Dec 23'],datasets:[{label:'Electronics',data:[45200,46800,48100,49500,51200,52800,54100,75700,56200,57800,59100,60500],borderColor:'%234F46E5',fill:false},{label:'Clothing',data:[18720,19100,19400,19800,20100,20500,20800,29100,21400,21800,22100,22500],borderColor:'%2310B981',fill:false},{label:'Home',data:[12460,12400,12350,12300,12250,12200,12150,17000,12050,12000,11950,11900],borderColor:'%23F59E0B',fill:false}]},options:{title:{display:true,text:'Weekly Revenue by Category (Q4 2024)'}}}
93
+ ```
94
+
95
+ **ASCII Alternative**:
96
+ ```
97
+ Weekly Revenue by Category (Q4 2024)
98
+
99
+ Electronics ▁▂▂▃▃▄▄█▅▅▆▆ $45K → $60K (+34%)
100
+ Clothing ▁▁▂▂▂▃▃█▃▃▃▄ $19K → $23K (+20%)
101
+ Home ▂▂▂▂▂▂▂▄▁▁▁▁ $12K → $12K (-5%)
102
+ Oct Nov Dec
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Demo 2: Root Cause Analysis Request
108
+
109
+ **User Request**: "Why did revenue drop last month?"
110
+
111
+ ### Skill Chain: `/quarri-diagnose` (with metric tree decomposition)
112
+
113
+ ---
114
+
115
+ ### Stage 1: Identify the Metric
116
+ - **Target**: Revenue
117
+ - **Direction**: Decrease
118
+ - **Period**: Last month vs previous month
119
+
120
+ ### Stage 2: Build Metric Tree
121
+
122
+ ```
123
+ Revenue = Customers × Orders/Customer × Revenue/Order
124
+
125
+ ├── Customers (unique buyers)
126
+ │ ├── New Customers
127
+ │ └── Returning Customers
128
+
129
+ ├── Orders per Customer (frequency)
130
+
131
+ └── Revenue per Order (basket size)
132
+ ├── Units per order
133
+ └── Price per unit
134
+ ```
135
+
136
+ ### Stage 3: Query Components
137
+
138
+ **Period Comparison:**
139
+ | Component | Previous Month | Current Month | Change % |
140
+ |-----------|----------------|---------------|----------|
141
+ | Revenue | $100,000 | $90,000 | **-10%** |
142
+ | Customers | 1,000 | 920 | **-8%** |
143
+ | Orders/Customer | 2.50 | 2.45 | -2% |
144
+ | Revenue/Order | $40.00 | $39.90 | -0.25% |
145
+
146
+ ### Stage 4: Impact Attribution
147
+
148
+ ```
149
+ Revenue dropped 10% ($100K → $90K = -$10K)
150
+
151
+ Impact Attribution:
152
+ ┌─────────────────────┬──────────┬─────────┬──────────┬──────────────┐
153
+ │ Component │ Previous │ Current │ Change % │ Impact $ │
154
+ ├─────────────────────┼──────────┼─────────┼──────────┼──────────────┤
155
+ │ Customers │ 1,000 │ 920 │ -8% │ -$8,000 ◀── │
156
+ │ Orders/Customer │ 2.5 │ 2.45 │ -2% │ -$1,800 │
157
+ │ Revenue/Order │ $40 │ $39.90 │ -0.25% │ -$200 │
158
+ └─────────────────────┴──────────┴─────────┴──────────┴──────────────┘
159
+
160
+ PRIMARY DRIVER: Customer count (-8%, 80% of total decline)
161
+ ```
162
+
163
+ ### Stage 5: Drill Down
164
+
165
+ ```
166
+ Customer Count dropped 8% (1,000 → 920)
167
+
168
+ Sub-component Analysis:
169
+ ┌─────────────────────┬──────────┬─────────┬──────────┐
170
+ │ Component │ Previous │ Current │ Change % │
171
+ ├─────────────────────┼──────────┼─────────┼──────────┤
172
+ │ New Customers │ 300 │ 200 │ -33% ◀──│
173
+ │ Returning Customers │ 700 │ 720 │ +3% │
174
+ └─────────────────────┴──────────┴─────────┴──────────┘
175
+
176
+ PRIMARY DRIVER: New customer acquisition (-33%)
177
+ ```
178
+
179
+ ```
180
+ New Customer Acquisition dropped 33% (300 → 200)
181
+
182
+ By Channel:
183
+ ┌─────────────────────┬──────────┬─────────┬──────────┐
184
+ │ Channel │ Previous │ Current │ Change % │
185
+ ├─────────────────────┼──────────┼─────────┼──────────┤
186
+ │ Paid Search │ 150 │ 80 │ -47% ◀──│
187
+ │ Paid Social │ 80 │ 60 │ -25% │
188
+ │ Organic │ 70 │ 60 │ -14% │
189
+ └─────────────────────┴──────────┴─────────┴──────────┘
190
+
191
+ ROOT CAUSE: Paid search acquisition dropped 47%
192
+ ```
193
+
194
+ ### Stage 6: Output
195
+
196
+ ```markdown
197
+ ## Diagnosis: Revenue Dropped 10% ($100K → $90K)
198
+
199
+ ### Root Cause Chain
200
+ ```
201
+ Revenue ↓10%
202
+ └── Customer Count ↓8% (80% of impact)
203
+ └── New Customers ↓33%
204
+ └── Paid Search ↓47% ← ROOT CAUSE
205
+ ```
206
+
207
+ ### Confidence Level
208
+ **High** - Clear single driver with consistent attribution at each level
209
+
210
+ ### Evidence
211
+ - Paid search was largest acquisition channel (50% of new customers)
212
+ - Drop coincides with Q4 when CPCs typically increase 20-40%
213
+ - Retention improved (+3%), ruling out product/service issues
214
+
215
+ ### Hypothesis
216
+ Paid search performance degraded due to increased Q4 competition
217
+ driving up CPCs. The 47% drop in paid search volume directly
218
+ explains 80% of the revenue decline.
219
+
220
+ ### Recommended Actions
221
+
222
+ **Immediate (This Week)**
223
+ 1. Review Google Ads auction insights for competitive pressure
224
+ 2. Check for any campaign changes around the decline date
225
+ 3. Analyze CPC trends - did cost per click increase?
226
+
227
+ **Short-term (This Month)**
228
+ 1. Increase budget if ROAS is still profitable despite higher CPCs
229
+ 2. Test new ad copy to improve Quality Score
230
+ 3. Expand to lower-competition keywords
231
+
232
+ **Investigation Needed**
233
+ 1. What was the CPC change? (external vs internal)
234
+ 2. Did conversion rate from paid search change?
235
+ 3. Are competitors running aggressive promotions?
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Demo 3: Metric Definition with Tree
241
+
242
+ **User Request**: "Create a metric for customer lifetime value with its component drivers"
243
+
244
+ ### Skill: `/quarri-metric`
245
+
246
+ ---
247
+
248
+ ### Output:
249
+
250
+ ```markdown
251
+ ## Metric Definition: Customer Lifetime Value (CLV)
252
+
253
+ ### Summary
254
+ **Name**: Customer Lifetime Value
255
+ **Description**: Total revenue expected from a customer over their entire relationship
256
+ **Synonyms**: CLV, LTV, Lifetime Value, Customer Value
257
+
258
+ ### Calculation
259
+ CLV = Average Revenue Per User (ARPU) × Average Customer Lifetime × Gross Margin
260
+
261
+ ### SQL Template
262
+ ```sql
263
+ WITH customer_metrics AS (
264
+ SELECT
265
+ customer_id,
266
+ SUM(revenue) as total_revenue,
267
+ COUNT(*) as order_count,
268
+ MIN(order_date) as first_order,
269
+ MAX(order_date) as last_order,
270
+ DATEDIFF('day', MIN(order_date), MAX(order_date)) as tenure_days
271
+ FROM quarri.bridge
272
+ GROUP BY customer_id
273
+ )
274
+ SELECT
275
+ AVG(total_revenue) as avg_revenue_per_customer,
276
+ AVG(tenure_days) / 365.0 as avg_lifetime_years,
277
+ AVG(total_revenue) * (AVG(tenure_days) / 365.0) as estimated_clv
278
+ FROM customer_metrics
279
+ WHERE order_count >= 2 -- Exclude one-time buyers
280
+ ```
281
+
282
+ ### Metric Tree
283
+ ```
284
+ CLV = ARPU × Avg Lifetime × Gross Margin
285
+
286
+ ├── ARPU (Average Revenue Per User)
287
+ │ ├── Order Frequency
288
+ │ │ ├── Time between purchases
289
+ │ │ └── Reactivation rate
290
+ │ └── Average Order Value
291
+ │ ├── Units per order
292
+ │ └── Price per unit
293
+
294
+ ├── Average Customer Lifetime
295
+ │ ├── Retention Rate (monthly)
296
+ │ ├── Churn Rate = 1 - Retention
297
+ │ └── Avg Lifetime = 1 / Churn Rate
298
+
299
+ └── Gross Margin
300
+ ├── Revenue
301
+ └── Cost of Goods Sold
302
+ ```
303
+
304
+ ### Dimensions
305
+ - **Segment**: Enterprise vs SMB vs Consumer
306
+ - **Acquisition Channel**: Paid vs Organic vs Referral
307
+ - **Product Category**: Electronics vs Clothing vs Home
308
+ - **Cohort**: By signup month
309
+
310
+ ### Validation Results
311
+ - Query executed successfully
312
+ - Sample CLV: $847 (all customers)
313
+ - By segment: Enterprise $2,340 | SMB $612 | Consumer $234
314
+
315
+ ### Status
316
+ Ready to save
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Summary: Skill Chaining Patterns
322
+
323
+ | Request Type | Skill Chain | Output |
324
+ |--------------|-------------|--------|
325
+ | Simple query | query | SQL + results |
326
+ | Full analysis | analyze → query → insights → chart | Pipeline with viz |
327
+ | Root cause | diagnose (with metric tree) | Attribution + actions |
328
+ | Metric definition | metric | Definition + tree |
329
+ | Visualization | chart | QuickChart URL + alternatives |
330
+
331
+ The skills-first architecture ensures:
332
+ 1. **Correct routing** based on request intent
333
+ 2. **Proper chaining** for complex requests
334
+ 3. **Consistent output** formats across skills
335
+ 4. **Professional frameworks** (MECE, Metric Trees) applied automatically
@@ -0,0 +1,189 @@
1
+ # Skill Test Scenarios
2
+
3
+ Test scenarios for the Quarri skills-first architecture, documenting expected skill chaining behavior.
4
+
5
+ ## Skill Architecture Overview
6
+
7
+ ```
8
+ ┌─────────────────────────────────────────────────────────────────┐
9
+ │ User Request │
10
+ └─────────────────────────────────────────────────────────────────┘
11
+
12
+
13
+ ┌─────────────────────────────────────────────────────────────────┐
14
+ │ Skill Router (Claude) │
15
+ │ Matches request to appropriate skill based on intent │
16
+ └─────────────────────────────────────────────────────────────────┘
17
+
18
+ ┌─────────────────────┼─────────────────────┐
19
+ ▼ ▼ ▼
20
+ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐
21
+ │ Simple Skills │ │ Orchestrator │ │ Root Cause │
22
+ │ │ │ Skills │ │ Skills │
23
+ │ - query │ │ │ │ │
24
+ │ - chart │ │ - analyze │ │ - diagnose │
25
+ │ - explain │ │ (chains to │ │ (uses │
26
+ │ - insights │ │ query → │ │ metric │
27
+ │ - metric │ │ insights → │ │ trees) │
28
+ │ - extract │ │ chart) │ │ │
29
+ └───────────────┘ └───────────────┘ └───────────────┘
30
+ ```
31
+
32
+ ## Test Scenarios
33
+
34
+ ### Category 1: Simple Queries (Single Skill)
35
+
36
+ | Request | Expected Skill | Expected Behavior |
37
+ |---------|----------------|-------------------|
38
+ | "Show revenue by region" | `/quarri-query` | Generate SQL, execute, return results |
39
+ | "What does this SQL do: SELECT ..." | `/quarri-explain` | Plain English explanation |
40
+ | "Create a bar chart of sales" | `/quarri-chart` | QuickChart URL + alternatives |
41
+ | "Define a metric for customer LTV" | `/quarri-metric` | Guided metric creation |
42
+
43
+ ### Category 2: Analysis Requests (Orchestrated Skills)
44
+
45
+ | Request | Primary Skill | Chained Skills | Expected Behavior |
46
+ |---------|---------------|----------------|-------------------|
47
+ | "Analyze revenue trends" | `/quarri-analyze` | query → insights → chart | Full pipeline with stats and visualization |
48
+ | "Give me insights on customer orders" | `/quarri-analyze` | query → insights → chart | MECE breakdown + recommendations |
49
+ | "What's happening with our sales?" | `/quarri-analyze` | query → insights | Statistical analysis + business interpretation |
50
+
51
+ ### Category 3: Root Cause Analysis (Diagnostic Skills)
52
+
53
+ | Request | Primary Skill | Expected Behavior |
54
+ |---------|---------------|-------------------|
55
+ | "Why did revenue drop last month?" | `/quarri-diagnose` | Metric tree decomposition, impact attribution, root cause identification |
56
+ | "What's causing churn to increase?" | `/quarri-diagnose` | Drill-down analysis with confidence level |
57
+ | "Why is conversion rate declining?" | `/quarri-diagnose` | Funnel analysis with recommendations |
58
+
59
+ ### Category 4: Complex Multi-Skill Scenarios
60
+
61
+ #### Scenario A: "Analyze why revenue dropped and visualize the trend"
62
+ ```
63
+ 1. /quarri-diagnose (root cause)
64
+ ├── Build revenue metric tree
65
+ ├── Query components for current vs previous
66
+ ├── Identify primary driver
67
+ └── Generate hypothesis
68
+ 2. /quarri-chart (visualization)
69
+ └── Create trend chart showing decline
70
+ ```
71
+
72
+ #### Scenario B: "Create a revenue metric and show me its components"
73
+ ```
74
+ 1. /quarri-metric (definition)
75
+ ├── Define revenue metric
76
+ └── Build metric tree
77
+ 2. /quarri-query (data retrieval)
78
+ └── Query each tree component
79
+ 3. /quarri-insights (analysis)
80
+ └── Statistical summary of each component
81
+ ```
82
+
83
+ #### Scenario C: "Give me a full analysis of customer acquisition trends with recommendations"
84
+ ```
85
+ 1. /quarri-analyze (orchestrator)
86
+ ├── /quarri-query
87
+ │ └── SQL for acquisition by channel over time
88
+ ├── /quarri-insights
89
+ │ ├── Statistical analysis (trends, correlations)
90
+ │ └── Business insights with recommendations
91
+ └── /quarri-chart
92
+ └── Multi-line chart by acquisition channel
93
+ ```
94
+
95
+ #### Scenario D: "Why did conversion drop? Show me the funnel breakdown."
96
+ ```
97
+ 1. /quarri-diagnose (root cause)
98
+ ├── Build conversion funnel metric tree
99
+ ├── Compare current vs previous period
100
+ ├── Identify stage with biggest drop
101
+ └── Generate root cause hypothesis
102
+ 2. /quarri-chart (visualization)
103
+ └── Funnel chart or waterfall showing drop-off
104
+ ```
105
+
106
+ ## Expected Skill Selection Logic
107
+
108
+ ### Keywords → Skill Mapping
109
+
110
+ | Keywords in Request | Likely Skill |
111
+ |---------------------|--------------|
112
+ | "show", "list", "get", "what is" | `/quarri-query` |
113
+ | "analyze", "trends", "insights", "patterns" | `/quarri-analyze` |
114
+ | "why", "cause", "reason", "explain (change)", "dropped", "increased" | `/quarri-diagnose` |
115
+ | "chart", "graph", "visualize", "plot" | `/quarri-chart` |
116
+ | "explain (SQL)", "what does this mean" | `/quarri-explain` |
117
+ | "define", "create metric", "KPI", "metric tree" | `/quarri-metric` |
118
+ | "statistics", "distribution", "correlation", "outliers" | `/quarri-insights` |
119
+ | "extract", "pipeline", "sync", "connector" | `/quarri-extract` |
120
+
121
+ ### Complexity → Orchestration
122
+
123
+ | Request Complexity | Skill Pattern |
124
+ |--------------------|---------------|
125
+ | Simple data retrieval | Single skill (query) |
126
+ | Analysis with insights | Orchestrated (analyze) |
127
+ | Root cause investigation | Diagnostic (diagnose) |
128
+ | Multi-faceted request | Multiple skill calls |
129
+
130
+ ## Validation Checklist
131
+
132
+ ### For Each Test Scenario, Verify:
133
+
134
+ - [ ] Correct skill(s) selected based on request intent
135
+ - [ ] Skill chaining happens in correct order
136
+ - [ ] Data flows properly between chained skills
137
+ - [ ] Output format matches skill documentation
138
+ - [ ] Error handling works when a skill fails mid-chain
139
+ - [ ] MECE framework applied for complex "why" questions
140
+ - [ ] Metric trees used for diagnostic questions
141
+
142
+ ### Output Quality Checks:
143
+
144
+ - [ ] Insights are specific (include numbers)
145
+ - [ ] Insights are contextual (include comparisons)
146
+ - [ ] Insights are actionable (include recommendations)
147
+ - [ ] Charts use appropriate format (QuickChart default)
148
+ - [ ] Root cause has confidence level
149
+ - [ ] Recommendations are prioritized (immediate vs short-term)
150
+
151
+ ## Test Commands (When MCP Server Active)
152
+
153
+ ```bash
154
+ # 1. Simple query
155
+ /quarri-query "show total revenue by month"
156
+
157
+ # 2. Full analysis (should chain: query → insights → chart)
158
+ /quarri-analyze "analyze customer order trends over the past 6 months"
159
+
160
+ # 3. Root cause (should use metric tree decomposition)
161
+ /quarri-diagnose "why did revenue drop last month?"
162
+
163
+ # 4. Statistical insights
164
+ /quarri-insights "what's the distribution of order values?"
165
+
166
+ # 5. Metric with tree
167
+ /quarri-metric "create a metric for customer lifetime value with its component drivers"
168
+
169
+ # 6. Chart with format options
170
+ /quarri-chart "create an ASCII chart of revenue by region"
171
+ ```
172
+
173
+ ## Known Limitations
174
+
175
+ 1. **MCP Server Required**: Skills require active Quarri MCP connection
176
+ 2. **Database Required**: Must have database selected via `quarri_select_database`
177
+ 3. **Schema Awareness**: Complex queries need schema context from `quarri_get_schema`
178
+ 4. **Metric Trees**: Diagnose skill works best when metric definitions exist
179
+
180
+ ## Success Criteria
181
+
182
+ The skills-first architecture is working correctly when:
183
+
184
+ 1. Simple queries (show X) go directly to `/quarri-query`
185
+ 2. Analysis requests (analyze X) trigger the orchestration chain
186
+ 3. Diagnostic questions (why did X) use metric tree decomposition
187
+ 4. Chart output includes QuickChart URLs by default
188
+ 5. MECE framework appears in complex analysis output
189
+ 6. Root cause analysis includes confidence levels and recommendations