mysql · sanjay3290 — скилл для Claude Code: read-only запросы к MySQL
Скилл гоняет SELECT-запросы к нескольким базам MySQL и блокирует любые записи. Пригодится, когда надо посмотреть схему или данные, не рискуя продом.
npx skills add sanjay3290/ai-skills --skill mysql -a claude-codeЧто делает mysql
Скилл запускает Python-скрипт scripts/query.py, который подключается к базам из конфига и выполняет только чтение. Сессия открывается с SET SESSION TRANSACTION READ ONLY, а валидатор пропускает лишь SELECT, SHOW, DESCRIBE, EXPLAIN и WITH. Несколько операторов в одном запросе отклоняются.
Список баз задаётся в connections.json в папке скилла или в ~/.config/claude/mysql-connections.json. У каждой записи есть имя, описание, хост, порт, база, пользователь и пароль. Описание нужно для авто-выбора: если спросить про заказы, скилл поищет базу с orders или transactions в описании. Файл содержит пароли, поэтому ему нужны права 600 — chmod 600 connections.json.
Нужен Python 3.8+ и mysql-connector-python из requirements.txt. Запрос обрывается через 30 секунд, а строк возвращается не больше 10 000 — на больших таблицах это повод сразу ставить --limit. Для локальных баз SSL можно выключить через "ssl_disabled": true.
Какие задачи решает
- посмотреть схему таблиц перед написанием миграции
- вытащить выборку из прода, ничего там не меняя
- найти нужную базу среди нескольких подключений по описанию
- проверить, что в таблице вообще лежит, без клиента MySQL под рукой
- ограничить тяжёлый запрос по строкам и времени
Примеры запросов агенту
- покажи список настроенных баз MySQL
- выведи схему таблиц в базе production
- сделай SELECT из orders с лимитом 100
Как установить mysql
1Через Skills CLI (Vercel)
npx skills add sanjay3290/ai-skills --skill mysql -a claude-code2Вручную: положить файлы
~/.claude/skills/mysql/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/mysql/
1Через Skills CLI (Vercel)
npx skills add sanjay3290/ai-skills --skill mysql -a codex2Вручную: положить файлы
.agents/skills/mysql/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add sanjay3290/ai-skills --skill mysql -a cursor2Вручную: положить файлы
.cursor/skills/mysql/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install sanjay3290/ai-skills mysql2Вручную: положить файлы
.github/skills/mysql/SKILL.md1Через Skills CLI (Vercel)
npx skills add sanjay3290/ai-skills --skill mysql -a gemini-cli2Командой платформы
gemini skills install https://github.com/sanjay3290/ai-skills --path skills/mysqlВручную: положить файлы
.devin/skills/mysql/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add sanjay3290/ai-skills --skill mysql -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора15
Другие версии mysql
Похожие
Рядом в теме «Данные и базы»
Все скиллы по теме «Данные и базы» →Вопросы о mysql
Как установить mysql в Claude?
Выполните npx skills add sanjay3290/ai-skills --skill mysql -a claude-code. Скилл встанет в ~/.claude/skills/mysql/SKILL.md.
Что делает скилл mysql?
Выполняет read-only SQL-запросы к нескольким базам MySQL: показывает таблицы, схему и данные. Все операции записи блокируются.
Что нужно подготовить до первого запроса?
Python 3.8+, пакет mysql-connector-python из requirements.txt и файл connections.json с данными подключений. Пароли в нём — поставьте права 600.
Исходный текст
SKILL.md · Apache-2.0
---
name: mysql
description: "Execute read-only SQL queries against multiple MySQL databases. Use when: (1) querying MySQL databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descriptions for intelligent auto-selection. Blocks all write operations (INSERT, UPDATE, DELETE, DROP, etc.) for safety."
license: Apache-2.0
metadata:
author: sanjay3290
version: "1.0"
---
# MySQL Read-Only Query Skill
Execute safe, read-only queries against configured MySQL databases.
## Requirements
- Python 3.8+
- mysql-connector-python: `pip install -r requirements.txt`
## Setup
Create `connections.json` in the skill directory or `~/.config/claude/mysql-connections.json`.
**Security**: Set file permissions to `600` since it contains credentials:
```bash
chmod 600 connections.json
```
```json
{
"databases": [
{
"name": "production",
"description": "Main app database - users, orders, transactions",
"host": "db.example.com",
"port": 3306,
"database": "app_prod",
"user": "readonly_user",
"password": "your-password",
"ssl_disabled": false
}
]
}
```
### Config Fields
| Field | Required | Description |
|-------|----------|-------------|
| name | Yes | Identifier for the database (case-insensitive) |
| description | Yes | What data this database contains (used for auto-selection) |
| host | Yes | Database hostname |
| port | No | Port number (default: 3306) |
| database | Yes | Database name |
| user | Yes | Username |
| password | Yes | Password |
| ssl_disabled | No | Set to `true` to disable SSL (default: false) |
| ssl_ca | No | Path to CA certificate file |
| ssl_cert | No | Path to client certificate file |
| ssl_key | No | Path to client private key file |
## Usage
### List configured databases
```bash
python3 scripts/query.py --list
```
### Query a database
```bash
python3 scripts/query.py --db production --query "SELECT * FROM users LIMIT 10"
```
### List tables
```bash
python3 scripts/query.py --db production --tables
```
### Show schema
```bash
python3 scripts/query.py --db production --schema
```
### Limit results
```bash
python3 scripts/query.py --db production --query "SELECT * FROM orders" --limit 100
```
## Database Selection
Match user intent to database `description`:
| User asks about | Look for description containing |
|-----------------|--------------------------------|
| users, accounts | users, accounts, customers |
| orders, sales | orders, transactions, sales |
| analytics, metrics | analytics, metrics, reports |
| logs, events | logs, events, audit |
If unclear, run `--list` and ask user which database.
## Safety Features
- **Read-only session**: Connection uses MySQL `SET SESSION TRANSACTION READ ONLY` (primary protection)
- **Query validation**: Only SELECT, SHOW, DESCRIBE, EXPLAIN, WITH queries allowed
- **Single statement**: Multiple statements per query rejected
- **SSL support**: Configurable SSL with CA, client cert, and key support
- **Query timeout**: 30-second max_execution_time enforced (MySQL 5.7.8+)
- **Memory protection**: Max 10,000 rows per query to prevent OOM
- **Column width cap**: 100 char max per column for readable output
- **Credential sanitization**: Error messages don't leak passwords
## Troubleshooting
| Error | Solution |
|-------|----------|
| Config not found | Create `connections.json` in skill directory |
| Authentication failed | Check username/password in config |
| Connection timeout | Verify host/port, check firewall/VPN |
| SSL error | Try `"ssl_disabled": true` for local databases |
| Permission warning | Run `chmod 600 connections.json` |
| max_execution_time not supported | Upgrade to MySQL 5.7.8+ or MariaDB 10.1.1+ |
## Exit Codes
- **0**: Success
- **1**: Error (config missing, auth failed, invalid query, database error)
## Workflow
1. Run `--list` to show available databases
2. Match user intent to database description
3. Run `--tables` or `--schema` to explore structure
4. Execute query with appropriate LIMIT
© sanjay3290 · Apache-2.0 · sanjay3290/ai-skills