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
{
"instruction": "Use prepared statements for all queries, wrap related writes in transactions, and prepare frequently used statements once for reuse",
"relevant_when": "Agent writes SQLite queries in a Node.js application using better-sqlite3",
"context": "String interpolation in SQL is an injection risk. better-sqlite3 prepared statements (db.prepare) use ? placeholders. Transactions (db.transaction) wrap multiple writes atomically and are dramatically faster for bulk inserts (one fsync vs N fsyncs). Preparing statements once at module level caches the query plan.",
"sources": [
{
"type": "file",
"filename": "skills/sqlite-node-best-practices/SKILL.md",
"tile": "tessl-labs/sqlite-node-best-practices@0.2.0"
}
],
"checklist": [
{
"name": "prepared-statements",
"rule": "Agent uses db.prepare() with ? placeholders for all queries — never string interpolation or template literals to inject values into SQL",
"relevant_when": "Agent writes any SQL query in Node.js with better-sqlite3"
},
{
"name": "transactions-for-related-writes",
"rule": "Agent wraps related multi-statement writes in db.transaction() so they commit or roll back atomically",
"relevant_when": "Agent writes code that performs multiple related INSERT/UPDATE/DELETE operations"
},
{
"name": "bulk-inserts-in-transaction",
"rule": "Agent wraps bulk/batch inserts in a single db.transaction() rather than inserting rows one at a time without a transaction",
"relevant_when": "Agent writes code that inserts multiple rows into SQLite"
},
{
"name": "cached-prepared-statements",
"rule": "Agent prepares frequently used statements once (at module level or in a setup function) and reuses them, rather than calling db.prepare() inside every function call",
"relevant_when": "Agent creates query functions that will be called repeatedly"
}
]
}