diag-mysql-slow-query

diag-mysql-slow-query is a skill for Claude Code, Codex from seed-forge/harness-ai-kit. It costs 82 tokens per session (1,722 once invoked), scanned A, original, Apache-2.0.

A runbook for finding why MySQL database queries are slow. It examines slow-query records and execution plans, which show how MySQL carries out a query.

In plain words
What is it for?
Use it to inspect MySQL 5.7 or newer, review slow-query logs and performance data, run EXPLAIN checks, and produce a report with optimization suggestions.
Why use it?
It turns vague reports such as slow pages or timeouts into a list of the slowest query patterns and likely causes. These can include missing indexes, reading whole tables, large result sets or lock waits.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to inspect MySQL 5.7 or newer, review slow-query logs and performance data, run EXPLAIN checks, and produce a report with optimization suggestions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/seed-forge/harness-ai-kit/diag-mysql-slow-query
Install

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.

Any agent
npx skills add seed-forge/harness-ai-kit --skill diag-mysql-slow-query
Clone the repo
git clone --depth 1 https://github.com/seed-forge/harness-ai-kit

Made for: Claude Code, Codex.

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 diag-mysql-slow-query

README.md
[![agentmods](https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/diag-mysql-slow-query/github.svg)](https://agentmods.dev/skills/seed-forge/harness-ai-kit/diag-mysql-slow-query)
Your own site
<a href="https://agentmods.dev/skills/seed-forge/harness-ai-kit/diag-mysql-slow-query"><img src="https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/diag-mysql-slow-query/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 diag-mysql-slow-query

Your own site · 80×15
<a href="https://agentmods.dev/skills/seed-forge/harness-ai-kit/diag-mysql-slow-query"><img src="https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/diag-mysql-slow-query.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,722 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00082 $0.01722
Opus 5 $0.00041 $0.00861
Sonnet 5 $0.00016 $0.00344
Haiku 4.5 $0.00008 $0.00172

Measured 11d ago against content hash 04e4ec1e34fb, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

diag-mysql-slow-query 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 11d 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.

skills/diag-mysql-slow-query/SKILL.md · 216 lines

How it starts

The opening of the file, as written. The whole thing — 216 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MySQL Slow Query Full-Chain Diagnostics

用途

当用户报告查询慢、接口超时、或怀疑 SQL 性能问题时触发。覆盖:

  • 接口响应变慢,怀疑数据库层
  • SHOW PROCESSLIST 看到大量 Sending data / Waiting for table metadata lock
  • 慢查询日志告警
  • 定期慢 SQL 巡检

本技能是自包含诊断 Runbook

输入

  • MySQL 连接信息(host / port / user / password)
  • 可选:已知慢 SQL 片段或时间段

输出

  • 慢查询分析报告(填充输出模板)
  • Top-N 慢 SQL + EXPLAIN 结果 + 优化建议

前置条件

要求
MySQL 权限 PROCESS, SELECT(performance_schema)
版本 MySQL 5.7+(8.0 优先用 performance_schema)

诊断步骤

Step 1: 检查慢查询日志配置

SHOW VARIABLES LIKE 'slow_query_log';        -- 是否开启
SHOW VARIABLES LIKE 'slow_query_log_file';   -- 日志路径
SHOW VARIABLES LIKE 'long_query_time';       -- 阈值(秒)
SHOW VARIABLES LIKE 'log_queries_not_using_indexes';  -- 是否记录无索引查询
SHOW VARIABLES LIKE 'min_examined_row_limit';

如果未开启,建议临时开启(需 SUPER 权限):

SET GLOBAL slow_query_log = ON;
SET GLOBAL long_query_time = 1;
SET GLOBAL log_queries_not_using_indexes = ON;

Step 2: 从 performance_schema 获取 Top-N 慢 SQL(MySQL 8.0+)

SELECT
  DIGEST_TEXT AS query_pattern,
  COUNT_STAR AS exec_count,
  ROUND(SUM_TIMER_WAIT / 1000000000000, 2) AS total_time_s,
  ROUND(AVG_TIMER_WAIT / 1000000000000, 4) AS avg_time_s,
  SUM_ROWS_EXAMINED AS rows_examined,
  SUM_ROWS_SENT AS rows_sent,
  SUM_NO_INDEX_USED AS no_index_count,
  FIRST_SEEN, LAST_SEEN
FROM performance_schema.events_statements_summary_by_digest
WHERE SCHEMA_NAME IS NOT NULL
  AND DIGEST_TEXT NOT LIKE 'SHOW%'
  AND DIGEST_TEXT NOT LIKE 'SET%'
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 20;

Step 3: EXPLAIN 可疑 SQL

EXPLAIN FORMAT=JSON {slow_query};
-- 或
EXPLAIN ANALYZE {slow_query};  -- MySQL 8.0.18+

关注:

字段 问题信号
type = ALL 全表扫描
rows >> 实际返回行数 扫描过多
Extra = Using filesort 排序未用索引
Extra = Using temporary 临时表
possible_keys = NULL 无可用索引

Step 4: 检查缺失索引

-- 未使用索引的查询统计(8.0+)
SELECT
  OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME,
  COUNT_STAR, COUNT_READ, COUNT_WRITE
FROM performance_schema.table_io_waits_summary_by_index_usage
WHERE INDEX_NAME IS NULL
  AND OBJECT_SCHEMA NOT IN ('mysql', 'performance_schema', 'information_schema')
ORDER BY COUNT_STAR DESC
LIMIT 20;

Read the full file on GitHub · 216 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 11d ago First seen · 216 lines · 82 tokens per session scan A 04e4ec1e34fb

Subscribe to this mod's changes

diag-mysql-slow-query is a skill published in the GitHub repository seed-forge/harness-ai-kit (22 stars, last pushed 10d ago), licensed Apache-2.0. It adds 82 tokens to every session and 1,722 once invoked, about $0.0004 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-30.

Related

Other skills, from other repositories

sql-optimization-patterns

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

wshobson/agents · 44 tokens

lcx-report-bug

Create a high-signal bug issue or PR in the repo that owns the defect. Use this whenever the user asks to report, file, open, or triage a LazyCodex, lazycodex-ai, omo-codex, Codex plugin, or upstream Codex CLI bug, especially when they need source-backed root cause, reproduction steps, fix guidance, and GitHub routing.

code-yeongyu/oh-my-openagent · 85 tokens

ast-grep

Searches and rewrites code by AST shape across 25 languages. Use when the target is a syntax pattern (every call/class/import shaped like X, a codemod, a YAML rule) rather than literal text; for plain strings, comments, or filenames, use rg.

code-yeongyu/oh-my-openagent · 61 tokens

debugging

Runs a hypothesis-driven debugging loop across any language or binary, escalating to orthogonal oracle angles and locking the fix with a failing test. Use for crashes, silent failures, hangs, wrong responses, memory leaks, async misbehavior, or reverse engineering.

code-yeongyu/oh-my-openagent · 53 tokens

lcx-doctor

Diagnose LazyCodex and Codex CLI installation health against the latest sources. Use whenever the user asks for a doctor or health check, says LazyCodex, lazycodex-ai, omo-codex, or Codex behaves oddly after an install, update, or config change, suspects a stale, drifted, or broken setup, or wants the local install…

code-yeongyu/oh-my-openagent · 93 tokens

remove-deadcode

Remove unused code from this project with ultrawork mode, LSP-verified safety, atomic commits. Triggers: remove dead code, dead code, cleanup, remove unused.

code-yeongyu/oh-my-openagent · 41 tokens