gameplay-analytics
Covers player event tracking, session tracking, cohort retention (D1, D7, D30), ordered funnels and retention targets for a game backend on PostgreSQL with a…
от fcsouza★ 29 звёзд на GitHub
Установить gameplay-analytics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Gameplay Analytics
Events go from the game server into a Redis list, a single worker drains the list into PostgreSQL in batches, and retention and funnels run as SQL over the stored tables.
Rules
- Name events
noun_verb, snake_case, past tense for finished actions:level_completed,item_purchased,match_ended. Keep a finite catalog intemplates/event-catalog.md; an event not in the catalog does not ship. - Every event carries
userId,sessionId,createdAt,version,platform. The client fills them. It drops events tracked before a session starts instead of filing them under a fake session id. - Never block gameplay on analytics.
track()returns at once and never throws. A Redis outage loses events, not frames. - Buffer in Redis, insert in batches.
track()does LPUSH. One worker per Redis key runsflush(), which reads the oldest batch from the list tail, inserts it, then trims it. The insert skips ids that already exist, so a crash between insert and trim replays safely. Two flushers on one key insert the same batch twice and trim twice, losing events. - Track sessions explicitly: start, heartbeat, end. Do not infer sessions from gaps between events. Players crash and lose network without sending
end, so runcloseIdleSessions(db, idleMs)on a schedule withidleMsset to a few heartbeat intervals. - Retention is cohort-based. A cohort is the UTC day of a player's first session. D is the share of a cohort with a session on exactly cohort day + N. Report a cohort only after its day N has ended. "Players active yesterday" is DAU, not retention.
- Funnels are ordered. A player counts at step K only after doing step K-1. Choose the key on purpose:
session_idfor flows that must finish in one sitting (tutorial, first match),user_idfor flows across sessions (install to first purchase). The query is intemplates/retention-dashboard.md. - Store UTC, compute days in UTC. Use
(now() AT TIME ZONE 'UTC')::datefor today.CURRENT_DATEfollows the connection's time zone. - Keep analytics tables apart from gameplay tables. They are append-only, large and read by different queries.
- Tag experiments on the event, do not fork code paths for analytics. Put
experimentIdandvariantinpropertiesand group by them in SQL.
Setup
Install the packages (versions this skill was checked against:
drizzle-orm0.45.4,ioredis6.0.0). Install your Postgres driver aspostgres-game-schemadescribes.bun add drizzle-orm ioredis bun add -d drizzle-kitCopy
boilerplate/analytics-schema.tsinto your schema directory, then generate and run the migration withbunx drizzle-kit generateandbunx drizzle-kit migrate.Create one client per connected player. The caller owns both connections:
import { AnalyticsClient, type AnalyticsDb } from './analytics-client'; import type Redis from 'ioredis'; export const analyticsFor = (redis: Redis, db: AnalyticsDb, player: { id: string; platform: string }) => new AnalyticsClient({ redis, db, userId: player.id, platform: player.platform, version: process.env.GAME_VERSION ?? 'dev' });Instrument the game server. Do not await these calls:
analytics.trackSession('start'); // on connect analytics.track('level_completed', { levelId: 'level_12', score: 4500, deaths: 3 }); analytics.track('tutorial_step_completed', { step: 3, experimentId: 'onboarding_v2', variant: 'shortened' }); analytics.trackSession('heartbeat'); // on a fixed interval while connected analytics.trackSession('end'); // on disconnectIn one worker process, on a schedule: call
flush()on oneAnalyticsClientbuilt for that worker (await workerClient.flush(); it drains until the list is empty and skips, with a log line, any buffered row that is not a valid event) andawait closeIdleSessions(db, idleMs). Nightly, store cohorts withstoreRetentionCohorts(db, n)for n in 1, 7, 30, fromtemplates/retention-dashboard.md.
Retention targets
This skill gives no D1, D7 or D30 target numbers. A benchmark only compares if its source states the same definition of "day N" as rule 6, the same platform and the same genre. Set targets from your own baseline:
- Ship with the cohort job running. Wait until at least four weekly sets of cohorts have matured past day 30.
- For each of D1, D7 and D30, take the median
retention_pctacross those mature cohorts fromanalytics_retention_cohorts. That is the baseline. - Split the baseline by
platformand by acquisition source before comparing; a new channel changes the mix, not the game. - Set a target as a change over the baseline that one release is meant to cause, and judge it only on cohorts that started after the release.
- Alert when a mature cohort falls well below the baseline, not when a young
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- boilerplate/analytics-client.ts
- boilerplate/analytics-schema.ts
- references/sources.md
- templates/event-catalog.md
- templates/retention-dashboard.md
FAQ
Что делает скилл gameplay-analytics?
Covers player event tracking, session tracking, cohort retention (D1, D7, D30), ordered funnels and retention targets for a game backend on PostgreSQL with a Redis buffer. Use when instrumenting what players do in a game, measuring whether players come back, finding where new players drop out of the tutorial or first match, or setting retention targets.
Как установить скилл gameplay-analytics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gameplay-analytics запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…