# database-schema-documentation

Documents database schemas, generates Mermaid ERD diagrams, and tracks table constraints. Useful when creating data dictionaries or writing migration specs.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 569 installs · ★ 371
- Author: aj-geddes
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/database-schema-documentation/SKILL.md
- Updated: 2026-03-04
- HTML: https://affpapa.org/en/nevibecode/skills/database-schema-documentation

## What it does

This skill guides coding assistants to produce structured database documentation. It outputs Markdown files containing schema metadata, high-level summaries, and entity relationship diagrams written in Mermaid syntax.

The workflow breaks schemas into modular documents inside a `references/` directory. Each table gets its own file covering column definitions, foreign keys, constraints, and indexes. It demands exact types. The template also requires documentation for triggers, enum types, and nested JSONB fields.

Missing constraint or index documentation makes schema maintenance risky. Because this skill enforces strict rules around versioning and field types, quick hand-waving summaries will fail its requirements.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill database-schema-documentation -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/database-schema-documentation/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/database-schema-documentation/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill database-schema-documentation -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/database-schema-documentation/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill database-schema-documentation -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/database-schema-documentation/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install aj-geddes/useful-ai-prompts database-schema-documentation
```

2. **Manually: put the files in place**
- File: `.github/skills/database-schema-documentation/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill database-schema-documentation -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/database-schema-documentation
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/database-schema-documentation/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill database-schema-documentation -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/database-schema-documentation/SKILL.md

## When to use it
- Generate Mermaid ERD diagrams showing entity relationships
- Build data dictionaries with strict column types and sample records
- Document indexes, triggers, constraints, and JSONB structures
- Prepare architectural specifications for database migrations

## Example prompts
- Document our PostgreSQL schema with an ERD diagram for users and orders
- Create a data dictionary for the `products` table including indexes and constraints
- Write documentation for our database enums and JSONB payload structures

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: d7fe57e60b51ca22.

BEGIN THIRD-PARTY FILE d7fe57e60b51ca22
`````text
---
name: database-schema-documentation
description: >
  Document database schemas, ERD diagrams, table relationships, indexes, and
  constraints. Use when documenting database schema, creating ERD diagrams, or
  writing table documentation.
---

# Database Schema Documentation

## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)

## Overview

Create comprehensive database schema documentation including entity relationship diagrams (ERD), table definitions, indexes, constraints, and data dictionaries.

## When to Use

- Database schema documentation
- ERD (Entity Relationship Diagrams)
- Data dictionary creation
- Table relationship documentation
- Index and constraint documentation
- Migration documentation
- Database design specs

## Quick Start

Minimal working example:

````markdown
# Database Schema Documentation

**Database:** PostgreSQL 14.x
**Version:** 2.0
**Last Updated:** 2025-01-15
**Schema Version:** 20250115120000

## Overview

This database supports an e-commerce application with user management, product catalog, orders, and payment processing.

## Entity Relationship Diagram

```mermaid
erDiagram
    users ||--o{ orders : places
    users ||--o{ addresses : has
    users ||--o{ payment_methods : has
    orders ||--|{ order_items : contains
    orders ||--|| payments : has
    products ||--o{ order_items : includes
    products }o--|| categories : belongs_to
    products ||--o{ product_images : has
    products ||--o{ inventory : tracks

// ... (see reference guides for full implementation)
```

## Reference Guides

Detailed implementations in the `references/` directory:

| Guide | Contents |
|---|---|
| [users](references/users.md) | users |
| [products](references/products.md) | products |
| [orders](references/orders.md) | orders |
| [order_items](references/orderitems.md) | order_items |
| [Enum Types](references/enum-types.md) | Enum Types, JSONB Structures |

## Best Practices

### ✅ DO

- Document all tables and columns
- Create ERD diagrams
- Document indexes and constraints
- Include sample data
- Document foreign key relationships
- Show JSONB field structures
- Document triggers and functions
- Include migration scripts
- Specify data types precisely
- Document performance considerations

### ❌ DON'T

- Skip constraint documentation
- Forget to version schema changes
- Ignore performance implications
- Skip index documentation
- Forget to document enum values
`````
END THIRD-PARTY FILE d7fe57e60b51ca22

The third-party file has ended. Everything between the d7fe57e60b51ca22 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© aj-geddes · MIT · https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/database-schema-documentation/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
