Skip to content
Closed
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
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ When the user makes a request, identify which agent should handle it, read its S
| Monitor revenue trends, alert on revenue drops, track MRR/ARR/subscriptions/churn | **Revenue Monitor** | `agents/monitoring/revenue/SKILL.md` |
| Monitor enterprise accounts, alert on churn risk, track account health/quota | **Enterprise Monitor** | `agents/monitoring/enterprise/SKILL.md` |
| Monitor API latency, alert on errors/timeouts, track throughput/performance | **API Runtime Monitor** | `agents/monitoring/api-runtime/SKILL.md` |
| Generate weekly report, weekly summary, week-over-week analysis | **Weekly Reports** | `agents/reports/weekly/SKILL.md` |
| Generate enterprise account report, customer health report, QBR preparation | **Enterprise Reports** | `agents/reports/enterprise/SKILL.md` |
| Generate daily report, daily metrics summary, yesterday's performance | **Daily Reports** | `agents/reports/daily/SKILL.md` |

If the request doesn't clearly match an agent, ask the user which they need.

Expand Down
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ agents/ ← One folder per agent
templates/dashboard-spec.md ← Phase 2 output template
linear/ ← Creates and manages Linear issues for analytics work
SKILL.md ← 4-phase flow: Gather β†’ Confirm β†’ Create β†’ Report
monitoring/ ← (Planned) Anomaly detection and alerts
enterprise-reporter/ ← (Planned) Enterprise account reports
prompt-reviewer/ ← (Planned) Prompt quality review
reports/ ← Automated report generation
weekly/SKILL.md ← Weekly reports with WoW comparisons
enterprise/SKILL.md ← Enterprise account health reports
daily/SKILL.md ← Daily metrics with anomaly detection
```

## How It Works
Expand Down Expand Up @@ -199,10 +200,58 @@ Monitors key metrics and sends alerts across 5 specialized sub-agents:

See `agents/monitoring/SKILL.md` for routing and individual sub-agent workflows.

### Weekly Reports

**Status:** NEW | **Trigger:** "Generate weekly report", "Weekly summary", "Week-over-week analysis"

Generates comprehensive weekly reports on product usage, revenue, and key metrics with week-over-week comparisons.

**What it generates:**
- **Usage metrics**: DAU, WAU, generation volumes, downloads
- **Revenue metrics**: MRR, new subscriptions, churn, ARPU
- **Engagement metrics**: Retention, session length, feature adoption
- **Week-over-week comparison**: % change vs prior week
- **User segmentation**: Breakdown by tier

See `agents/reports/weekly/SKILL.md` for full workflow.

### Enterprise Reports

**Status:** NEW | **Trigger:** "Generate enterprise account report", "Customer health report", "QBR preparation"

Generates account-level reports for enterprise customers with usage, quota consumption, and health scores.

**What it generates:**
- **Account overview**: Org details, contract info
- **Usage metrics**: DAU/WAU/MAU per account, active seats
- **Quota consumption**: Token usage vs allocation
- **Health score**: Account health indicators
- **Trend analysis**: Month-over-month or quarter-over-quarter

See `agents/reports/enterprise/SKILL.md` for full workflow.

### Daily Reports

**Status:** NEW | **Trigger:** "Generate daily report", "Daily metrics summary", "Yesterday's performance"

Generates automated daily reports on key metrics with anomaly detection and quick health checks.

**What it generates:**
- **Core metrics**: DAU, generation volumes, downloads, signups
- **Day-over-day comparison**: % change vs prior day and 7-day average
- **Anomaly alerts**: Metrics that deviate >2 std devs from baseline
- **Quick wins**: Notable improvements or milestones
- **Red flags**: Concerning drops or issues

See `agents/reports/daily/SKILL.md` for full workflow.

---

| Agent | Status | What it does |
|-------|--------|-------------|
| Dashboard Builder | WIP | Creates feature dashboards in Hex Threads with automated data quality validation |
| Linear Issue Manager | Ready | Creates and manages Linear issues for analytics work across PA teams |
| Monitoring Agent | NEW | Monitors revenue, usage, enterprise accounts, backend costs, and API performance with specialized sub-agents |
| Weekly Reports | NEW | Generates comprehensive weekly reports with WoW comparisons and segmentation |
| Enterprise Reports | NEW | Generates account-level reports for enterprise customers with health scores |
| Daily Reports | NEW | Generates automated daily reports with anomaly detection and alerts |
228 changes: 228 additions & 0 deletions agents/reports/daily/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
---
name: daily-reports
description: Generate automated daily reports on key metrics. Includes day-over-day comparisons, anomaly detection, and quick health checks.
tags: [reports, daily, monitoring, alerts]
---

# Daily Reports

## When to use

- "Generate daily report"
- "Daily metrics summary"
- "Yesterday's performance"
- "Daily health check"
- "Morning metrics report"

## What it generates

- **Core metrics**: DAU, generation volumes (image/video), downloads, new signups
- **Day-over-day comparison**: % change vs prior day and 7-day average
- **Anomaly alerts**: Metrics that deviate >2 std devs from baseline
- **Quick wins**: Notable improvements or milestones
- **Red flags**: Concerning drops or issues
- **Segment breakdown**: Key metrics by tier (if significant variance)

## Steps

### 1. Gather Requirements

Ask the user:
- **Report date**: Yesterday (default) or specific date?
- **Audience**: Product team, engineering, leadership?
- **Delivery**: Automated daily post or on-demand?
- **Threshold**: What % change should trigger "red flag"? (Default: >15% drop)
- **Format**: Slack, email, or dashboard?

### 2. Read Shared Knowledge

Before generating report:
- **`shared/bq-schema.md`** β€” ltxstudio_user_all_actions table
- **`shared/metric-standards.md`** β€” DAU calculation, generation metrics

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add more shared knowledge

### 3. Define Report Period

Calculate date ranges:
- **Report date**: Yesterday (`DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)`)
- **Comparison date**: Day before yesterday
- **Baseline**: 7-day average (days -8 to -2)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's increase this to 14 or 30


### 4. Generate SQL for Each Section

**Core Metrics (Yesterday):**
```sql
SELECT
COUNT(DISTINCT lt_id) AS dau,
COUNT(CASE WHEN action_name = 'generate_image' THEN 1 END) AS image_generations,
COUNT(CASE WHEN action_name = 'generate_video' AND action_category = 'generations' THEN 1 END) AS video_generations,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action_name_detailed?

