Fighting AI Slop with Invariants and Type-Safe Boundaries
AI Engineergo watch the original →
the gist
To manage AI-generated code, move away from human-centric code reviews toward automated, agent-driven verification and foundational type systems that make entire classes of errors impossible.
Managing AI Slop with Automated Invariants
Instead of enforcing rigid human standards, the author advocates for building automated "slop detectors" that treat AI generation as a tool rather than a final product. By running agents continuously over the transcripts of other agents, teams can flag hallucinations, identify inefficient tool calls, and compare different approaches to determine which produces the most reliable output. This detection layer is anchored by hard invariants, such as an architecture.md file that defines stable system layers, and CLI tools that visualize dependency graphs to catch leaky abstractions before they merge into the codebase.
Attacking the Foundational Layer
To truly eliminate slop, the author argues for moving beyond patching existing languages like TypeScript or Python, which contain inherent design compromises for human productivity. The proposed solution is to build systems from first principles using BAML, a language designed to provide strong, type-safe boundaries across Python, TypeScript, and Rust.
Key technical strategies include:
- Exhaustive Error Handling: The system infers error types without manual annotation, allowing the compiler to prove that all potential failures, such as division by zero, are handled.
- Cross-Language Interop: BAML functions are accessible across different languages, allowing developers to pass generics, lambdas, and closures across boundaries while maintaining type safety.
- Agent-First Tooling: Rather than relying on standard grep, the system provides tools that describe code, include docstrings, and generate standalone CLI binaries for every function, enabling agents to navigate and execute code without human intervention.
- Execution Tracing: By building tracing into the foundation, the system provides performance-cost-free execution traces that allow agents to identify bugs and inefficiencies automatically.