sqlalchemy-code-review
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.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/anderskev/sqlalchemy-code-reviewWhat This Skill Does
The sqlalchemy-code-review skill acts as a specialized static analysis agent for SQLAlchemy 2.0 and Alembic. It automates the detection of common architectural pitfalls, such as improper session lifecycle management, accidental N+1 query patterns, and non-performant ORM usage. By providing a structured checklist and referencing core documentation files, it ensures that your data access layer remains consistent, scalable, and memory-efficient throughout the application lifecycle.
Installation
To integrate this skill into your environment, run the following command via the OpenClaw terminal:
clawhub install openclaw/skills/skills/anderskev/sqlalchemy-code-review
Use Cases
This skill is essential during code reviews and refactoring phases. It is most effectively used when migrating legacy SQLAlchemy 1.x code to the 2.0 paradigm, verifying that async context managers are correctly implemented in FastAPI or similar asynchronous frameworks, and auditing Alembic migration scripts to ensure they are fully reversible. Developers can also use this to catch performance bottlenecks before they reach production, particularly when dealing with high-cardinality relationships or bulk database operations.
Example Prompts
- "Review this code block for potential N+1 issues and suggest the correct
joinedloadstrategy to optimize performance." - "I am seeing session management errors in my logs; can you inspect this repository snippet and check if I am closing my async sessions correctly?"
- "Please review this Alembic migration file to ensure the
downgradefunction is implemented correctly and there are no direct dependencies on ORM models."
Tips & Limitations
The sqlalchemy-code-review skill excels at spotting syntax and structural patterns but cannot replace a comprehensive integration test suite. While it identifies potential N+1 queries, it is limited by the context provided in the snippet; for the best results, provide the associated model definitions along with your query logic. Always ensure your environment variables and database engine configurations are masked if sharing code snippets. For complex data migrations, always verify that the generated op.execute commands match your database's specific dialect capabilities to avoid runtime failures during deployment.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-anderskev-sqlalchemy-code-review": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: code-execution
Related Skills
tutorial-docs
Tutorial patterns for documentation - learning-oriented guides that teach through guided doing
fetch-pr-feedback
Fetch review comments from a PR and evaluate with receive-feedback skill
swift-testing-code-review
Reviews Swift Testing code for proper use of
rust-testing-code-review
Reviews Rust test code for unit test patterns, integration test structure, async testing, mocking approaches, and property-based testing. Covers Rust 2024 edition changes including async fn in traits for mocks,
explanation-docs
Explanation documentation patterns for understanding-oriented content - conceptual guides that explain why things work the way they do