Db mysql

From evolution-foundation/evo-nexus · View interactive version

Db mysql is an AI agent skill from the GitHub repository evolution-foundation/evo-nexus. Query MySQL / MariaDB databases configured in .env (DB_MYSQL_N_*). Use when the user asks to query, explore, or audit data in a MySQL database. Picks connection by label (e.g. 'orders-dev', 'analytics-prod') or numeric index. Read-only by default — writes refused unless DB_MYSQL_N_ALLOW_WRITE=true o

How to use this skill

Skill file

db-mysql

Query MySQL / MariaDB databases declared in .env. Connections follow the same numbered pattern as SOCIAL_YOUTUBE_N_* / SOCIAL_INSTAGRAM_N_* — one block per database, labelled for humans, picked by label or index at call time.

Setup — one-time, per database

Add a block to .env (gitignored). Increment the index per connection:

# ── MySQL: orders-dev ────────────────────────────────
DB_MYSQL_1_LABEL=orders-dev
DB_MYSQL_1_HOST=mysql.dev.internal
DB_MYSQL_1_PORT=3306
DB_MYSQL_1_DATABASE=orders
DB_MYSQL_1_USER=agent_readonly
DB_MYSQL_1_PASSWORD=...                # raw; .env is gitignored
# DB_MYSQL_1_SSL_CA_PATH=/path/ca.pem  # optional, enables TLS verification
# DB_MYSQL_1_ALLOW_WRITE=false         # default false
# DB_MYSQL_1_QUERY_TIMEOUT=30          # seconds, default 30
# DB_MYSQL_1_MAX_ROWS=1000             # default 1000

Alternative — full DSN instead of components (DSN wins when both are set):

DB_MYSQL_2_LABEL=analytics-prod
DB_MYSQL_2_DSN=mysql://agent_ro:***@analytics.prod.internal:3306/analytics

LABEL is always required — it's how agents pick the connection.

Usage

All commands output a single JSON line on stdout (safe to pipe). Errors go to stderr as JSON and exit non-zero.

List configured connections

python3 .claude/skills/db-mysql/scripts/db_client.py accounts

Health-check a connection

python3 .claude/skills/db-mysql/scripts/db_client.py test orders-dev

Run a read-only query

python3 .claude/skills/db-mysql/scripts/db_client.py query orders-dev \
  "SELECT count(*) FROM customers WHERE created_at > now() - interval 7 day"

Explore schema

# List all tables (excludes mysql/information_schema/performance_schema/sys)
python3 .claude/skills/db-mysql/scripts/db_client.py tables orders-dev

# Describe a table
python3 .claude/skills/db-mysql/scripts/db_client.py describe orders-dev customers
# Schema-qualified:
python3 .claude/skills/db-mysql/scripts/db_client.py describe orders-dev analytics.events

Output shape

Successful query:

{
  "ok": true,
  "query_id": "uuid-v4",
  "label": "orders-dev",
  "columns": ["id", "email", "created_at"],
  "rows": [[1, "a@b.com", "2026-04-22 12:00:00"]],
  "row_count": 1,
  "truncated": false,
  "full_result_path": null,
  "execution_time_ms": 12
}

When rows exceed MAX_ROWS, truncated is true and full_result_path points to a CSV in ADWs/logs/db-queries/<query_id>.csv — the agent can read that file directly instead of re-running.

Error:

{"ok": false, "error_code": "write_blocked", "error": "Write query blocked — connection 'orders-dev' has ALLOW_WRITE=false. ...", "label": "orders-dev"}

Error codes:

Guardrails

Workflow

  1. If the user doesn't specify a label, run accounts to see what's configured and pick the one that matches their intent. If ambiguous, ask.
  2. Write the smallest SQL that answers the question — prefer aggregates, LIMIT, and EXPLAIN before dumping rows.
  3. Run via query. Inspect the result.
  4. For performance-sensitive queries, load the deep-dive references below.

Dependencies

Deep-dive references

These load the PlanetScale database-skills repo verbatim — same content the upstream authors ship for their own tooling.

Upstream: planetscale/database-skills (MIT). Credit to PlanetScale for the reference content.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.