sqlalchemy-code-review
БесплатноБез исполняемых скриптовНе проверенReviews SQLAlchemy 2.0 and Alembic code for session lifecycle, Mapped relationships, N+1 queries, bulk DML, and safe migrations. Use when reviewing SQLAlchemy…
от existential-birds★ 92 звезды на GitHubОб этом скилле
SQLAlchemy Code Review
Quick Reference
| Issue Type | Reference |
|---|---|
Session lifecycle, async_sessionmaker, async sessions |
references/sessions.md |
Mapped / relationship(), lazy loading, N+1, selectinload |
references/relationships.md |
select() vs query(), ORM overhead, insert()/update() bulk ops |
references/queries.md |
Alembic patterns, autocommit_block(), reversible data migrations |
references/migrations.md |
Review Checklist
- Sessions use context managers (
with,async with) from configuredsessionmaker/async_sessionmaker - No session sharing across requests or threads
- Async sessions use
async_sessionmakerwithexpire_on_commit=False(no removed 1.xautocommitparameter) - Models use SQLAlchemy 2.0
Mapped[T] = mapped_column(...)typing -
relationship()uses appropriatelazystrategy (lazy="raise"or explicitselectinload/joinedload) - No lazy loading in loops (N+1 queries)
- Using SQLAlchemy 2.0
select()syntax, not legacyquery() - Bulk operations use Core
insert()/update(), not ORM add/update loops - Migrations are reversible with working
downgrade() - Data migrations use
op.execute(sa.text(...))or Coretable()/column(), not ORM models - Concurrent index builds use
with op.get_context().autocommit_block():(postgresql_concurrently=True) - Migration dependencies properly ordered
Gates (SQLAlchemy-specific)
Run once per SQLAlchemy-related finding, after anchoring file:line per review-verification-protocol (review-verification-protocol) 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_sessionmaker, 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 →
references/sessions.md - Reviewing model relationships →
references/relationships.md - Reviewing database queries →
references/queries.md - Reviewing Alembic migration files →
references/migrations.md
Review Questions
- Are all sessions created from a reused factory and managed with context managers?
- Are relationships configured (
Mapped,lazy="raise",selectinload/joinedload) to avoid N+1 queries? - Are queries using SQLAlchemy 2.0
select()syntax andinsert()/update()for bulk DML? - Are all migrations reversible, parameterized, and using
autocommit_block()for concurrent indexes?
Установить sqlalchemy-code-review в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sqlalchemy-code-review?
Reviews SQLAlchemy 2.0 and Alembic code for session lifecycle, Mapped relationships, N+1 queries, bulk DML, and safe migrations. Use when reviewing SQLAlchemy models, queries, async sessions, or Alembic revisions.
Как установить скилл sqlalchemy-code-review?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sqlalchemy-code-review запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic