PostgreSQL patterns for Python with psycopg and asyncpg — connection pooling,
99
99%
Does it follow best practices?
Impact
99%
1.15xAverage score across 5 eval scenarios
Passed
No known issues
{
"instruction": "Use proper async patterns for asyncpg: pool lifecycle, context managers, cursors for large results, and transaction management",
"relevant_when": "Agent writes async Python code with asyncpg or PostgreSQL, or sets up async database access",
"context": "asyncpg pools must be created with 'await asyncpg.create_pool()' inside an async function (not at module level), and closed on shutdown. All connection acquisition must use 'async with pool.acquire() as conn:' context managers. Large result sets should use async cursors inside transactions. Transactions use 'async with conn.transaction():' context manager. asyncpg uses $1/$2 numbered placeholders, not %s.",
"sources": [
{
"type": "file",
"filename": "skills/postgresql-python-best-practices/SKILL.md",
"tile": "tessl-labs/postgresql-python-best-practices@0.2.0"
}
],
"checklist": [
{
"name": "async-pool-lifecycle",
"rule": "asyncpg pool is created inside an async function with 'await asyncpg.create_pool()' and closed on shutdown with 'await pool.close()', not created at module import time",
"relevant_when": "Agent creates an asyncpg connection pool"
},
{
"name": "async-context-manager-acquire",
"rule": "Connections are acquired using 'async with pool.acquire() as conn:' context manager to guarantee release back to pool, never bare 'await pool.acquire()' without matching release",
"relevant_when": "Agent writes async code that uses asyncpg connections"
},
{
"name": "async-transaction-context",
"rule": "Transactions use 'async with conn.transaction():' context manager for automatic commit/rollback, not manual BEGIN/COMMIT SQL",
"relevant_when": "Agent writes async transactions with asyncpg"
},
{
"name": "server-side-cursor-for-large-results",
"rule": "Large result sets use server-side cursors (conn.cursor() with async iteration or fetchmany) inside a transaction, not fetchall() which loads everything into memory",
"relevant_when": "Agent writes queries that may return very large result sets"
},
{
"name": "asyncpg-numbered-placeholders",
"rule": "asyncpg queries use $1, $2, $N numbered placeholders with separate positional arguments, not %s or named parameters",
"relevant_when": "Agent writes asyncpg queries with parameters"
}
]
}evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
postgresql-python-best-practices