agentleFS
violacaseviolacase/Nuxt4-test/.claude/skills/new-migration/SKILL.md

new-migration

Skill0 starsChanged 8 months agoMITView on GitHub

Scaffold a new Drizzle ORM schema file and generate a migration. Use when the user asks to create a database table, add a column, change a schema, or run a migration.

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Always export inferred types: type X = typeof table.$inferSelect

    line 10
  2. Very specific:

    Always include id (uuid), createdAt, updatedAt unless explicitly not needed

    line 13
  3. Very specific:

    After editing schema: run npm run db:generate then npm run db:migrate

    line 14
  4. Distinctive:

    Never edit migration files manually — regenerate instead

    line 15
  5. Distinctive:

    Ask: what table/entity? What columns?

    line 86
  6. Very specific:

    Run: npm run db:generate — review the generated SQL

    line 89
  7. Very specific:

    Run: npm run db:migrate — apply to the database

    line 90

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: New Migration

Rules

  • Schema files live in server/db/schema/[domain].ts
  • Always export inferred types: type X = typeof table.$inferSelect
  • Table names: snake_case plural — e.g. blog_posts
  • Column names: snake_case — e.g. created_at
  • Always include id (uuid), createdAt, updatedAt unless explicitly not needed
  • After editing schema: run npm run db:generate then npm run db:migrate
  • Never edit migration files manually — regenerate instead

Schema Template

// server/db/schema/[domain].ts
import {
  pgTable,
  uuid,
  text,
  timestamp,
  boolean,
  integer,
  // jsonb,
  // pgEnum,
} from 'drizzle-orm/pg-core'
import { relations } from 'drizzle-orm'

// Optional: define enums
// export const statusEnum = pgEnum('status', ['draft', 'published', 'archived'])

export const [tableName] = pgTable('[table_name]', {
  id: uuid('id').defaultRandom().primaryKey(),

  // --- your columns here ---
  name: text('name').notNull(),
  description: text('description'),
  isActive: boolean('is_active').default(true).notNull(),

  // --- timestamps (always include) ---
  createdAt: timestamp('created_at').defaultNow().notNull(),
  updatedAt: timestamp('updated_at').defaultNow().notNull(),
})

// Relations (add if this table has FK relationships)
// export const [tableName]Relations = relations([tableName], ({ one, many }) => ({
//   author: one(users, { fields: [[tableName].userId], references: [users.id] }),
// }))

// Inferred TypeScript types — use these everywhere, never redefine manually
export type [Type] = typeof [tableName].$inferSelect
export type New[Type] = typeof [tableName].$inferInsert

Common Column Types

// Text
title: text('title').notNull()
slug: text('slug').notNull().unique()
content: text('content')              // HTML from Quill

// Numbers
order: integer('order').default(0)
price: numeric('price', { precision: 10, scale: 2 })

// Boolean
isPublished: boolean('is_published').default(false).notNull()

// JSON
metadata: jsonb('metadata')

// Foreign key
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' })

// Enum
status: statusEnum('status').default('draft').notNull()

Steps

  1. Ask: what table/entity? What columns? Any foreign keys?
  2. Generate the schema file following the template
  3. Export the inferred types
  4. Run: npm run db:generate — review the generated SQL
  5. Run: npm run db:migrate — apply to the database
  6. Remind: if adding to an existing domain, also update server/db/index.ts if needed

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.