AgentLayer▸docs
Connect it

Database

Read-only Postgres queries and schema for the databases you name, plus a scratch copy of a local database for risky schema work.

The Database pack lets your agent look inside your Postgres databases: list them, read their schema, and run queries that cannot write. Ask in plain words: "what tables does the app database have?", "how many orders came in this week?".

What it gives you

Three read tools: database_list shows your connections with host, port and database name, never credentials; database_schema reads a schema; database_query runs a query. A fourth, database_fork, makes a scratch copy of a local database.

Two guards keep reads safe:

  • Postgres itself rejects writes. Every query runs inside a BEGIN READ ONLY transaction with a statement timeout and is rolled back.
  • Secret values stay out of the conversation. A column holding keys, tokens or passwords is checked with aggregates only (count(col), a count of its nulls, min(length(col))). It is never selected, grouped by or cut with substring.

What it needs

A Postgres connection string for each database. There is no account to create and no cost. For tighter control, point the connection string at a role that can only SELECT.

Switch it on

Run the walk

Run configure-skills and pick Database. It grants the four tools and asks for a short name for each database, such as app or analytics. The name is only a label.

Add the connection strings in your editor

A connection string holds a password, so it goes in <HOME>/.state/secrets/.env, never in chat. Each AGENT_DB_<NAME> line becomes a connection called <name>:

AGENT_DB_APP=postgres://user:pass@localhost:5432/app_dev
AGENT_DB_ANALYTICS=postgres://user:pass@host:5432/analytics

A name is written in capitals with anything but letters and digits as _, so read-replica is AGENT_DB_READ_REPLICA.

Relaunch and check

Start your host again from the home, then ask "list my databases". To add a database later, add another line and relaunch.

A scratch copy for risky changes

database_fork clones a local database with CREATE DATABASE <fork> TEMPLATE <source>: pure SQL, no dump files. Run a destructive schema change against the copy and the original is untouched.

  • It refuses remote hosts.
  • It names the fork after the current branch.
  • It can repoint an env file at the fork.
  • drop: true removes the fork.

Where it's used

  • Worktrees: setup-worktree uses database_fork to give a worktree its own database.
  • Reach and see: the capability group this pack belongs to.
  • MCP tools: each tool in one line.

On this page