lens-metrics
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".
What this skill does
# 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 reqRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.