# How to Ship Millions of Lines of Agent-Written Code — Jarred Sumner, Anthropic

## Executive summary

Jarred Sumner, creator of Bun, details the process of shipping a multi-million line code base generated by AI agents. The project introduced an Ahead-of-Time (AOT) compiler to Bun, the runtime behind Claude Code, resulting in a 4x reduction in memory usage and a 2x faster startup time. The speaker emphasizes that the success of this massive project hinges not on the coding approach, but on the robustness of pre-existing tests, which are used to verify the trustworthiness of agent-written code.

## Key takeaways

- Testing Dictates Approach: The project's approach was driven by the need to verify functionality and ensure reliability, making testing more critical than the specific implementation strategy (2:27).
- AOT vs. JIT for Performance: The AOT compiler was implemented to reduce the CPU time typically spent compiling code on demand (JIT), which is particularly critical for applications like Cloud Code (3:57).
- Agent Workflow Management: The development cycle involves writing code in large batches, followed by dedicated fixing and testing phases. Long-lived subagents are used for maintenance and context retention (9:12, 15:21).
- Trusting Pre-existing Tests: The primary mechanism for ensuring code quality is relying on tests that predate the project, which provides a level of trust that is difficult to achieve when rewriting codebases (6:57).

## Technical details

- AOT Compiler Implementation: The AOT compiler was merged via a multi-million line PR to Bun, aiming to replace the runtime cost of JIT compilation. The resulting code uses 4x less memory and starts 2x faster (0:00, 4:42).
- Type Handling: In the AOT process, TypeScript types are treated as 'predictions' rather than absolute truths, which is noted as being effective for models that write compilers (6:12).
- Verification and Fuzzing: Verification involves running three versions of an application (JIT, AOT, no types) and using tools like V8 Zilly, extended to test TypeScript types, to fuzz patterns and catch bugs (8:27, 16:51).
- Breaking Changes: The AOT compiler introduced two breaking changes, primarily related to security measures designed to prevent prototype pollution attacks, which also benefited performance (8:27).

## Practical implications

- For large-scale refactoring, the speaker suggests that a complete rewrite (if tests are portable) can sometimes be a more reliable path than incremental refactoring.
- AI-driven development requires a structured process involving batch coding followed by rigorous, dedicated testing and fixing cycles.
- Continuous measurement and 'nudging' the AI models are necessary to prevent diminishing returns in large agent projects.

## Topics

AI Engineering, Runtime Systems, Ahead-of-Time Compilation, Software Testing, Agentic Workflow, Jarred Sumner, Bun

Source: https://www.youtube.com/watch?v=TvsF67C2F54
