analytics-with-claude-code: Skill for Claude Code

.claude/skills/metric-calculator/SKILL.md

metric-calculator is a skill for Claude Code from adityawrk/analytics-with-claude-code. It costs 72 tokens per session (4,238 once invoked), scanned A, original, MIT.

A business-metrics skill that defines and calculates measures such as retention, customer lifetime value, acquisition cost, churn, conversion, growth, recurring revenue, and active users. It provides SQL templates and Python implementations with assumptions and edge cases.

In plain words
What is it for?
Use it to define a KPI, calculate a retention curve, analyze a conversion funnel, or measure growth, recurring revenue, churn, or user activity. It can provide implementations for PostgreSQL, BigQuery, Snowflake, and Python.
Why use it?
It reduces ambiguity around metric definitions and helps avoid misleading results caused by unclear time periods, missing values, division by zero, or time zones. It also includes checks for whether results are sensible.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

This is adityawrk/analytics-with-claude-code's own configuration. It tells Claude Code how to work on analytics-with-claude-code itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything analytics-with-claude-code configures →

Reuse

Borrowing it

Nothing to install: this file belongs to adityawrk/analytics-with-claude-code. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/adityawrk/analytics-with-claude-code/main/.claude/skills/metric-calculator/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/adityawrk/analytics-with-claude-code

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for metric-calculator

