Formally verifying Claude Agent SDK with Lean via Claude: 16 bug-fix PRs from a few prompts

bcherny · x · 2026-09-24

Engineer bcherny shares how he used Claude Opus 5.5 to formally verify the Claude Agent SDK in Lean — a couple of short prompts yielded 16 PRs fixing bugs and race conditions. His workflow: have Claude build a model of the program targeting tricky state machines or race-prone code, find counter-examples (suspected bugs), reproduce them, then fix. It's not whole-codebase verification (yet), just modeling and checking the hairiest parts. He also combines Lean with TLA+ to cover data flow, concurrency, and state management, noting Claude is excellent at both languages even if you aren't.

Related event: Anthropic Dev Uses Opus 5.5 + Lean to Formally Verify Agent SDK, Fixing 16 Bugs(16 posts)→

Original post →

More from coding & agent

coding & agent channel →