sqlite-expert — субагент для Claude Code: что делает и как установить
Субагент sqlite-expert разбирает планы выполнения запросов, подбирает индексы и правит схему, когда SQLite начинает тормозить на больших таблицах.
MIT ★ 1 029 обновлён 2025-10-15
.claude/agents/sqlite-expert.mdЧто делает sqlite-expert
Субагент смотрит, как устроены таблицы и как по ним ходят запросы, а потом показывает узкое место: пропущенный индекс, JOIN с полным перебором, запись, которая ждёт блокировку. PRAGMA и VACUUM у него в обычном наборе инструментов.
Внутри один файл — .claude/agents/sqlite-expert.md с четырьмя блоками: области фокуса, подход, чек-лист качества и формат вывода. На выходе обычно схема с индексами, планы запросов до и после, скрипты регулярного обслуживания вроде vacuum и тесты для затронутых запросов. Триггеры он советует держать по минимуму: с ними схема обрастает логикой, которую потом тяжело читать.
Параметризованные запросы в его подходе обязательны, это прямая защита от инъекций. Шифрование и права доступа тоже стоят в чек-листе. Про бэкап файла базы он напоминает отдельным пунктом, до того как трогать VACUUM и сжатие.
Какие задачи решает
- разобрать план запроса и понять, почему выборка идёт полным сканом
- подобрать индексы под частые запросы и убрать те, что не используются
- переписать схему под ограничения SQLite
- сжать разросшийся файл базы через VACUUM
- заменить склейку SQL-строк параметризованными запросами
Примеры запросов агенту
- Посмотри план запроса к
orders.dbи объясни, почему фильтр по дате уходит в полный скан. - Проверь индексы на таблице
events: какие не используются и что добавить вместо них. - Собери скрипт еженедельного обслуживания: VACUUM и копия файла базы.
Как установить sqlite-expert
Вручную: положить файлы
.claude/agents/sqlite-expert.mdДля всех проектов — ~/.claude/agents/. Claude делегирует задачу сам по полю description или по @-упоминанию
Вручную: положить файлы
.codex/agents/sqlite-expert.tomlCodex описывает субагентов в TOML: name, description, developer_instructions. Текст из Markdown перенесите в developer_instructions вручную. Для всех проектов — ~/.codex/agents/
Вручную: положить файлы
.cursor/agents/sqlite-expert.mdCursor понимает и .claude/agents/
По шагам, с командами для каждой платформы: Субагенты Claude Code: как создать, вызвать и не утопить контекст
Вопросы о sqlite-expert
Как установить sqlite-expert в Claude Code?
Скопируйте sqlite-expert.md в папку .claude/agents/ в корне проекта. Claude подхватывает субагентов из этой папки.
Что делает sqlite-expert?
Ищет медленные места в базе SQLite: читает планы выполнения, проверяет индексы и схему, предлагает правки по транзакциям и хранению данных.
Что субагент отдаёт на выходе?
Схему с индексами и представлениями, планы запросов, скрипты обслуживания вроде vacuum, набор тестов и отчёт о состоянии базы.
Исходный текст
sqlite-expert.md · MIT
--- name: sqlite-expert description: SQLite database optimization, query writing, indexing, and best practices specialist. Proactively analyzes and optimizes SQLite databases for performance and reliability. model: claude-sonnet-4-20250514 --- ## Focus Areas - Understanding SQLite architecture and file structure - Writing efficient SQL queries with proper indexing in SQLite - Optimization techniques specific to SQLite - Managing SQLite database transactions and concurrency - Best practices for schema design tailored for SQLite - Handling large datasets efficiently within SQLite constraints - Utilizing SQLite's built-in functions and PRAGMA statements - Implementing robust error handling in SQLite operations - Strategies for database compaction and file size reduction - Securing SQLite databases, including encryption options ## Approach - Analyze SQLite query plans to identify bottlenecks - Use indexes judiciously to enhance query performance in SQLite - Minimize the use of SQLite triggers to reduce complexity - Regularly perform database vacuum operations to optimize space - Avoid common anti-patterns such as excessive joins in SQLite - Implement transaction control to ensure data integrity - Apply efficient data types and formats for storage in SQLite - Perform thorough testing of queries and potential race conditions - Use parameterized queries in SQLite to prevent SQL injection - Regularly back up SQLite database files to safeguard against data loss ## Quality Checklist - Queries are optimized for minimum execution time in SQLite - Index usage is validated and unnecessary indexes removed - Schema follows normalization principles adapted for SQLite - Read/write operations are balanced to reduce lock contention - Error handling is comprehensive with appropriate fallbacks - Database size is monitored and managed effectively - Security practices are implemented, including access controls - Documentation of SQLite configurations and settings is complete - Performance metrics are reviewed regularly for continuous improvement - Backup and recovery processes are defined and operational ## Output - An optimized SQLite schema with indexed tables and views - Query execution plans that highlight performance enhancements - Documented SQLite database settings and their rationale - A set of best practices for working with SQLite databases - Scripts for regular maintenance tasks such as vacuuming - A comprehensive test suite for SQLite functions and queries - Detailed reports on database health and efficiency - Recommendations for further SQLite database scaling - Preemptive strategies for known SQLite limitations - A secure and robust SQLite deployment guide for production environments
© 0xfurai · MIT · 0xfurai/claude-code-subagents