Skip to content
DIGITO
← All playbooks

Playbook · Builders whose AI coding agent can reach a real database

Let an AI agent near your database: read-only first, changes by review

A one-page rules file your agent reads before every session, a read-only login for it, and a short list of commands that never run without your yes.

  • No code
  • Your details stay with you
  • Free AI tools
read-only login just for the agent
1read-only login just for the agent
changes to the live database without your yes
0changes to the live database without your yes
rules, written once, read every session
6rules, written once, read every session

DIGITO ·

Maintained by DIGITO bot

An AI coding agent with database access can fix a report in a minute. It can also run a command that empties a table, or one that locks it while customers are trying to buy, and then tell you the task went well. Green tests do not prove the live data is fine, because tests rarely run against the live data.

The rules here come from how DIGITO's own site is built with agents: every production change goes through a pull request, the main branch refuses direct pushes, and the live site only updates when a build that runs the site's tests passes. The same idea works for a database. Let the agent read freely on a login that cannot write, make changes on a copy, and keep a short list of commands that only run after a person says yes.

01

What changes

Today

  • The agent connects with your own admin login.
  • It tries changes on the live data.
  • You learn what it did from its summary.

After this playbook

  • The agent reads on a login that cannot change anything.
  • Changes run on a copy, then go live through a review.
  • You check the real database, not the agent's report.
02

Six rules before the first query

  1. 1

    Back up and test the restore

    Take a backup before the agent connects, then restore it once to a scratch database. A backup you have never restored is a hope, not a backup.

  2. 2

    Give the agent its own read-only login

    Create a database user that can only read, and give the agent that one. In PostgreSQL that is a role granted SELECT and nothing else. Never share your admin login.

  3. 3

    Make changes on a copy

    Any change runs first on a staging copy with the same structure. The agent can be bold there; the live data never sees a first try.

  4. 4

    List the commands that wait for your yes

    DELETE, UPDATE, DROP, TRUNCATE, ALTER and new indexes on large tables. In PostgreSQL a normal CREATE INDEX blocks writes to the table until it finishes; CREATE INDEX CONCURRENTLY avoids that but takes longer and cannot run inside a transaction.

  5. 5

    Ship changes as reviewed files

    Database changes go live as migration files in a pull request, read by a person, the same way code does. No live edits from a chat.

  6. 6

    Check the database, not the summary

    After a run, look at row counts, the migration log and the table that changed. If the agent's report and the database disagree, the database is right.

03

Build your database house rules

Change the details. The prompt updates as you type. Copy it into ChatGPT, Claude or Gemini.

Your prompt

Write a one-page house rules file for an AI coding agent that can reach my database. Write it in English, in plain words, as a list the agent must follow every session.

Database: PostgreSQL on a hosted service, one production and one staging database
The agent may read: all tables except customers and payments
The agent may change: schema and test data on staging only
Commands that always wait for my yes: DELETE, UPDATE, DROP, TRUNCATE, ALTER, CREATE INDEX on tables over 1 million rows
Backups: nightly backup; restore tested on Nov 1

Include these sections: allowed, ask first, never. Add a rule that the agent stops and asks if a command could lock a table, change many rows or delete data, and a rule that it reports what it actually ran, command by command. End with a three-question test I can give the agent to check that it follows the file.

Nothing you type here is sent anywhere. It stays in this page until you paste it.

04

Paste it into the AI you already use

  1. 1Open chatgpt.com or the ChatGPT app and start a new chat.
  2. 2Paste the prompt and send it.
  3. 3Ask it to point out any command in your ask-first list that your database runs differently from PostgreSQL.
  4. 4Save the rules in the project and run the three-question test before the agent gets any database access.
05

Done when

0 / 4 done

Ticks are not saved. Reloading the page clears them.

06

Questions

Is read-only access enough to be safe?

It removes the worst risks: the agent cannot delete or change data. Heavy read queries can still slow a busy database, so point it at a replica or a copy when you can.

My agent says it needs write access to finish. Now what?

Give write access on the staging copy, not the live database. If the change works there, it goes live as a reviewed migration.

Does this only apply to PostgreSQL?

No. The rules are the same for MySQL, SQL Server or SQLite. Only the commands that lock tables differ, so check your database's own documentation for the ask-first list.

Where the numbers come from

  • PostgreSQL 18 documentation: CREATE INDEX

    Official docs. A standard index build locks the table against inserts, updates and deletes until it finishes; CONCURRENTLY avoids that lock, takes significantly longer, cannot run inside a transaction block and can leave an invalid index if it fails. Read Nov 17, 2026.

Next up, picked by DIGITO bot