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": "Design SQLite schemas with STRICT tables, indexes on foreign key columns, migration patterns, INTEGER for money, TEXT for dates, and CHECK constraints for enums",
"relevant_when": "Agent creates or modifies SQLite table schemas in a Node.js application",
"context": "SQLite does NOT auto-index foreign key columns (unlike PostgreSQL), so every DELETE on a parent table without an FK index triggers a full child-table scan. STRICT tables enforce type checking that SQLite otherwise skips. Money must be INTEGER (cents) to avoid floating-point errors. Dates must be TEXT in ISO 8601 format. Migrations should be sequential and tracked in a _migrations table, not scattered CREATE TABLE IF NOT EXISTS.",
"sources": [
{
"type": "file",
"filename": "skills/sqlite-node-best-practices/SKILL.md",
"tile": "tessl-labs/sqlite-node-best-practices@0.2.0"
}
],
"checklist": [
{
"name": "indexes-on-foreign-keys",
"rule": "Agent creates an explicit CREATE INDEX on every foreign key column in the schema",
"relevant_when": "Agent defines tables with foreign key relationships in SQLite"
},
{
"name": "migration-pattern",
"rule": "Agent uses a sequential migration pattern with a _migrations tracking table, not inline CREATE TABLE IF NOT EXISTS scattered in app code",
"relevant_when": "Agent creates SQLite tables in a Node.js application"
},
{
"name": "money-as-integer",
"rule": "Agent stores monetary values as INTEGER (cents) not REAL or FLOAT",
"relevant_when": "Agent defines columns that store prices, amounts, or monetary values"
},
{
"name": "dates-as-text",
"rule": "Agent stores dates/timestamps as TEXT with ISO 8601 format using datetime('now') defaults, not as INTEGER unix timestamps or REAL",
"relevant_when": "Agent defines columns that store dates or timestamps in SQLite"
},
{
"name": "strict-tables",
"rule": "Agent creates tables with the STRICT keyword to enforce column type checking",
"relevant_when": "Agent creates new SQLite tables"
},
{
"name": "check-constraints-for-enums",
"rule": "Agent uses CHECK constraints to validate enum-like TEXT columns (e.g. CHECK (status IN ('a', 'b', 'c')))",
"relevant_when": "Agent defines columns that should only accept a fixed set of values"
},
{
"name": "integer-primary-key",
"rule": "Agent uses INTEGER PRIMARY KEY (rowid alias) for primary keys, using AUTOINCREMENT only when ID reuse must be prevented",
"relevant_when": "Agent defines primary key columns in SQLite tables"
}
]
}