db-managerBLOCK
Claude Code skill for safe PostgreSQL access from project .env files
Overview
From the repository's own README, as read at the audited commit. Badges and raw HTML are left out.
[](https://github.com/jeanpfs/db-manager/actions/workflows/ci.yml) [](./LICENSE) [](https://github.com/jeanpfs/db-manager/releases)
A Claude Code skill for safe PostgreSQL access from project .env files.
The skill auto-detects DATABASE_URL in your project's .env files, lets the agent run psql against the right environment, and gates destructive operations behind an explicit confirmation protocol.
Features
- Auto-discovers
.env,.env.local,.env.development,.env.staging,.env.productionwithDATABASE_URL/DB_URL/POSTGRES_URL - Per-project session keyed by working directory, stored under
~/.cache/db-manager/with mode600 - Session file holds only the path to the
.envand a label — never the URL itself - Mandatory schema inspection (
\d) before generating SQL - Strict confirmation block for any mutation (
INSERT,UPDATE,DELETE,DROP,ALTER,EXPLAIN ANALYZE, etc.) - Extra
CONFIRM PRODUCTIONlock when the label containsprod - Audit log of every confirmed destructive operation
Requirements
- Claude Code (skills are loaded from
~/.claude/skills/) bash≥ 4psqlandpg_dump(PostgreSQL client tools)find,grep,cut,head,printf,mktemp,install,chmodsha256sum(Linux) orshasum(macOS) — the snippets fall back automatically
Tested on macOS 14+ and Ubuntu 22.04+. CI runs on ubuntu-latest and macos-latest.
Install
git clone https://github.com/jeanpfs/db-manager.git cd db-manager ./install.sh
This copies SKILL.md, LICENSE, README.md and references/ into ~/.claude/skills/db-manager/. Exi
b5623b57df89OBSERVED · 2026-10-14Install
Commands as the repository documents them. They are shown, not run.
git clone https://github.com/jeanpfs/db-manager.git
git clone https://github.com/jeanpfs/db-manager.git
Host compatibility
What the documentation claims. We have not run a compatibility test.
| Host | Status | Notes |
|---|---|---|
| claude-code | mentioned |
What it tells the agent
The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.
---
name: db-manager
description: >
Use when the user asks to query a database, run SQL, check tables, inspect schema,
connect to PostgreSQL, switch database environments, or any task involving database
access (SELECT, INSERT, UPDATE, DELETE, pg_dump, psql). Also use when starting a
session in a project that has .env files with DATABASE_URL. Triggers: "query the
database", "run this SQL", "show me the tables", "check the schema", "connect to
the database", "switch to staging/production", "list the tables", "describe schema",
"what's in the database", "show data from".
argument-hint: "[SQL query or command]"
license: MIT
allowed-tools: Bash(psql *), Bash(pg_dump *), Bash(grep *), Bash(echo *), Bash(printf *), Bash(mkdir *), Bash(chmod *), Bash(test *), Bash(shasum *), Bash(sha256sum *), Bash(find *), Bash(cut *), Bash(head *), Bash(basename *), Bash(tr *), Bash(sed *), Bash(date *), Bash(install *), Read, Grep, Glob, Write, Edit
---
# DB Manager — PostgreSQL Direct Access
## Session status
!`SESSION_DIR="${HOME}/.cache/db-manager"; if command -v sha256sum >/dev/null 2>&1; then SESSION_KEY=$(printf %s "$PWD" | sha256sum | cut -c1-16); else SESSION_KEY=$(printf %s "$PWD" | shasum -a 256 | cut -c1-16); fi; SESSION_FILE="${SESSION_DIR}/session_${SESSION_KEY}"; if [ -f "$SESSION_FILE" ] && [ ! -L "$SESSION_FILE" ]; then DB_LABEL=$(grep '^DB_LABEL=' "$SESSION_FILE" | cut -d= -f2-); DB_SOURCE=$(grep '^DB_SOURCE=' "$SESSION_FILE" | cut -d= -f2-); echo "CONNECTED: ${DB_LABEL} (source: ${DB_SOURCE})"; else echo "NO_SESSION"; fi`
> Hash helper used throughout: `sha256sum` on Linux, `shasum -a 256` on macOS — both produce the same hex digest, the snippets fall back automatically.
## Core principle
Read `DATABASE_URL` from project `.env` files only when needed. The session file stores **only metadata** (path to the `.env` and a label) — never the URL itself. Never `source` the session file: it is data, not code.
## Session setup (only if NO_SESSION)
1. Find `.env` files with `DATABASE_URL` in the project:
```bash
find . \( -name ".env" -o -name ".env.local" -o -name ".env.development" -o -name ".env.dev" \
-o -name ".env.staging" -o -name ".env.production" \) \
-not -path "*/node_modules/*" -not -path "*/.git/*" 2>/dev/null | while read -r f; do
match=$(grep -E "^(DATABASE_URL|DB_URL|POSTGRES_URL)=" "$f" 2>/dev/null | head -1)
[ -n "$match" ] && echo "$f"
done
```
2. If multiple found, ask the user which one. If only one, use it.
3. Save session metadata under `~/.cache/db-manager/` (mode `600`):
```bash
ENV_PATH="<selected .env>"
PROJECT=$(basename "$PWD" | tr -cd 'a-zA-Z0-9._-')
LABEL_SUFFIX="<dev|staging|production|...>"
SESSION_DIR="${HOME}/.cache/db-manager"
mkdir -p "$SESSION_DIR" && chmod 700 "$SESSION_DIR"
if command -v sha256sum >/dev/null 2>&1; then
SESSION_KEY=$(printf %s "$PWD" | sha256sum | cut -c1-16)
else
SESSION_KEY=$(printf %s "$PWD" | shasum -a 256 | cut -c1-16)
fi
SESSION_FILE="${SESSION_DIR}/session_${SESSION_KEY}"
if [ -L "$SESSION_FILE" ]; then
echo "REFUSING: session path is a symlink"; exit 1
fi
umask 077
{
printf 'DB_ENV_PATH=%s\n' "$ENV_PATH"
printf 'DB_LABEL=%s/%s\n' "$PROJECT" "$LABEL_SUFFIX"
printf 'DB_SOURCE=%s\n' "$ENV_PATH"
} > "$SESSION_FILE"
chmod 600 "$SESSION_FILE"
```
4. Test the connection without persisting the URL:
```bash
DB_URL=$(grep -E "^(DATABASE_URL|DB_URL|POSTGRES_URL)=" "$ENV_PATH" | head -1 | cut -d= -f2-)
DB_URL="${DB_URL%\"}"; DB_URL="${DB_URL#\"}"
DB_URL="${DB_URL%\'}"; DB_URL="${DB_URL#\'}"
psql "$DB_URL" -c "SELECT 1" >/dev/null 2>&1 && echo "Connected" || echo "FAILED"
```
## Running queries
Re-read the URL from the `.env` referenced by the session every time — never persist it:
```bash
SESSION_DIR="${HOME}/.cache/db-manager"
if command -v sha256sum >/dev/null 2>&1; then
SESSION_KEY=$(printf %s "$PWD" | sha256sum | cut -c1-16)
else
SESSION_KEY=$(printf %s "$PWD" | shasum -a 256 | cut -c1-16)
fi
SESSION_FILE="${SESSION_DIR}/session_${SESSION_KEY}"
ENV_PATH=$(grep '^DB_ENV_PATH=' "$SESSION_FILE" | cut -d= -f2-)
DB_URL=$(grep -E "^(DATABASE_URL|DB_URL|POSTGRES_URL)=" "$ENV_PATH" | head -1 | cut -d= -f2-)
DB_URL="${DB_URL%\"}"; DB_URL="${DB_URL#\"}"
DB_URL="${DB_URL%\'}"; DB_URL="${DB_URL#\'}"
psql "$DB_URL" -c "SELECT ..."
```
> Note on argv exposure: PostgreSQL connection URIs as the first positional argument to `psql` may be visible in `/proc/<pid>/cmdline` on Linux while the process runs. For higher assurance, configure `~/.pgpass` (mode `600`) and pass only host/db/user instead of the full URL.
## Query protocol — MANDATORY
**NEVER guess column names.** Before writing any SELECT, INSERT, UPDATE, or DELETE:
1. Run `\d tablename` for each table involved
2. Only then write SQL using the actual column names
**Exceptions:**
- Table already inspected earlier in the same conversation
- User provides the exact SQL to run
## Destructive operations
For destructive operations, follow the mandatory confirmation protocol in [security-rules.md](references/security-rules.md). **Never skip confirmation.**
## Schema dump (opt-in)
Only when the user explicitly asks:
```bash
ENV_PATH=$(grep '^DB_ENV_PATH=' "$SESSION_FILE" | cut -d= -f2-)
DB_URL=$(grep -E "^(DATABASE_URL|DB_URL|POSTGRES_URL)=" "$ENV_PATH" | head -1 | cut -d= -f2-)
DB_URL="${DB_URL%\"}"; DB_URL="${DB_URL#\"}"
DB_URL="${DB_URL%\'}"; DB_URL="${DB_URL#\'}"
mkdir -p docs
pg_dump "$DB_URL" --schema-only --no-owner --no-acl --no-comments > docs/schema.sql
```
## Managing the session
Switch to a different `.env` for the same project:
```bash
# Re-run the "Session setup" steps with a different ENV_PATH; the file is
# overwritten in place under ~/.cache/db-manager/.
```
Forget the current session:
```bash
SESSION_DIR="${HOME}/.cache/db-manager"
if command -v sha256sum >/dev/null 2>&1; then
SESSION_KEY=$(printf %s "$PWD" | sha256sum | cut -c1-16)
else
SESSION_KEY=$(printf %s "$PWD" | shasum -a 256 | cut -c1-16)
fi
rm -f "${SESSIONTrust audit
BLOCKgrade D · trust 69/100 Do not install this without reading the findings. The audit found something that could harm you or your machine.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | PASS |
| L2 | Instruction surface (what it tells the agent) | FAIL |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- none-observed
- Network
- none-observed
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (5)
Read `DATABASE_URL` from project `.env` files only when needed. The session file stores **only metadata** (path to the `.env` and a label) — never the URL itself. Never `source` the session file: it i
Re-read the URL from the `.env` referenced by the session every time — never persist it:
Claude Code skill for safe PostgreSQL access from project .env files
- Per-project sessions stored under `~/.cache/db-manager/` (mode `600`); session metadata only — credentials are re-read from the project `.env` on every query.
A [Claude Code](https://docs.claude.com/en/docs/claude-code) skill for safe PostgreSQL access from project `.env` files.
Gates applied: no_behavioural_pass.
b5623b57df89full audit observations/trust-audit/skill/jeanpfs__db-manager.json · Report an issue / request a re-scanAudit history
Every audit this skill has had.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-14 | b5623b57df89 | BLOCK | D | 69 | first audit |
Questions
What does the db-manager skill do?
Claude Code skill for safe PostgreSQL access from project .env files
Is db-manager safe to install?
No — not without reading the findings first. The audit graded it D (69/100) and found 3 critical or high issues in the source. Each one is listed on this page with the file and line it is on.
What can db-manager access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
Which assistants does db-manager work with?
Its documentation mentions claude-code. That is what the text claims, not a compatibility test we ran.
How current is this page?
The grade is for one exact copy of the source (b5623b57df89), read on 2026-10-14. The repository is watched, and a new audit runs when it changes — this is the first audit.