Skip to main content

postgres-query

Run PostgreSQL queries for testing, debugging, and performance analysis. Use when you need to query the database directly, run EXPLAIN ANALYZE, compare query results, or test SQL optimizations. Always uses read-only connections unless explicitly directed otherwise. Use when this capability is needed.

跳到安装

来源信息

仓库
tomevault-io/tomes
最近来源活动
2026年7月23日 21:48
检测到的 SKILL.md 语言
英语
星标
1
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
postgres-query
description
Run PostgreSQL queries for testing, debugging, and performance analysis. Use when you need to query the database directly, run EXPLAIN ANALYZE, compare query results, or test SQL optimizations. Always uses read-only connections unless explicitly directed otherwise. Use when this capability is needed.
metadata
{"author":"civitai"}
# PostgreSQL Query Testing Use this skill to run ad-hoc PostgreSQL queries for testing, debugging, and performance analysis. ## Running Queries Use the included query script: ```bash node .claude/skills/postgres-query/query.mjs "SELECT * FROM \"User\" LIMIT 5" ``` ### Options | Flag | Description | |------|-------------| | `--explain` | Run EXPLAIN ANALYZE on the query | | `--writable` | Use primary database instead of read replica (requires user permission) | | `--timeout <s>`, `-t` | Query timeout in seconds (default: 30) | | `--file`, `-f` | Read query from a file | | `--json` | Output results as JSON | | `--quiet`, `-q` | Minimal output, only results | ### Examples ```bash # Simple query node .claude/skills/postgres-query/query.mjs "SELECT id, username FROM \"User\" LIMIT 5" # Check query performance node .claude/skills/postgres-query/query.mjs --explain "SELECT * FROM \"Model\" WHERE id = 1" # Override default 30s timeout for longer queries node .claude/skills/postgres-query/query.mjs --timeout 60 "SELECT ... (complex query)" # Query from file node .claude/skills/postgres-query/query.mjs -f my-query.sql # JSON output for processing node .claude/skills/postgres-query/query.mjs --json "SELECT id, username FROM \"User\" LIMIT 3" ``` ## Safety Features 1. **Read-only by default**: Uses `DATABASE_REPLICA_URL` to prevent accidental writes 2. **Write protection**: Blocks INSERT/UPDATE/DELETE/DROP unless `--writable` flag is used 3. **Explicit permission required**: Before using `--writable`, you MUST ask the user for permission ## When to Use --writable Only use the `--writable` flag when: - The user explicitly requests write access - You need to test write operations - You're verifying transaction behavior **IMPORTANT**: Always ask the user for permission before running with `--writable`. ## Comparing Query Performance To compare two query approaches: ```bash # Run first approach node .claude/skills/postgres-query/query.mjs --explain "SELECT ... (approach 1)" # Run second approach node .claude/skills/postgres-query/query.mjs --explain "SELECT ... (approach 2)" # Compare actual results node .claude/skills/postgres-query/query.mjs --json "SELECT ... (approach 1)" > /tmp/q1.json node .claude/skills/postgres-query/query.mjs --json "SELECT ... (approach 2)" > /tmp/q2.json ``` ## Verifying Index Usage Run with `--explain` and look for: - **Good**: "Index Scan", "Bitmap Index Scan", "Index Only Scan" - **Bad**: "Seq Scan" on large tables (indicates missing or unused index) ```bash node .claude/skills/postgres-query/query.mjs --explain "SELECT * FROM \"Account\" WHERE provider = 'discord'" ``` --- > Converted and distributed by [TomeVault](https://tomevault.io/claim/civitai) — claim your Tome and manage your conversions. <!-- tomevault:4.0:skill_md:2026-04-11 -->
在 GitHub 查看