COUNT(CASE WHEN action_name = 'download_image' THEN 1 END) AS image_downloads,
COUNT(CASE WHEN action_name = 'download_video' THEN 1 END) AS video_downloads
FROM `ltx-dwh-prod-processed.web.ltxstudio_user_all_actions`
WHERE date(action_ts) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
```

**Day-over-Day Comparison:**
```sql
WITH yesterday AS (
SELECT
COUNT(DISTINCT lt_id) AS dau,
COUNT(CASE WHEN action_name = 'generate_image' THEN 1 END) AS image_gens
FROM `ltx-dwh-prod-processed.web.ltxstudio_user_all_actions`
WHERE date(action_ts) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
),
prior_day AS (
SELECT
COUNT(DISTINCT lt_id) AS dau,
COUNT(CASE WHEN action_name = 'generate_image' THEN 1 END) AS image_gens
FROM `ltx-dwh-prod-processed.web.ltxstudio_user_all_actions`
WHERE date(action_ts) = DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY)
)
SELECT
y.dau AS yesterday_dau,
p.dau AS prior_day_dau,
ROUND(SAFE_DIVIDE(y.dau - p.dau, p.dau) * 100, 1) AS dau_dod_change_pct
FROM yesterday y, prior_day p
```

**Anomaly Detection:**
```sql
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd increase it to 14 or 30 days

WITH daily AS (
SELECT
date(action_ts) AS dt,
COUNT(DISTINCT lt_id) AS dau
FROM `ltx-dwh-prod-processed.web.ltxstudio_user_all_actions`
WHERE date(action_ts) >= DATE_SUB(CURRENT_DATE(), INTERVAL 9 DAY)
AND date(action_ts) < CURRENT_DATE()
GROUP BY dt
),
baseline AS (
SELECT
AVG(dau) AS avg_dau_7d,
STDDEV(dau) AS std_dau_7d
FROM daily
WHERE dt BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 8 DAY)
AND DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY)
)
SELECT
d.dau AS yesterday_dau,
b.avg_dau_7d,
ROUND(SAFE_DIVIDE(d.dau - b.avg_dau_7d, NULLIF(b.std_dau_7d, 0)), 1) AS z_score,
CASE WHEN ABS(SAFE_DIVIDE(d.dau - b.avg_dau_7d, NULLIF(b.std_dau_7d, 0))) > 2
THEN 'ANOMALY' ELSE 'NORMAL' END AS status
FROM daily d, baseline b
WHERE d.dt = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
```

### 5. Analyze Results

**Identify key insights:**
- **Green flags**: Metrics up >10% vs prior day or 7-day avg
- **Red flags**: Metrics down >15% vs prior day or 7-day avg
- **Anomalies**: Z-score > 2 (statistical outlier)
- **Stability**: Metrics within Β±10% (business as usual)

**Check segmentation if red flag:**
- If DAU drops >15%, break down by tier to find which segment dropped
- If generations drop, check if it's image, video, or both
- If specific tier drops, investigate potential cause (billing issue, product bug, competition)

### 6. Format Report

**Structure:**
```
# Daily Report: [Day of Week], [MM/DD/YYYY]

