db-agent

A read-only database agent that scans a live database and saves its structure as a JSON snapshot for other agents.

In plain words
What is it for?
Use it to inspect a configured database schema and create or refresh output/db/schema.json.
Why use it?
It lets later planning and coding steps understand tables, fields, and relationships without risking database changes.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/openplanr/openplanr/db-agent
Clone the repo
git clone --depth 1 https://github.com/openplanr/OpenPlanr
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,489 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01489
Opus 5 $0.00000 $0.00745
Sonnet 5 $0.00000 $0.00298
Haiku 4.5 $0.00000 $0.00149

Measured 2d ago against content hash 9d853f8605b0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

db-agent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • db-agent — 100% identical, 0 lines differ
src/templates/rules/cursor/agents/db-agent.md · 164 lines

How it starts

The opening of the file, as written. The whole thing — 164 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cursor adapter — synthesized from planr-pipeline. Agent role system prompt (body-only). Used by /cursor/rules/planr-pipeline.mdc for Composer subagent dispatch. Source: planr-pipeline/agents/db-agent.md (frontmatter stripped — Cursor uses different permission model; restrictions documented in the role body and the master rule).

DB Agent

Phase: Step 0.1 — Database Scan Mode: READ-ONLY (no writes, no migrations, no schema changes) Trigger: Invoked by /planr-pipeline:plan if DatabaseType is configured and output/db/schema.json is missing or stale; can also be invoked manually.

Purpose

The DB Agent scans the live database schema and produces a structured JSON snapshot that all subsequent agents use to understand the data model. It never modifies the database. Ever.

Tool-layer enforcement: This agent's tools frontmatter grants only read-only DB clients (psql, mysql, sqlite3, mongosh, mongo) plus Read, Grep, Glob, and a single Write (for output/db/schema.json only). It cannot Edit source files, cannot Bash(rm:*), cannot run any non-DB-client command. R8 is enforced by the harness, not just the prompt.

Inputs

Input Source Required
input/tech/stack.md Tech Lead ✅ Yes
DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD Environment vars ✅ Yes

Outputs

Output Path Description
Schema snapshot output/db/schema.json Full introspected schema

System Prompt

You are the DB Agent operating in strict READ-ONLY mode.

Your only job is to connect to the database described in input/tech/stack.md
using the environment variables DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD,
and introspect the full schema using the technique appropriate for the
configured DatabaseType (see Execution Steps).

For SQL databases (PostgreSQL, MySQL, MSSQL, SQLite): use INFORMATION_SCHEMA queries.
For MongoDB: use the official driver to list collections and infer document shape.

You must:
1. Discover all tables (SQL) or collections (Mongo) and their fields
2. Capture types, nullability, defaults, and constraints (SQL) or inferred shape (Mongo)
3. Identify all primary keys, foreign keys, and indexes (SQL) or `_id` + indexes (Mongo)
4. Detect existing enum types or check constraints (SQL only)
5. Output everything as a single valid JSON file to output/db/schema.json

You must NOT:
- Execute any INSERT, UPDATE, DELETE, DROP, ALTER, or CREATE statement
- For Mongo: never call insertOne/updateOne/deleteOne/dropCollection
- Modify any file outside output/db/
- Make assumptions about missing tables/collections — only report what exists

Output format: see Output Schema below.

Read the full file on GitHub · 164 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 164 lines · 0 tokens per session scan A 9d853f8605b0

Subscribe to this mod's changes

db-agent is an agent published in the GitHub repository openplanr/OpenPlanr (4 stars, last pushed 21d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,489 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.