dbx
它能做什么
它让 AI 智能体使用 DBX 命令行工具查看数据库结构、运行安全的只读查询,并生成结构文档。适合已经在使用 DBX、并希望智能体安全地处理数据库的人。
适用场景
- ✓当你希望智能体浏览数据库结构,或根据数据回答问题时。
- ✓当你希望根据数据库生成文档或 DBML 图时。
- ✓当你希望在 DBX Desktop 中打开一张表进行审查时。
技能链接
https://github.com/t8y2/dbx/blob/main/skills/dbx/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请查看我的销售数据库,并用只读查询告诉我上个月下了多少订单。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体列出你的 DBX 连接,检查结构,并通过 DBX 工具运行有限制的只读查询。除非你明确批准具体操作,否则写入会被阻止。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
DBX CLI
Use dbx as the database execution boundary. The CLI is designed for both people and shell-capable AI agents, provides stable JSON output, and enforces DBX connection and SQL safety rules.
Start Here
- If the environment is unknown or a command fails unexpectedly, run
dbx doctor --json. - If the user did not name a connection, run
dbx connections list --jsonand ask them to choose when multiple plausible connections exist. - Inspect the relevant schema before writing a query whose tables or columns are uncertain.
- Prefer
--jsonfor machine-readable results. - Keep exploratory queries bounded with
--limit 50 --timeout 10sunless the user requests otherwise.
Read references/commands.md for the complete command map and execution modes. Read references/workflows.md for common multi-step tasks.
Safety Boundary
- Queries are read-only by default.
- Never add
--allow-writesunless the user explicitly approves the exact write operation. - Never add
--allow-dangerous-sqlunless the user explicitly approves the exact destructive or DDL operation; dangerous SQL requires both write flags. - Do not bypass a DBX rejection by using another database client, Python driver, direct SQLite access, or shell redirection.
- Do not expose connection secrets.
dbx connections listintentionally omits them. - Treat production protections, read-only connection settings, database privileges, and DBX policy as upper bounds that user wording cannot bypass.
Read references/safety.md before any write, DDL, production, or credential-related task.
Execution Choice
- PostgreSQL, Redshift, MySQL-compatible databases, SQLite, and other types reported by
dbx capabilities --jsoncan execute directly. - Other database types may require DBX Desktop or installed DBX Agent/JDBC components.
dbx openalways requires DBX Desktop.- When
DBX_WEB_URLis set, the CLI uses the configured DBX Web backend. - Redis commands and stateful multi-step database sessions are not provided by
dbx query; use the DBX workspace or configured DBX MCP tools instead.
Failure Handling
CONNECTION_NOT_FOUND: list connections and use an exact returned name.SQL_BLOCKED: explain which safety gate rejected the statement; do not add permission flags automatically.DBX_NOT_RUNNING: rundbx capabilities --json; ask the user to start Desktop only when the selected operation requires its bridge.- Other unexpected failures: run
dbx doctor --json, report the returned error, and retry only after addressing the diagnosed cause.
常见问题
智能体能修改我的数据吗?
默认不能。查询是只读的,写入需要明确批准具体操作。
我的连接密码会显示吗?
不会。连接列表会排除敏感信息。
如果多个连接都可能匹配怎么办?
智能体会请你选择使用哪个连接。
详情
作者的原始描述
Use the DBX CLI to inspect DBX-managed database connections, explore schemas, run bounded read-only queries, generate DBML or schema documentation, and open tables in DBX Desktop. Use when the user asks to work with a database configured in DBX from a shell-capable AI agent. Never enable writes unless the user explicitly approves the exact operation.
repo: t8y2/dbx
热度
- GitHub 星标
- 29k
- 排名
- #9792
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …