SQLite best practices for Node.js with better-sqlite3 — WAL mode, pragmas, foreign keys, STRICT tables, transactions, migrations, graceful shutdown, and query patterns
97
98%
Does it follow best practices?
Impact
96%
1.65xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent proactively applies SQLite best practices when building a coffee shop API. The task describes only business requirements -- it never mentions WAL mode, pragmas, foreign key indexing, transactions, STRICT tables, or graceful shutdown. These should all be applied automatically.",
"type": "weighted_checklist",
"checklist": [
{
"name": "WAL mode enabled",
"description": "db.ts sets PRAGMA journal_mode = WAL on the database connection",
"max_score": 10
},
{
"name": "Foreign keys ON",
"description": "db.ts sets PRAGMA foreign_keys = ON on the database connection",
"max_score": 10
},
{
"name": "Busy timeout set",
"description": "db.ts sets PRAGMA busy_timeout to a positive value (e.g. 5000)",
"max_score": 7
},
{
"name": "synchronous = NORMAL",
"description": "db.ts sets PRAGMA synchronous = NORMAL",
"max_score": 5
},
{
"name": "Graceful shutdown with db.close()",
"description": "Application calls db.close() on SIGTERM or SIGINT for clean WAL checkpoint",
"max_score": 8
},
{
"name": "Transaction for order creation",
"description": "Creating an order with its items uses db.transaction() so the order and all items are committed atomically",
"max_score": 12
},
{
"name": "Prepared statements throughout",
"description": "ALL queries use db.prepare() with ? placeholders — no string interpolation or template literal injection of values into SQL",
"max_score": 10
},
{
"name": "Indexes on foreign key columns",
"description": "Schema creates explicit indexes on order_items.order_id and order_items.menu_item_id (SQLite does not auto-index FKs)",
"max_score": 10
},
{
"name": "Migration pattern used",
"description": "Schema uses a sequential migration pattern with a tracking table, not scattered CREATE TABLE IF NOT EXISTS",
"max_score": 7
},
{
"name": "Money stored as INTEGER cents",
"description": "Prices and totals are stored as INTEGER (cents), not REAL or FLOAT",
"max_score": 7
},
{
"name": "CHECK constraint on order status",
"description": "Order status column uses a CHECK constraint to validate allowed values",
"max_score": 5
},
{
"name": "STRICT tables",
"description": "Tables are created with the STRICT keyword for type enforcement",
"max_score": 5
},
{
"name": "JSON for customizations",
"description": "Customizations are stored as TEXT/JSON and queried with json_extract or json functions where appropriate",
"max_score": 4
}
]
}