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.
npx agentmods add instructions/zx06/xsql/agents-mdgit clone --depth 1 https://github.com/zx06/xsqlWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.02569 | $0.02569 |
| Opus 5 | $0.01285 | $0.01285 |
| Sonnet 5 | $0.00514 | $0.00514 |
| Haiku 4.5 | $0.00257 | $0.00257 |
Grade A, and why
xsql AGENTS.md 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 yesterday.
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.
How it starts
The opening of the file, as written. The whole thing — 181 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
本文件用于指导 AI agent / 自动化代码生成工具在 xsql 项目中进行一致、可维护、可扩展的开发。
1. 项目定位(必须理解)
- xsql:AI-first 的跨数据库 CLI 工具(Golang)。
- 核心目标:
- 对 AI/agent 友好:稳定的机器可读输出、稳定错误码/退出码、可导出 tool spec。
- 支持 MySQL/PostgreSQL,且 driver 架构可扩展。
- 支持 Go 内实现 SSH proxy(driver 自定义 dial,必要时回退本地端口转发)。
任何改动都不得破坏既定的输出契约与错误码稳定性。
2. 文档是事实来源(Source of Truth)
实现前先阅读:
docs/architecture.mddocs/cli-spec.mddocs/error-contract.mddocs/config.mddocs/env.mddocs/db.mddocs/ssh-proxy.mddocs/ai.mddocs/rfcs/- RFC 文档目录
若实现与文档冲突:优先更新文档并说明原因,再实现。
强约束(Docs/RFC-first):
- 以文档为准:实现必须与
docs/*一致。 - 方案发生变化必须先改文档:任何会改变对外行为/契约/架构的变更,必须先通过文档(建议用 RFC)明确。
- 实现不得领先于文档:合并时必须保证"文档与实现一致"。
- RFC 维护位置:
docs/rfcs/(见docs/rfcs/README.md)。
3. 架构与目录约束(不要越界)
推荐结构(实现时请遵循):
cmd/xsql:CLI 入口(只做参数解析、调用 app、输出)internal/app:应用编排(核心入口,供未来 MCP/TUI/Web 复用)internal/config:配置加载/合并/校验 + profileinternal/secret:keyring/加密/明文兼容internal/db:driver registry + 执行引擎internal/mcp:MCP Server 实现internal/ssh:SSH proxy(driver dial/端口转发)+ ssh_config(可选)internal/output:json/yaml/table/csv + 流式写internal/errors:错误码/退出码/结构化错误internal/spec:tool spec 导出
强制规则:
- 核心逻辑不得依赖 CLI 框架类型(cobra 的 Command 等不应出现在 internal)。
- 输出/日志严格分流:stdout=数据,stderr=日志。
4. AI-first 输出与错误契约(强约束)
4.1 输出
- 成功:
{"ok":true,...} - 失败:
{"ok":false,"error":{"code":"...","message":"...","details":{...}}} - 非 TTY 默认 JSON;TTY 默认 table(详见
docs/cli-spec.md)。
4.2 错误码与退出码
- 必须集中在
internal/errors维护(单一来源)。 - 退出码建议:0/2/3/4/5/10(详见
docs/cli-spec.md)。 - 新增错误码:
- 先在文档与代码的错误码表登记
- 保持向后兼容(只增不改、不复用旧含义)
5. 配置/ENV/CLI 合并规则(强约束)
- 优先级:CLI > ENV > Config。
- ENV 前缀:
XSQL_。 - Secrets:默认使用 OS keyring;config 明文仅作为可选能力(详见
docs/config.md)。 - 不允许在日志/错误 details 中输出明文密码/私钥内容。
6. 数据库与只读策略(强约束)
- 目标数据库:MySQL + PostgreSQL。
- 可扩展性:通过 driver registry 扩展新 DB。
- 默认只读:防止误操作,默认启用双重只读保护(SQL 静态分析 + 数据库事务级只读)。
- CLI 写入双重授权:profile 必须配置
unsafe_allow_write: true,且当前query/ai命令必须同时携带--unsafe-allow-write;任一条件缺失都保持只读。 - AI 调用标记:Codex 发起的 xsql CLI 调用必须携带
--attr source=codex-cli,建议同时追加agent、env、team、task等 attr;其他 AI 客户端应使用自己的稳定 source 值,且不得覆盖 source。 - 只读拦截必须返回明确错误码(退出码=4)。
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.
- yesterday First seen · 181 lines · 2,569 tokens per session scan A 85f81642f288
xsql AGENTS.md is an instructions file published in the GitHub repository zx06/xsql (7 stars, last pushed 4d ago), licensed MIT. It adds 2,569 tokens to every session, about $0.0128 per session on Opus 5. 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.
Other instructions, from other repositories
graphjin AGENTS.md
Instructions for dosco/graphjin, covering graphjin agent guide, architectural overview, directory structure & responsibilities, build commands and coding guidelines.
sqlglot AGENTS.md
Instructions for tobymao/sqlglot, covering contributing to sqlglot, about sqlglot, development commands, installation and basic installation.
whodb AGENTS.md
Instructions for clidey/whodb, covering whodb development guide, git commits — hard rule, terminology, non-negotiable rules and behavioral guidelines.
spiceai copilot-instructions.md
Instructions for spiceai/spiceai, covering spice.ai agent instructions, data correctness — absolute top priority, evidence — no claim without a reproduction, build, test, lint (expensive — read first) and git & prs.
sq AGENTS.md
Instructions for neilotoole/sq, covering agents.md, about sq, key documents, common commands and conventions.
chdb AGENTS.md
Instructions for chdb-io/chdb, covering agents.md — chdb, 1. fully lazy execution architecture, 2. natural execution triggering (explicit calls prohibited), 3. unified architecture, simplicity first and 4. testing principles.