ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified developer tools Safety 5/5

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.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/anderskev/sqlalchemy-code-review
Or

What 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

  1. "Review this code block for potential N+1 issues and suggest the correct joinedload strategy to optimize performance."
  2. "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?"
  3. "Please review this Alembic migration file to ensure the downgrade function 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

Author@anderskev
Stars4473
Views1
Updated2026-05-01
View Author Profile
AI Skill Finder

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 skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-anderskev-sqlalchemy-code-review": {
      "enabled": true,
      "auto_update": true
    }
  }
}

Tags(AI)

#sqlalchemy#python#database#orm#backend
Safety Score: 5/5

Flags: code-execution