Borrowing it
Nothing to install: this file belongs to AllenMuu/mysql-cli. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/AllenMuu/mysql-cli/main/AGENTS.mdgit clone --depth 1 https://github.com/AllenMuu/mysql-cliWrote 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.
[](https://agentmods.dev/instructions/allenmuu/mysql-cli/agents-md)<a href="https://agentmods.dev/instructions/allenmuu/mysql-cli/agents-md"><img src="https://agentmods.dev/badge/instructions/allenmuu/mysql-cli/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.
<a href="https://agentmods.dev/instructions/allenmuu/mysql-cli/agents-md"><img src="https://agentmods.dev/badge/instructions/allenmuu/mysql-cli/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.02779 | $0.02779 |
| Opus 5.5 | $0.01112 | $0.01112 |
| Sonnet 5.5 | $0.00556 | $0.00556 |
| Haiku 4.5 | $0.00278 | $0.00278 |
Grade A, and why
mysql-cli 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 2mo 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.
How it starts
The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.
This file provides guidance to AI agents when working with code in this repository.
项目定位
Go 实现的 MySQL CLI,目标是替代 designcomputer/mysql_mcp_server:把原 MCP 的全部只读/写能力下沉为命令行子命令,让任何能跑 shell 的 AI agent(Claude Code / Cursor / Codex / Aider)无需 MCP runtime 即可查询 MySQL。设计前提是 agent 是首要调用方(默认 JSON 输出、稳定退出码),REPL 仅供人类调试,不是主路径。
常用命令
go build ./... # 编译
go vet ./... # 静态检查
go test ./... # 单元测试(默认,136 用例,全部用 sqlmock,无需 DB)
go test ./internal/query/ -run TestApplyLimit -v # 跑单个测试
go test -cover ./... # 覆盖率(项目目标 ≥80%,历史区间 81%~92%)
go test -coverprofile=cover.out ./... && go tool cover -func=cover.out # 覆盖率明细
./scripts/skill-format-check.sh skills/ # 校验 SKILL.md frontmatter
./scripts/skill-format-check/test.sh # skill-format-check 自测(good/bad 用例)
集成测试需要真实 MySQL,用 testcontainers-go 起 mysql:8 容器,默认跳过:
RUN_INTEGRATION=1 go test -tags=integration ./internal/integration/ -v
internal/integration/integration_test.go 带 //go:build integration 构建标签,且 TestMain 在 RUN_INTEGRATION 未设置时直接 os.Exit(m.Run()) 跳过容器初始化。Docker 未运行时不要开此变量。
架构(分层与依赖方向)
包严格单向依赖,result 是无依赖底层,避免循环引用:
cmd/mysql-cli/main -> cli(cobra 装配 + 退出码映射 + config 子命令)
↓
config ─-> conn ─-> query ─-> result
│ │ └─-> safety(无依赖,纯逻辑)
│ └─-> schema ─-> result/safety
└─ env/file 解析 repl(聚合 query+schema+format)
format ← result
result- 共享Result{Columns, Rows, RowsAffected, LastInsertID},是 query/schema(生产者)与 format/cli(消费者)之间的中立契约。safety- 纯逻辑、零依赖、完全可单测。SQL 分类(read/dml/ddl/unknown)、只读闸门、标识符校验、多语句检测、破坏性操作识别。改动安全模型时只动这里。config- TOML 命名数据源 +MYSQL_*环境变量兼容(零配置迁移自原 MCP)。解析优先级:CLI flag > env > file > default(见Resolve)。密码支持${ENV}占位符展开。conn- 由config.Datasource渲染 go-sql-driver DSN 并开连接池;SSH 隧道在Open前建立,DSN 指向本地转发端口。Pool.Close先关隧道再关*sql.DB(生命周期绑定,见下)。query-Execute(读,走QueryContext)、ExecuteWrite(单条 DML/DDL,包在事务里提交)、ExecuteTxn(多条原子事务)。每条语句都过 safety 闸门 + 多语句检测。schema- 只读探索命令(schema/sample/tables/databases/read/explore/analyze),对应原 MCP 的get_schema_info/get_table_sample/list_resources/read_resource。所有标识符在拼接 SQL 前经safety.Validate*校验。format-result.Result-> json/table/csv/tsv;JSON 严格信封{success,data,error:{code,message}}。cli- cobra 子命令 + 全局 flag +mapError把核心 error 翻译成退出码;含config子命令(init/list/global/project)。repl- readline 交互壳,仅人类调试用,复用 query/schema/format。
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.
- 2mo ago Changed · +51 tokens per session b2e666ca17e7
- 2mo ago First seen · 92 lines · 2,728 tokens per session scan A acec484d6253
mysql-cli AGENTS.md is an instructions file published in the GitHub repository AllenMuu/mysql-cli (4 stars, last pushed 2mo ago), licensed MIT. It adds 2,779 tokens to every session, about $0.0111 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.
mysql-cli AGENTS.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| mysql-cli AGENTS.mdAllenMuu/mysql-cli | Instructions file | 4 | 2mo ago | MIT | A | 2,779 | Codex, OpenCode |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 9,719 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 143k | today | MIT | A | 7,461 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 5,649 | GitHub Copilot |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 149k | today | MIT | A | 4,680 | Codex, OpenCode |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 3,093 | GitHub Copilot |
| vscode ai-customization.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 1,907 | GitHub Copilot |