Claude Code is built for interactive sessions. You type, it acts, the conversation ends. That is the right shape for a developer at a keyboard. It is the wrong shape for an agent that needs to keep watch on something. A queue. An inbox. A file. A webhook. A remote service. To turn Claude Code into a persistent worker you wrap it in a loop. This post is the wrapper. I will start with the fifteen-line shell version that gets you running in a minute, then walk through the persistent stream-json version that you actually want for anything beyond a demo. The full script is at the bottom. Why not just spawn claude -p every tick? The naive shape of a polling agent is to spawn a fresh claude -p process each tick, send a prompt, read the output, and exit. It works on a whiteboard. In practice the cold-start cost is brutal: MCP servers handshake on spawn. A multi-second cost on every tick, every time. CLAUDE.md and the skill catalogue have to be re-read and re-cached.…