How to Build an AI Agent with Claude Code (Prompts Included)
Claude Code can write most of an agent for you, but only if you give it a clear spec and make it plan before it codes. This guide walks through the five steps we use, each with the exact prompt.
Step zero: decide whether you need an agent
Many "agents" should really be workflows: a fixed sequence of steps with an LLM call in the middle. Agents make sense when the path is not known in advance and the model has to choose tools and decide when it is done. That flexibility costs money, latency and predictability, so be sure you need it. If you are unsure, write the spec first; the decision usually becomes obvious.
The build process
Spec. Turn your idea into a one-page spec with users, goals, tools, inputs, outputs and success criteria.
Loop. Design the observe-think-act loop, including stop conditions and step limits so it cannot run forever.
Tools. Generate strict JSON schemas for each tool. Clear names, descriptions and argument types matter more than clever prompts.
Subagents. Split specialised work (research, coding, review) into subagents with narrow instructions and tool access.
Evaluate. Build a small test harness before you ship, so every change can be checked against real cases.
In Claude Code, paste each prompt into a fresh session in your project folder. Ask it to show you a plan and wait for your approval before writing files. Commit after each step so you can roll back.
Security from day one
Agents read untrusted text (web pages, emails, documents), and that text can contain instructions. Keep tool permissions minimal, require human approval for anything irreversible such as sending, paying or deleting, keep secrets in environment variables and never in prompts, and log every tool call. The full edition includes dedicated prompts for prompt-injection defence and system-prompt hardening.
The prompts
Agent Idea to Spec (AG-001)
Best tool: Claude or GPT-6 Astra for structured product thinking.
ROLE: You are a senior AI product engineer who designs reliable agents.
CONTEXT: Agent idea: [AGENT_IDEA]. Users: [TARGET_USERS]. Constraints: [CONSTRAINTS] (budget, latency, privacy).
TASK: Turn the idea into a one-page agent spec: the job it does, inputs, outputs, tools it needs, decisions it makes on its own versus with a human, failure modes and success metrics.
OUTPUT FORMAT: Markdown spec with those headings, plus a "Version 1 scope" list of what to leave out.
Agent Loop Blueprint (AG-005)
Best tool: Any model.
ROLE: You are an agent-systems engineer.
CONTEXT: Agent goal: [AGENT_GOAL]. Language: [PROGRAMMING_LANGUAGE].
TASK: Describe the core loop step by step (observe, plan, act, check, stop) with stopping conditions, retry limits, a maximum step budget and error handling. Provide pseudo-code.
OUTPUT FORMAT: Numbered loop description, pseudo-code block, and a list of guardrails.
Tool Schema Generator (AG-014)
Best tool: Any model; verify against your provider's current tool-calling docs.
ROLE: You are an API designer who writes clear tool definitions for LLMs.
CONTEXT: Function to expose: [FUNCTION_DESCRIPTION]. Parameters: [PARAMETERS].
TASK: Write a JSON Schema tool definition with a precise name, a description that says when to use and when not to use the tool, typed parameters with descriptions, and required fields.
OUTPUT FORMAT: JSON code block, then 3 example calls and 1 example where the tool should not be called.
Subagent Definition Writer (AG-039)
Best tool: Claude Code (custom subagents) or Grok Build (subagents).
ROLE: You are configuring specialized subagents for an agentic coding tool.
CONTEXT: Project: [PROJECT_DESCRIPTION]. Repetitive side tasks: [SIDE_TASKS] (for example: test running, code review, docs research).
TASK: Write a subagent definition for each side task: name, a short description that tells the main agent when to delegate, the minimum tools it needs, and a focused system prompt.
OUTPUT FORMAT: One Markdown block per subagent, ready to save as a file. Keep each description under 2 sentences.
Build: Agent Evaluation Harness (AG-034)
Best tool: Claude Code or Grok Build.
ROLE: You are an LLMOps engineer.
GOAL: Build an evaluation harness for my agent at [AGENT_REPO_PATH].
REQUIREMENTS:
- Test cases in YAML: input, expected behavior, and grading method (exact match, contains, JSON schema, or model-graded rubric).
- Run all cases, record pass or fail, latency and token cost, and produce an HTML or Markdown report.
- Compare two prompt or model versions side by side.
PROCESS: Explore my agent's code first, then plan. Add 10 starter test cases based on what the agent does.
OUTPUT: How to run evals, how to add cases, and the first report.
The AI Agents Edition has 60 prompts like these, including fifteen complete build briefs, multi-agent orchestration patterns, red-team sessions and deployment plans.
Get all of them: AI Agents Edition
The full edition is $20. The complete bundle with all four editions is $39.