# Gates vs. Nets: The Two Layers AI Coding Agents Never Build
<!--
ref: @knowledge/frameworks/gates-vs-nets-production-readiness
type: framework
tags: [AI coding, software engineering, security, production systems, error handling]
triggers: [AI-generated code fails in production, missing error handling, security flaws in business logic, code lacks testing]
trigger_prompt: When evaluating AI-generated code, especially if it exhibits failures or security vulnerabilities, consider the missing structural layers that should have been implemented.
version: 2
updated_at: 2026-10-18T05:41:42.058Z
-->

Every production-readiness practice is either a gate that keeps bad input out or a net that catches the failure that got through — and a language model, left alone, builds neither.

*Synthesized from Sean Kochel, "Turning a Vibe-Coded Demo Into a Real Product (11 Things)."*

Sean Kochel's framing for why AI-assisted demos collapse in production is not a talent gap or a tooling gap — it's that the two structural layers a working engineering org takes for granted are exactly the two a model will never volunteer.

**Gates** stop bad inputs from reaching production at all:
- A spec the model can be held to as a contract
- Tests that can actually fail (red-green-refactor; every fixed bug becomes a regression test)
- A CI check on pull request — lint, then type check, then the full suite, then build, in that order, with a red step blocking the deploy
- Branch rules: feature branches or worktrees, no direct commits to `main`
- Authorization checks, enforced twice — in the API and again at the database row level

**Nets** catch what slips past:
- A global fallback error handler at app boundaries, so users never see a raw stack trace
- Front-end and back-end error boundaries piped to a monitor
- Timeouts and retries around every external API call
- Rollback paths for both code and schema
- Observability: centralized logs (with request ID and user ID attached), metric dashboards with threshold alerts, and traces showing the path data took before it broke

The diagnostic value of the frame is in the asymmetry. Kochel's observation is that models are *lazy* in a specific, predictable way: they take the happy path, write tests that cannot fail, skip indexes, generate N+1 queries, and swallow errors. Every one of those is a missing gate or a missing net. So when auditing an AI-built codebase, the productive question isn't "is this code good" — it's "which gate is absent, and which net is absent." Both layers have to be installed deliberately by a human, because neither emerges from the generation process.

A corollary worth holding onto: **business-logic flaws are security flaws**. Kochel's example of *failing open* — a malformed request breaks a check and a free-tier user lands on pro-tier API access, running up your bill — is a missing gate that no security scanner will label as one.

---

*Related: `@content/youtube/yifan-bth/unlocking-cursor-ai-top-8-hidden-features` · `@content/youtube/yifan-bth/how-i-use-ai-git-to-code-3x-faster-real-dev-workflow-with-cursor` · `@content/youtube/tiago-forte/i-connected-claude-to-everything-then-i-saw-the-gap` · `@content/youtube/indy-dev-dan/mac-mini-agents-openclaw-is-a-nightmare-use-these-skills-instead` · `@content/youtube/cole-medin/google-just-dropped-a-masterclass-on-agentic-engineering-its-so-good`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*