Assists with managing database structures and ORM queries in AdonisJS applications.

Install

mkdir -p .claude/skills/lucid && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17043" && unzip -o skill.zip -d .claude/skills/lucid && rm skill.zip

Installs to .claude/skills/lucid

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use when working with AdonisJS Lucid ORM and SQL layer: database configuration, migrations, schema generation, schema classes, models, CRUD operations, model query builder, query scopes, hooks, serialization, relationships, transactions, pagination, debugging, validation rules, model factories, seeders, or database query builders. Trigger for tasks involving @adonisjs/lucid, database/schema.ts, app/models, database/migrations, database/factories, database/seeders, db service queries, Lucid relationships, or model behavior.
528 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Manage database configuration and migrations
  • Generate database schemas and schema classes
  • Define models with relationships, hooks, and scopes
  • Perform CRUD operations using model query builder or db service
  • Handle transactions and serialization

How it works

The skill guides the user through AdonisJS Lucid ORM operations, treating the database as the source of truth and emphasizing migrations for schema changes and models for domain behavior.

Inputs & outputs

You give it
User request related to AdonisJS Lucid ORM, database schema, models, or queries
You get back
Database migrations, schema classes, model definitions, query builder code, or transaction implementations

When to use lucid

  • Create database migrations
  • Define model relationships
  • Build complex database queries
  • Manage schema classes

About this skill

Lucid

Use this skill for the Lucid database layer in AdonisJS applications. Lucid is database-first: migrations change the database, Lucid generates database/schema.ts, and models extend generated schema classes while declaring relationships, hooks, scopes, serialization, and domain behavior.

When a task also touches controllers, routes, validators, policies, services, or broader AdonisJS architecture, use adonisjs alongside this skill. When writing tests around Lucid behavior, use japa alongside this skill.

Core Rules

  • Treat the database as the source of truth.
  • Write schema changes in migrations, then run migrations or schema:generate to refresh database/schema.ts.
  • Do not manually edit generated database/schema.ts.
  • Model files should usually extend generated schema classes and contain relationships, hooks, scopes, serialization overrides, and domain methods.
  • Use the db service for SQL-heavy queries, reports, one-off scripts, or when model hydration is unnecessary.
  • Use model queries when you need Active Record behavior, relationships, hooks, scopes, serialization, or model instances.
  • Prefer managed transactions with db.transaction(async (trx) => ...) unless the transaction lifetime must cross function boundaries.
  • Always scope destructive update/delete queries with where clauses.
  • Preload relationships instead of querying inside loops.
  • Use withCount, withAggregate, has, and whereHas for relationship-aware filtering and aggregates.

Workflow

For feature work that changes persisted data:

  1. Identify existing tables, generated schema classes, models, and relationships.
  2. Write or update migrations first.
  3. Run the migration or note the command required to regenerate database/schema.ts.
  4. Update models to extend the generated schema class and add Lucid-only behavior.
  5. Add or update relationships with explicit keys when conventions do not match.
  6. Use query builders, scopes, or factories based on the access pattern.
  7. Verify with focused tests or a typecheck command available in the repo.

For existing-database adoption:

  1. Configure the connection.
  2. Exclude unmanaged tables in schemaGeneration.excludeTables.
  3. Run node ace schema:generate.
  4. Create models only for tables the application owns.
  5. Handle convention mismatches with schema rules or model-level overrides.

Choosing the Right API

NeedPrefer
Table creation or schema changeMigration with BaseSchema
Typed model columnsGenerated schema class from database/schema.ts
Domain behavior on rowsModel methods and hooks
Relationship loading/filteringModel query builder
Reports or SQL-heavy readsdb.from, db.query, raw query builder
Multi-write consistencyManaged transaction
Test dataModel factories
Initial/dev dataDatabase seeders

References

Load the relevant local reference before implementing:

  • references/schema-and-models.md for migrations, schema generation, schema classes, CRUD, scopes, hooks, and serialization.
  • references/query-builders.md for db service queries, model query builder behavior, pagination, raw SQL, and debugging.
  • references/transactions.md for managed/manual transactions, isolation, savepoints, row locks, model transactions, and relationship writes inside transactions.
  • references/relationships.md for belongsTo, hasOne, hasMany, manyToMany, hasManyThrough, preloads, relationship filters, aggregates, and writes.
  • references/testing.md for test database state, factories, factory relationships, pivot attributes, hooks, and seeders.

Each reference contains the essential working patterns first and links to the deeper official Lucid docs at the end.

Anti-Patterns

AvoidPrefer
Editing database/schema.ts by handMigrations, schema rules, or model overrides
Declaring every column manually in model filesExtend the generated *Schema class
Running relationship queries inside loopspreload, nested preloads, withCount, withAggregate
Unscoped update or deleteAlways include explicit where constraints
Manual transactions for simple operationsManaged db.transaction callback
Mocking Lucid query behavior for integration pathsUse Japa with test DB/factories
Using models for every report queryUse the db service when plain rows are enough

When not to use it

  • When working with controllers, routes, validators, policies, services, or broader AdonisJS architecture exclusively
  • When writing tests around Lucid behavior without Japa

Prerequisites

@adonisjs/lucid package

Limitations

  • The skill does not manually edit generated database/schema.ts
  • The skill does not run relationship queries inside loops
  • The skill does not use unscoped update or delete operations

How it compares

This skill provides a structured approach to database interaction within AdonisJS, focusing on database-first principles and specific API choices, unlike generic ORM usage.

Compared to similar skills

lucid side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
lucid (this skill)03moNo flagsIntermediate
database-migration33moNo flagsAdvanced
create-migration14moNo flagsBeginner
316-frameworks-spring-mongodb-migrations-mongock02moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

database-migration

wshobson

Execute database migrations across ORMs and platforms with zero-downtime strategies, data transformation, and rollback procedures. Use when migrating databases, changing schemas, performing data transformations, or implementing zero-downtime deployment strategies.

324

create-migration

owid

Create a new database migration file for the OWID MySQL database. Use when the user needs to create a database schema change or migration.

13

316-frameworks-spring-mongodb-migrations-mongock

jabrena

Use when you need to add or review Mongock MongoDB data migrations in a Spring Boot application — including Maven coordinates, Spring Data MongoDB drivers, migration scan packages, @ChangeUnit classes, lock/transaction settings, and Testcontainers verification. This should trigger for requests such

00

alwib-backend

Tsuev

Develop and maintain the Alwib NestJS backend in `backend/`. Use when implementing or refactoring modules, controllers, services, DTO validation, Swagger docs, authentication/authorization flows, Prisma schema and migrations, and backend lint/test flows.

00

prisma-v7

develsvai

`web/`의 Prisma 7 설정과 generated client import 규칙을 맞추기 위한 스킬이다. 스키마 변경, migration, import 패턴 정리, Prisma 타입 사용 시 적용한다.

00

nestjs-database

li-lance

Implement data access patterns, Scaling, Migrations, and ORM selection in NestJS. Use when implementing TypeORM/Prisma repositories, migrations, or database patterns in NestJS. (triggers: **/*.entity.ts, prisma/schema.prisma, TypeOrmModule, PrismaService, MongooseModule, Repository)

00

Search skills

Search the agent skills registry