---
name: "astro-db-libsql-schema"
description: "Manage lightweight, type-safe SQL databases directly within Astro projects using Astro DB."
metadata:
  author: "Astro"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup astro db"
  - "define astro db table"
  - "query astro db drizzle"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Astro DB Embedded SQL Database & Studio Integration

Configures Astro DB: defining database schemas in db/config.ts, querying with Drizzle-based query builder (db.select().from(Comment)), automated local libSQL migrations, and Astro Studio cloud synchronization.

## When to Invoke
Invoke this skill whenever you need to:
- setup astro db
- define astro db table
- query astro db drizzle

## Execution SOP & Rules
1. Install @astrojs/db integration and run astro db:setup.
2. Define schema in db/config.ts using defineTable({ columns: { id: column.number({ primaryKey: true }) } }).
3. Execute queries: import { db, Comments } from 'astro:db'; const all = await db.select().from(Comments);.
4. Push database schema migrations to production using astro db push.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
