Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
414de9b
Add postgres-database-migration skill
cevian Apr 8, 2026
f18e94c
Add ghost-database skill and update postgres router
cevian Apr 8, 2026
1901d87
Fix Ghost billing description: Spaces are containers, not tiers
cevian Apr 8, 2026
c2ae4c6
Remove ghost pause: databases auto-pause after 30 days idle
cevian Apr 9, 2026
80b5783
Remove MCP tool names from ghost-database keywords
cevian Apr 9, 2026
c6346eb
Add MCP read-only mode section and ghost config to CLI reference
cevian Apr 9, 2026
48c743c
Remove private GitHub repo link from ghost-database skill
cevian Apr 9, 2026
a807b4f
Add all installation methods: macOS/Linux, Windows, Debian, Red Hat
cevian Apr 9, 2026
d908022
Fix examples to use database IDs instead of names
cevian Apr 9, 2026
2067705
Complete CLI command reference with all ghost commands
cevian Apr 9, 2026
8651b95
Add view_skill to MCP tools table
cevian Apr 9, 2026
74b7f2f
Fix DROP INDEX CONCURRENTLY lock level description
cevian Apr 9, 2026
6020b33
Add NOWAIT as alternative retry pattern for high-traffic systems
cevian Apr 9, 2026
deb2973
Note fork-testing limitation and recommend PgDog for high-uptime apps
cevian Apr 9, 2026
3e06975
Warn that EXPLAIN ANALYZE executes the statement, wrap in ROLLBACK
cevian Apr 9, 2026
fe67d78
Improve ghost-database skill with MCP tool calls and share workflow
cevian May 20, 2026
78107b3
Clarify forking works from dedicated to on-demand instances
cevian May 21, 2026
60c4d55
Expand ghost-database skill description and trigger conditions
cevian May 21, 2026
2656a2a
Address PR review: use name_or_id in ghost commands and examples
cevian Jun 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
259 changes: 259 additions & 0 deletions skills/ghost-database/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
---
name: ghost-database
description: |
Use this skill for persistent PostgreSQL storage in agent workflows — spin up databases on demand, test schema migrations safely on forks, and pass databases as assets between agents using Ghost.

**Trigger when user asks to:**
- Create a new PostgreSQL database quickly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need "quickly" here?

- Manage database lifecycle in agent workflows
- Fork a database to test changes safely
- Run analytics or heavy queries on a fork without impacting the production database
- Share a database snapshot so others can spin up their own copy
- Pass a database as an input or output between agents
- Create a database for agents
- Need many databases that are billed only when queried
- Set up the Ghost MCP server or CLI

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the Ghost MCP currently proxies the pg-aiguide MCP tools (including view_skill), are we at all concerned that this skill could create confusion for agents that are already using the Ghost MCP?

Like, if a user asks to fork a database, how will the agent decide between using this skill (which mostly recommends using ghost CLI commands directly, which is not really what we want if the MCP is installed) or just calling the ghost_fork tool? Maybe it would use the skill first and then still decide to call the MCP tool afterwards... but even in that case, using the skill would just be extra wasted tokens (the Ghost MCP is already self-describing, so if it's already installed, I don't think there's much more that this skill would help with, beyond maybe explaining some of the less well-documented features).

It seems like this skill is mostly geared towards setting up Ghost the first time and understanding its capabilities (e.g. when evaluating whether to use it). But if Ghost is already installed (as MCP server), I feel like this skill could potentially be counter-productive.

Any ideas for what we should do about that? We could potentially just filter this skill out when we proxy the view_skill tool, but we don't do anything like that currently (we proxy the tools as-is), and in any case, it wouldn't work for pre-existing versions of Ghost that are already in the wild.


**Note:** If the Ghost MCP server is already installed, use its tools directly — this skill is for environments without the MCP or as a reference for what's possible.

**Keywords:** Ghost, ghost.build, database, create database, fork database, PostgreSQL, managed Postgres, MCP, agent database, connection string
license: Apache-2.0
metadata:
author: tigerdata
---

# Ghost Database Management

Ghost is a managed PostgreSQL service designed for agents. Your account is organized into Spaces, each with unlimited on-demand databases and forks sharing a pool of compute hours (billed in 15-minute chunks when queries are executed). Free tier: 100 hours/month, 1TB storage.

When you need continuous operation, promote any database to a **dedicated instance** — a separately billed, always-on database.

Additional features:
- **CLI and MCP native:** create and query databases from the terminal or any MCP-compatible agent
- **Instant forking:** full database copies in seconds for safe experimentation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were avoiding "instant", since few people consider 90s to be instantaneous.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Instant forking:** full database copies in seconds for safe experimentation
- **Zero-copy forking:** full database copies in seconds for safe experimentation

- **Shareable snapshots:** share a database snapshot via URL — anyone with the link can spin up their own copy in their own space
- **MCP read-only mode:** `ghost config set read_only true` locks all MCP tools into read-only — SQL queries execute in read-only mode and destructive tools (`ghost_delete`, `ghost_password`, `ghost_rename`) are blocked

Website: https://ghost.build

## Installation

Multiple installation methods are provided. If you aren't sure, use the first one.

### Install Script (macOS/Linux/WSL)

```bash
curl -fsSL https://install.ghost.build | sh
```
Comment thread
cevian marked this conversation as resolved.

### Install Script (Windows PowerShell)

```powershell
irm https://install.ghost.build/install.ps1 | iex
```

### Debian/Ubuntu

```bash
curl -s https://packagecloud.io/install/repositories/timescale/ghost/script.deb.sh | sudo os=any dist=any bash
sudo apt-get install ghost
```

### Red Hat/Fedora

```bash
curl -s https://packagecloud.io/install/repositories/timescale/ghost/script.rpm.sh | sudo os=rpm_any dist=rpm_any bash
sudo yum install ghost
```
Comment on lines +39 to +67

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this skill could benefit from some progressive disclosure, and this section in particular seems like it'd usually be a waste of tokens. You only need to install ghost once.

@nathanjcochran nathanjcochran Apr 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I think maybe we should try to decide whether this skill is mostly for getting Ghost set up the first time (in which case maybe listing all of the installation methods here is fine), or if we think it's useful as a continual reference for how to use Ghost. Personally, I'm kind of skeptical that it's going to be helpful once Ghost is already installed (since the MCP is self-describing anyways, and this skill would just be a conflicting source of information). See my other comment about that. I think maybe we should try to narrow in on exactly how/when we want this skill to be used, because I'm a little concerned that this skill could end up taking priority over using the Ghost MCP tools directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's fair. I agree this skill is redundant with the MCP tools, and the skill description over-promises on what it is for in a way that could be problematic.

I kinda think there should be a "choosing a db provider" skill, and then possibly an "installing ghost" sub-page.


## Getting Started

**CLI**
```bash
ghost login # Authenticate with GitHub
ghost create # Create a new database (returns an ID, e.g. abc123)
ghost list # List all databases with their IDs
ghost connect <name-or-id> # Get connection string
```

**MCP**
```
ghost_login() // Authenticate with GitHub
ghost_create({ name: "my-db" }) // → returns { id: "abc123", ... }
ghost_list() // List all databases with their IDs
ghost_connect({ name_or_id: "abc123" }) // Get connection string
```

## Core Workflows

### Create and Query a Database

**CLI**
```bash
# Create a database (returns an ID like abc123)
ghost create my-app-db

# Run SQL directly
ghost sql abc123 "CREATE TABLE users (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, email TEXT NOT NULL UNIQUE, created_at TIMESTAMPTZ NOT NULL DEFAULT now())"

# Query it
ghost sql abc123 "SELECT * FROM users"

# Open interactive psql session
ghost psql abc123
Comment on lines +102 to +103

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to say that this requires psql to be installed and in your PATH

```

**MCP**
```
ghost_create({ name: "my-app-db" })
// → returns { id: "abc123", ... }

ghost_sql({ name_or_id: "abc123", query: "CREATE TABLE users (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, email TEXT NOT NULL UNIQUE, created_at TIMESTAMPTZ NOT NULL DEFAULT now())" })

ghost_sql({ name_or_id: "abc123", query: "SELECT * FROM users" })
```

### Fork for Safe Experimentation

Forking creates a full copy of your database in seconds — same schema, same data. Use forks to test migrations, experiment with schema changes, or let agents explore without risk to your working database. You can fork a dedicated instance into an on-demand instance — useful for testing against a production copy without paying for always-on compute.

For a complete migration testing workflow using forks — including pre/post validation queries and rollback planning — see the `postgres-database-migration` skill.

**CLI**
```bash
# Fork a database (returns the fork's ID, e.g. def456)
ghost fork abc123 my-app-db-experiment

# Test changes on the fork
ghost sql my-app-db-experiment "ALTER TABLE users ADD COLUMN role TEXT NOT NULL DEFAULT 'user'"

# If it worked: apply to original
ghost sql abc123 "ALTER TABLE users ADD COLUMN role TEXT NOT NULL DEFAULT 'user'"

# If it failed: delete the fork, original is untouched
ghost delete my-app-db-experiment --confirm
```

**MCP**
```
ghost_fork({ name_or_id: "abc123", name: "my-app-db-experiment" })
// → returns { id: "def456", ... }

ghost_sql({ name_or_id: "def456", query: "ALTER TABLE users ADD COLUMN role TEXT NOT NULL DEFAULT 'user'" })

// If it worked: apply to original
ghost_sql({ name_or_id: "abc123", query: "ALTER TABLE users ADD COLUMN role TEXT NOT NULL DEFAULT 'user'" })

// If it failed: delete the fork, original is untouched
ghost_delete({ name_or_id: "def456" })
```

### Auto-Pause and Resume

Databases automatically pause after 30 days of idle time to conserve compute hours. Storage is retained. Resume a paused database when you need it again:

**CLI**
```bash
ghost resume abc123 --wait
```

**MCP**
```
ghost_resume({ name_or_id: "abc123" })
```

### Inspect Schema

**CLI**
```bash
ghost schema abc123
```

**MCP**
```
ghost_schema({ name_or_id: "abc123" })
```

Returns an LLM-optimized schema representation of all tables, columns, indexes, and constraints.

### Share a Database

Sharing creates a snapshot anyone can use to spin up their own copy — no access to your space required. Useful for sharing sample datasets, bug reproductions, or starter databases.

Agents can also use shares as a way to pass databases as assets: an agent can produce a database as output by sharing it (handing the recipient a URL to spin up their own copy), or accept a share token as input to start from a pre-populated database.

**CLI**
```bash
# Share a database (returns a share URL)
ghost share abc123

# Share with an expiry
ghost share abc123 --expires 24h

# Recipient creates their own database from the share token
ghost create --from-share <token>

# Manage shares
ghost share list abc123
ghost share revoke <token>
```

**MCP**
```
ghost_share({ name_or_id: "abc123" })
// → returns { share_token: "...", url: "..." }

ghost_share({ name_or_id: "abc123", expires: "24h" })

// Recipient creates their own database from the share token
ghost_create({ from_share: "<token>" })

// Manage shares
ghost_share_list()
ghost_share_revoke({ share_token: "<token>" })
```

## CLI Command Reference

For a full list of commands and flags, run:

```bash
ghost --help
ghost <command> --help # e.g. ghost create --help
```

## MCP Integration

The Ghost MCP server gives agents full database lifecycle control — create, fork, query, inspect, resume, and delete databases without human intervention.

### Install the MCP Server

```bash
ghost mcp install
```

Supports: Claude Code, Cursor, Windsurf, Codex, Gemini, VS Code, Kiro.

### MCP Read-Only Mode

To give agents safe read-only access, enable read-only mode before starting the MCP server:

```bash
ghost config set read_only true
```

This locks all MCP tools into read-only: `ghost_sql` executes queries in read-only mode, and destructive tools (`ghost_delete`, `ghost_password`, `ghost_rename`) are blocked entirely.


## When to Use Ghost

**Good fit:**
- Persistent Postgres storage for agent workflows
- Giving each agent or even agentic execution a dedicated database
- Creating and discarding databases freely without cost anxiety
- Database forking for safe experimentation and migration testing
- Hard spending caps with predictable billing (compute hours in 15-minute chunks)

**Not the right fit:**
- You need a web dashboard (Ghost is CLI/MCP only)
- You need non-Postgres databases
Loading
Loading