xsql: Instructions file for Codex

AGENTS.md

xsql AGENTS.md is an instructions file for Codex, OpenCode from zx06/xsql. It costs 2,593 tokens per session, scanned A, original, MIT.

Project instructions for xsql, a command-line tool that connects to MySQL and PostgreSQL databases and is designed to produce predictable output for AI agents.

In plain words
What is it for?
Guiding database commands, configuration, SSH connections, machine-readable output, and the tool's internal Go architecture.
Why use it?
They require changes to follow the project's documentation and preserve stable output and error codes.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md; mentions Codex.

This is zx06/xsql's own configuration. It tells Codex and OpenCode how to work on xsql itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything xsql configures →

View source ↗ zx06/xsql
Reuse

Borrowing it

Nothing to install: this file belongs to zx06/xsql. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/zx06/xsql/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/zx06/xsql

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for xsql AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/zx06/xsql/agents-md/github.svg)](https://agentmods.dev/instructions/zx06/xsql/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/zx06/xsql/agents-md"><img src="https://agentmods.dev/badge/instructions/zx06/xsql/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for xsql AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/zx06/xsql/agents-md"><img src="https://agentmods.dev/badge/instructions/zx06/xsql/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 2,593 This file is loaded in full into every session.
When invoked 2,593 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What 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.

ModelPer sessionOnce invoked
Fable 5.1 $0.02593 $0.02593
Opus 5.5 $0.01037 $0.01037
Sonnet 5.5 $0.00519 $0.00519
Haiku 4.5 $0.00259 $0.00259

Measured 2d ago against content hash e3d63e4be745, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 2d ago.

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.

AGENTS.md · 181 lines

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.md
  • docs/cli-spec.md
  • docs/error-contract.md
  • docs/config.md
  • docs/env.md
  • docs/db.md
  • docs/ssh-proxy.md
  • docs/ai.md
  • docs/rfcs/ - RFC 文档目录

若实现与文档冲突:优先更新文档并说明原因,再实现。

强约束(Docs/RFC-first):

  • 以文档为准:实现必须与 docs/* 一致。
  • 方案发生变化必须先改文档:任何会改变对外行为/契约/架构的变更,必须先通过文档(建议用 RFC)明确。
  • 实现不得领先于文档:合并时必须保证"文档与实现一致"。
  • RFC 维护位置:docs/rfcs/(见 docs/rfcs/README.md)。

3. 架构与目录约束(不要越界)

推荐结构(实现时请遵循):

  • cmd/xsql:CLI 入口(只做参数解析、调用 app、输出)
  • internal/app:应用编排(核心入口,供 MCP/Web 等复用)
  • internal/config:配置加载/合并/校验 + profile
  • internal/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)。
  • 新增错误码:
    1. 先在文档与代码的错误码表登记
    2. 保持向后兼容(只增不改、不复用旧含义)

5. 配置/ENV/CLI 合并规则(强约束)

  • 优先级:CLI > ENV > Config。
  • ENV 前缀:XSQL_。
  • Secrets:默认使用 OS keyring;config 明文仅作为可选能力(详见 docs/config.md)。
  • 不允许在日志/错误 details 中输出明文密码/私钥内容。

6. 数据库与只读策略(强约束)

  • 目标数据库:MySQL + PostgreSQL。
  • 可扩展性:通过 driver registry 扩展新 DB。
  • 默认只读:防止误操作,默认启用双重只读保护(SQL 静态分析 + 数据库事务级只读)。
  • CLI / MCP 写入双重授权:profile 必须配置 unsafe_allow_write: true,且当前 query 命令或 mcp server 必须同时携带 --unsafe-allow-write(或 XSQL_MCP_UNSAFE_ALLOW_WRITE=true);任一条件缺失都保持只读。Web 始终强制只读。
  • AI 调用标记:Codex 发起的 xsql CLI 调用必须携带 --attr source=codex-cli,建议同时追加 agent、env、team、task 等 attr;其他 AI 客户端应使用自己的稳定 source 值,且不得覆盖 source。
  • 只读拦截必须返回明确错误码(退出码=4)。

Read the full file on GitHub · 181 lines

Changes

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.

  1. 2d ago Changed · +31 tokens per session e3d63e4be745
  2. 29d ago Changed · -7 tokens per session af02d06de853
  3. 2mo ago First seen · 181 lines · 2,569 tokens per session scan A 85f81642f288

Subscribe to this mod's changes

xsql AGENTS.md is an instructions file published in the GitHub repository zx06/xsql (7 stars, last pushed 3d ago), licensed MIT. It adds 2,593 tokens to every session, about $0.0104 per session on Opus 5.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.

Related

xsql AGENTS.md compared with instructions from other repositories

xsql AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
xsql AGENTS.mdzx06/xsqlInstructions file73d agoMITA2,593Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,649GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
vscode ai-customization.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA1,907GitHub Copilot