What you need to know
Surfaces frame Claude differently
| Surface | What frames the model |
|---|---|
| claude.ai apps | Anthropic's own system prompt, plus Projects, knowledge and memory features |
| Messages API | Only what your request contains. No default system prompt, no tools, no files, no memory |
| Claude Code | Its own system prompt, tools, CLAUDE.md, settings and permissions |
| Cloud platforms (Bedrock, Vertex AI, Foundry) | The same models, but feature availability can lag the first-party API |
A prompt that worked in the chat app or in Claude Code can behave differently on the API because the framing is gone. State the role, tone, language and format your app needs, and provide tools and documents explicitly (or use the Agent SDK for a Claude Code-style harness).
What crosses the boundary
Everything in the request enters the model's context: system prompt, history, documents, tool results. Everything the model returns can reach your users. Design both directions.
- Minimize inbound data. Send the fields a task needs, not the whole record. Look facts up in code and use Claude for language where possible. "Ignore the payment fields" does not reduce exposure.
- Shape tool results. A tool that returns a full profile when the task needs a city puts personal data into context for nothing.
- Keep secrets and confidential logic out of prompts. Anything in context can leak; apply pricing rules or business logic in backend code.
- Treat outside content as data. Emails, uploads and web pages are untrusted; never place user-supplied text in the system prompt.
- Validate outbound data. Use schemas and check results (citations, fields) before they reach the browser or another system.
Sessions and state
The Messages API stores nothing for you. Your application decides:
- Where history lives (your database), for whom (one history per user or case, never shared), and for how long (a retention rule you can enforce and delete on).
- What to resend each turn (the part of history the reply needs, often summarized).
- Resuming on another device means loading the stored history; a session ID exists only in higher-level runtimes such as Managed Agents.
Schema decisions
If the front end needs exact fields, constrain the response with a JSON schema and validate it server-side. If a requirement says "every citation must be verifiable," ground answers in supplied documents and check citations before display.
In the exam
Items describe an application design and ask whether it meets a requirement (privacy, isolation, consistency, verifiability) or why behavior differs between surfaces. Prefer designs that minimize data, keep state and secrets in the backend, isolate users and validate output. Distractors rely on instructions to ignore data, client-side keys, API-side storage that does not exist, or shared prompts.
Check your understanding
A prompt is friendly in claude.ai but plain on the API with no system prompt. Why?
Show answer
Answer: A. Each surface frames the model differently; the API sends only what you include.
A health app sends the full patient record to answer "When is my next appointment?" What reduces exposure?
Show answer
Answer: B. Only data the task needs should cross the boundary.
Users must resume chats on another device. What must the app do?
Show answer
Answer: D. The Messages API is stateless; the app owns history.
Apply it: Draw Larkspur's refill-assistant boundary
Larkspur's mobile app will call the refill assistant. The assistant needs prescription status, can request refills, must never give dosing advice, and handles protected health information. The first prototype called the API from the app and sent the full patient profile with every message.
- Redraw the call path from app to Claude.
- List what crosses the boundary inbound and outbound, and what must not.
- Decide where history lives and for how long.
Done when: the key, unneeded data and unvalidated output never cross.
Show model answer
1. App to Larkspur backend (user authenticated), backend to Claude API. The backend holds the key, adds the system prompt, tools and per-user history, and applies rules.
2. Inbound: the user's message, recent history, and tool results limited to prescription name, status, refills left and pickup store. Never: full profile, address, payment data, the API key. Outbound: the reply text, checked for dosing content by a classifier step or rule before display; refill requests go through the refill tool, which validates supply length and logs an audit record.
3. In Larkspur's database, per patient, for 30 days, then deleted; only the last few turns plus a short summary are resent each time.