By Sagar Shankaran, Founder of CallSphere
Reusable code-level patterns for Claude agents — sectioned prompts, tool catalogs as UI, tiered context, and policy-as-data — with examples and a diagram.
Key takeaways
After you have built one Claude agent, you start to see the same shapes recur — the prompt that always works, the tool layout that keeps Claude from guessing, the context structure that survives a forty-step run. These are patterns, in the old software sense: named, reusable solutions to recurring problems. This post collects the ones that have earned their keep across real agentic systems, at the level of actual code and prompt structure rather than abstract advice.
None of these are exotic. What makes them valuable is that they compose. A well-structured prompt plus a well-organized tool catalog plus disciplined context management produces an agent that behaves predictably even as the task grows. Skip one and the others can't fully compensate.
A system prompt that drifts into a wall of prose is hard to maintain and easy for the model to misread. The durable pattern is a fixed set of labeled sections, always in the same order, so you can edit one without disturbing the others. A reliable layout is: role, hard constraints, how to use tools, the output contract, and when to stop.
SYSTEM = """
# Role
You are a support triage agent. You resolve or route customer issues.
# Constraints
- Never promise refunds; only the refund tool authorizes them.
- If you are unsure, ask one clarifying question before acting.
# Tools
Use kb_search for product facts, ticket_create to escalate,
refund_issue only after kb_search confirms eligibility.
# Output contract
End with a JSON block: {resolution, next_action, confidence}.
# Stop
Stop once next_action is set or you have asked one question.
"""
The "Stop" section is the one most prompts omit and the one that most improves behavior. Telling Claude explicitly when its job is done reduces both runaway loops and premature endings.
Think of your tool definitions the way you think of a menu in a well-designed app: each option distinct, each label unambiguous, no two doing nearly the same thing. When two tools overlap, Claude has to guess, and guesses are where reliability dies. The fix is orthogonality — every tool occupies a clearly different region of capability.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
flowchart TD
A["Model needs an action"] --> B{"Reading or writing?"}
B -->|Read| C["kb_search: facts & docs"]
B -->|Write| D{"Reversible?"}
D -->|Yes| E["ticket_create: escalate"]
D -->|No| F["refund_issue: gated action"]
C --> G["Structured result back to model"]
E --> G
F --> G
The diagram shows the decision a well-shaped catalog lets Claude make cleanly: read versus write, and within write, reversible versus irreversible. If your tools force the model to make this distinction by reading long descriptions, the catalog is doing the prompt's job. Encode the structure in the tool boundaries themselves.
The context that goes to Claude each turn should not be a flat transcript. The pattern that scales is three tiers. The pinned tier holds the goal and immutable constraints — it never gets evicted. The summary tier is a rolling, compressed account of what has happened, regenerated as the run grows. The recent tier is the last few turns verbatim, where fidelity matters most.
In code this is a small class that renders these tiers in order. When the recent tier exceeds a threshold, you fold its oldest entries into the summary tier and drop them from recent. The model always sees goal, then a tight history, then the live exchange — coherent regardless of how long the run gets.
A tempting anti-pattern is to scatter business rules through your runtime: "if the tool failed and it's a refund and the customer is premium, then...". This becomes unmaintainable fast. The better pattern pushes policy into two places the model can see: the output of tools (structured results with flags like eligible, retryable, requires_human) and the prompt's contract. The model then reasons over explicit data instead of you hard-coding every branch.
Free-form text is a liability the moment another system depends on the agent's answer. The output-contract pattern fixes this by requiring the agent to end every run with a structured block — typically JSON — whose shape you validate before trusting it. The contract lives in the system prompt's "Output" section, and your runtime parses and checks it. If validation fails, you feed the error back to the model for one corrective turn rather than crashing downstream.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
{ "resolution": "refund_issued",
"next_action": "none",
"confidence": 0.82,
"sources": ["kb_4821"] }
The confidence and sources fields are the underrated parts. They let downstream code route low-confidence results to a human and let you audit which knowledge the agent actually relied on. An agent that must cite its sources tends to make fewer unsupported claims, because the contract forces it to ground each answer in something concrete.
| Problem | Pattern | Signal you need it |
|---|---|---|
| Prompt hard to maintain | Sectioned prompt | Edits cause regressions |
| Model picks wrong tool | Catalog as UI | Overlapping tool calls |
| Long runs lose the plot | Tiered context | Coherence drops after many turns |
| Logic sprawl | Policy in data | Nested runtime conditionals |
There is no hard limit, but past roughly a dozen tools the catalog starts to confuse the model unless the tools are genuinely orthogonal. If you have many, consider grouping related ones behind a single tool with a mode parameter, or splitting into subagents each with a focused catalog.
One or two tight examples of the output contract help a lot; long example transcripts usually hurt by eating context and biasing the model toward copying. Show the shape of a good answer, not a full sample conversation, unless the task is genuinely few-shot in nature.
Agent Skills are a way to package the "how to use tools" guidance so Claude loads it dynamically only when relevant, keeping the base prompt lean. They complement the catalog pattern: tools say what is possible, Skills say how to do specific procedures well.
CallSphere turns these prompt, tool, and context patterns into voice and chat agents that answer every call, pull data mid-conversation, and schedule work without a human in the loop. See the patterns in production at callsphere.ai.
Source & attribution: This is an independent, original explainer inspired by Anthropic's coverage on the Claude blog. Claude, Claude Code, Claude Cowork, Claude Opus, and the Model Context Protocol are products and trademarks of Anthropic. CallSphere is not affiliated with or endorsed by Anthropic.

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
Anthropic's Claude Fable 5 and Mythos 5 explained: pricing, availability, frontier benchmarks, the dual-model safeguard architecture, and what they mean for AI agents.
Where Claude Code, MCP, and multi-agent systems are taking GTM engineering next, and how to prepare your team now for standing and multi-agent workflows.
Where Claude Cowork and the Claude agent ecosystem are heading next — standing agents, MCP, skills as a moat — and the concrete moves to prepare your team now.
The metrics, leading signals, and anti-metrics that prove Claude Cowork is working — acceptance rate, time-to-outcome, and why usage counts mislead.
Shipping an agentic GTM workflow is easy; proving it works is hard. The metrics, signals, and eval loops that show a Claude Code rebuild is paying off.
A realistic end-to-end Claude Cowork use case: a quarterly vendor-spend review from vague ask to shipped deliverable, with every agentic step shown.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI