# sql-database-assistant

sql-database-assistant — a skill for Claude Code that runs static linting on SQL queries, extracts schema documentation from DDL, and creates forward and rollback migrations.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 100 installs · ★ 1183 repo stars
- Author: borghei
- License: LicenseRef-MIT-Commons-Clause · policy=link-only · description only; the file stays with the author
- Source: https://github.com/borghei/Claude-Skills/tree/HEAD/engineering/sql-database-assistant/SKILL.md
- Updated: 2026-10-23
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/borghei-sql-database-assistant

## What it does

The skill evaluates SQL text using three bundled Python utilities. The `query_optimizer.py` script inspects queries for unindexed scans, `SELECT *`, leading wildcards in `LIKE`, missing `WHERE` clauses, and `= NULL` comparisons. The `schema_explorer.py` tool parses DDL definitions into tables, column types, default values, and foreign keys formatted as Markdown or JSON.

For schema versioning, `migration_generator.py` diffs two DDL snapshots to produce up and commented down steps. It halts with exit code 1 whenever dropped columns or altered types appear unless invoked with `--allow-destructive`. The scripts perform purely static parsing without database connections or query plans, and generated statements target PostgreSQL syntax. Renamed columns are handled as a drop followed by an add, meaning rollback commands reconstruct table structure but do not recover data. Running the tools requires Python.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add borghei/Claude-Skills --skill sql-database-assistant -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add borghei/Claude-Skills --skill sql-database-assistant -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add borghei/Claude-Skills --skill sql-database-assistant -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install borghei/Claude-Skills engineering/sql-database-assistant/SKILL.md
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add borghei/Claude-Skills --skill sql-database-assistant -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/borghei/Claude-Skills --path engineering/sql-database-assistant
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add borghei/Claude-Skills --skill sql-database-assistant -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/borghei/Claude-Skills/tree/HEAD/engineering/sql-database-assistant/SKILL.md

## When to use it
- Spot anti-patterns such as `SELECT *` and leading wildcards in raw SQL
- Generate Markdown schema reference docs directly from a DDL file
- Produce UP and DOWN migration SQL by diffing two schema files
- Catch destructive schema changes in CI pipelines via non-zero exit codes

## Example prompts
- Review queries.sql for missing indexes and scan anti-patterns
- Document table structures and keys from schema.sql in Markdown
- Generate a migration diff from schema_v1.sql to schema_v2.sql

## Similar
- [database-migrations-sql-migrations](https://affpapa.org/en/nevibecode/skills/database-migrations-sql-migrations.md) — skill · 1 install
- [database-design](https://affpapa.org/en/nevibecode/skills/moizibnyousaf-database-design.md) — skill · 624 installs
- [database-design-patterns](https://affpapa.org/en/nevibecode/skills/database-design-patterns.md) — skill · 152 installs
- [Database Migrations taste](https://affpapa.org/en/nevibecode/prompts/database-migrations-taste.md) — prompt · ★ 178201 repo stars
- [704-technologies-sql](https://affpapa.org/en/nevibecode/skills/704-technologies-sql.md) — skill · 227 installs
- [sql-pro](https://affpapa.org/en/nevibecode/skills/httpsgithubcomjeffallan-sql-pro.md) — skill · 6900 installs

## Other versions with the same name
- [sql-database-assistant · alirezarezvani](https://affpapa.org/en/nevibecode/skills/sql-database-assistant.md) — 727 installs

From the same set: [borghei/claude-skills](https://affpapa.org/en/nevibecode/by/borghei/claude-skills.md) — 120 cards

---
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
