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": "Always configure SQLite connections with required pragmas (WAL, foreign_keys, busy_timeout, synchronous), graceful shutdown, and a single shared connection",
"relevant_when": "Agent creates or modifies a Node.js application that uses or will use SQLite with better-sqlite3",
"context": "SQLite foreign_keys are OFF by default (must set per connection). WAL mode enables concurrent reads during writes. busy_timeout prevents SQLITE_BUSY errors on concurrent access. synchronous=NORMAL is safe with WAL. A single shared connection is correct for better-sqlite3 (synchronous driver, one writer). db.close() on shutdown ensures WAL checkpoint completes.",
"sources": [
{
"type": "file",
"filename": "skills/sqlite-node-best-practices/SKILL.md",
"tile": "tessl-labs/sqlite-node-best-practices@0.2.0"
}
],
"checklist": [
{
"name": "wal-mode-enabled",
"rule": "Agent sets PRAGMA journal_mode = WAL on the SQLite connection",
"relevant_when": "Agent creates or opens a SQLite database in Node.js"
},
{
"name": "foreign-keys-enabled",
"rule": "Agent sets PRAGMA foreign_keys = ON on the SQLite connection",
"relevant_when": "Agent creates or opens a SQLite database in Node.js"
},
{
"name": "busy-timeout-set",
"rule": "Agent sets PRAGMA busy_timeout to a positive value (e.g. 5000) on the SQLite connection",
"relevant_when": "Agent creates or opens a SQLite database in Node.js"
},
{
"name": "synchronous-normal",
"rule": "Agent sets PRAGMA synchronous = NORMAL (safe with WAL, better performance than default FULL)",
"relevant_when": "Agent creates or opens a SQLite database in Node.js with WAL mode"
},
{
"name": "graceful-shutdown",
"rule": "Agent calls db.close() on SIGTERM and/or SIGINT to ensure clean WAL checkpoint on process exit",
"relevant_when": "Agent creates a Node.js application that uses SQLite"
},
{
"name": "single-shared-connection",
"rule": "Agent creates one Database instance and exports/shares it, not a new connection per request",
"relevant_when": "Agent creates a Node.js application with multiple modules or routes that use SQLite"
},
{
"name": "better-sqlite3-chosen",
"rule": "Agent uses better-sqlite3 (synchronous) rather than the callback-based sqlite3 package",
"relevant_when": "Agent adds SQLite to a Node.js project and chooses which package to install"
}
]
}