.agentconf/skills/community-metrics/SKILL.md
Create new community metrics by adding enum values, recording functions, wiring, backfill migrations, and API integration. Use when adding new community metrics, creating metrics, or tracking community activity.
npx skillsauth add 6529-collections/6529seize-backend community-metricsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill guides you through the complete process of creating a new community metric in the 6529 SEIZE Backend.
Community metrics track various activities and statistics. Creating a new metric involves six steps:
MetricRollupHourMetricMetricsRecorderopenapi.yaml in /community-metrics endpointCommunityMetricsService.getCommunityMetricsSummaryBefore implementing, gather these details using AskUserQuestion:
DROPS_CREATED, WAVE_PARTICIPATIONS, RATINGS_GIVENrecordMetric(metric: MetricRollupHourMetric)recordMetric(metric: MetricRollupHourMetric, entityId: string)recordMetric(metric: MetricRollupHourMetric, amount: number)recordMetric(metric: MetricRollupHourMetric, identityId: string)drops.api.service.ts in createDrop()waves.api.service.ts in multiple methodsratings.api.service.ts in rating submission methodsgetCommunityMetricsSummary?Find MetricRollupHourMetric (likely in src/entities/ or src/enums/) and add the new metric:
export enum MetricRollupHourMetric {
// ... existing metrics
NEW_METRIC_NAME = 'NEW_METRIC_NAME'
}
In MetricsRecorder class (find with Glob or Grep), add a method to record the metric:
async recordNewMetricName(args: any): Promise<void> {
await this.recordMetric(
MetricRollupHourMetric.NEW_METRIC_NAME,
// additional arguments as needed
);
}
In the identified locations, call the recording function:
await this.metricsRecorder.recordNewMetricName(args);
Important: Ensure MetricsRecorder is available in the service. Check constructor for dependency injection.
Run the migration command:
npm run migrate:new backfill-metric-name-metric
This creates two files:
migrations/TIMESTAMP-backfill-metric-name-metric.up.sqlmigrations/TIMESTAMP-backfill-metric-name-metric.down.sqlIn the .up.sql file, write SQL to backfill historical data. Common pattern:
-- Insert historical metric data
INSERT INTO metric_rollup_hour (metric, hour, value, created_at)
SELECT
'NEW_METRIC_NAME' as metric,
DATE_FORMAT(created_at, '%Y-%m-%d %H:00:00') as hour,
COUNT(*) as value,
NOW() as created_at
FROM relevant_table
WHERE created_at IS NOT NULL
GROUP BY DATE_FORMAT(created_at, '%Y-%m-%d %H:00:00')
ON DUPLICATE KEY UPDATE
value = VALUES(value);
Delete the .down.sql file and update the .js migration file to do nothing in the down migration:
async down() {
// Do nothing - we don't rollback metric backfills
}
Find /community-metrics endpoint in openapi.yaml and add the new field to the response schema:
CommunityMetricsSummary:
type: object
properties:
# ... existing metrics
new_metric_name:
type: integer
description: Description of what this metric represents
After editing, regenerate types:
cd src/api-serverless && npm run restructure-openapi && npm run generate
Find CommunityMetricsService.getCommunityMetricsSummary and add the metric aggregation based on the chosen strategy:
For Sum Strategy:
const newMetricName = await this.db.execute<{total: number}>(
`SELECT COALESCE(SUM(value), 0) as total
FROM metric_rollup_hour
WHERE metric = :metric`,
{ metric: MetricRollupHourMetric.NEW_METRIC_NAME }
);
return {
// ... existing metrics
new_metric_name: newMetricName[0]?.total ?? 0
};
For Custom Strategy: Implement the specific SQL query needed for the aggregation logic.
After implementation, verify:
MetricRollupHourMetricMetricsRecordernpm run restructure-openapi && npm run generate)getCommunityMetricsSummarynpm test)npm run build)Use these search patterns to find relevant files:
MetricRollupHourMetric: Grep "enum MetricRollupHourMetric"MetricsRecorder: Glob "**/*MetricsRecorder*"CommunityMetricsService: Glob "**/CommunityMetricsService*"migrations/ directoryopenapi.yaml in project rootCOMMENTS_CREATED to MetricRollupHourMetricasync recordCommentCreated() { await this.recordMetric(MetricRollupHourMetric.COMMENTS_CREATED); }comments.api.service.ts after comment creationcomments table grouped by hourcomments_created: integer to responseCOMMENTS_CREATED valuesAskUserQuestion to gather the four required pieces of informationdevelopment
Create, improve, or review Codex/OpenAI Agent Skills and SKILL.md files. Use when writing a new skill, updating an existing skill, designing skill frontmatter and trigger behavior, choosing scripts/references/assets, validating skill structure, or turning repeatable Codex workflows into reusable skills.
development
Write, open, iterate, merge, and optionally deploy pull requests in the 6529 SEIZE backend with clear PR descriptions, safe validation notes, review-bot follow-up, DCO-signed commits only when explicitly requested, backend/API checks, lambda deployment planning, and staging or production deployment gates. Use when preparing PR bodies, creating PRs, responding to CodeRabbit or Claude review bots, deciding whether a PR is ready, merging, or carrying a backend/API PR through staging/prod rollout.
development
Add or change identity notification types in the 6529 SEIZE backend by updating notification causes, domain data types, DB-to-domain mappers, UserNotifier creation methods, push notification rendering/settings, notification API mappings, OpenAPI enums, and tests. Use when adding new notification types, creating identity notifications, changing notification payloads, or extending push/API notification behavior.
testing
Implement database-related changes in this repository, including schema changes via TypeORM entities, repository/query patterns, request-context transactions, DB tests, and explicit data migrations. Use when working on DB schema updates, repositories or *Db classes, SQL queries, transactions, data backfills, or app logic that reads or writes MySQL data.