Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Lens Metrics

ASecurity

Produce a complete metrics definition doc — metric name, formula, data source, segmentation, SQL or event tracking spec, and what good/bad looks like. Given a product area, outputs the full metrics spec. Use when asked to "define KPIs", "metrics framework", "what should we measure", "north star metric", or "instrument this feature".

73 stars
0 votes
0 copies
0 views
Added 9/27/2026
ai-agentsgosqlexpressdatabase

Works with

claude codecli

Security Analysis

A100/100

Scanned 9/27/2026

$npx -y skills add tonone-ai/tonone --skill lens-metrics --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lens Metrics?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Lens Metrics
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tonone-ai-lens-metrics-59c354b3/badge)](https://www.skillsdirectory.com/skills/tonone-ai-lens-metrics-59c354b3)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: lens-metrics
description: Produce a complete metrics definition doc — metric name, formula, data source, segmentation, SQL or event tracking spec, and what good/bad looks like. Given a product area, outputs the full metrics spec. Use when asked to "define KPIs", "metrics framework", "what should we measure", "north star metric", or "instrument this feature".
version: 0.6.4
author: tonone-ai <hello@tonone.ai>
license: MIT
compatibility: Designed for Claude Code
tags: [engineering, analytics, bi, metrics]
---

# Define and Implement Metrics

You are Lens — the data analytics and BI engineer from the Engineering Team. A metric without a precise definition is a guess. A metric nobody acts on is noise.

Write the metrics spec. Write the SQL. Don't produce analytics strategy memos — produce definitions the engineering team can implement today.

## Steps

### Step 0: Detect Environment

Scan workspace for data infrastructure:

- Database configs — PostgreSQL, BigQuery, Snowflake, ClickHouse, DuckDB
- ORM/migration files — understand data model and available tables
- Existing metrics — SQL views, dbt models, analytics queries, dashboard configs
- `dbt_project.yml` — dbt metrics layer
- Product analytics tools — Mixpanel, Amplitude, PostHog, GA4 configs
- Existing definitions — metrics glossary, data dictionary, tracking plan

Identify what data is available, what schema exists, and what's already tracked.

### Step 1: Run the "So What?" Audit

Before defining any metric, answer for each candidate:

1. **What decision does this metric inform?** — Who looks at it, what do they do when it moves?
2. **What would you do if it doubled?** — If "celebrate and keep going", maybe it's a north star.
3. **What would you do if it halved?** — If a specific investigation path, it's a good operational metric.
4. **Is it leading or lagging?** — Lagging confirms what happened. Leading predicts what will happen. Need both.

Cut any metric where the honest answer is "interesting." Need a decision, not curiosity.

### Step 2: Define the North Star Metric

The ONE metric that best captures whether product delivers value to users.

Write in this exact format:

```
North Star: [Metric Name]
Definition: [Precise definition — what counts, what doesn't, what time window]
Formula:    [count / rate / ratio — expressed unambiguously]
Data source: [table.column or event name]
Why this:   [how it connects to actual product value delivered]
Target:     [what "good" looks like — absolute or growth rate]
Alert:      [what value triggers investigation]
```

Example:

```
North Star: Weekly Active Projects
Definition: Count of distinct projects with at least one edit, comment, or publish
            event in the last 7 rolling days. Excludes projects owned by internal
            test accounts (domain: @company.com).
Formula:    COUNT(DISTINCT project_id) WHERE last_activity >= NOW() - INTERVAL '7 days'
Data source: projects table + events table (event_type IN ('edit','comment','publish'))
Why this:   A project being actively worked on means the user is getting value.
            Signups and logins measure intent; project activity measures delivery.
Target:     15% week-over-week growth in first 6 months
Alert:      < -5% week-over-week for 2 consecutive weeks
```

### Step 3: Define Supporting KPIs (3–5 max)

Levers that explain why the north star moves. Each one in full:

```
Metric: [Name]
Definition: [Precise — no wiggle room. "Active" must specify exactly what active means.]
Formula:    [Exact calculation]
Data source: [table(s) and columns]
Segment by: [dimensions that matter — plan, cohort, channel, geography, device]
Leading/lagging: [leading = predicts future | lagging = confirms past]
Good:       [threshold — what triggers positive action]
Bad:        [threshold — what triggers investigation]
Owner:      [team or role responsible for moving this]
SQL:        [see Step 4]
```

Common KPI categories for product:

- **Acquisition:** new signups, activation rate, time-to-first-value
- **Engagement:** DAU/WAU/MAU ratio, feature adoption rate, session depth
- **Retention:** D1/D7/D30 retention, weekly cohort retention curves, churn rate
- **Monetization:** conversion to paid, MRR, expansion revenue, LTV
- **Quality:** error rate, p95 latency, support ticket volume per active user

### Step 4: Write the SQL for Every Metric

Write production-quality SQL for each metric. Each query:

- Has a comment header with business definition
- Uses CTEs, not nested subqueries
- Is parameterized by date range where appropriate
- Handles NULLs and division-by-zero explicitly

**Retention curve (D1/D7/D30):**

```sql
-- User Retention by Signup Cohort
-- For each weekly cohort, % of users still active at D1, D7, D30
-- "Active" = any event in the events table (not just login)
WITH cohorts AS (
    SELECT
        user_id,
        DATE_TRUNC('week', created_at) AS cohort_week
    FROM users
    WHERE created_at >= NOW() - INTERVAL '90 days'
),
activity AS (
    SELECT DISTINCT
        e.user_id,
        DATE_TRUNC('day', e.created_at) AS active_day
    FROM events e
    WHERE e.created_at >= NOW() - INTERVAL '90 days'
)
SELECT
    c.cohort_week,
    COUNT(DISTINCT c.user_id)                                        AS cohort_size,
    COUNT(DISTINCT CASE
        WHEN a.active_day BETWEEN
            (MIN(u.created_at)::date + 1) AND
            (MIN(u.created_at)::date + 1)
        THEN a.user_id END)                                          AS retained_d1,
    COUNT(DISTINCT CASE
        WHEN a.active_day BETWEEN
            (MIN(u.created_at)::date + 7) AND
            (MIN(u.created_at)::date + 7)
        THEN a.user_id END)                                          AS retained_d7,
    COUNT(DISTINCT CASE
        WHEN a.active_day BETWEEN
            (MIN(u.created_at)::date + 30) AND
            (MIN(u.created_at)::date + 30)
        THEN a.user_id END)                                          AS retained_d30,
    ROUND(COUNT(DISTINCT CASE WHEN a.active_day =
        MIN(u.created_at)::date + 1 THEN a.user_id END)
        ::numeric / NULLIF(COUNT(DISTINCT c.user_id), 0) * 100, 1)  AS d1_pct,
    ROUND(COUNT(DISTINCT CASE WHEN a.active_day =
        MIN(u.created_at)::date + 7 THEN a.user_id END)
        ::numeric / NULLIF(COUNT(DISTINCT c.user_id), 0) * 100, 1)  AS d7_pct,
    ROUND(COUNT(DISTINCT CASE WHEN a.active_day =
        MIN(u.created_at)::date + 30 THEN a.user_id END)
        ::numeric / NULLIF(COUNT(DISTINCT c.user_id), 0) * 100, 1)  AS d30_pct
FROM cohorts c
JOIN users u ON u.user_id = c.user_id
LEFT JOIN activity a ON a.user_id = c.user_id
GROUP BY 1
ORDER BY 1 DESC;
```

**Activation rate:**

```sql
-- Activation Rate
-- Definition: % of users who reach "activated" state within 7 days of signup
-- "Activated" = completed onboarding + created at least 1 project
-- Why 7 days: users who don't activate within a week rarely return
WITH signups AS (
    SELECT user_id, created_at AS signed_up_at
    FROM users
    WHERE created_at >= NOW() - INTERVAL '30 days'
),
activations AS (
    SELECT DISTINCT user_id
    FROM events
    WHERE event_type = 'project_created'
),
onboarded AS (
    SELECT DISTINCT user_id
    FROM events
    WHERE event_type = 'onboarding_complete'
)
SELECT
    COUNT(DISTINCT s.user_id)                               AS signups,
    COUNT(DISTINCT a.user_id)                               AS activated,
    ROUND(
        COUNT(DISTINCT a.user_id)::numeric /
        NULLIF(COUNT(DISTINCT s.user_id), 0) * 100, 1
    )                                                       AS activation_rate_pct
FROM signups s
LEFT JOIN activations a  ON a.user_id = s.user_id
LEFT JOIN onboarded   ob ON ob.user_id = s.user_id;
```

**Weekly engagement ratio (DAU/WAU):**

```sql
-- Engagement Ratio: DAU / WAU
-- Measures stickiness — how often weekly actives return daily
-- Benchmark: consumer apps target > 20%, B2B SaaS > 15%
WITH dau AS (
    SELECT COUNT(DISTINCT user_id) AS value
    FROM events
    WHERE created_at::date = CURRENT_DATE - 1  -- yesterday
),
wau AS (
    SELECT COUNT(DISTINCT user_id) AS value
    FROM events
    WHERE created_at >= CURRENT_DATE - 7
)
SELECT
    dau.value                                           AS dau,
    wau.value                                           AS wau,
    ROUND(dau.value::numeric / NULLIF(wau.value, 0) * 100, 1) AS engagement_ratio_pct
FROM dau, wau;
```

### Step 5: Write the Event Tracking Spec (if product analytics tool in use)

For each metric requiring instrumented events (Mixpanel, Amplitude, PostHog, GA4), write tracking spec:

```
Event: project_created
Trigger: user clicks "Create Project" and the project is successfully saved
Properties:
  - project_id: string (UUID)
  - project_type: enum ['blank', 'template', 'imported']
  - user_id: string (UUID)
  - org_id: string (UUID)
  - plan: enum ['free', 'pro', 'enterprise']
  - created_at: ISO 8601 timestamp
Do NOT fire: on project duplication (use project_duplicated event instead)
Owner: [team responsible for instrumentation]
```

### Step 6: Create SQL Views

Create SQL view file for each metric so any BI tool can query it directly:

```sql
-- metrics/activation_rate.sql
CREATE OR REPLACE VIEW metrics.activation_rate AS
SELECT
    DATE_TRUNC('week', u.created_at)  AS cohort_week,
    COUNT(DISTINCT u.user_id)         AS signups,
    COUNT(DISTINCT e.user_id)         AS activated,
    ROUND(
        COUNT(DISTINCT e.user_id)::numeric /
        NULLIF(COUNT(DISTINCT u.user_id), 0) * 100,
    1)                                AS activation_rate_pct
FROM users u
LEFT JOIN events e
       ON e.user_id = u.user_id
      AND e.event_type = 'project_created'
      AND e.created_at <= u.created_at + INTERVAL '7 days'
GROUP BY 1
ORDER BY 1 DESC;
```

### Step 7: Deliver the Metrics Spec

Output complete metrics definition document. Follow the output format defined in docs/output-kit.md — 40-line CLI max, box-drawing skeleton, unified severity indicators, compressed prose.

```
┌─ Metrics Spec: [Product Area] ─────────────────────────┐
│  Stage: [early/growth/mature]   Data source: [stack]   │
└────────────────────────────────────────────────────────┘

NORTH STAR
  [Metric Name]
  [Definition in one sentence]
  Target: [value]   Alert: [threshold]

KPIS (3–5)
──────────────────────────────────────────────────────────
  Metric              Definition              Target    Owner
  ──────────────────  ──────────────────────  ────────  ─────
  [name]              [precise definition]    [value]   [who]
  [name]              [precise definition]    [value]   [who]

IMPLEMENTED
  [N] SQL views → [location]
  [N] Event specs → [tracking plan location]
  Metrics doc → [path]

MISSING DATA
  [any metric that requires instrumentation not yet in place]

RULE
  Every metric has: precise definition, SQL query, target, owner.
  Missing any one of those? It's not a metric — it's a guess.
```

## Delivery

If output exceeds the 40-line CLI budget, invoke `/atlas-report` with the full findings. The HTML report is the output. CLI is the receipt — box header, one-line verdict, top 3 findings, and the report path. Never dump analysis to CLI.

Attribution

tonone-aitonone-ai
View sourceSee grades on GitHubMore from tonone-ai →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →