Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Claude
  • CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
  • Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
  • One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
  • Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Choosing a Claude Code Extension: Skill, Hook, Rules File, Subagent, Slash Command or Plugin
  • Rolling Out Claude Code to a Team: Settings Precedence, dontAsk in CI, a Hook for Every-Time Rules and a Plugin for Five Repos
  • A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
  • The Claude Messages API: Your First Call, Field by Field
  • Claude Tool Use: How tool_use and tool_result Work in the Messages API
  • Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
  • Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
  • Claude Streaming Events: The Event Order, message_stop, Tool Arguments, Stop Reasons and a WebSocket Relay
  • Images, PDFs and Thinking Blocks in the Claude Messages API: Typed Blocks In, Typed Blocks Out
  • Getting Data Into Claude: PDF Documents, the Files API, Search Results and Citations
  • Opus, Sonnet or Haiku: Pick the Claude Model per Job, and Test the Request When a New Release Arrives
  • Adaptive Thinking and Effort in Claude: Two Dials, Set per Workload, and the Thinking Block You Must Pass Back
  • Claude Cost Tracking From usage: Count Before, Cap During, Read After, Then Find the Line That Drives the Bill
  • Claude Cache Breakpoints: Where to Put cache_control, How to Move It With the Chat, and Why the Reads Stay at Zero
  • Claude Message Batches or Real Time: Choose by Who Is Waiting, Match by custom_id, Resend Only the Failures
  • Calling Claude Through Amazon Bedrock, Google Cloud and Microsoft Foundry: Same Call, Different Door
  • The Life Cycle of a Claude App: Six Phases, a Model That Retires, and a Release Gate for Every Change
  • Pinning Claude Model IDs and Upgrading Safely: One Change at a Time, a Golden-Set Replay and a Staged Rollout
  • Content Boundaries and Schema Design for Claude: Fence the Input in a Tag, Let the Output Say I Don't Know
  • The Agentic Loop and stop_reason: Keep Turning on tool_use, Stop on end_turn, Cap the Turns
  • The Claude Agent SDK: query(), ClaudeAgentOptions and @tool, in Python and TypeScript
  • Fix the Agent: Four Broken Claude Agent SDK Configs, From the Symptom to the One Wrong Line
  • Claude Managed Agents: Cloud Sandbox, Self-Hosted Sandbox or Self-Hosted Service
  • Agent SDK Hooks for Deterministic Actions: PreToolUse, PostToolUse, and Four Hooks That Fail Silently
  • Memory and Context-Window Patterns for Claude Agents: Context Editing, Compaction and the Memory Tool
  • Reading an Agent Trace: Five Signatures, Five Missing Patterns, and How Long a Fact Must Live
  • Tool Descriptions for Claude: How Claude Picks a Tool, and How to Stop It Picking the Wrong One
  • Tool Input Schemas and Error Responses for Claude: Required Fields, Enums, is_error and a Retry Flag
  • Tool Response Shaping and a Lean Tool Set: Give Claude a Sticky Note, Not the Filing Cabinet
  • Fix the Tool Schema: Read the Trace, Fix the Card, Re-Run (Four Real Schema Bugs)
  • Client Tools, Server Tools and Approval Gates: Who Runs the Tool, and Who Says Yes First
  • Built-in Tool, Custom Tool, Skill or MCP Server? Pick the Lightest One That Fits
  • System Prompt or User Turn: Where Each Instruction Goes, and Output Limits Your Code Enforces
  • Refine the Prompt One Line at a Time, Then Clean and Fence the Customer's Text
  • Prompt Revision Driven by Evals: Name the Cause, Change One Thing, Rerun the Whole Suite
  • Long-Running Sessions: Compact, Prune, Isolate or Start Fresh, Decided by Naming the Failure
  • Context Isolation Through Subagents: Read the Logs Elsewhere, Keep One Line
  • Defensive Parsing of Claude Replies: Check the Stop Reason, Read the Block or the Text, Then Validate the Values
  • Full Context or Retrieval: Choose by Corpus Size, Cost and Freshness
  • Skepticism Toward Confident Output: Check the Quote, the Record and the Sum Before You Send
  • Debugging a Claude App: Three Error Types, the Recovery Each One Earns, and the First Failing Row
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Fix the Cause, Not the Symptom: Four Recovery Drills for an LLM App, Each Checked on a New Input
  • Integration Layer or Model Output? Three Taps and Three Questions to Find Where a Wrong Answer Lives
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Designing an Overnight Document Pipeline on Claude: Batch Lane, Live Lane, a Cached Prefix and a custom_id Reconcile
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps
  • Build a Claude Refund App: the Messages API, Two Tools, an MCP Server and a Hook in One Loop
  • Ship a Claude App: an Eval Gate, Two Guardrail Layers, a Cost Check From usage and a Pinned Model
  • Lab: a 30-Case Golden Set, a Calibrated Judge and a Per-Slice CI Gate on a Claude Refund App
  • Lab: Cut a Claude App's Bill by 62 Percent With Usage Data, Layered Cache Breakpoints and a Batch Job
  • Lab: Three Planted Bugs in a Claude App, a Vague Prompt, a Mistyped Tool Schema and a Broken Stream Handler
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Lab: Harden a Claude App, an Uncalibrated Judge, a Retry Loop That Retries Everything and a Hook Matcher With a Gap
  • Lab: Turn a Claude App Into a Reusable Template, One Pinned Model Id, No Key in Code and Evals Built From Data
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  1. Blog
  2. /
  3. Claude
  4. /
  5. Building with the Claude API