README.md
[![agentmods](https://agentmods.dev/badge/skills/adityawrk/analytics-with-claude-code/metric-calculator/github.svg)](https://agentmods.dev/skills/adityawrk/analytics-with-claude-code/metric-calculator)
Your own site
<a href="https://agentmods.dev/skills/adityawrk/analytics-with-claude-code/metric-calculator"><img src="https://agentmods.dev/badge/skills/adityawrk/analytics-with-claude-code/metric-calculator/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for metric-calculator

Your own site · 80×15
<a href="https://agentmods.dev/skills/adityawrk/analytics-with-claude-code/metric-calculator"><img src="https://agentmods.dev/badge/skills/adityawrk/analytics-with-claude-code/metric-calculator.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 72 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,238 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00072 $0.04238
Opus 5 $0.00036 $0.02119
Sonnet 5 $0.00014 $0.00848
Haiku 4.5 $0.00007 $0.00424

Measured 10d ago against content hash 3bb22afc602e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

metric-calculator scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/metric-calculator/SKILL.md · 464 lines

How it starts

The opening of the file, as written. The whole thing — 464 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Business Metric Calculator

You are a senior analytics engineer. When asked to calculate business metrics, you will provide precise definitions, SQL queries, and Python implementations. Always clarify assumptions and edge cases.

General Principles

  1. Always state the metric definition before writing any code. Ambiguous definitions cause more damage than buggy code.
  2. Always specify the time window (daily, weekly, monthly, trailing 28-day, etc.).
  3. Always handle edge cases: division by zero, null values, partial periods, timezone considerations.
  4. Always validate the output with sanity checks (e.g., retention rates should be between 0% and 100%, churn + retention should approximate 100%).
  5. Provide both SQL and Python unless the user specifies a preference. SQL templates should work with minimal modification on PostgreSQL, BigQuery, and Snowflake. Note dialect differences where relevant.

Metric 1: Cohort-Based Retention

Definition

Retention rate for cohort C at period N = (users from cohort C active in period N) / (total users in cohort C) * 100

A "cohort" is defined by the user's first action date (signup, first purchase, etc.), grouped by week or month.

SQL Template

-- Cohort retention analysis
-- Adjust: cohort_period (WEEK/MONTH), activity table, user identifier
WITH cohorts AS (
    SELECT
        user_id,
        DATE_TRUNC('MONTH', MIN(event_date)) AS cohort_month
    FROM events
    WHERE event_type = 'signup'  -- or first purchase, first login, etc.
    GROUP BY user_id
),
activity AS (
    SELECT DISTINCT
        user_id,
        DATE_TRUNC('MONTH', event_date) AS activity_month
    FROM events
    WHERE event_type IN ('login', 'purchase', 'pageview')  -- define "active"
),
retention AS (
    SELECT
        c.cohort_month,
        a.activity_month,
        DATE_DIFF(a.activity_month, c.cohort_month, MONTH) AS period_number,  -- BigQuery syntax
        -- For PostgreSQL: EXTRACT(YEAR FROM age(a.activity_month, c.cohort_month)) * 12
        --                + EXTRACT(MONTH FROM age(a.activity_month, c.cohort_month))
        COUNT(DISTINCT a.user_id) AS active_users
    FROM cohorts c
        INNER JOIN activity a ON c.user_id = a.user_id
    GROUP BY c.cohort_month, a.activity_month
),
cohort_sizes AS (
    SELECT
        cohort_month,
        COUNT(DISTINCT user_id) AS cohort_size
    FROM cohorts
    GROUP BY cohort_month
)
SELECT
    r.cohort_month,
    cs.cohort_size,
    r.period_number,
    r.active_users,
    ROUND(r.active_users * 100.0 / cs.cohort_size, 2) AS retention_rate
FROM retention r
    INNER JOIN cohort_sizes cs ON r.cohort_month = cs.cohort_month
WHERE r.period_number >= 0
ORDER BY r.cohort_month, r.period_number;

Read the full file on GitHub · 464 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 464 lines · 72 tokens per session scan A 3bb22afc602e

Subscribe to this mod's changes

metric-calculator is a skill published in the GitHub repository adityawrk/analytics-with-claude-code (5 stars, last pushed 6mo ago), licensed MIT. It adds 72 tokens to every session and 4,238 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

pr-verify

Verify a Docglow change actually works before submitting or merging a PR. Runs the conformance suite, then a behavioral verification pass (flag matrix, artifact-join spot checks, pipeline contract sweep, payload budget). Use when reviewing a PR, self-reviewing a branch before opening a PR, or when asked to "verify…

docglow/docglow · 79 tokens

dbt-expert

Expert-level dbt (data build tool), models, tests, documentation, incremental models, macros, and Jinja templating. Use when the user mentions analytics engineering, SQL, data transformation, Jinja, or testing, or when the task involves Project Structure and Configuration, Sources and Staging Models, Intermediate and…

personamanagmentlayer/pcl · 76 tokens

developing-incremental-models

Develops and troubleshoots dbt incremental models. Use when working with incremental materialization for: (1) Creating new incremental models (choosing strategy, uniquekey, partition) (2) Task mentions "incremental", "append", "merge", "upsert", or "late arriving data" (3) Troubleshooting incremental failures (merge…

AltimateAI/data-engineering-skills · 112 tokens

altimate-code

Delegates dbt and warehouse work to altimate-code, a specialized CLI agent with 100+ purpose-built data tools. USE THIS SKILL FIRST whenever the task mentions or implies: warehouse access (Snowflake, BigQuery, Redshift, Databricks, Postgres, MySQL, DuckDB), column-level lineage, downstream-impact analysis, dbt builds…

AltimateAI/data-engineering-skills · 0 tokens

debugging-dbt-errors

Debugs and fixes dbt errors systematically. Use when working with dbt errors for: (1) Task mentions "fix", "error", "broken", "failing", "debug", "wrong", or "not working" (2) Compilation Error, Database Error, or test failures occur (3) Model produces incorrect output or unexpected results (4) Need to troubleshoot…

AltimateAI/data-engineering-skills · 112 tokens

documenting-dbt-models

Documents dbt models and columns in schema.yml. Use when working with dbt documentation for: (1) Adding model descriptions or column definitions to schema.yml (2) Task mentions "document", "describe", "description", "dbt docs", or "schema.yml" (3) Explaining business context, grain, meaning of data, or business rules…

AltimateAI/data-engineering-skills · 105 tokens