From Prompt to Production: The Spec-Driven Workflow I Use With Claude Code A developer describes a spec-driven workflow using Claude Code to build a stateful AI agent that queries PostgreSQL, analyzes results, and sends summary emails. The initial implementation lacked memory, idempotency, and budget limits, leading to failures like duplicate emails and lost state on restart. The article presents a practical system for turning complex designs into reliable production architecture. Member-only story From Prompt to Production: The Spec-Driven Workflow I Use With Claude Code A practical system for turning complex, high-stakes system designs into reliable, production-grade architecture. I gave Claude Code a task that sounds like the holy grail of modern software engineering: Build a stateful AI agent that can query our PostgreSQL database, analyze the results, and send a summary email to the client. The request looked clear. The application already had a database connection, an LLM client, and an email service. Claude just needed to wire them together into an autonomous loop. A few minutes later, the terminal blinked back to life. It had created an agent loop, a few tool definitions, and a passing unit test. It looked like a spectacular example of AI-assisted development. Then I reviewed the implementation. The agent had no memory; if the server restarted mid-execution, it lost its state and started over. It had no idempotency; if the LLM hallucinated and called the “send email” tool twice, the client got two emails. It had no budget limits; when it got stuck in a reasoning loop, it…