Agent skill

Database Schema

by alinaqi in alinaqi/maggy

Schema awareness - read before coding, type generation, prevent column errors

MITAuto-check passedDatabases

Install Database Schema

skills CLI
$ npx skills add alinaqi/maggy --skill database-schema -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install alinaqi/maggy database-schema --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/alinaqi/maggy.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/database-schema .claude/skills/database-schema && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
database-schema
GitHub stars
707
Token cost
~3.1k tokens
SKILL.md length
378 words
Files
1
Skills in repo
71
Repo updated
First seen
Licence
MIT

At a glance

Schema awareness - read before coding, type generation, prevent column errors

  • Works in 4 steps: Read schema file immediately → Read _project_specs/schema-reference.md… → Note in session state what… → …
  • Tasks that involve ORMs and data access
  • SKILL.md covers Core Rule: Read Schema Before…, Schema File Locations (By Stack), Pre-Code Checklist (Database… and Type Generation Commands, plus 6 more sections
  • Calls supabase and npx

What it does

Database Schema is an agent skill from alinaqi/maggy. Schema awareness - read before coding, type generation, prevent column errors

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering ORMs and data access and Database schema design. It works with Prisma, Supabase, TypeScript and SQL. The repository describes itself as: What started as an opinionated Claude Code setup kit is now an autonomous AI engineering command center. The licence is MIT.

When your agent uses it

  • Tasks that involve ORMs and data access
  • Tasks that involve Database schema design

Example prompts

  • “/database-schema”

Requirements

  • Python 3
  • Node.js

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Read schema file immediately
  2. Read _project_specs/schema-reference.md if exists
  3. Note in session state what tables/columns are relevant
  4. Reference schema explicitly when writing code

What it can do on your machine

Read from SKILL.md and the folder at commit 72a456e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • supabase
    • npx

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use supabase and npx, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Database Schema loads about 3.1k tokens when it runs. Until then it costs about 23 tokens; SKILL.md has 378 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~23
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from alinaqi/maggy at commit 72a456e, republished under its MIT licence (© alinaqi). 378 words, ~3,060 tokens.

Download SKILL.mdSave it as .claude/skills/database-schema/SKILL.md (or your agent's skills folder).
name
database-schema
description
Schema awareness - read before coding, type generation, prevent column errors
when-to-use
Before writing any database queries or modifying data models
user-invocable
false
paths
**/schema.*, **/migrations/**, **/models/**, **/*.prisma, **/drizzle/**
effort
medium

Database Schema Awareness Skill

Problem: Claude forgets schema details mid-session - wrong column names, missing fields, incorrect types. TDD catches this at runtime, but we can prevent it earlier.


Core Rule: Read Schema Before Writing Database Code

MANDATORY: Before writing ANY code that touches the database:

┌─────────────────────────────────────────────────────────────┐
│  1. READ the schema file (see locations below)              │
│  2. VERIFY columns/types you're about to use exist          │
│  3. REFERENCE schema in your response when writing queries  │
│  4. TYPE-CHECK using generated types (Drizzle/Prisma/etc)   │
└─────────────────────────────────────────────────────────────┘

If schema file doesn't exist → CREATE IT before proceeding.


Schema File Locations (By Stack)

StackSchema LocationType Generation
Drizzlesrc/db/schema.ts or drizzle/schema.tsBuilt-in TypeScript
Prismaprisma/schema.prismanpx prisma generate
Supabasesupabase/migrations/*.sql + typessupabase gen types typescript
SQLAlchemyapp/models/*.py or src/models.pyPydantic models
TypeORMsrc/entities/*.tsDecorators = types
Raw SQLschema.sql or migrations/Manual types required

Create _project_specs/schema-reference.md for quick lookup:

markdown
# Database Schema Reference

*Auto-generated or manually maintained. Claude: READ THIS before database work.*

## Tables

### users
| Column | Type | Nullable | Default | Notes |
|--------|------|----------|---------|-------|
| id | uuid | NO | gen_random_uuid() | PK |
| email | text | NO | - | Unique |
| name | text | YES | - | Display name |
| created_at | timestamptz | NO | now() | - |
| updated_at | timestamptz | NO | now() | - |

### orders
| Column | Type | Nullable | Default | Notes |
|--------|------|----------|---------|-------|
| id | uuid | NO | gen_random_uuid() | PK |
| user_id | uuid | NO | - | FK → users.id |
| status | text | NO | 'pending' | enum: pending/paid/shipped/delivered |
| total_cents | integer | NO | - | Amount in cents |
| created_at | timestamptz | NO | now() | - |

## Relationships
- users 1:N orders (user_id)

## Enums
- order_status: pending, paid, shipped, delivered

Pre-Code Checklist (Database Work)

Before writing any database code, Claude MUST:

markdown
### Schema Verification Checklist
- [ ] Read schema file: `[path to schema]`
- [ ] Columns I'm using exist: [list columns]
- [ ] Types match my code: [list type mappings]
- [ ] Relationships are correct: [list FKs]
- [ ] Nullable fields handled: [list nullable columns]

Example in practice:

markdown
### Schema Verification for TODO-042 (Add order history endpoint)

- [x] Read schema: `src/db/schema.ts`
- [x] Columns exist: orders.id, orders.user_id, orders.status, orders.total_cents, orders.created_at
- [x] Types: id=uuid→string, total_cents=integer→number, status=text→OrderStatus enum
- [x] Relationships: orders.user_id → users.id (many-to-one)
- [x] Nullable: none of these columns are nullable

Type Generation Commands

Drizzle (TypeScript)
typescript
// Schema defines types automatically
// src/db/schema.ts
import { pgTable, uuid, text, integer, timestamp } from 'drizzle-orm/pg-core';

export const users = pgTable('users', {
  id: uuid('id').primaryKey().defaultRandom(),
  email: text('email').notNull().unique(),
  name: text('name'),
  createdAt: timestamp('created_at').notNull().defaultNow(),
});

export const orders = pgTable('orders', {
  id: uuid('id').primaryKey().defaultRandom(),
  userId: uuid('user_id').notNull().references(() => users.id),
  status: text('status').notNull().default('pending'),
  totalCents: integer('total_cents').notNull(),
  createdAt: timestamp('created_at').notNull().defaultNow(),
});

// Inferred types - USE THESE
export type User = typeof users.$inferSelect;
export type NewUser = typeof users.$inferInsert;
export type Order = typeof orders.$inferSelect;
export type NewOrder = typeof orders.$inferInsert;
Prisma
prisma
// prisma/schema.prisma
model User {
  id        String   @id @default(uuid())
  email     String   @unique
  name      String?
  orders    Order[]
  createdAt DateTime @default(now()) @map("created_at")

  @@map("users")
}

model Order {
  id         String   @id @default(uuid())
  userId     String   @map("user_id")
  user       User     @relation(fields: [userId], references: [id])
  status     String   @default("pending")
  totalCents Int      @map("total_cents")
  createdAt  DateTime @default(now()) @map("created_at")

  @@map("orders")
}
bash
# Generate types after schema changes
npx prisma generate
Supabase
bash
# Generate TypeScript types from live database
supabase gen types typescript --local > src/types/database.ts

# Or from remote
supabase gen types typescript --project-id your-project-id > src/types/database.ts
typescript
// Use generated types
import { Database } from '@/types/database';

type User = Database['public']['Tables']['users']['Row'];
type NewUser = Database['public']['Tables']['users']['Insert'];
type Order = Database['public']['Tables']['orders']['Row'];
SQLAlchemy (Python)
python
# app/models/user.py
from sqlalchemy import Column, String, DateTime
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.sql import func
from app.db import Base
import uuid

class User(Base):
    __tablename__ = "users"

    id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    email = Column(String, nullable=False, unique=True)
    name = Column(String, nullable=True)
    created_at = Column(DateTime(timezone=True), server_default=func.now())

    # Relationships
    orders = relationship("Order", back_populates="user")
python
# app/schemas/user.py - Pydantic for API validation
from pydantic import BaseModel, EmailStr
from uuid import UUID
from datetime import datetime

class UserBase(BaseModel):
    email: EmailStr
    name: str | None = None

class UserCreate(UserBase):
    pass

class User(UserBase):
    id: UUID
    created_at: datetime

    class Config:
        from_attributes = True

Schema-Aware TDD Workflow

Extend the standard TDD workflow for database work:

┌─────────────────────────────────────────────────────────────┐
│  0. SCHEMA: Read and verify schema before anything else     │
│     └─ Read schema file                                     │
│     └─ Complete Schema Verification Checklist               │
│     └─ Note any missing columns/tables needed               │
├─────────────────────────────────────────────────────────────┤
│  1. RED: Write tests that use correct column names          │
│     └─ Import generated types                               │
│     └─ Use type-safe queries in tests                       │
│     └─ Tests should fail on logic, NOT schema errors        │
├─────────────────────────────────────────────────────────────┤
│  2. GREEN: Implement with type-safe queries                 │
│     └─ Use ORM types, not raw strings                       │
│     └─ TypeScript/mypy catches column mismatches            │
├─────────────────────────────────────────────────────────────┤
│  3. VALIDATE: Type check catches schema drift               │
│     └─ tsc --noEmit / mypy catches wrong columns            │
│     └─ Tests validate runtime behavior                      │
└─────────────────────────────────────────────────────────────┘

Common Schema Mistakes (And How to Prevent)

MistakeExamplePrevention
Wrong column nameuser.userName vs user.nameRead schema, use generated types
Wrong typetotalCents as stringType generation catches this
Missing nullable checkuser.name! when nullableSchema shows nullable fields
Wrong FK relationshiporder.userId vs order.user_idCheck schema column names
Missing columnUsing user.avatar that doesn't existRead schema before coding
Wrong enum valuestatus: 'complete' vs 'completed'Document enums in schema reference
Type-Safe Query Examples

Drizzle (catches errors at compile time):

typescript
// ✅ Correct - uses schema-defined columns
const user = await db.select().from(users).where(eq(users.email, email));

// ❌ Wrong - TypeScript error: 'userName' doesn't exist
const user = await db.select().from(users).where(eq(users.userName, email));

Prisma (catches errors at compile time):

typescript
// ✅ Correct
const user = await prisma.user.findUnique({ where: { email } });

// ❌ Wrong - TypeScript error
const user = await prisma.user.findUnique({ where: { userName: email } });

Raw SQL (NO protection - avoid):

typescript
// ❌ Dangerous - no type checking, easy to get wrong
const result = await db.query('SELECT * FROM users WHERE user_name = $1', [email]);
// Should be 'email' not 'user_name' - won't catch until runtime

Show full SKILL.md (142 more words)Show less

Migration Workflow

When schema changes are needed:

┌─────────────────────────────────────────────────────────────┐
│  1. Update schema file (Drizzle/Prisma/SQLAlchemy)          │
├─────────────────────────────────────────────────────────────┤
│  2. Generate migration                                       │
│     └─ Drizzle: npx drizzle-kit generate                    │
│     └─ Prisma: npx prisma migrate dev --name add_column     │
│     └─ Supabase: supabase migration new add_column          │
├─────────────────────────────────────────────────────────────┤
│  3. Regenerate types                                         │
│     └─ Prisma: npx prisma generate                          │
│     └─ Supabase: supabase gen types typescript              │
├─────────────────────────────────────────────────────────────┤
│  4. Update schema-reference.md                               │
├─────────────────────────────────────────────────────────────┤
│  5. Run type check - find all broken code                    │
│     └─ npm run typecheck                                    │
├─────────────────────────────────────────────────────────────┤
│  6. Fix type errors, update tests, run full validation       │
└─────────────────────────────────────────────────────────────┘

Session Start Protocol

When starting a session that involves database work:

  1. Read schema file immediately
  2. Read _project_specs/schema-reference.md if exists
  3. Note in session state what tables/columns are relevant
  4. Reference schema explicitly when writing code

Session state example:

markdown
## Current Session - Database Context

**Schema read:** ✓ src/db/schema.ts
**Tables in scope:** users, orders, order_items
**Key columns:**
- users: id, email, name, created_at
- orders: id, user_id, status, total_cents
- order_items: id, order_id, product_id, quantity, price_cents

Anti-Patterns

  • ❌ Guessing column names - Always read schema first
  • ❌ Using raw SQL strings - Use ORM with type generation
  • ❌ Hardcoding without verification - Check schema before using any column
  • ❌ Ignoring type errors - Schema drift shows up as type errors
  • ❌ Not regenerating types - After migration, always regenerate
  • ❌ Assuming nullable - Check schema for nullable columns

Checklist

Setup
  • Schema file exists in standard location
  • Type generation configured
  • _project_specs/schema-reference.md created
  • Types regenerate on schema change
Per-Task
  • Schema read before writing database code
  • Schema Verification Checklist completed
  • Using generated types (not raw strings)
  • Type check passes (catches column errors)
  • Tests use correct schema

© alinaqi, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/database-schema of alinaqi/maggy.

Open the folder on GitHubat commit 72a456e

Compare with similar skills

Database Schema next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Database Schema compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Database Schema this skillalinaqi/maggy707—~3.1kAutomated safety check: PassMIT
Drizzle Orm Expertdavila7/claude-code-templates32k3 repos~2.6kAutomated safety check: PassMIT
Database FundamentalsDanielPodolsky/ownyourcode2901 repos~1.6kAutomated safety check: PassMIT
Prisma 8 Contract-First ORMprisma/orm48k—~3.7kAutomated safety check: NotesApache-2.0
DB SculptorEliasOulkadi/shokunin114—~3.1kAutomated safety check: NotesMIT
Prisma Migrationopenathleteorg/openathlete100—~575Automated safety check: PassAGPL-3.0

Similar skills

  • Drizzle Orm Expert

    davila7/claude-code-templates

    Expert in Drizzle ORM for TypeScript — schema design, relational queries, migrations, and serverless database integration.

    32k GitHub starsUsed in 3 repos~2.6k tokens
    DatabasesAuto-check passed
  • Database Fundamentals

    DanielPodolsky/ownyourcode

    Reviews schema design, SQL queries, ORM patterns. An agent skill from DanielPodolsky/ownyourcode.

    290 GitHub starsUsed in 1 repo~1.6k tokens
    DatabasesAuto-check passed
  • Official

    Routes Prisma 8 tasks such as contracts, migrations, queries and upgrades to the right reference files for projects on the contract-first @prisma/orm packages.

    48k GitHub stars~3.7k tokensUpdated yesterday
    DatabasesAuto-check: notes
  • DB Sculptor

    EliasOulkadi/shokunin

    Design database schemas with Prisma/Drizzle, PostgreSQL index strategy (B-tree, GIN, GiST, BRIN, Hash), query optimization (EXPLAIN ANALYZE), migration safety (expand/contract, zero-downtime), and…

    114 GitHub stars~3.1k tokensUpdated 3 days ago
    DatabasesAuto-check: notes
  • Prisma Migration

    openathleteorg/openathlete

    Change the OpenAthlete database schema safely with Prisma, covering the migration SQL, production safety, account deletion coverage and tests.

    100 GitHub stars~575 tokensUpdated yesterday
    DatabasesAuto-check passed
  • Prisma Patterns

    affaan-m/ECC

    Prisma ORM patterns for TypeScript backends — schema design, query optimization, transactions, pagination, and critical traps like updateMany returning count not records, $transaction timeouts…

    274k GitHub starsUsed in 1 repo~3.8k tokens
    DatabasesAuto-check: notes

More from alinaqi/maggy

All 71 skills in this repo
  • AI Models

    alinaqi/maggy

    Latest AI models reference - Claude, OpenAI, Gemini, Eleven Labs, Replicate

    707 GitHub starsUsed in 1 repo~4.1k tokens
    Auto-check passed
  • Azure Cosmosdb

    alinaqi/maggy

    Azure Cosmos DB partition keys, consistency levels, change feed, SDK patterns

    707 GitHub starsUsed in 1 repo~4.5k tokens
    Auto-check passed
  • LLM Patterns

    alinaqi/maggy

    AI-first application patterns, LLM testing, prompt management

    707 GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed
  • Aeo Optimization

    alinaqi/maggy

    AI Engine Optimization - semantic triples, page templates, content clusters for AI citations

    707 GitHub stars~3.7k tokensUpdated 13 days ago
    Auto-check passed
  • Agent Teams

    alinaqi/maggy

    Claude Code Agent Teams - default team-based development with strict TDD pipeline enforcement

    707 GitHub stars~5k tokensUpdated 13 days ago
    Auto-check: notes
  • Android Java

    alinaqi/maggy

    Android Java development with MVVM, ViewBinding, and Espresso testing

    707 GitHub stars~3.9k tokensUpdated 13 days ago
    Auto-check: notes

Categories

Questions about Database Schema

What does Database Schema do?

Schema awareness - read before coding, type generation, prevent column errors. Database Schema is an agent skill from alinaqi/maggy.

When should I use Database Schema?

Database Schema fits situations like: tasks that involve ORMs and data access; tasks that involve Database schema design.

How do I install Database Schema in Claude Code?

Run `npx skills add alinaqi/maggy --skill database-schema -a claude-code`. Or copy the skill folder (skills/database-schema in alinaqi/maggy) into .claude/skills/database-schema in your project. Claude Code loads it when a task matches its description.

How do I install Database Schema in Codex?

Run `npx skills add alinaqi/maggy --skill database-schema -a codex`. Or copy the skill folder (skills/database-schema in alinaqi/maggy) into .agents/skills/database-schema in your project. Codex loads it when a task matches its description.

Can I use Database Schema in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alinaqi/maggy --skill database-schema -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/database-schema, .gemini/skills/database-schema, .github/skills/database-schema and .opencode/skills/database-schema in your project.

What does Database Schema need to run?

Going by SKILL.md and its folder, Database Schema needs the command-line tools its instructions call (supabase and npx). Our summary lists: Python 3; Node.js.

Does Database Schema access the network?

SKILL.md contains no URLs. Its commands use npx, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Database Schema safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Database Schema use?

Database Schema is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Database Schema use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Database Schema?

Skills that share tags, products or a category with Database Schema: Drizzle Orm Expert (davila7/claude-code-templates, 32k stars), Database Fundamentals (DanielPodolsky/ownyourcode, 290 stars), Prisma 8 Contract-First ORM (prisma/orm, 48k stars) and DB Sculptor (EliasOulkadi/shokunin, 114 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Database Schema?

alinaqi (a GitHub user) maintains it in alinaqi/maggy, which has 707 GitHub stars. The repository holds 71 skills in this directory. The repository was last updated on September 24, 2026.

Source: alinaqi/maggy on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.