Skip to content
Agent Memory
Skill

/postgres-adopt

Detect which gbrain engine is in use (PGLite vs Postgres), prefer Postgres for agent-harness installs, install/provision Postgres (Supabase discovery via SUPABASE_ACCESS_TOKEN, local Postgres, opt-in Docker), and move an existing PGLite brain to Postgres with its history (plan,

From plugin
gbrain
33k80 skills

Claude Code

$ npx -y skills add garrytan/gbrain --skill postgres-adopt --agent claude-code

SKILL.md

postgres-adopt.SKILL.md
name: postgres-adopt
description: |
  Detect which gbrain engine is in use (PGLite vs Postgres), prefer Postgres
  for agent-harness installs, install/provision Postgres (Supabase discovery
  via SUPABASE_ACCESS_TOKEN, local Postgres, opt-in Docker), and move an
  existing PGLite brain to Postgres with its history (plan, ask, run).
  Detection is one engine-free command; the install ladder is one flag.
triggers:
  - "which gbrain engine"
  - "pglite or postgres"
  - "gbrain engine status"
  - "upgrade to postgres"
  - "switch gbrain to postgres"
  - "install postgres for gbrain"
  - "move my brain to supabase"
  - "set up postgres for the brain"
tools:
  - exec
mutating: true
brain_first: exempt

Postgres Adopt

> The engine is the brain's foundation: PGLite is the zero-config floor, > Postgres is where concurrency, multi-machine access, and 1000+ pages live. > This skill answers "which one am I on?", prefers Postgres when the > operator wants it, and moves data safely — never by flipping config.

Contract

This skill guarantees:

  • Detection is engine-free and read-only: `gbrain engine status --json`

answers with the database down (that is the point of the command).

  • Engine changes NEVER happen by editing config. A PGLite brain moves with

`gbrain migrate --to postgres` (alias `--to supabase`), which graduates it: plan first (exit 3), run only with the user's `--yes --expect <plan_hash>`, verify every table, then flip routing. This skill wraps it; it never reimplements it.

  • The target URL never appears in a command, transcript or output: it lives

in `GBRAIN_TARGET_URL` and every command uses `--url-env GBRAIN_TARGET_URL`.

  • Provisioning consent is explicit: the docker rung needs `--allow-docker`,

creating a database on a local server needs `--allow-create-db`. Headless mutation of infrastructure the operator didn't opt into never happens.

Step 1 — Detect

gbrain engine status --json

Branch on the output:

  • `effective_engine: "postgres"` and (optionally) `--probe` says ok →

report healthy, done.

  • `effective_engine: "postgres"` but the probe fails → this is an ACCESS

problem, not an adoption problem: route to [db-repair](../db-repair/SKILL.md).

  • `config_file_engine` differs from `effective_engine` → an env URL is

overriding the config file; tell the operator which one wins — the signal is `db_url_source` (`env:GBRAIN_DATABASE_URL` / `env:DATABASE_URL` means env wins; `env.note` additionally fires when both env URLs are set or the cwd-.env shadow guard excluded one).

  • `thin_client: true` → the brain lives on a remote server; engine choices

belong to that host. Stop.

  • `effective_engine: null` (no brain) → Step 2.
  • `effective_engine: "pglite"` with data → Step 3.
  • The output has a `graduation` block whose `state` is not `none` (in progress,

interrupted, graduated or split) → Step 4.

Step 2 — Fresh install, Postgres-first

gbrain init --prefer-postgres

The ladder tries, in order: an env URL → Supabase Management-API discovery (`SUPABASE_ACCESS_TOKEN`, plus `SUPABASE_PROJECT_REF` on multi-project accounts and `SUPABASE_DB_PASSWORD` for the connection string) → a local Postgres (only when `PGHOST`/`PGPORT`/`PGUSER`/`PGPASSWORD` are set or `--local-postgres` is passed) → docker → PGLite. Each unusable rung prints a one-line note and falls through; nothing is silent.

  • Ask the operator BEFORE adding `--allow-docker` (it creates and owns a

`gbrain-postgres` container that survives reboots) or `--allow-create-db` (it runs CREATE DATABASE on their local server).

  • `--json` reports `{engine, ladder_rung, url_source}` — relay which rung won.
  • If the ladder lands on PGLite, that is a fine outcome: say so, and note the

upgrade path below is available whenever they want it.

Step 3 — Existing PGLite brain: plan, ask, run

Full reference: [Move a PGLite brain to Postgres](https://github.com/garrytan/gbrain/blob/master/docs/guides/move-to-postgres.md).

1. **Target URL.** Ask the user to put the connection string in an environment variable without pasting it into the conversation (`read -rs GBRAIN_TARGET_URL && export GBRAIN_TARGET_URL`). On Supabase use the transaction pooler; on an IPv4-only host also set `GBRAIN_DIRECT_DATABASE_URL` to the session pooler. 2. **Plan.** This changes nothing and exits 3 with the `confirmation_required` document:

   gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json

Relay `user_message`, what moves, what stays on this computer, blockers and the estimate. Stop and wait for the user. A blocker with its own `fix` gets cleared first (ask when it says `ask_user`). 3. **Run, after the user agrees.** Use `fix.command` from the document:

   gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>

`preview_changed` means the plan changed: go back to step 2. For thousands of pages run it in the background and poll `gbrain migrate --status --json`. 4. **Report.** Relay the target doctor verdict from the run's output, that existing tokens, OAuth clients and local writers stay valid, the `gbrain mcp expose` follow-up for other machines, and, if a serve handed the brain over, that the user restarts the MCP client.

  • A `gbrain serve` holding the brain hands it over on its own; never ask the

user to stop it first. `graduation_source_writer_held` names the process to stop when one does not.

  • The old data dir is kept as `<path>.graduated-<run_id>` (doctor's

`pglite_leftovers` reports it). Deleting it is the user's call.

  • `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages and points at

the plan command — that warning is this skill's cue.

Step 4 — A move already underway

gbrain migrate --status --json

It is read-only and names the next command for the state. Exit 75 or a run in progress → wait and poll. Interrupted → `gbrain migrate --resume` (or `g

Read more
@garrytan
Ships withgbrain

Garry's Opinionated OpenClaw/Hermes Agent Brain

Stars on GitHub

Momentum

stars in total
33.0k
Star history of garrytan/gbrain on GitHub, a chart by star-history.com

Other skills on gbrain.

brain-ingest-gate

brain-ingest-gate

Pre-write quality gate for content entering the brain. No raw copies: a bare cp/mv into the brain repo is a bug. Before any new…

@garrytan@garrytanInstall Skill
brain-link-discipline

brain-link-discipline

When you report a brain page to the user — created, edited, committed, or relayed from a subagent — a working link is part of the…

@garrytan@garrytanInstall Skill
brain-ops

brain-ops

Brain knowledge base operations. The core read/write cycle: brain-first lookup, read-enrich-write loop, source attribution,…

@garrytan@garrytanInstall Skill
concept-synthesis

concept-synthesis

Deduplicate and synthesize raw concept stubs into a tiered intellectual map (T1 Canon to T4 Riff), tracing idea evolution across…

@garrytan@garrytanInstall Skill
context-audit

context-audit

Token-hygiene audit of the always-loaded context stack — CLAUDE.md, AGENTS.md, auto-memory MEMORY.md, and the bootstrap-rendered…

@garrytan@garrytanInstall Skill
correction-pipeline

correction-pipeline

When the user corrects a factual error, root-cause it immediately. Don't just note the correction — trace the error to its…

@garrytan@garrytanInstall Skill

More skills from other plugins.

agent-cost-report

agent-cost-report

Believable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude…

@thedotmack@thedotmackInstall Skill
bot-handoff

bot-handoff

Keep a durable record of work passed between Bots in the shared Hindsight memory bank. Use when handing work to another Bot, when…

@vectorize-io@vectorize-ioInstall Skill
mempalace

mempalace

Install, configure, and operate MemPalace, including a private local palace, a shared-brain hub, or a client joining an existing…

@mempalace@mempalaceInstall Skill
mempalace

mempalace

Install, configure, and operate MemPalace, including a private local palace, a shared-brain hub, or a client joining an existing…

@milla-jovovich@milla-jovovichInstall Skill

Questions about postgres-adopt.

Which coding agents can use postgres-adopt?
postgres-adopt installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.