Ghost: A Database for Our Times?

I recently encountered a product that appears to be tailor-made for AI-related applications. Ghost, developed by ghost.build, positions itself as “the first database built for agents.”

Ghost is an “agent-first” Postgres database platform designed to empower developers and AI agents to create, fork, inspect, query, manipulate, and delete entire databases effortlessly. Remarkably, it is completely free to use.

The creators of Ghost operated under a straightforward premise: if agents are tasked with building software, testing migrations, inspecting schemas, running SQL, and experimenting with data, they require databases that are as disposable and programmable as code sandboxes. Ghost fulfills this requirement seamlessly.

When a user creates a Ghost database or forks an existing one, these databases are hosted on Ghost’s Cloud infrastructure, rather than on local machines. This makes Ghost particularly advantageous for testing, prototyping, agent workflows, branch databases, migration experiments, and disposable database environments.

In contrast to traditional managed databases, which are structured around long-lived production infrastructure, Ghost allows for a more dynamic approach. Users can create databases on demand, fork them for isolated copies, execute SQL queries, inspect schemas, experiment with different table configurations, and discard them when finished.

This flexibility makes Ghost an ideal companion for AI tools such as Codex and Claude Code. These tools can reason about code, write migrations, debug queries, generate seed data, inspect logs, and utilize MCP tools. Ghost’s integrated MCP server provides Codex with direct database management capabilities, eliminating the need for vague instructions, copied connection strings, or manual dashboard operations.

N.B. I have no affiliation or association with the company or team behind Ghost or the Ghost product itself.

Prerequisites

Before diving into the installation process, ensure you have one of Ghost’s supported coding agents installed on your system. These include:

Claude Code
Codex
Cursor
Gemini CLI
Google Antigravity
Kiro CLI
VS Code
Windsurf

Additionally, a GitHub account is necessary, as you will need to grant Ghost access during the login process.

Installing Ghost

For users on Linux, WSL on Windows, or macOS, the installation can be initiated with the following curl command:

$ curl -fsSL https://install.ghost.build | sh

If you are using Windows, execute this command in a PowerShell terminal:

PS C:Usersthoma> irm https://install.ghost.build/install.ps1 | iex

Then, log in by running:

PS C:Usersthoma> ghost login

Opening browser for authentication...
Found space: nj5scy2orp
Successfully logged in as [email protected]

Upon successful login, you will see a screen prompting you to authorize Ghost to proceed.

After logging in, the next step is to make the Ghost MCP server accessible to your preferred coding agent. For instance, if you are using Codex, enter the following command and select your agent from the list:

PS C:Usersthoma> ghost mcp install

Select an MCP client to configure:
  1. Claude Code
> 2. Codex
  3. Cursor
  4. Gemini CLI
  5. Google Antigravity
  6. Kiro CLI
  7. VS Code
  8. Windsurf

Typing: 2
Successfully installed Ghost MCP server configuration for codex
Configuration file: C:Usersthoma.codexconfig.toml

Next steps:
   1. Restart codex to load the new configuration
   2. The Ghost MCP server will be available as 'ghost'

PS C:Usersthoma>

Check that your setup is OK

  • To verify that the Ghost MCP is installed correctly, enter the following command:
PS C:Usersthoma> ghost mcp list

TYPE    NAME
prompt  design-postgis-tables
prompt  design-postgres-tables
prompt  find-hypertable-candidates
prompt  migrate-postgres-tables-to-hypertables
prompt  pgvector-semantic-search
prompt  postgres
prompt  postgres-hybrid-text-search
prompt  setup-timescaledb-hypertables
tool    ghost_connect
tool    ghost_create
tool    ghost_create_dedicated
tool    ghost_delete
tool    ghost_feedback
tool    ghost_fork
tool    ghost_fork_dedicated
tool    ghost_list
tool    ghost_login
tool    ghost_logs
tool    ghost_password
tool    ghost_pause
tool    ghost_rename
tool    ghost_resume
tool    ghost_schema
tool    ghost_sql
tool    ghost_status
tool    search_docs
tool    view_skill

