sqlalchemy-code-review

Review SQLAlchemy 2.0+ code for anti-patterns in sessions, queries, relationships, and migrations.

Updated Feb 17, 2026
One-click install
npx skills add https://github.com/javierhbr/random-poc --skill sqlalchemy-code-review-javierhbr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlalchemy-code-review
Source: https://github.com/javierhbr/random-poc/tree/main/custom-skills/beagle-main/plugins/beagle-python/skills/sqlalchemy-code-review
Command: npx skills add https://github.com/javierhbr/random-poc --skill sqlalchemy-code-review-javierhbr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write more robust, performant, and maintainable SQLAlchemy code by identifying common anti-patterns and suggesting best practices.

Core Features & Use Cases

  • Session Management: Ensures proper session lifecycle and context management.
  • Query Optimization: Detects and advises on N+1 query issues, inefficient data loading, and outdated query syntax.
  • Migration Best Practices: Reviews Alembic migration scripts for reversibility, safety, and efficiency.
  • Use Case: Before merging a new feature that heavily uses SQLAlchemy, run this Skill to automatically flag potential performance bottlenecks or data integrity risks in the ORM and migration code.

Quick Start

Use the sqlalchemy-code-review skill to review the provided SQLAlchemy code file.

Frequently Asked Questions about sqlalchemy-code-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check my SQLAlchemy code for N+1 query issues and session management anti-patterns?

To check SQLAlchemy code for N+1 query issues and session management anti-patterns, review the codebase for common ORM misuses, improper session lifecycles, and outdated query syntax. This ensures proper query optimization and robust database interaction.

What are common SQLAlchemy anti-patterns to look for before merging a database feature?

Common SQLAlchemy anti-patterns before merging include improper session context management, inefficient data loading causing N+1 queries, flawed relationship definitions, and unsafe Alembic migration scripts lacking reversibility or data integrity checks.

How do I review Alembic migration scripts for safety and reversibility in SQLAlchemy 2.0+?

Review Alembic migration scripts for safety and reversibility by checking for proper upgrade and downgrade paths, ensuring data integrity during schema evolution, and verifying migration efficiency to prevent bottlenecks in SQLAlchemy 2.0+ applications.

Does this SQLAlchemy review process target outdated query syntax in Python ORM applications?

Yes, the SQLAlchemy review process targets outdated query syntax in Python ORM applications by detecting legacy patterns and advising on modern query optimization techniques for better performance and code clarity.

What is the best way to enforce SQLAlchemy best practices for performance and code clarity?

The best way to enforce SQLAlchemy best practices for performance and code clarity is to automatically review relationship definitions, session management, and migration scripts to flag potential performance bottlenecks and data integrity risks.

When do I need to review SQLAlchemy session lifecycle and context management?

You need to review SQLAlchemy session lifecycle and context management when developing applications requiring robust database interaction, ensuring proper session handling to maintain data integrity and prevent connection leaks in Python.