sqlalchemy-code-review — скилл для Claude Code: установка
Скилл sqlalchemy-code-review проверяет SQLAlchemy-код на ошибки в сессиях, связях, запросах и миграциях. Нужен при ревью проектов на SQLAlchemy 2.0 и Alembic.
Apache-2.0 228 установок ★ 89 обновлён 2026-09-15
npx skills add existential-birds/beagle --skill sqlalchemy-code-review -a claude-codeЧто делает sqlalchemy-code-review
Скилл разбирает жизненный цикл Session и асинхронных сессий, настройки relationship(), ленивую загрузку и запросы N+1. Он также проверяет переход на синтаксис select(), массовые операции и миграции Alembic с upgrade() и downgrade().
Внутри есть чек-лист и ссылки на отдельные справочные материалы по сессиям, связям, запросам и миграциям. Для каждого замечания скилл требует привязать проблему к file:line: для N+1 нужно показать цикл и связь, а для миграции — конкретную операцию op.* или op.execute().
Без подтверждения через file:line находку нельзя выпускать в ревью: правила скилла требуют собрать доказательства, снизить уверенность или переформулировать замечание как вопрос.
Какие задачи решает
- проверить закрытие синхронных и асинхронных сессий
- найти N+1 при загрузке связей в циклах
- заменить устаревший
query()наselect() - оценить массовые операции ORM
- проверить обратимость миграций Alembic
Примеры запросов агенту
- Проверь этот модуль на ошибки в жизненном цикле
Sessionи привяжи каждое замечание кfile:line. - Проведи ревью моделей и запросов: найди N+1, проверь
relationship(),joinedloadиselectinload. - Проверь миграции Alembic на корректные
upgrade()иdowngrade(), указав конкретные строки.
Как установить sqlalchemy-code-review
1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill sqlalchemy-code-review -a claude-code2Вручную: положить файлы
~/.claude/skills/sqlalchemy-code-review/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/sqlalchemy-code-review/
1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill sqlalchemy-code-review -a codex2Вручную: положить файлы
.agents/skills/sqlalchemy-code-review/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill sqlalchemy-code-review -a cursor2Вручную: положить файлы
.cursor/skills/sqlalchemy-code-review/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install existential-birds/beagle plugins/beagle-python/skills/sqlalchemy-code-review2Вручную: положить файлы
.github/skills/sqlalchemy-code-review/SKILL.md1Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill sqlalchemy-code-review -a gemini-cli2Командой платформы
gemini skills install https://github.com/existential-birds/beagle --path plugins/beagle-python/skills/sqlalchemy-code-reviewВручную: положить файлы
.devin/skills/sqlalchemy-code-review/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill sqlalchemy-code-review -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о sqlalchemy-code-review
Как установить sqlalchemy-code-review в Claude Code?
Выполните npx skills add existential-birds/beagle --skill sqlalchemy-code-review -a claude-code, затем проверьте файл ~/.claude/skills/sqlalchemy-code-review/SKILL.md.
Что делает sqlalchemy-code-review?
Скилл проверяет сессии, связи, N+1, SQLAlchemy 2.0-запросы, массовые операции и миграции Alembic. Замечания проходят проверки с привязкой к файлам и строкам.
Что нужно указать для замечания о N+1?
Нужно показать цикл или повторный вызов, а также назвать связь либо SQL-шаблон, который выполняется на каждой итерации. Оба факта должны иметь привязку к file:line.
Исходный текст
SKILL.md · Apache-2.0
--- name: sqlalchemy-code-review description: Reviews SQLAlchemy code for session management, relationships, N+1 queries, and migration patterns. Use when reviewing SQLAlchemy 2.0 code, checking session lifecycle, relationship() usage, or Alembic migrations. --- # SQLAlchemy Code Review ## Quick Reference | Issue Type | Reference | |------------|-----------| | Session lifecycle, context managers, async sessions | [references/sessions.md](references/sessions.md) | | relationship(), lazy loading, N+1, joinedload | [references/relationships.md](references/relationships.md) | | select() vs query(), ORM overhead, bulk ops | [references/queries.md](references/queries.md) | | Alembic patterns, reversible migrations, data migrations | [references/migrations.md](references/migrations.md) | ## Review Checklist - [ ] Sessions use context managers (`with`, `async with`) - [ ] No session sharing across requests or threads - [ ] Sessions closed/cleaned up properly - [ ] `relationship()` uses appropriate `lazy` strategy - [ ] Explicit `joinedload`/`selectinload` to avoid N+1 - [ ] No lazy loading in loops (N+1 queries) - [ ] Using SQLAlchemy 2.0 `select()` syntax, not legacy `query()` - [ ] Bulk operations use bulk_insert/bulk_update, not ORM loops - [ ] Async sessions use proper async context managers - [ ] Migrations are reversible with `downgrade()` - [ ] Data migrations use `op.execute()` not ORM models - [ ] Migration dependencies properly ordered ## Gates (SQLAlchemy-specific) Run **once per SQLAlchemy-related finding**, after you can anchor **`file:line`** (see [review-verification-protocol](../review-verification-protocol/SKILL.md)) and **before** the finding ships. If a step’s pass condition is not met, **do not** assert the finding as written—gather evidence, withdraw, downgrade severity, or rephrase as a question. ### Gate 1 — Session scope and lifecycle | Step | Action | **Pass condition** | |------|--------|---------------------| | 1a | Open the module where the session is created or injected (not from memory). | **`file:line`** for `Session`, `sessionmaker`, `async_session`, or the factory/`Depends()` that yields a session. | | 1b | If claiming leak, cross-request sharing, or missing cleanup: trace the session’s scope (context manager, `try`/`finally`, middleware). | **Scoped region** cited with a **`file:line` range**, or withdraw if scope is correct after the read. | ### Gate 2 — N+1, lazy loading, eager loads | Step | Action | **Pass condition** | |------|--------|---------------------| | 2a | Identify the loop or repeated call site (ORM attribute access, `execute` in a loop). | **`file:line`** for the loop or hot path. | | 2b | If claiming N+1: name the relationship or query pattern emitted per iteration. | **Relationship or per-iteration SQL pattern** with **`file:line`**, or rephrase as a question if unclear. | ### Gate 3 — Migrations (Alembic) | Step | Action | **Pass condition** | |------|--------|---------------------| | 3a | Open the revision file (e.g. under `versions/`, or the project’s Alembic layout). | **Repo-relative path** + **`file:line`** for `revision` / `upgrade` / `downgrade`. | | 3b | If claiming broken `downgrade()` or risky data migration: point at the `op.*` / `op.execute()` involved. | **Snippet or line range** in that file for each claimed op, or withdraw. | ## When to Load References - Reviewing session creation/cleanup → sessions.md - Reviewing model relationships → relationships.md - Reviewing database queries → queries.md - Reviewing Alembic migration files → migrations.md ## Review Questions 1. Are all sessions properly managed with context managers? 2. Are relationships configured to avoid N+1 queries? 3. Are queries using SQLAlchemy 2.0 `select()` syntax? 4. Are all migrations reversible and properly tested?
© existential-birds · Apache-2.0 · existential-birds/beagle