Write Script Mysql
windmill-labs/windmill
MUST use when writing MySQL queries.
Full-chain MySQL deadlock analysis. An agent skill from openocta/openocta_skills.
$ npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install openocta/openocta_skills mysql-deadlock-analyzer --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/openocta/openocta_skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/mysql-deadlock-analyzer .claude/skills/mysql-deadlock-analyzer && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "mysql-deadlock-analyzer" agent skill from https://github.com/openocta/openocta_skills/tree/main/mysql-deadlock-analyzer into .claude/skills/mysql-deadlock-analyzer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "mysql-deadlock-analyzer", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/openocta/openocta_skills/tree/main/mysql-deadlock-analyzerType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install openocta/openocta_skills mysql-deadlock-analyzer --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/openocta/openocta_skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/mysql-deadlock-analyzer .agents/skills/mysql-deadlock-analyzer && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "mysql-deadlock-analyzer" agent skill from https://github.com/openocta/openocta_skills/tree/main/mysql-deadlock-analyzer into .agents/skills/mysql-deadlock-analyzer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "mysql-deadlock-analyzer", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install openocta/openocta_skills mysql-deadlock-analyzer --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/openocta/openocta_skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/mysql-deadlock-analyzer .cursor/skills/mysql-deadlock-analyzer && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "mysql-deadlock-analyzer" agent skill from https://github.com/openocta/openocta_skills/tree/main/mysql-deadlock-analyzer into .cursor/skills/mysql-deadlock-analyzer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "mysql-deadlock-analyzer", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/openocta/openocta_skills.git --path mysql-deadlock-analyzer--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install openocta/openocta_skills mysql-deadlock-analyzer --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/openocta/openocta_skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/mysql-deadlock-analyzer .gemini/skills/mysql-deadlock-analyzer && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "mysql-deadlock-analyzer" agent skill from https://github.com/openocta/openocta_skills/tree/main/mysql-deadlock-analyzer into .gemini/skills/mysql-deadlock-analyzer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "mysql-deadlock-analyzer", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install openocta/openocta_skills mysql-deadlock-analyzerInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/openocta/openocta_skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/mysql-deadlock-analyzer .github/skills/mysql-deadlock-analyzer && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "mysql-deadlock-analyzer" agent skill from https://github.com/openocta/openocta_skills/tree/main/mysql-deadlock-analyzer into .github/skills/mysql-deadlock-analyzer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "mysql-deadlock-analyzer", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install openocta/openocta_skills mysql-deadlock-analyzer --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/openocta/openocta_skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/mysql-deadlock-analyzer .opencode/skills/mysql-deadlock-analyzer && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "mysql-deadlock-analyzer" agent skill from https://github.com/openocta/openocta_skills/tree/main/mysql-deadlock-analyzer into .opencode/skills/mysql-deadlock-analyzer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "mysql-deadlock-analyzer", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
mysql-deadlock-analyzerFull-chain MySQL deadlock analysis. An agent skill from openocta/openocta_skills.
Mysql Deadlock Analyzer is an agent skill from openocta/openocta_skills. Full-chain MySQL deadlock analysis. Captures InnoDB status, parses lock chains, identifies deadlock patterns (AB-BA / Gap Lock / FK), finds current lock waits and long transactions, outputs structured report with fix recommendations. Supports MySQL 5.7+ performanceschema and 5.6 compatibility mode.
Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `README.md` and `mate.json`).
It sits in Databases. It works with MySQL. The repository describes itself as: 本仓库用于汇集第三方贡献的 OpenOcta 技能(Skill)资源,便于分享、版本管理与分发。 The licence is MIT.
5 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 6ac4479. It shows what the files ask for, not the result of running them.
Pre-approves these tools, so the agent can use them without asking each time:
db_querydb_get_statusdb_get_processlistFrom allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are sql and bash).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Mysql Deadlock Analyzer loads about 2.2k tokens when it runs. Until then it costs about 81 tokens; SKILL.md has 414 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from openocta/openocta_skills at commit 6ac4479, republished under its MIT licence (© openocta). 414 words, ~2,157 tokens.
.claude/skills/mysql-deadlock-analyzer/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.Deadlocks are among the most difficult database issues to diagnose — they involve multiple transactions, lock chains, and often intermittent patterns. This skill performs a full-chain deadlock analysis:
Error: 1213 Deadlock found)Innodb_deadlocks counter increasing| Tool | Purpose |
|---|---|
db_query | Run diagnostic SQL queries |
db_get_status | Get InnoDB deadlock counters |
db_get_processlist | Check for blocking queries |
PROCESS — View all threads and InnoDB status-- Get deadlock count and recent lock metrics
SHOW GLOBAL STATUS LIKE 'Innodb_deadlocks';
SHOW GLOBAL STATUS LIKE 'Innodb_row_lock_waits';
SHOW GLOBAL STATUS LIKE 'Innodb_row_lock_time_avg';
-- Capture full InnoDB status (contains LATEST DETECTED DEADLOCK section)
SHOW ENGINE INNODB STATUS;-- Current lock waits (who is blocking whom)
SELECT
waiting_trx.trx_id AS waiting_trx,
blocking_trx.trx_id AS blocking_trx,
waiting_trx.trx_state AS wait_state,
waiting_trx.trx_started AS wait_started,
waiting_trx.trx_query AS wait_query,
blocking_trx.trx_query AS block_query
FROM information_schema.innodb_lock_waits w
JOIN information_schema.innodb_trx waiting_trx ON w.requesting_trx_id = waiting_trx.trx_id
JOIN information_schema.innodb_trx blocking_trx ON w.blocking_trx_id = blocking_trx.trx_id;
-- Fallback for MySQL 5.6:
SELECT * FROM information_schema.innodb_trx ORDER BY trx_started;-- Transactions running longer than 60 seconds
SELECT
trx_id, trx_state, trx_started,
TIMESTAMPDIFF(SECOND, trx_started, NOW()) AS duration_sec,
trx_tables_locked, trx_rows_locked,
LEFT(trx_query, 200) AS current_query
FROM information_schema.innodb_trx
WHERE TIMESTAMPDIFF(SECOND, trx_started, NOW()) > 60
ORDER BY trx_started;From the InnoDB status output, extract and classify:
| Pattern | Description | Typical Fix |
|---|---|---|
| AB-BA | Transaction A locks row1→row2, B locks row2→row1 | Ensure consistent access order |
| Gap Lock | Next-key lock on index gap | Reduce range scans, use RC isolation |
| FK Cascade | Foreign key triggers cascading lock | Add index on FK column |
| Auto-Inc | Concurrent inserts competing for auto-inc lock | Use innodb_autoinc_lock_mode=2 |
| Lock Upgrade | S-lock upgraded to X-lock | Reduce transaction scope |
SHOW VARIABLES LIKE 'innodb_print_all_deadlocks';
SHOW VARIABLES LIKE 'tx_isolation';
SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';🔒 MySQL Deadlock Analysis Report
═════════════════════════════════
📋 Instance: {host}:{port}
Analysis Time: {timestamp}
🔍 Deadlock Status
Total Deadlocks: {count}
Row Lock Waits: {count}
Avg Lock Wait: {ms}ms
📜 Latest Deadlock (from InnoDB Status)
┌─────────────────────────────────────────┐
│ Transaction A (ID: {trx_id}) │
│ Status: {status} Duration: {time}s │
│ Holds: {locks_held} │
│ Waits: {locks_waited} │
│ SQL: {sql_fragment} │
├─────────────────────────────────────────┤
│ Transaction B (ID: {trx_id}) │
│ Status: {status} Duration: {time}s │
│ Holds: {locks_held} │
│ Waits: {locks_waited} │
│ SQL: {sql_fragment} │
└─────────────────────────────────────────┘
Pattern: {AB-BA / Gap Lock / FK / Auto-Inc}
⚠️ Current Lock Waits
{If blocking chains exist, list them}
📊 Long Transactions ({count} found)
| Trx ID | Duration | State | SQL |
|--------|----------|-------|-----|
💡 Root Cause
{Analysis conclusion}
🛠️ Recommendations
1. {SQL-level fix} — e.g., add index, change access order
2. {Code-level fix} — e.g., unify lock order, add retry
3. {Config-level fix} — e.g., enable innodb_print_all_deadlocksUser: "Check for deadlocks on db-prod-01"
AI Response:
🔒 Deadlock Analysis — db-prod-01:3306
Total Deadlocks: 0 ✅ (no deadlocks recorded)
Row Lock Waits: 0 ✅ (no lock contention)
Long Transactions: 3 found
| Trx ID | Duration | State | SQL |
|--------|----------|----------|-----|
| 5847M | 0s | RUNNING | SELECT ... |
| 5847K | 0s | RUNNING | UPDATE ... |
💡 Conclusion: No current deadlock issues.
Recommendation: Enable innodb_print_all_deadlocks = ON
to capture future deadlock details automatically.innodb_print_all_deadlocks = ON for continuous monitoring-- Always enable this in production
SET GLOBAL innodb_print_all_deadlocks = ON;
-- Monitor lock wait timeout (default 50s)
SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';
-- For high-concurrency workloads
SET GLOBAL innodb_autoinc_lock_mode = 2;-- Deadlock rate (deadlocks per minute)
SELECT
VARIABLE_VALUE AS deadlocks,
NOW() AS collected_at
FROM performance_schema.global_status
WHERE VARIABLE_NAME = 'Innodb_deadlocks';
-- Row lock contention rate
SELECT
VARIABLE_VALUE AS lock_waits,
NOW() AS collected_at
FROM performance_schema.global_status
WHERE VARIABLE_NAME = 'Innodb_row_lock_waits';
-- Average lock wait time (milliseconds)
SELECT
ROUND(VARIABLE_VALUE / 1000, 2) AS avg_lock_wait_ms
FROM performance_schema.global_status
WHERE VARIABLE_NAME = 'Innodb_row_lock_time_avg';Alert thresholds for monitoring:
| Metric | Warning | Critical |
|---|---|---|
| Deadlocks/min | > 1 | > 5 |
| Row lock waits/min | > 100 | > 500 |
| Avg lock wait | > 100ms | > 500ms |
For continuous deadlock capture beyond innodb_print_all_deadlocks:
# Percona Toolkit: capture deadlocks to a file
pt-deadlock-logger \
--host={host} --port={port} \
--user={user} --password={password} \
--dest D=/tmp/deadlocks.log \
--daemonize --interval 30
# Output format:
# server ts thread txn_id txn_time user host ip db tbl idx lock_type lock_mode wait_hold queryAfter identifying the deadlocked SQL, replay to verify the lock pattern:
-- Check the execution plan of the deadlocked query
EXPLAIN FORMAT=JSON {deadlocked_sql};
-- Check if the query uses the correct index
SHOW INDEX FROM {table};
-- Verify row scan count vs actual data volume
SELECT COUNT(*) FROM {table} WHERE {where_clause};| Action | Query |
|---|---|
| Deadlock count | SHOW STATUS LIKE 'Innodb_deadlocks' |
| InnoDB status | SHOW ENGINE INNODB STATUS |
| Current transactions | SELECT * FROM information_schema.innodb_trx |
| Lock waits (5.7+) | SELECT * FROM performance_schema.data_lock_waits |
| Lock waits (5.6) | SELECT * FROM information_schema.innodb_lock_waits |
| Enable deadlock logging | SET GLOBAL innodb_print_all_deadlocks = ON |
Use this skill for comprehensive deadlock diagnosis — from detection to root cause to fix.
© openocta, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 2 other files in mysql-deadlock-analyzer of openocta/openocta_skills.
Open the folder on GitHubat commit 6ac4479
Mysql Deadlock Analyzer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Mysql Deadlock Analyzer this skillopenocta/openocta_skills | 166 | — | ~2.2k | Automated safety check: Pass | MIT | |
| Write Script Mysqlwindmill-labs/windmill | 18k | — | ~2.2k | Automated safety check: Pass | Custom licence | |
| Mysqlolasunkanmi-SE/codebuddy | 141 | — | ~399 | Automated safety check: Pass | MIT | |
| How To Communicatedatabasus/databasus | 8.8k | — | ~3.9k | Automated safety check: Pass | MIT | |
| Tgf Server Devthkhxm/tgf | 128 | — | ~1.3k | Automated safety check: Notes | MIT | |
| DB Ops SopOpenDCAI/DataMind | 423 | — | ~388 | Automated safety check: Pass | Apache-2.0 |
windmill-labs/windmill
MUST use when writing MySQL queries.
olasunkanmi-SE/codebuddy
Manage MySQL databases via the mysql CLI. An agent skill from olasunkanmi-SE/codebuddy.
databasus/databasus
Communicate clearly in every response, progress update and agent-authored document.
thkhxm/tgf
基于 tgf v2(github.com/thkhxm/tgf/v2)用确定性的 tgfctl 工作流创建、验证和维护 Go 游戏服务器项目。
OpenDCAI/DataMind
Database operations runbook — backup, recovery, performance tuning, troubleshooting.
AltimateAI/data-engineering-skills
Delegates dbt and warehouse tasks such as lineage, migrations and cost attribution to the altimate-code CLI agent and relays its answer back.
openocta/openocta_skills
对远程多实例MySQL数据库执行全方位深度巡检,覆盖基础健康、连接负载、性能慢查询、索引冗余、主从复制、容量空间、账号安全、配置风险八大维度,全自动完成巡检扫描、风险识别、问题定级、优化建议、报告归档与飞书推送,适用于生产/测试所有运行中MySQL实例常态化合规巡检。适用场景:用户要求进行 MySQL 全链路健康检查、MySQL 综合巡检、MySQL 风险扫描、MySQL 性能审计、MySQL…
openocta/openocta_skills
Linux 与网络设备只读健康巡检;直接运行 scripts/patrol.sh,配置由平台侧信道注入,Agent 不读取环境变量
openocta/openocta_skills
分析微信公众号后台数据,包括文章阅读量、评论、点赞等统计。当用户需要分析微信公众号数据、导出公众号文章统计报表时调用此技能。
openocta/openocta_skills
Replication lag root cause analysis with automated resolution workflow.
openocta/openocta_skills
Slow query diagnosis with root cause analysis and index optimization recommendations.
openocta/openocta_skills
Comprehensive TiDB cluster inspection. An agent skill from openocta/openocta_skills.
Works with
Categories
Full-chain MySQL deadlock analysis. An agent skill from openocta/openocta_skills. Mysql Deadlock Analyzer is an agent skill from openocta/openocta_skills. Full-chain MySQL deadlock analysis.
Mysql Deadlock Analyzer fits situations like: databases work in your project.
Run `npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a claude-code`. Or copy the skill folder (mysql-deadlock-analyzer in openocta/openocta_skills) into .claude/skills/mysql-deadlock-analyzer in your project. Claude Code loads it when a task matches its description.
Run `npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a codex`. Or copy the skill folder (mysql-deadlock-analyzer in openocta/openocta_skills) into .agents/skills/mysql-deadlock-analyzer in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add openocta/openocta_skills --skill mysql-deadlock-analyzer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mysql-deadlock-analyzer, .gemini/skills/mysql-deadlock-analyzer, .github/skills/mysql-deadlock-analyzer and .opencode/skills/mysql-deadlock-analyzer in your project.
SKILL.md names no scripts, command-line tools or credentials: Mysql Deadlock Analyzer is instructions for the agent only. Its frontmatter pre-approves these tools: db_query, db_get_status, db_get_processlist.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Mysql Deadlock Analyzer is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.2k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Mysql Deadlock Analyzer: Write Script Mysql (windmill-labs/windmill, 18k stars), Mysql (olasunkanmi-SE/codebuddy, 141 stars), How To Communicate (databasus/databasus, 8.8k stars) and Tgf Server Dev (thkhxm/tgf, 128 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
openocta (a GitHub user) maintains it in openocta/openocta_skills, which has 166 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on June 22, 2026.
Source: openocta/openocta_skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.