Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 2 additions & 15 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- **`cmd/`** - Binary entry points. Contains `ghost/main.go` (the main CLI binary, which sets up context/signal handling and delegates to the internal command infrastructure), `npm-publisher/` (a CI tool that generates and publishes npm packages for each platform), and `generate-docs/` (generates Markdown CLI reference docs to `docs/cli/`).
- **`internal/`** - All core application logic (non-public Go packages).
- **`internal/cmd/`** - Cobra command implementations for all CLI commands (create, fork, list, delete, pause, resume, connect, psql, sql, schema, logs, password, pricing, rename, status, feedback, api-key, login, logout, config, mcp, version, upgrade, completion, payment). Each command lives in its own file, named to match the command in snake_case (e.g. `ghost payment list` → `payment_list.go`). Helper files like `completion.go`, `errors.go`, and `logger.go` contain shared utilities. Commands that are not yet ready for public release can be gated behind the `GHOST_EXPERIMENTAL` env var (see `internal/common/app.go`'s `App.Experimental` field).
- **`internal/cmd/`** - Cobra command implementations for all CLI commands (init, create, fork, list, delete, pause, resume, connect, psql, sql, schema, logs, password, pricing, rename, status, feedback, api-key, login, logout, config, mcp, version, upgrade, completion, payment). Each command lives in its own file, named to match the command in snake_case (e.g. `ghost payment list` → `payment_list.go`). Helper files like `completion.go`, `errors.go`, and `logger.go` contain shared utilities. Commands that are not yet ready for public release can be gated behind the `GHOST_EXPERIMENTAL` env var (see `internal/common/app.go`'s `App.Experimental` field).
- **`internal/api/`** - API client layer. Includes an OpenAPI-generated REST client (`client.go`, `types.go`), shared HTTP client singleton, and request/response types. **Do not edit `client.go` or `types.go` by hand** — they are generated from `openapi.yaml` (see [Code Generation](#code-generation)). The `mock/` subdirectory contains a generated mock of `ClientWithResponsesInterface` for use in tests.
- **`internal/config/`** - Configuration management. Handles config file loading (via Viper), credential storage (keyring with file fallback), and version checking.
- **`internal/common/`** - Shared business logic used across commands and MCP tools. Includes API client initialization, database connection/schema/query utilities, error handling with exit codes, and version update checks.
Expand All @@ -18,20 +18,7 @@

## Build & Test

Always run the following after editing Go code:

- Build:
- `go install ./...`
- Format:
- `go fmt ./...`
- Fix:
- `go mod tidy`
- `go fix -omitzero=false ./...`
- Lint:
- `go vet ./...`
- `go tool staticcheck ./...`
- Test:
- `go test ./...`
After editing Go code, run `./check` from the repo root. It runs `go install`, `go fmt`, `go mod tidy`, `go fix`, `go vet`, `staticcheck`, and `go test` in one shot.

## Testing

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ npm install -g @ghost.build/cli
## Usage

```bash
ghost login # Authenticate with GitHub OAuth
ghost mcp install # Install the MCP server
ghost init # Interactively configure Ghost (PATH, login, MCP, completions)
ghost create # Create a new Postgres database
ghost list # List all databases
```
Expand All @@ -68,6 +67,7 @@ ghost list # List all databases
| `fork` | Fork a database |
| `fork dedicated` | Fork a database as dedicated |
| `help` | Help about any command |
| `init` | Interactively configure Ghost |
| `invoice` | View invoices |
| `list` | List all databases |
| `logs` | View logs for a database |
Expand Down
10 changes: 10 additions & 0 deletions check
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -ex

go install ./...
go fmt ./...
go mod tidy
go fix -omitzero=false ./...
go vet ./...
go tool staticcheck ./...
go test ./...
1 change: 1 addition & 0 deletions docs/cli/ghost.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Ghost is a command-line interface for managing PostgreSQL databases.
* [ghost delete](ghost_delete.md) - Delete a database
* [ghost feedback](ghost_feedback.md) - Submit feedback, a bug report, or a support request
* [ghost fork](ghost_fork.md) - Fork a database
* [ghost init](ghost_init.md) - Interactively configure Ghost
* [ghost invoice](ghost_invoice.md) - View invoices
* [ghost list](ghost_list.md) - List all databases
* [ghost login](ghost_login.md) - Authenticate with GitHub OAuth
Expand Down
38 changes: 38 additions & 0 deletions docs/cli/ghost_init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: "ghost init"
slug: "ghost_init"
description: "CLI reference for ghost init"
---

## ghost init

Interactively configure Ghost

### Synopsis

Interactively configure Ghost. Walks through adding Ghost to your PATH, login, MCP server installation, and shell completions.

```
ghost init [flags]
```

### Options

```
-h, --help help for init
--skip-if-configured Exit with a short message if every step is already configured
```

### Options inherited from parent commands

```
--analytics enable/disable usage analytics (default true)
--color enable colored output (default true)
--config-dir string config directory (default "~/.config/ghost")
--version-check check for updates (default true)
```

### SEE ALSO

* [ghost](ghost.md) - CLI for managing Postgres databases
* [ghost init path](ghost_init_path.md) - Add Ghost to your PATH
36 changes: 36 additions & 0 deletions docs/cli/ghost_init_path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "ghost init path"
slug: "ghost_init_path"
description: "CLI reference for ghost init path"
---

## ghost init path

Add Ghost to your PATH

### Synopsis

Add Ghost's install directory to your PATH by appending a snippet to your shell rc file. This command does not prompt for confirmation, so it can be used from scripts.

```
ghost init path [flags]
```

### Options

```
-h, --help help for path
```

### Options inherited from parent commands

```
--analytics enable/disable usage analytics (default true)
--color enable colored output (default true)
--config-dir string config directory (default "~/.config/ghost")
--version-check check for updates (default true)
```

### SEE ALSO

* [ghost init](ghost_init.md) - Interactively configure Ghost
11 changes: 5 additions & 6 deletions docs/cli/ghost_mcp_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ configuration files for the specified client.

Supported Clients:
claude-code Configure for Claude Code
cursor Configure for Cursor
windsurf Configure for Windsurf
codex Configure for Codex
cursor Configure for Cursor
gemini Configure for Gemini CLI
vscode Configure for VS Code
antigravity Configure for Google Antigravity
kiro-cli Configure for Kiro CLI
vscode Configure for VS Code
windsurf Configure for Windsurf

The command will:
- Automatically detect the appropriate configuration file location
Expand All @@ -32,7 +32,7 @@ The command will:
- Merge with existing MCP server configurations (doesn't overwrite other servers)
- Validate the configuration after installation

Pass "all" to configure every supported client. If no client is specified, you'll be prompted to select one interactively.
Pass "all" to configure every supported client. If no client is specified, you'll be prompted to pick one or more clients interactively.

```
ghost mcp install [client] [flags]
Expand All @@ -41,7 +41,7 @@ ghost mcp install [client] [flags]
### Examples

```
# Interactive client selection
# Interactive client selection (multi-select)
ghost mcp install

# Install for Claude Code (User scope - available in all projects)
Expand Down Expand Up @@ -78,4 +78,3 @@ ghost mcp install [client] [flags]
### SEE ALSO

* [ghost mcp](ghost_mcp.md) - Ghost Model Context Protocol (MCP) server

5 changes: 2 additions & 3 deletions docs/cli/ghost_mcp_uninstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Uninstall Ghost MCP server configuration from a client

Uninstall the Ghost MCP server configuration from a supported MCP client.

Pass "all" to uninstall from all supported clients. If no client is specified, you'll be prompted to select one interactively.
Pass "all" to uninstall from all supported clients. If no client is specified, you'll be prompted to select one or more interactively.
Only the Ghost MCP server entry named "ghost" is removed; other MCP server entries are left untouched.

```
Expand All @@ -22,7 +22,7 @@ ghost mcp uninstall [client] [flags]
### Examples

```
# Interactive client selection
# Interactive client selection (multi-select)
ghost mcp uninstall

# Uninstall from Cursor
Expand Down Expand Up @@ -56,4 +56,3 @@ ghost mcp uninstall [client] [flags]
### SEE ALSO

* [ghost mcp](ghost_mcp.md) - Ghost Model Context Protocol (MCP) server

1 change: 0 additions & 1 deletion docs/cli/ghost_pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ ghost pricing [flags]
### SEE ALSO

* [ghost](ghost.md) - CLI for managing Postgres databases

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
golang.org/x/mod v0.35.0
golang.org/x/oauth2 v0.36.0
golang.org/x/sync v0.20.0
golang.org/x/sys v0.43.0
golang.org/x/term v0.42.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -90,7 +91,6 @@ require (
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.36.0 // indirect
golang.org/x/tools v0.43.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading