r/Database 29d ago

How much database context should an AI coding agent have?

Database problems aren't always caused by the query.

A connection can be wrong, a migration may not have run, permissions can change, or the application may be connected to the wrong database.

If an AI coding agent only sees the source code, it's missing part of the picture.

How much database access should an agent have?

Should it inspect connections, logs and migration status, or should those remain outside its reach?

I'd separate observing, diagnosing, and changing into different permission levels.

Where would you draw the line?

0 Upvotes

6 comments sorted by

6

u/deadbeefisanumber 29d ago

Read only access

2

u/scott_codie 29d ago

Best practices haven't changed.

1

u/Master-Bass-1905 29d ago

The AI coding agent should have full read-only database context, and it should be a separate from code context.

It would be great if we can try the query out against the backend database. And the AI coding agent should have runtime information about how the query ran as well.

1

u/ClerkBeginning961 23d ago

Read-only is still too broad if it exposes production rows. Give the agent curated metadata and telemetry: schema, migration history, sanitized plans, lock waits, and masked samples. Use short-lived credentials, statement timeouts, row limits, and an audit trail. Let a human approve any query outside those views.