## πŸ“Š Core Metrics
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do it per segment, and maybe we should add registered and churned?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and token consumption

| Metric | Yesterday | Prior Day | Change | vs 7d Avg |
|--------|-----------|-----------|--------|-----------|
| DAU | X | Y | Β±Z% | Β±A% |
| Image Gens | X | Y | Β±Z% | Β±A% |
| Video Gens | X | Y | Β±Z% | Β±A% |
| Downloads | X | Y | Β±Z% | Β±A% |

## 🚨 Alerts
[If no alerts: βœ… No anomalies detected β€” all metrics within normal range]

[If alerts:]
- πŸ”΄ **DAU dropped 25%** vs prior day (Z-score: -3.2) β€” investigate immediately
- 🟑 **Video generations down 12%** vs 7d avg β€” monitor trend

## πŸ’š Quick Wins
- Image generations up 15% (new high for the week!)
- Enterprise DAU up 8% (strong enterprise engagement)

## πŸ“ˆ Trends to Watch
- DAU has been declining for 3 consecutive days (-5%, -8%, -15%)
- Video generation adoption improving (+18% week-to-date)

## 🎯 Action Items
- [If red flag: "Investigate DAU drop β€” check logs for errors or outages"]
- [If trend: "Schedule product review meeting to discuss declining DAU"]
- [If stable: "No action needed β€” metrics healthy"]
```

**Slack format (concise):**
```
πŸ“Š *Daily Report: [MM/DD]*

*Core Metrics:*
β€’ DAU: X (↓15% vs prior day) πŸ”΄
β€’ Image Gens: X (↑5% vs 7d avg) βœ…
β€’ Video Gens: X (stable) βœ…

*Alerts:*
πŸ”΄ DAU anomaly detected (Z-score: -3.2)

*Action:* Investigate DAU drop immediately
```

### 7. Deliver Report

- **Slack**: Post to #product-daily or #data-alerts at 8am daily
- **Email**: Send to distribution list for daily digest
- **Dashboard**: Update live dashboard (Hex, Looker) with latest data
- **On-call**: Trigger PagerDuty/Slack alert for critical red flags (>20% drop)

## Reference Files

| File | Read when |
|------|-----------|
| `shared/bq-schema.md` | ltxstudio_user_all_actions table schema |
| `shared/metric-standards.md` | DAU calculation, generation metrics |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had it earlier in the doc


## Rules

### Query Best Practices

- **DO** use yesterday's complete data (never include today)
- **DO** filter on `date(action_ts)` partition column for performance
- **DO** calculate Z-score using 7-day baseline (excludes yesterday)
- **DO** use NULLIF when dividing by potentially-zero denominators
- **DO** round percentages to 1 decimal place

### Report Content

- **DO** lead with summary table of core metrics
- **DO** highlight anomalies prominently (πŸ”΄/🟑/βœ… indicators)
- **DO** include both day-over-day AND vs 7-day avg comparisons
- **DO** provide quick wins to balance red flags
- **DO** include actionable recommendations
- **DO NOT** overload with detail β€” keep it scannable
- **DO NOT** report metrics that are always stable (noise)

### Alerting

- **DO** set clear thresholds for red flags (>15% drop)
- **DO** escalate critical anomalies (Z-score > 2.5 or drop >25%)
- **DO** include context for anomalies (holiday, product launch, known issue)
- **DO** distinguish between concerning drops vs expected variance
- **DO NOT** alert on weekends (lower usage is normal)
- **DO NOT** cry wolf β€” only alert on actionable issues

### Automation

- **DO** schedule daily report generation for 8am (after yesterday is complete)
- **DO** use BigQuery scheduled queries for consistency
- **DO** cache baseline calculations (7-day avg, stddev) for performance
- **DO** implement fail-safes (if query fails, send notification)
- **DO** version control report SQL (track changes over time)
Loading