eobrien60/forge/obh-retrofit-analytics
Claude Code and agent skill by eobrien60/forge
- community
Checking that the SKILL.md file is still in the repository.
Use to assess or replace hand-rolled KPI/metric code with @obh/analytics. Finds live count(*)/group-by aggregation endpoints, rollup cron and tables, and third-party tracking (Mixpanel/Amplitude/GA) calls, then maps each KPI to an event-derived metric timeseries. Assessment-only by default; implements on request.
Install
npx vskill@latest install eobrien60/forge/obh-retrofit-analyticsSKILL.md
The same SKILL.md was published earlier as eobrien60/forge/obh-retrofit-analytics.
Purpose: derive KPIs from domain events instead of aggregating product tables on the fly. Each metric is defined once (event + aggregation); the worker rolls facts into time buckets; the API serves a queryable timeseries. Requires an event catalogue (see obh-add-events) — metrics are computed from event facts, not the product tables.
Assessment (read-only)
- Find the metric code. Grep for: live aggregation in request handlers (
count(*),sum(...),group by date_trunc(...)); rollup/summary tables and the cron that fills them; dashboard/KPI endpoints; and third-party tracking (mixpanel,amplitude,analytics.track,gtag).
- Inventory each KPI. For each: what it measures, the aggregation (count / sum-of-a-field / …), the bucket granularity (day/week/…), and which state change it counts. Flag expensive live aggregations and drift-prone rollup tables as the risks this move fixes.
- Map each KPI to a `defineMetric`. Give each a key and bind it to the event(s) it derives from:
defineMetric({ key: "notes_created", events: "note.created", aggregation: "count" })(or a sum over a payload field). If the counted state change has no event, record that obh-add-events must run first.
- Map query to the target grammar. The KPI endpoint becomes
analytics.timeseries({ workspaceId, metric, bucket })overcreateAnalyticsClient({ db, metrics }). Note that analytics rolls up events from now on, so historical KPIs need an event backfill/replay.
Produces the analytics retrofit plan. Nothing above mutates the repo — a valid stopping point when you only need the survey.
Implementation (only after the plan is agreed)
- Install.
forge add analytics(--dry-runfirst; auto-addsevents). Adds the migration, the client +GET /api/analytics/:metricroute inapps/api, and the worker side (analytics-metrics.ts,dispatch.d/analytics.tswithevents: ["*"],consumers.d/analytics.tsrolling facts into buckets each tick). Runpnpm migrate.
- Author the metrics. Replace the example
defineMetricwith the KPIs from the plan, keeping the api and worker copies in sync (the worker never imports fromapps/api). Confirm the source events are emitted (obh-add-events).
- Backfill and cut over. For KPIs that need history, replay the source events so past buckets fill. Point dashboards at the timeseries endpoint, then retire the live-aggregation queries and rollup cron/tables once the timeseries covers them.
- Validate.
forge doctor.
Output
Assessment → the analytics retrofit plan: a table of KPI → metric key → source event(s) → aggregation → bucket → replacement (timeseries), the events that must exist first, and a historical-backfill note. Implementation → the installed client/route/worker with authored metrics, the backfilled buckets, and the retired live-aggregation/rollup code.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/obh-retrofit-analytics/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/eobrien60/forge/obh-retrofit-analytics)