How to Build an AI Agent: From One Prompt to a Production Setup
Ten production AI-agent setups from Stripe, Uber, Meta, Cloudflare and more โ what each does, how it's built, and where to start. The model is the easy part; the harness is what makes it work.

How to Build an AI Agent: From One Prompt to a Production Setup
The best engineering teams in the world no longer use "an AI agent." They use sets of them โ each one built differently for a different job. Stripe's coding agents merge more than 1,000 pull requests a week. At Uber, over 70% of pull requests now involve a local or cloud agent (with humans still reviewing). Spotify has auto-merged more than 2.5 million maintenance pull requests through its fleet system.
The striking thing, once you read how these were built, is how little of the work is the model. Engineering teams at Stripe, Uber, DoorDash, Shopify, Meta, Microsoft, Cloudflare and others have published their architectures and real metrics. Across all of them, the model is the easy part. The harness around it โ the loop, the guardrails, the verification โ is what makes an agent reliable. This guide distills those write-ups into ten production setups and the handful of rules they all share.
What an agent actually is
OpenAI's practical guide reduces an agent to three parts: a model that reasons and decides, tools (the functions and APIs it can call), and instructions (the rules for how it behaves). Anthropic puts it even more bluntly: agents are "typically just LLMs using tools based on environmental feedback in a loop."
The model is the smallest part. What companies spend months on is everything around it โ the harness:
- The loop: call the model, run the tool it asked for, return the result, repeat.
- Context and memory: what the agent sees this turn, and what survives to the next session.
- Sandbox: an isolated machine where it can run code without touching anything real.
- Tool access: usually through an MCP gateway that decides which tools are available for each task.
- Guardrails: read-only by default, spend caps, and human approval for anything risky.
- Verification: tests, linters, or a second agent that checks the work before it ships.
The model decides. The harness controls what it can actually do.
Workflow or agent?
These systems split into two kinds. In a workflow, models and tools run through predefined code paths. In an agent, the model chooses its own steps. In practice most production setups mix both โ Stripe calls theirs "blueprints": fixed steps like lint and push, with agent loops in between for the parts that need judgment.
The five patterns
Almost every setup below is built from these building blocks:
- Prompt chaining โ each step processes the output of the previous one.
- Routing โ classify the input and send it to a specialized handler.
- Parallelization โ split the work, or run the same task several times and compare.
- Orchestrator/workers โ a lead agent breaks the task up, hands parts to workers, merges results.
- Evaluator/optimizer โ one agent produces, another critiques, repeat until it passes.
One agent, or many?
Start with one. Split only when the instructions get tangled or the tools start to overlap. Microsoft learned this the hard way: the first Azure SRE Agent had 100+ narrow tools and 50+ subagents, and long hand-off chains almost always failed. The rebuild landed on a few generalist agents and five core tools. The rule of thumb: add a second agent only when it does a genuinely different job โ like checking the first one's work.
The ten setups
1. Background coding agent
An engineer files a task in Slack or a ticket, walks away, and comes back to a finished pull request. A fresh sandbox per task, fixed steps (lint, push, open PR) wrapped around agent loops, automatic verifiers, and a human who reviews and merges โ the agent never does. Stripe's "Minions" run this at 1,000+ merged PRs/week; Spotify's "Honk" uses an LLM judge that vetoes about a quarter of sessions for going off-scope; Shopify's "River" co-authors 1 in 8 merged PRs. Start here: anthropics/claude-code-action.
2. Code review agent
It reviews every PR before a human does and keeps only the comments worth reading. A coordinator scores the risk and calls in specialist reviewers (security, performance, quality), each finding is double-checked, duplicates are merged, and a human can always override. Cloudflare's coordinator appoints up to seven reviewers and logged 131,246 review runs across 48,095 merge requests in a month (median 3m39s, median $0.98, overridden on just 0.6%). DoorDash runs 10,000+ PRs/week at roughly $3โ4 per review; Uber's uReview sees 75% of comments marked useful. Start here: the /review command in garrytan/gstack or the review skills in obra/superpowers.
3. Migration agent
Take one boring change that must happen in thousands of places and apply it everywhere. A script finds every file, one agent works per file in its own git worktree, fixed gates (tests, lint, type-check) decide when it's done, and failures feed back for a retry. Airbnb migrated ~3,500 test files at 97% automation โ a projected 1.5-year job done in six weeks. Google reports 80% of changes AI-authored in one ID migration; DoorDash cleaned stale feature flags at $4.79 and 13.8 minutes each. Start here: the dispatching-parallel-agents and using-git-worktrees skills in obra/superpowers.
4. On-call / SRE agent
It joins the incident the moment an alert fires and investigates while humans are still opening laptops. Deterministic checks pull recent deploys and dashboards first, several hypotheses are investigated in parallel, every conclusion must cite a specific query or log line, and the agent is read-only โ restarts and rollbacks go through a human. Microsoft's Azure SRE Agent has handled 35,000+ incidents and cut Azure App Service live-site mitigation from a 40.5-hour human average to about three minutes. Ramp's OCA posts a first update in ~5 minutes; Meta cut median detection-to-mitigation from 9.5 to 3.8 hours. Start here: OpenAI's "Build an SRE agent for incident response" cookbook.
5. Security agent
It triages alerts and hunts for vulnerabilities, so the security team only looks at what's real. Plain code assembles the evidence before any model runs, specialist agents work different angles in parallel, and the agents that find issues run on different models than the ones that verify them โ a finding without evidence gets dropped. Cloudflare's agentic security operations checks every citation in application code; Figma cut time-to-resolution by 71%; Shopify's "Dispatch" surfaced 300+ findings across 80+ apps in six weeks. Start here: trailofbits/skills (42 plugins; many security-focused).
6. Data analyst agent
Anyone asks a question in plain English and gets an answer with the SQL behind it. The real work is the knowledge layer โ table descriptions, metric definitions, example queries โ which the agent searches before writing anything, and queries run under the user's own permissions. DoorDash's "Vera" moved its eval pass rate from 43% to 90% across 200,000+ datasets; Notion's "Data Scout" cut requests to the data team ~80% in two months; OpenAI's in-house agent serves 3,500+ users over 600 PB. Start here: the data plugin in anthropics/knowledge-work-plugins.
7. Customer support agent
It answers what it can and hands the rest to a human with context already gathered. A small, cheap model routes each request; simple lookups go to plain code, common questions to retrieval, and only messy cases reach the full agent โ with guardrails and LLM judges on every answer. Lyft cut the time to build a new support agent from ~6 months to ~2 weeks; DoorDash cut hallucinations by 90%; Coinbase's CEEcil can open PRs but never merge them. Start here: the customer-support-agent quickstart.
8. Research agent
It takes a broad question, searches many sources in parallel, and returns a report where every claim has a citation. A lead agent plans and saves the plan to memory, parallel workers each search one angle and return short summaries, and a final pass matches every claim to its source. Anthropic's multi-agent research beat a single-agent setup by 90.2% on its internal eval โ at ~15ร the tokens of a normal chat. Harvey lifted legal redline quality from 53% to 87%; Perplexity's Computer Deep Research scores 83.8% on BrowseComp. Start here: assafelovic/gpt-researcher.
9. Knowledge agent (second brain)
It captures what experts know โ the stuff never written down โ and gives it to every agent and new hire. Short, structured knowledge files (not giant docs), written by builder agents and checked by critic agents, with facts that expire unless reconfirmed. Meta mapped 4,100+ pipeline files into 59 context files, taking AI context coverage from ~5% to 100%; its organizational second brain uses ~80% fewer tokens per turn; Notion's "Lore" gave agents memory that passed 102 of 149 scenarios vs 82 without. Start here: makenotion/lore.
10. Scheduled automation agent
It wakes on a schedule, checks your sources, and tells you only what changed โ no prompt needed. A cron job starts a fresh session, read-only access with credentials in a vault, bookmarks so it resumes where it stopped, and a spend cap so a stuck loop can't burn money. Anthropic's reference daily brief runs on Managed Agents capped at $5/run; GitHub's Agentic Workflows are markdown compiled into Actions, read-only by default, never auto-merging. Start here: the managed-agents/daily-brief example (there's a scheduled Sentry-triage one in the same folder).
The six rules every setup shares
Ten jobs, ten companies, and the same rules keep appearing:
- A separate checker. The agent that does the work never grades it.
- Code before the model. Fetch data, run checks, gather evidence with plain code first; the model only does the parts that need judgment.
- Read-only by default. Anything that changes the real world goes through a human โ draft PRs, approval buttons, plan sign-off.
- Evidence for every claim. A conclusion without a log line, query, or source behind it gets dropped.
- Narrow permissions per task. Each job gets only the tools it needs.
- Real test cases. Past incidents, past questions, past PRs โ replayed after every change.
Copy those six and almost any setup above will hold up.
Where to start
Don't build all ten. Pick the most annoying part of your week: drowning in small tickets โ background coding agent; PRs waiting days โ code review agent; one change needed in 500 places โ migration agent; woken up by alerts โ on-call agent; the same data questions daily โ data analyst agent; the same customer questions โ support agent; checking five tools every morning โ scheduled automation.
Start narrow, start read-only, and put one checker on top. Every company here started the same way: one boring task, measured, then the next one. The model is the easy part โ the setup around it is what makes it work.
We're turning each of these setups into a hands-on course with starter repos and exercises. In the meantime, explore free AI courses on Toolglade Learn, and browse open-source AI apps and Claude Code agents & skills you can build on.