agentleFS
its-shitzuits-shitzu/AgentStack/.claude/skills/add-crud-feature/SKILL.md

add-crud-feature

Skill1 starsChanged 5 months agoMITView on GitHub

Generate a complete CRUD resource (Drizzle model + server actions + dashboard table/form UI) from a natural-language description, following AgentStack's conventions. Use when the user asks to add a new resource/entity to the app (e.g. "add an Invoice resource", "I need a Task model with title, status, due date").

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always add organizationId (FK to organizations.id) — every resource in this app is scoped to an organization.

    line 15
  2. Very specific:

    Schema: create src/db/schema/<resource-plural>.ts exporting a pgTable named <resourcePlural>.

    line 27
  3. Very specific:

    Migration: after writing the schema, tell the user to run pnpm db:generate then pnpm db:push (or run it yourself if you have shell access …

    line 29
  4. Very specific:

    Server actions: create src/app/(dashboard)/dashboard/<resource-plural>/actions.ts with a "use server" directive.

    line 31
  5. Very specific:

    Call requireOrganization() from @/lib/session and filter/scope by organizationId.

    line 32
  6. Very specific:

    Use createId() from @/lib/id for new primary keys.

    line 34
  7. Very specific:

    Navigation: add an entry to src/components/dashboard/nav-items.ts pointing at /dashboard/<resource-plural>, with a sensible lucide-react …

    line 41
  8. Distinctive:

    Don't add features beyond what was asked (no soft-delete, no audit log, no pagination) unless the user requested it.

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

add-crud-feature

Generates a full vertical slice for a new business resource: database table, server actions, dashboard page, table, and form — wired into navigation. Read AGENTS.md first for the project-wide conventions this skill assumes.

Inputs

Parse from the user's natural-language request:

  • Resource name (singular, PascalCase for types, kebab-case for files/routes, snake_case for the DB table). E.g. "Invoice" → Invoice, invoice, invoices.
  • Fields: name, type (text/number/boolean/date/enum), required/optional. Infer reasonable types if the user is vague (e.g. "amount" → numeric in cents, "status" → enum).
  • Always add organizationId (FK to organizations.id) — every resource in this app is scoped to an organization. Never create a resource without it.

Reference files (read these before generating anything)

  • src/db/schema/organizations.ts — table definition pattern (pgTable, id as text PK via createId(), timestamps, FK with onDelete: "cascade").
  • src/app/(dashboard)/dashboard/settings/organization/page.tsx — server component reading data with Drizzle + requireOrganization().
  • src/app/(dashboard)/dashboard/settings/billing/billing-actions.tsx + billing/page.tsx — pattern for a server page + a "use client" actions component.
  • src/components/shared/data-table.tsx — generic DataTable component to reuse for the listing table.
  • src/components/dashboard/nav-items.ts — where to register the new nav entry.

Steps

  1. Schema: create src/db/schema/<resource-plural>.ts exporting a pgTable named <resourcePlural>. Columns: id text primaryKey, the requested fields, organizationId text notNull references(() => organizations.id, { onDelete: "cascade" }), createdAt/updatedAt timestamps notNull defaultNow(). Re-export it from src/db/schema/index.ts.
  2. Migration: after writing the schema, tell the user to run pnpm db:generate then pnpm db:push (or run it yourself if you have shell access and a DATABASE_URL is configured) — do not hand-write SQL migrations.
  3. Server actions: create src/app/(dashboard)/dashboard/<resource-plural>/actions.ts with a "use server" directive. Implement create<Resource>, update<Resource>, delete<Resource>, list<Resource>s. Every query/mutation must:
    • Call requireOrganization() from @/lib/session and filter/scope by organizationId.
    • Validate input with a Zod schema before touching the DB.
    • Use createId() from @/lib/id for new primary keys.
  4. UI:
    • src/app/(dashboard)/dashboard/<resource-plural>/page.tsx — server component, fetches rows via the list action, renders <<Resource>Table>.
    • src/components/<resource-plural>/<resource>-table.tsx — uses the shared DataTable component, one column per field plus an actions column (edit/delete via a dialog using src/components/ui/dialog.tsx).
    • src/components/<resource-plural>/<resource>-form.tsx — "use client" form using Input/Label/Select/Switch from src/components/ui/* matched to field types, calling the server actions, with useState for pending/error state (mirror billing-actions.tsx's fetch+loading pattern, but call server actions directly via startTransition instead of fetch).
  5. Navigation: add an entry to src/components/dashboard/nav-items.ts pointing at /dashboard/<resource-plural>, with a sensible lucide-react icon.
  6. Report back: list every file created/modified and the exact migration commands the user still needs to run.

Conventions to enforce

  • No any. Derive row types with typeof <table>.$inferSelect / $inferInsert.
  • Files: kebab-case. Component names inside files: PascalCase.
  • Server actions live in actions.ts colocated with the page, never in lib/.
  • Don't add features beyond what was asked (no soft-delete, no audit log, no pagination) unless the user requested it.

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.