skills/python-peewee/SKILL.md
Use when working with Peewee ORM patterns, especially DatabaseProxy setup, scoped connection/transaction handling, and SQLite-based tests.
npx skillsauth add narumiruna/agent-skills python-peeweeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use Peewee with DatabaseProxy, scoped connection handling, explicit transactions, and isolated SQLite tests. Core principle: initialize the database at the boundary, then keep models and tests deterministic.
BaseModel.DatabaseProxy for app and test databases.connection_context() vs atomic().| Need | Pattern |
| --- | --- |
| Deferred database binding | DatabaseProxy() |
| Model base class | class BaseModel(Model) with Meta.database |
| Scoped connection | with db.connection_context(): |
| Transactional writes | with db.atomic(): |
| SQLite tests | temporary SqliteDatabase fixture |
DatabaseProxy and one BaseModel for the model graph.connection_context() to open and close connections for scoped work.atomic() around write units that must commit or roll back together.from peewee import DatabaseProxy, Model
db_proxy = DatabaseProxy()
class BaseModel(Model):
class Meta:
database = db_proxy
from peewee import SqliteDatabase
db = SqliteDatabase("app.db", pragmas={"foreign_keys": 1})
db_proxy.initialize(db)
with db_proxy.obj.connection_context():
rows = MyModel.select().limit(100)
with db_proxy.obj.atomic():
a.save()
b.save()
db = db_proxy.obj
with db.connection_context():
with db.atomic():
...
Use connection_context() for scoped connections (open/close).
Use atomic() for atomic writes (BEGIN/COMMIT/ROLLBACK).
import pytest
from peewee import SqliteDatabase
@pytest.fixture
def test_db(tmp_path):
db = SqliteDatabase(str(tmp_path / "test.db"))
db_proxy.initialize(db)
with db.connection_context():
db.create_tables([MyModel])
yield db
with db.connection_context():
db.drop_tables([MyModel])
Use in function-based pytest tests:
def test_create_user(test_db):
with test_db.atomic():
user = User.create(name="Ada")
assert User.get_by_id(user.id).name == "Ada"
db_proxy.initialize(db) has run.atomic() as a substitute for opening a connection in code paths that also need explicit connection lifetime.development
Score or compare one or more agent skills across trigger clarity, workflow actionability, safety boundaries, verification rigor, incremental knowledge value, and leanness. Use only when the user explicitly asks for ratings, numerical quality scores, rubric-based scorecards, or scored comparisons; use creating-agent-skills for unscored reviews or revisions.
development
Assess or improve an existing codebase's architecture when the user asks about module boundaries, coupling, scattered ownership, testability, change locality, deep modules, seams, or behavior-preserving structural refactoring. Use for cross-module design rather than ordinary diff review or a confirmed edge-case bug fix.
development
Perform read-only security audits, vulnerability assessments, or threat-focused reviews of diffs, pull requests, code paths, or explicitly scoped repositories when security is the primary objective or acceptance criterion. Use reviewing-code for ordinary review with baseline security coverage and hardening-code-paths for fixing confirmed findings.
development
Run iterative multi-reviewer panels over a code diff, verify their findings, apply explicitly authorized fixes, and re-review the updated change until it passes or reaches a stopping condition. Use when the user asks for a panel loop, multi-model code-review consensus, or a review-fix-re-review cycle.