Claude Wrote a SQLite Extension in C and Rust: A Practical Test for Coding-Agent Operators
Simon Willison had Claude Opus 5.5 write one SQLite function in C and in Rust. The C build was 14 KB; a second prompt made it the fastest of all four builds.
Simon Willison wanted a SQLite function that turns strings like -$1,234.56 or 12.5% into numbers you can sum and sort. He asked a frontier model to build it twice, once in C and once in Rust, then measured what came back.
The post, published 8 November 2026, is a small, concrete test of where a coding agent helps and where the operator still owns the result.

The ask was short and specific
The first prompt was compact: a SQLite custom function parse_number(value) that strips separators, currency symbols and percent signs, handles a leading minus, and returns NULL for anything it cannot parse. Willison added a clause to compare a C extension with a Rust one on performance, code complexity and shared-object size.
He ran it in regular Claude chat on Opus 5.5. That is the shape of request agents handle well: a short initial parsing contract, an explicit output type and a checkable failure mode. It is still only a starting contract. The prompt never settled which numeric syntax to accept, what happens on overflow, how whitespace is treated, or whether a trailing percent sign means 12.5 or 0.125.
Size and speed pulled in opposite directions
The first results pulled size against speed. The C extension was 14 KB; the rusqlite build was 321 KB and the sqlite-loadable-rs build 298 KB. But the Rust builds were faster on mixed and decimal data, because the Rust equivalent of C’s strtod is “twice as fast”. So he asked for a second attempt: write your own C function for parsing text into a decimal number that catches up to or beats the Rust implementation.
| Cost per row | first C | new C | rusqlite | sqlite-loadable |
|---|---|---|---|---|
| Mixed data | 67 ns | 19 ns | 46 ns | 41 ns |
| Integers only | 25 ns | 16 ns | 36 ns | 32 ns |
| Decimals only | 106 ns | 18 ns | 55 ns | 47 ns |
Over two million rows the rewritten C module won every data shape. The margin was widest where the first version was weakest: the first C build cost 106 ns per decimal row against 18 ns for the rewrite. On integers that first build was already ahead of both Rust builds, at 25 ns against 36 and 32 ns. The three data shapes exposed very different sizes of performance gap rather than different winners. The post’s summary puts the optimized C build at 16 to 19 ns per row, and the report records 8 million fuzz checks with all four builds agreeing on type preservation, parsing rules and floating-point accuracy.
The operator lesson is not that C beats Rust. It is narrower: a named gap and a measurable target make for a checkable second prompt, and the benchmark tells you whether the rewrite landed.
The part the model cannot own: the FFI boundary and the proof
An extension still has to be registered with SQLite, and that is where the real risk lives. SQLite’s documentation on application-defined SQL functions says custom functions are created with the sqlite3_create_function() family of interfaces and that each database connection registers its own functions, with no shorthand for sharing them across connections. Further down the same page, a security section warns that an application-defined function can become a vulnerability even when the application never calls it, because a modified schema can invoke it from a view, a trigger or a check constraint. The precautions listed there are turning off trusted schema on each connection, compiling with -DSQLITE_TRUSTED_SCHEMA=0, and tagging functions with side effects as SQLITE_DIRECTONLY.

An agent can hand you a .so file; it cannot decide whether your database files are trusted, whether your schema can be modified by an untrusted party, or whether the function you registered has side effects. The Claude Code documentation describes the surrounding workflow: agents work across files and tools, CLAUDE.md carries project instructions, and hooks run shell commands around agent actions. Writing the extension is not the same as deciding whether it should be trusted.
A five-step recipe worth stealing
- Write the contract before the code. Willison’s contract ran to one sentence and still left numeric syntax, overflow, whitespace and percent handling to the operator.
- Ask for two implementations, not one. Comparing C and Rust exposed the
strtodgap that a single build had hidden. The comparison produced the follow-up prompt. - Benchmark on your own data shapes. Mixed, integers only and decimals only exposed very different gaps: the first C build ran at 25 ns on integers and 106 ns on decimals. One aggregate number would have hidden the worst case.
- Point at the gap and set a measurable target. Willison’s second prompt did not ask the model to “make it faster”; it asked for a custom C decimal parser that catches up to or beats the Rust implementation. Asking for a diagnosis and the fix in one message is good practice, and keeping the benchmark makes the second round checkable.
- Verify the boundary yourself. Load the extension, register it per connection, decide the trusted schema posture, and fuzz against a reference implementation.
Automater has covered how AI agents actually work and the spec-driven development pattern this experiment models well: a written contract first, implementation second.
Where to be sceptical
The numbers come from one machine, one author’s harness and one workload. Treat the ordering as directional and re-measure on your own data. SQLite’s security warnings target functions with side effects, which a pure number parser does not have, but the posture still matters: parse_number() sits inside a database other SQL will call. That is the operator’s job, and it is the part that did not change.
Sources
- Research: parse_number() as a SQLite extension: C vs Rust — Simon Willison’s Weblog, 8 November 2026
- Application-Defined SQL Functions — SQLite documentation
- Overview — Claude Code Docs — Anthropic