SQLite best practices for Go — WAL mode, foreign_keys, busy_timeout, SetMaxOpenConns, context-aware queries, transactions, migrations
98
99%
Does it follow best practices?
Impact
97%
2.36xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent applies SQLite best practices for a high-read service. The redirect path is read-heavy (lookup) with a write (increment counter). WAL mode is especially important here for concurrent read/write. SetMaxOpenConns(1) is critical since many concurrent HTTP requests will access the DB. The unique constraint on short_code needs proper error handling. Context propagation from HTTP handlers matters for client disconnect handling.",
"type": "weighted_checklist",
"checklist": [
{
"name": "modernc.org/sqlite driver",
"description": "Uses modernc.org/sqlite (pure Go) rather than mattn/go-sqlite3",
"max_score": 7
},
{
"name": "WAL mode enabled",
"description": "WAL journal mode is set -- especially important for this read-heavy service to allow concurrent readers during writes",
"max_score": 12
},
{
"name": "foreign_keys enabled via DSN",
"description": "Foreign key enforcement is enabled via connection string pragma",
"max_score": 5
},
{
"name": "busy_timeout set",
"description": "busy_timeout pragma is configured for handling concurrent redirect requests",
"max_score": 8
},
{
"name": "SetMaxOpenConns(1)",
"description": "db.SetMaxOpenConns(1) is called -- essential since concurrent HTTP redirect requests all access the database",
"max_score": 12
},
{
"name": "HTTP context propagated to DB",
"description": "Database functions accept context.Context from r.Context() and use QueryContext/ExecContext",
"max_score": 10
},
{
"name": "Parameterized queries",
"description": "All queries use ? placeholders -- no string interpolation, especially important for the short code lookup which takes user input from the URL path",
"max_score": 10
},
{
"name": "defer rows.Close()",
"description": "Every QueryContext call is followed by defer rows.Close()",
"max_score": 5
},
{
"name": "sql.ErrNoRows handled",
"description": "The redirect lookup and stats functions check for sql.ErrNoRows and return an appropriate 404 response rather than a 500 error",
"max_score": 8
},
{
"name": "Unique constraint on short_code",
"description": "The schema includes a UNIQUE constraint on short_code, and the code handles the duplicate short code case (either by retrying with a new code or returning a conflict error)",
"max_score": 5
},
{
"name": "Index on short_code",
"description": "An index exists on short_code for fast redirect lookups (a UNIQUE constraint implicitly creates one, or an explicit index)",
"max_score": 5
},
{
"name": "Efficient click counter update",
"description": "The click counter is incremented with a single UPDATE statement (e.g., SET click_count = click_count + 1) rather than a read-modify-write pattern",
"max_score": 8
},
{
"name": "Migration pattern",
"description": "Schema uses a versioned migration pattern rather than bare CREATE TABLE statements",
"max_score": 5
}
]
}evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
sqlite-go-best-practices
verifiers