DEV Community

Cover image for So, I gave my coding agent direct database access...
Spencer Pauly
Spencer Pauly

Posted on

So, I gave my coding agent direct database access...

I've been connecting my coding agent to everything: Datadog logs, Linear, Slack. But, still get bottlenecked at the database.

I'll be debugging. The LLM can read the stack trace, make a ticket, scan the codebase, but can't introspect the database. So I can't prove what happened in the data.

At some point I hacked together a repo on my laptop. It generated SQL and talked to the database for me. And it worked better than I expected.

But, It also made me nervous.

Credentials sitting around, no real story for who could run what, no audit trail I could point at if something went sideways. I kept using it for a week and felt worse about it each day.

I wanted the same speed without the part where I pretend that's fine.

So I ended up with something I think is pretty cool. I call it querybear. It's a wrapper around my databse to make it AI agent friendly. It adds read-only access, row-level permissions, timeout enforcement, rate limiting, audit trails, schema introspection, and memory with long-living context.

And it's amazing! I can tell my agent to dive into anything and it can go digging around my data with no risk of misuse.
I know it's a weird pattern but I truly think it's the future.

Anyone else done similar?

Top comments (0)