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
explanation-docs
Explanation documentation patterns for understanding-oriented content - conceptual guides that explain why things work the way they do
tutorial-docs
Tutorial patterns for documentation - learning-oriented guides that teach through guided doing
pytest-code-review
Reviews pytest test code for async patterns, fixtures, parametrize, and mocking. Use when reviewing test_*.py files, checking async test functions, fixture usage, or mock patterns.
reference-docs
Reference documentation patterns for API and symbol documentation. Use when writing reference docs, API docs, parameter tables, or technical specifications. Triggers on reference docs, API reference, function reference, parameters table, symbol documentation.
serde-code-review
Reviews serde serialization code for derive patterns, enum representations, custom implementations, and common serialization bugs. Use when reviewing Rust code that uses serde, serde_json, toml, or any serde-based serialization format. Covers attribute macros, field renaming, and format-specific pitfalls.