From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps

Part 1 of the refund app build-along: turn one business need into four functional and four infrastructure requirements, map each to a model, an MCP server, a tool, a hook or evals, and prove with a trace that nothing is left uncovered.

Chaand Sheikh

·27 November 2026Building with the Claude API

What you will learn

  • Turn one business need into functional and infrastructure requirements
  • Pick a model, an MCP server, a tool, a hook and evals only after the requirements exist
  • Trace every design element to the requirements it meets
  • Find a gap in a draft design with a short Python check

Before you start

  • Basic Python
  • Claude tool use: tool_use and tool_result

A support lead gets the same question all day: Where is my refund? The business wants an assistant that answers it and refunds small orders. Before anyone picks a model or writes a tool, that one sentence has to become requirements, and the requirements have to become a design.

This is part 1 of a build-along. Over the next posts we build, ship, test and repair one small Claude app, the refund assistant. Here we only do the first two stages of its life: requirements and design.

Need, requirements, design

Every system moves through the same stages: requirements, design, build, test, release, operate and maintain. Life cycle management covers the whole path. Today we stay on the first two and do them well.

From the business need we ask two questions:

  • What must it do? Those are the functional requirements.
  • What must hold? Those are the infrastructure requirements.

Two questions we do not ask yet: which model, and which tools. That is too early. Think of building a home. The client says what they want, the plan lists the rooms (what the home does) and the wiring, plumbing and locks (what must hold), and only then does the blueprint pick walls and pipes. You don't buy bricks before you know the rooms.

A need says why. Requirements say what. Design says how.

requirements.py: eight things the app must satisfy

We write the requirements down as data, so the design can point at them by id.

"""One business need, turned into requirements."""
NEED = "Answer refund questions and refund small orders."

FUNCTIONAL = {
    "F1": "Look up an order by its id",
    "F2": "Answer the customer in plain words",
    "F3": "Refund a small order",
    "F4": "Hand a big refund to a human",
}

INFRA = {
    "I1": "Order data stays in our system",
    "I2": "Replies are quick enough for chat",
    "I3": "The refund limit holds every time",
    "I4": "A change is checked before release",
}

The first list is what users see. The second keeps the app safe and working. Notice I3: the refund limit holds every time. "Every time" is a strong word, and it will decide one of our design choices.

Every element meets a requirement

Now the design. Each element has to answer at least one requirement, and every requirement needs at least one element.

Requirements traced to design elements F1 look up an orderF2 answer in plain words F3 refund a small orderF4 hand big refund to human I1 order data stays with usI2 quick enough for chat I3 refund limit holds every timeI4 change checked before release model: SonnetMCP server: orders tool: issue_refundhook: PreToolUse evals: refund_cases
One element can meet two requirements, and no requirement is left without one. The hook (red) carries F4 and I3.
  • Model, Sonnet for F2 and I2: plain answers, fast enough for chat. A balanced model is only a first guess here; the evals confirm it later.
  • An MCP server called orders for F1 and I1: it serves the orders, and the data stays with us.
  • A tool, issue_refund, for F3.
  • A hook for F4 and I3. It runs before the tool does, and it can say no. Because it's code, it holds every time, which a sentence in a prompt can't promise.
  • Evals, refund_cases, for I4: a change is checked before release.

design.py: the trace and the gap check

The design is data too. Each element lists the requirement ids it meets. Two small functions turn that around.

"""Each design element says which requirements it meets."""
from requirements import FUNCTIONAL, INFRA

SONNET = "claude-sonnet-5-5"

DESIGN = [
    {"kind": "model", "name": SONNET, "meets": ["F2", "I2"]},
    {"kind": "mcp server", "name": "orders", "meets": ["F1", "I1"]},
    {"kind": "tool", "name": "issue_refund", "meets": ["F3"]},
    {"kind": "hook", "name": "PreToolUse", "meets": ["F4", "I3"]},
    {"kind": "evals", "name": "refund_cases", "meets": ["I4"]},
]


def trace(design):
    """For each requirement id, the design elements that meet it."""
    out = {}
    for item in design:
        for rid in item["meets"]:
            out.setdefault(rid, []).append(f"{item['kind']} {item['name']}")
    return out


def uncovered(design):
    """Requirement ids that no design element meets."""
    wanted = {**FUNCTIONAL, **INFRA}
    met = {rid for item in design for rid in item["meets"]}
    return sorted(set(wanted) - met)

trace answers "who meets F4?". uncovered answers "is anything missing?". The runner prints both, and also tries a rough draft that leaves the hook out.

"""Print the trace from each requirement to its design element, then check gaps."""
import design
from requirements import FUNCTIONAL, INFRA, NEED

print(f"need: {NEED}")
links = design.trace(design.DESIGN)
for rid in [*FUNCTIONAL, *INFRA]:
    print(f"{rid} -> {', '.join(links[rid])}")
draft = [d for d in design.DESIGN if d["kind"] != "hook"]
print(f"draft without the hook -> uncovered: {', '.join(design.uncovered(draft))}")
rest = design.uncovered(design.DESIGN)
print(f"full design -> uncovered: {', '.join(rest) or 'none'}")
need: Answer refund questions and refund small orders.
F1 -> mcp server orders
F2 -> model claude-sonnet-5-5
F3 -> tool issue_refund
F4 -> hook PreToolUse
I1 -> mcp server orders
I2 -> model claude-sonnet-5-5
I3 -> hook PreToolUse
I4 -> evals refund_cases
draft without the hook -> uncovered: F4, I3
full design -> uncovered: none

Read the last two lines. Drop the hook and two requirements fall through: nobody hands a big refund to a human, and nothing holds the limit. With the full design, nothing is uncovered. That one check is cheap, and it catches the design that "looks complete" but isn't.

Three designs that start too late

When a scenario hands you a business need and a few designs, these are the traps:

Tempting designWhat goes wrong
Pick the model and tools firstThe design has nothing to meet, so you can't tell if it is right
List only what the app doesThe infrastructure needs (data location, limits, release checks) go missing
Add every feature on offerSome elements meet no requirement and only add cost and risk

The right answer gets both kinds of requirements first, then traces each element to one.

Recap

StepOutput
NeedOne sentence: answer refund questions and refund small orders
RequirementsF1-F4 (what it does) and I1-I4 (what must hold)
DesignA model, an MCP server, a tool, a hook and evals
TraceEvery element names what it meets; uncovered returns none

Try it yourself: add a fifth infrastructure requirement, "I5 every refund is logged", run the script, and watch uncovered name it until you add an element that meets it.

Next: part 2, the build, where these five elements become four Python files and one loop.

Keep going in Claude · 55 of 66

Previous
Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
Next post
Build a Claude Refund App: the Messages API, Two Tools, an MCP Server and a Hook in One Loop
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Related posts

The Claude Messages API: Your First Call, Field by Field

One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.

Claude Tool Use: How tool_use and tool_result Work in the Messages API

Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.

Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared

Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.

Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move

Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.

On this page

  • Need, requirements, design
  • requirements.py: eight things the app must satisfy
  • Every element meets a requirement
  • design.py: the trace and the gap check
  • Three designs that start too late
  • Recap
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.