Agent skill

Database

by gridaco in gridaco/grida

Use BEFORE editing any file in supabase/migrations/ or supabase/schemas/, OR when the user runs a /database subcommand (compact local migration, rls scenarios, align).

Apache-2.0Auto-check passedAgent Workflows

Install Database

skills CLI
$ npx skills add gridaco/grida --skill database -a claude-code

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

GitHub CLI
$ gh skill install gridaco/grida database --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/gridaco/grida.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/database .claude/skills/database && 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
GitHub stars
2.7k
Token cost
~3.2k tokens
SKILL.md length
1,548 words
Files
1
Skills in repo
29
Repo updated
First seen
Licence
Apache-2.0

At a glance

Use BEFORE editing any file in supabase/migrations/ or supabase/schemas/, OR when the user runs a /database subcommand (compact local migration, rls scenarios, align).

  • Works in 3 steps: Applied migrations are immutable. → The RLS spec is the source of truth —… → schemas/*.sql is the human-friendly…
  • Runs a /database subcommand (compact local migration
  • SKILL.md covers Common mistake (read this first), /database compact local…, /database rls scenarios and /database align
  • Calls supabase and git

What it does

Database is an agent skill from gridaco/grida. Use BEFORE editing any file in supabase/migrations/ or supabase/schemas/, OR when the user runs a /database subcommand (compact local migration, rls scenarios, align). Encodes the three contracts that protect the Grida database layer: applied migrations are immutable, RLS implementation mirrors tests (never the reverse), schemas/.sql is the human-readable end-state. Companion to supabase/AGENTS.md (RLS, grants, security boundaries).

Its SKILL.md is about 3.2k 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 Agent Workflows, covering Agent instruction files and SQL. It works with Supabase and SQL. The licence is Apache-2.0.

When your agent uses it

  • Runs a /database subcommand (compact local migration
  • Tasks that involve Agent instruction files
  • Tasks that involve SQL

Example prompts

  • “/database”

Workflow steps

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

  1. Applied migrations are immutable.
  2. The RLS spec is the source of truth — implementations follow tests, not the reverse.
  3. schemas/*.sql is the human-friendly description of the final shape.

What it can do on your machine

Read from SKILL.md and the folder at commit 165496f. 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
    • git

    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 git, 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 loads about 3.2k tokens when it runs. Until then it costs about 116 tokens; SKILL.md has 1,548 words of instructions outside code blocks.

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

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 gridaco/grida at commit 165496f, republished under its Apache-2.0 licence (© gridaco). 1,548 words, ~3,192 tokens.

Download SKILL.mdSave it as .claude/skills/database/SKILL.md (or your agent's skills folder).
name
database
description
Use BEFORE editing any file in `supabase/migrations/` or `supabase/schemas/`, OR when the user runs a `/database` subcommand (`compact local migration`, `rls scenarios`, `align`). Encodes the three contracts that protect the Grida database layer: applied migrations are immutable, RLS implementation mirrors tests (never the reverse), `schemas/*.sql` is the human-readable end-state. Companion to `supabase/AGENTS.md` (RLS, grants, security boundaries).

Database — operating contracts

Three contracts this skill protects:

  1. Applied migrations are immutable.
  2. The RLS spec is the source of truth — implementations follow tests, not the reverse.
  3. schemas/*.sql is the human-friendly description of the final shape.

supabase/AGENTS.md is the harder rule layer (RLS, grants, security boundaries). For function changes, follow its canonical RPC role contract, including effective privileges, caller tests, and coverage of new overloads. This skill covers the recurring workflow tasks. Read both.

For realistic optional Library data without changing schema history or the canonical base seed, use the opt-library skill. Return here when that work changes migrations, schemas, RLS, or grants.


Common mistake (read this first)

When asked to "merge migrations" or "consolidate", the temptation is to collapse every supabase/migrations/* into a single canonical file. This is wrong if any of those files have already been applied to a deployed environment. Rewriting an applied migration:

  • Diverges file content from what supabase_migrations.schema_migrations records as already-run.
  • Makes future db reset produce a different starting state for new contributors than what the existing environment holds.
  • Can silently drop columns, policies, or grants the live system needs.

Before merging anything, classify each migration:

ClassSignalAllowed action
Applied (production)User confirms it's in production, OR file has been on main long enough to have shipped.Read-only. Never edit, never delete.
Applied (committed peers)Tracked on the current branch but originated upstream (already on main / canary).Read-only. Never edit, never delete.
Local-only (this PR)Newly added on the current working tree / branch, not yet merged to a deployed branch.Free to merge, rename, delete, rewrite.

None of these signals replace user confirmation. The only ground truth is the deployed schema_migrations table on staging/prod, which the agent cannot read. git log and git status indicate likelihood, not certainty. Default to asking.

Old timestamps don't mean "applied" — they can be brand-new files added to fix an ordering bug.


/database compact local migration

Merge multiple local-only migration files into one (or a few) before the PR ships. Local development naturally accumulates many small migrations for fast iteration without db reset; production prefers one coherent migration per feature.

When to invoke
  • Before opening a PR that adds 2+ migration files for the same feature.
  • User says "merge migrations", "consolidate migrations", "clean up the migration directory".
  • Reviewing a feature branch where migrations outnumber logical chunks.
Procedure
  1. Classify every migration in the working tree. Output: two lists, applied (leave alone) and local-only (candidates).
  2. Verify the classification with the user when uncertain. One confirmation message is cheaper than touching a shipped file.
  3. Plan the merge. For each local-only migration, record:
    • what schema/table it touches,
    • dependencies on earlier local-only migrations,
    • whether a later local-only migration supersedes it (ADD COLUMN then DROP COLUMN — both vanish in the merged file).
  4. Pick the consolidated filename. Use the timestamp of the latest local-only file in the chain so ordering relative to applied migrations stays intact. Rename if the merged content makes a different name more honest.
  5. Write the consolidated SQL as if it were the only file in the chain — no ADD … then DROP churn, no superseded function defs. Idempotent forms (CREATE TABLE IF NOT EXISTS, CREATE OR REPLACE FUNCTION, ADD COLUMN IF NOT EXISTS) make local re-runs safe.
  6. Delete the superseded local-only files. Only those — never touch the applied list.
  7. supabase db reset locally. Run supabase test db if pgTAP covers the affected tables.
  8. Note the fold in the PR description. Reviewers shouldn't have to diff timestamps to figure it out.
Worked example

Local-only (mergeable):

20260508120000_grida_billing_account_provisioning_uid.sql
20260508130000_grida_billing_metronome.sql
20260509120000_grida_billing_debit_cache.sql
20260509130000_grida_billing_alerts_multi_tier.sql

Applied (untouchable):

20260506132900_grida_billing.sql
20260507000000_grida_billing_backfill_provision.sql
20260507223000_grida_billing_security_invoker.sql

Right move: write one consolidated 20260508130000_grida_billing_metronome.sql (latest timestamp; v2 projector from alerts_multi_tier replaces v1 from metronome.sql), delete the other three local files, leave the applied trio untouched. Wrong move: cat all seven into one.


/database rls scenarios

Write or review RLS test scenarios for a tenant-scoped surface. Output is pgTAP coverage proving who can read/write what across personas. Not a description of the current implementation.

When to invoke
  • New tenant-scoped table, view, or RPC.
  • Existing RLS policies changing.
  • Reviewing a security-sensitive PR ("what could go wrong here?").
  • User runs /database rls scenarios <surface>.
The non-negotiable inversion

Implementation mirrors the test, not the other way around.

In RLS, the user journey is the spec. If a test says "a member of org A cannot read org B's project rows", that is a fact about how the product must behave. The implementation's job is to satisfy that fact. If the implementation currently leaks org B's rows, that's a security bug — fix the implementation, do not weaken the test.

Resist any pressure (including from yourself, mid-implementation):

  • Soften an assertion because the policy doesn't quite cover it yet.
  • Add SET LOCAL ROLE service_role to make a test pass.
  • Drop a "no-membership cannot read" case because seeding is inconvenient.
  • Replace is(count, 0) with ok(count >= 0).

A test failing because the policy is wrong is the test doing its job. A test failing because the test is wrong (mis-seeded fixture, typo'd UUID) gets fixed mechanically — never relax the assertion.

Show full SKILL.md (712 more words)Show less
The skill's job

You are the database/security expert helping the user lock down the spec:

  1. Listen for the user journey. Translate prose ("members read, owners edit, outsiders see nothing") into the persona matrix: insider-member, insider-owner, other-tenant-member, no-membership, anon. Each persona × each operation is a row in the test plan.
  2. Spell out the silent edges. Every product description has gaps. Always test:
    • Anon (no JWT) — auth.uid() returns NULL. A policy reading auth.uid() = owner_id becomes NULL = … (always false-ish); WITH CHECK must fail closed independently.
    • Cross-tenant member of the same role (different org, same plan).
    • RETURNING clause leaks — an INSERT … RETURNING * or UPDATE … RETURNING * may emit columns from rows a peer SELECT policy hides. Test that the writer doesn't leak fields they can't read back via SELECT.
    • "Soft-deleted" or archived_at-set rows — visibility differs.
    • Foreign-key rows whose policies depend on a parent's tenant boundary (joining policies that "widen" access).
  3. Polish the wording, never the meaning. "Owner can read their org's projects" → "row visible to authenticated when organization_id ∈ user's owned orgs". Same fact, SQL-shaped. If the user's words and the SQL diverge, stop and ask.
  4. Assert positive AND negative cases for every scenario.
  5. Use seeded personas (supabase/seed.sql), not ad-hoc UUIDs.
Output shape

One pgTAP file per surface (or per logical persona group when large). Skeleton + fixture/session conventions live in supabase/AGENTS.md § RLS testing — point readers there rather than re-list.

Anti-patterns to flag in review
  • Only positive assertions ("insider can read"), no negative ones — proves nothing about isolation.
  • Authenticating as service_role to read tenant rows — bypasses RLS, proves nothing.
  • Assertions phrased as "≥ 0 rows" or "row count is consistent" — accept the broken case.
  • A test changed at the same commit as the policy it covers, with the assertion weakened — almost always a tell that the impl was wrong and the test got dragged down to match.

/database align

Bring supabase/schemas/*.sql back in sync with the migrated state. Schemas are the human-friendly source of truth for the final shape of each domain schema. Migrations are the executable history; schemas are the readable end-state.

When to invoke
  • After landing a feature that added/modified columns, tables, policies, RPCs in any grida_* schema.
  • When schemas/*.sql and migrations/* visibly disagree.
  • User runs /database align.
What schemas/*.sql is for (and isn't)
Concernschemas/*.sqlmigrations/*.sql
What runs on the DBNoYes — supabase applies these.
Source of truth for executionNoYes.
Source of truth for humansYes — read first.No — chronological, hard to reason about.
UpdatedManually, periodically.Via supabase migration new.
DriftBest-effort, may lag.Never — runs against real DBs.

align is the periodic reset that keeps the human-readable layer trustworthy. See supabase/AGENTS.md for the upstream policy.

Procedure
  1. Pick one domain schema (e.g. grida_billing). Don't align everything in one pass — too easy to miss a divergence.
  2. Build the actual end-state from migrations. Read every migration that touches the schema, in order, and compose the final shape in your head (or a scratch file). The migrations themselves are the authoritative source — a pg_dump would give you the truth too, but in the wrong shape (alphabetised, comments stripped, catalog noise) and is harder to diff against a hand-organised schema file than just reading the migrations.
  3. Diff against schemas/<name>.sql. Common deltas:
    • Columns added by a later migration, not in the schema file.
    • Function signatures changed by CREATE OR REPLACE, not updated.
    • Policies dropped/replaced; schema still shows the old.
    • Comments: migrations carry COMMENT ON COLUMN; schemas often forget to mirror.
  4. Update schemas/<name>.sql to the migrated end-state. Keep the file's existing organisation (sections by table, header comments). Group grants and policies under the table they belong to — not by chronology.
  5. Do NOT modify any migration as part of this task. Schemas follow migrations; migrations never follow schemas. If a migration has a bug, fix it via a new migration (or compact flow above for unshipped local-only ones).
  6. supabase db reset afterwards as a smoke check.
Anti-patterns to flag
  • Editing schemas/*.sql instead of a migration to "fix a column" — the schema file is reference, not executable. The DB won't see it.
  • Editing a migration to "match the schema file" — backwards. The migration is what ran; the schema describes what migrations produced.
  • Real-time-sync tooling — reintroduces the surface-area problem the migration model exists to solve. Manual periodic alignment is the design.

© gridaco, Apache-2.0. 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 .agents/skills/database of gridaco/grida.

Open the folder on GitHubat commit 165496f

Compare with similar skills

Database 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 compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Database this skillgridaco/grida2.7k—~3.2kAutomated safety check: PassApache-2.0
Replica ArchitectJakeschincariol/replica-skill734—~1.1kAutomated safety check: PassMIT
Srtd CLIt1mmen/srtd105—~360Automated safety check: PassMIT
Expert DatabaseReJeCtAll/ExpertTeam-Codex113—~692Automated safety check: PassMIT
DB Migratealexeykrol/claude-code-starter194—~405Automated safety check: NotesNone
Stash Postgrescipherstash/stack157—~6.3kAutomated safety check: PassMIT

Similar skills

  • Replica Architect

    Jakeschincariol/replica-skill

    Plans the stack, database schema and API for an app clone, from the recon map replica-recon wrote.

    734 GitHub stars~1.1k tokensUpdated 4 days ago
    DatabasesAuto-check passed
  • Srtd CLI

    t1mmen/srtd

    This skill should be used when the user mentions "srtd", "sql templates", "migrations-templates", "live reload sql", "supabase functions", when working with files in supabase/migrations-templates/…

    105 GitHub stars~360 tokensUpdated 1 mo ago
    DatabasesAuto-check passed
  • Expert Database

    ReJeCtAll/ExpertTeam-Codex

    数据库优化专家入口。用于 Codex CLI 的 $expert-database 调用. An agent skill from ReJeCtAll/ExpertTeam-Codex.

    113 GitHub stars~692 tokensUpdated 3 mo ago
    DatabasesAuto-check passed
  • DB Migrate

    alexeykrol/claude-code-starter

    Миграция схемы базы данных: SQLite → PostgreSQL/Supabase. An agent skill from alexeykrol/claude-code-starter.

    194 GitHub stars~405 tokensUpdated 2 mo ago
    DatabasesAuto-check: notes
  • Stash Postgres

    cipherstash/stack

    Query EQL v3 encrypted columns from hand-written Postgres SQL over pg (node-postgres) or postgres (postgres-js) — no ORM.

    157 GitHub stars~6.3k tokensUpdated today
    DatabasesAuto-check passed
  • Memstack Security Rls Guardian

    cwinvestments/memstack

    A skill your agent uses when creating or altering database tables in Supabase or PostgreSQL projects.

    423 GitHub stars~3.4k tokensUpdated 10 days ago
    DatabasesAuto-check passed

More from gridaco/grida

All 29 skills in this repo
  • Desktop

    gridaco/grida

    Grida Desktop Electron shell and release-impact work: BrowserWindow, preload, window.grida, menus, protocol/deep links, file associations, Forge, path-scoped bridge security, Electron-only UI bugs…

    2.7k GitHub stars~3.2k tokensUpdated yesterday
    Auto-check: notes
  • Io Figma

    gridaco/grida

    Guides work on the Figma I/O package (@grida/io-figma, packages/grida-canvas-io-figma/).

    2.7k GitHub stars~2.2k tokensUpdated yesterday
    Auto-check: notes
  • Opt Library

    gridaco/grida

    Set up, download, verify, and seed the optional Grida Library developer corpus into local Supabase.

    2.7k GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed
  • Vision

    gridaco/grida

    Query images with a local Ollama vision model without loading the image into the main agent context.

    2.7k GitHub stars~1.5k tokensUpdated yesterday
    Auto-check passed
  • AI Models

    gridaco/grida

    Research, compare, and update shared AI model JSON for TypeScript, web, and Rust consumers.

    2.7k GitHub stars~5.7k tokensUpdated yesterday
    Auto-check passed
  • Agent System

    gridaco/grida

    Grida AI agent system work: @grida/daemon (DaemonServer, loopback HTTP perimeter, files/workspaces, secrets store, daemon discovery) and @grida/agent (the agent tenant: sessions, providers/BYOK…

    2.7k GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Database

What does Database do?

Use BEFORE editing any file in supabase/migrations/ or supabase/schemas/, OR when the user runs a /database subcommand (compact local migration, rls scenarios, align). Database is an agent skill from gridaco/grida. Use BEFORE editing any file in supabase/migrations/ or supabase/schemas/, OR when the user runs a /database subcommand (compact local migration, rls scenarios, align).

When should I use Database?

Database fits situations like: runs a /database subcommand (compact local migration; tasks that involve Agent instruction files; tasks that involve SQL.

How do I install Database in Claude Code?

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

How do I install Database in Codex?

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

Can I use Database 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 gridaco/grida --skill database -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, .gemini/skills/database, .github/skills/database and .opencode/skills/database in your project.

What does Database need to run?

Going by SKILL.md and its folder, Database needs the command-line tools its instructions call (supabase and git).

Does Database access the network?

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

Is Database 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 use?

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

How many tokens does Database use?

About 3.2k tokens (SKILL.md is roughly 13k 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?

Skills that share tags, products or a category with Database: Replica Architect (Jakeschincariol/replica-skill, 734 stars), Srtd CLI (t1mmen/srtd, 105 stars), Expert Database (ReJeCtAll/ExpertTeam-Codex, 113 stars) and DB Migrate (alexeykrol/claude-code-starter, 194 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Database?

gridaco (a GitHub organization) maintains it in gridaco/grida, which has 2,657 GitHub stars. The repository holds 29 skills in this directory. The repository was last updated on October 6, 2026.

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