Next, confirm that your agent can utilize the Ghost MCP server. You should see output similar to this (for Codex):

PS C:Usersthoma> codex mcp list

Name   Command                                                Args       Env  Cwd  Status   Auth
ghost  C:UsersthomaAppDataLocalProgramsGhostghost.exe  mcp start  -    -    enabled  Unsupported

If everything checks out, we can proceed to explore practical examples of using Ghost via its CLI and agents through the MCP server.

Example 1 — Creating a sales data database

Open your coding agent and input the following command:

Codex> Create a ghost database called sales_data that stores 10,000 dummy sales 
records. In the database, create whichever tables are suitable for such 
data. Do not include any indexes, primary or foreign keys for now.

The output from Codex was as follows:

Worked for 1m 32s
Created a fresh Ghost database named sales_data.

It contains 10,000 dummy sales order records and supporting tables:

customers           1,000
products            150
sales_reps          30
sales_orders        10,000
sales_order_items   30,000
Per your instruction, I did not create any:

primary keys
foreign keys
indexes

Verification confirmed there are no primary key constraints, no foreign key 
constraints, and no indexes on the sales tables.

This process took just over a minute and a half, showcasing the efficiency of Ghost.

Example 2 — Using the Ghost CLI

Now that we have a database at our disposal, let’s explore some Ghost CLI commands. While these commands are typically unnecessary since Codex and the Ghost MCP can handle most tasks, it’s beneficial to understand their functionality.

  • To list the databases, enter:
PS C:Usersthoma> ghost list

ID          NAME        STATUS   STORAGE
sip3qcs40a  sales_data  running  211MiB
  • To view the database tables and structure, use:
$ curl -fsSL https://install.ghost.build | sh

0

  • To select data from the sales_order table, execute:
$ curl -fsSL https://install.ghost.build | sh

1

  • Concerned about your agent potentially damaging your database? You can easily set your system to read-only:
$ curl -fsSL https://install.ghost.build | sh

2

A plethora of useful commands are available with the Ghost CLI. For a comprehensive list, simply type ghost — help into your command line.

However, as previously mentioned, one of the primary advantages of Ghost is the ability to manipulate databases using an AI agent. Let’s demonstrate this capability in action.

Example 3 — Using the Ghost MCP with our agent

We previously observed how swiftly a database can be created using Codex. Now, let’s illustrate how easy it is to experiment with databases using an agent.

  • To add 500,000 records to the sales_order_items table, input:
$ curl -fsSL https://install.ghost.build | sh

3

  • To select data from the sales_order_id table, use:
$ curl -fsSL https://install.ghost.build | sh

4

  • For performance tuning, execute:
$ curl -fsSL https://install.ghost.build | sh

5

The performance improvement after applying tuning was significant, showcasing a remarkable +200x enhancement in query runtime.

Example 4 — Building a dashboard app for our database

This example illustrates the seamless integration of an app developed with coding agents and a database constructed with the same tools.

$ curl -fsSL https://install.ghost.build | sh

6

Upon clicking the HTML link generated, I was greeted with a dynamic dashboard that accurately responded to various filter values.

Image by Author

Summary

Through these examples, the capabilities of Ghost’s database have been effectively showcased, highlighting its potential for rapid database manipulation and experimentation.

One of the standout features of Ghost is the ease with which users can conduct what-if scenarios with real databases. Whether you need to create multiple copies of an existing database for testing or modify indexes and primary keys, Ghost simplifies the process through natural language commands with your preferred coding agents, while still offering CLI options for more complex needs.

As demonstrated in the final example, Ghost’s compatibility with agentic coding tools facilitates the development of applications that integrate seamlessly with Ghost databases, enabling the creation of useful tools such as dashboards and other SaaS applications.

While it may be prudent to exercise caution before storing production data on Ghost, it serves as an excellent platform for proofs of concept and general experimentation. Once a satisfactory database structure is established using Ghost, replicating that structure in a production environment should be straightforward.

For further information on utilizing Ghost and accessing comprehensive documentation, please visit the official homepage: https://ghost.build/docs/#introduction.

Tech Optimizer
Ghost: A Database for Our Times?