ops/skills/database-skill/SKILL.md
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.
npx skillsauth add 6529-collections/6529seize-backend database-skillInstall 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.
Apply this skill any time work involves database schema, queries, repositories, or migrations.
src/entities.I, example: IMyThing.tsI and suffixed with Entity, example: MyThingEntitysrc/entities/entities.ts.bigint Unix epoch milliseconds for time fields over SQL datetime/date.@Entity(TABLE_NAME), add or use a table constant in src/constants/db-tables.ts.*Repository or *Db.await sqlExecutor.executeNativeQueriesInTransaction(async (connection) => {
const txCtx: RequestContext = { ...ctx, connection };
await firstRepository.doWork(txCtx);
await secondRepository.doMoreWork(txCtx);
});
ctx: RequestContext the last argument of new repository functions unless the surrounding class has an established incompatible pattern.const timerName = `${this.constructor.name}->methodName`;
try {
ctx.timer?.start(timerName);
// query work
} finally {
ctx.timer?.stop(timerName);
}
ctx.connection when present so operations participate in caller-provided transactions:
const rows = await this.db.execute<MyEntity>(
`select * from ${MY_TABLE} where id = :id`,
{ id },
ctx.connection ? { wrappedConnection: ctx.connection } : undefined
);
For TypeORM transaction blocks, obtain repositories from the transaction manager passed by the transaction callback instead of the global data source.Api* classes in repositories.src/constants/db-tables.ts instead of hardcoded table names whenever possible.execute<T>() and oneOrNull<T>().Array.prototype.sort, including string sorts.dbMigrationsLoop sync.npm run migrate:new migration-name
migrations/..down.sql file and leave exports.down present as a no-op; do not implement revert logic.Place DB/repository tests next to the file under test and name them with lowercase hyphenated words ending in .test.ts. For DB integration patterns, follow src/profiles/abusiveness-check.db.test.ts.
bigint for time where applicable.src/constants/db-tables.ts.*Db classes.ctx: RequestContext through new repository APIs.ctx.connection when available.Api* models in repositories.exports.down as a no-op.npm run lint.development
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.
development
Add or change community metrics in the 6529 SEIZE backend by updating metric rollup enums, recorder methods, recording call sites, optional historical backfills, OpenAPI response models, and community-metrics API aggregation. Use when adding new community metrics, exposing metric summaries or series, tracking community activity, or changing MetricsRecorder/MetricsDb behavior.