mysql-cli: Instructions file for Codex

AGENTS.md

mysql-cli AGENTS.md is an instructions file for Codex, OpenCode from AllenMuu/mysql-cli. It costs 2,779 tokens per session, scanned A, original, MIT.

A project guide for a Go command-line tool that lets AI agents query and modify MySQL databases through shell commands. MySQL is a database system, and a command-line tool is operated by typing commands rather than using a graphical interface.

In plain words
What is it for?
Use it when building, testing, reviewing, or extending the MySQL CLI. It covers compilation, static checks, unit tests, coverage, integration tests, database queries, and repository skill checks.
Why use it?
It explains the project’s command structure, layered design, output format, and testing rules so changes remain predictable for agents and users. It also distinguishes local unit tests from integration tests that need a real MySQL container.

Instructions file for CodexOpenCode

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

This is AllenMuu/mysql-cli's own configuration. It tells Codex and OpenCode how to work on mysql-cli 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 mysql-cli configures →

Reuse

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.

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

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 mysql-cli AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/allenmuu/mysql-cli/agents-md/github.svg)](https://agentmods.dev/instructions/allenmuu/mysql-cli/agents-md)
Your own site
<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.

agentmods 80×15 button for mysql-cli AGENTS.md

Your own site · 80×15
<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>
Per session 2,779 This file is loaded in full into every session.
When invoked 2,779 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.02779 $0.02779
Opus 5.5 $0.01112 $0.01112
Sonnet 5.5 $0.00556 $0.00556
Haiku 4.5 $0.00278 $0.00278

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

Security

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.

AGENTS.md · 92 lines

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。

Read the full file on GitHub · 92 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. 2mo ago Changed · +51 tokens per session b2e666ca17e7
  2. 2mo ago First seen · 92 lines · 2,728 tokens per session scan A acec484d6253

Subscribe to this mod's changes

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.

Related

mysql-cli AGENTS.md compared with instructions from other repositories

mysql-cli AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
mysql-cli AGENTS.mdAllenMuu/mysql-cliInstructions file42mo agoMITA2,779Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,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