2.5 Claude application design
The heaviest skill on the exam (8.6%). It is about where a piece of behaviour belongs.
How instructions reach Claude, per interface
| Interface | Instruction channels | Loaded when | Shared with the team? |
|---|---|---|---|
| Claude API / SDKs | system parameter; messages; tool descriptions; output_config; mid-conversation system messages | Every request, because the API is stateless | Only through your code |
| Claude Code | CLAUDE.md hierarchy, .claude/rules/, settings.json, skills, slash commands, subagent definitions, hooks | CLAUDE.md always; rules on matching paths; skills and commands on invocation | Yes, when the files are committed |
| Claude Agent SDK | Options object (system prompt, allowed tools, agents, hooks, MCP servers) plus the same file-based config | Per query, per session | Through the repo |
| Claude Desktop / claude.ai | Project instructions, per-conversation context, connected MCP servers | Per project or conversation | Only within the workspace/project |
The same sentence has different force in different channels. In a system prompt it is a strong prior. In CLAUDE.md it is a strong prior that costs tokens on every session. In a tool description it steers selection. In a hook it is an enforced invariant. When an item says "must always", the answer is the enforced channel — not the most emphatic wording.
Where to put a rule
| The rule | Put it |
|---|---|
| Applies to every request of this application | system prompt (cached prefix) |
| Applies to everyone working in this repo | Project CLAUDE.md, committed |
Applies only under src/api/** | .claude/rules/ with a path glob |
| Applies only to one recurring task | A skill or slash command, loaded on demand |
| Describes when to use a capability | The tool's description |
| Must hold every time, with no exception | A hook or a server-side check |
| Is a per-request detail | The user message, after the cache breakpoint |
| Is an operator instruction arriving mid-conversation | A mid-conversation system message in messages |
Content boundaries
Every application has a boundary between instructions you authored and data that arrived from elsewhere. Design it explicitly.
| Zone | Contents | Authority |
|---|---|---|
| Trusted instructions | System prompt, tool descriptions, hook logic | May direct behaviour |
| Semi-trusted | Authenticated user messages | May request actions within that user's permissions |
| Untrusted data | Retrieved documents, web pages, tool output from third parties, file uploads, other users' content | Data only. Never authority |
Mechanics that implement the boundary:
- Delimit and label untrusted content — an XML-ish tag with a name, and a statement that its contents are data to analyse, not instructions to follow.
- Never concatenate untrusted text into the system prompt.
- Scope the tools available on a turn that processes untrusted content to read-only ones.
- Gate the sensitive action on your side, so an injected instruction has nothing to reach (7.1).
- Do not echo untrusted content back into a privileged channel (a
CLAUDE.md, a stored system prompt, a memory file) without review.
Schema design
Schemas appear in three places — tool inputs, structured outputs, and your own persistence layer — and the same design rules apply.
| Rule | Why |
|---|---|
| One purpose per tool, one meaning per field | Overloaded fields force the model to guess |
| Describe every field | The description is the model's only spec; a bare "type": "string" invites format drift |
Constrain with enum where the value set is closed | Removes a whole class of invalid output |
| Make absence representable | Nullable or optional fields, so "not present in the document" is expressible without invention |
required only what is truly required | Over-required schemas convert unknowns into hallucinations |
additionalProperties: false plus strict: true | Guarantees validated tool input |
| Flat over deep | Deep nesting raises error rates and token cost |
| Version the schema | Downstream consumers need to know which shape they got |
| Carry provenance | Source, page, confidence, or a flag — so the consumer can decide, not guess |
Session hygiene
The API is stateless, so a "session" is whatever your code keeps. Poor hygiene shows up as cost, latency, and drift.
| Practice | Detail |
|---|---|
| Bound the history | A turn limit, a token budget, or compaction — history grows the bill on every turn |
| Prune tool output before appending | Keep the fields that matter; drop the payload |
| Keep the cacheable prefix stable | No timestamps, request IDs, or reshuffled tool lists inside it |
| Externalise durable facts | A memory store or scratchpad file, not reliance on the transcript surviving |
| Reset deliberately | A new task gets a new session rather than inheriting an unrelated 60-turn context |
| Isolate per user | One session per authenticated user; never share a conversation across identities |
| Separate concerns across sessions | Two unrelated tasks in one context interfere with each other |
In Claude Code the same hygiene is expressed with /clear, /compact, resuming a specific session, and delegating verbose exploration to a subagent.
Plugin management
Plugins package configuration — commands, skills, subagents, hooks, and MCP server definitions — so a team installs one thing instead of copying files.
| Concern | Practice |
|---|---|
| Source | Install from a known marketplace or repository; review what the plugin's hooks and MCP servers can do before enabling |
| Scope | Project-level for team-wide capability; user-level for personal preference |
| Pinning | Pin a version; an auto-updating plugin changes behaviour without a deploy |
| Dependencies | Record which MCP servers, binaries, and environment variables a plugin needs (2.6) |
| Least privilege | A plugin's tools and hooks inherit real power — audit allowed-tools and any command it can run |
| Conflicts | Two plugins defining the same command name, or overlapping tool names, need explicit resolution |
Quiz
- Question 1
A coding convention must apply to every developer on a repository from the moment they pull, and must not depend on anyone configuring their machine. Where does it belong?
- Question 2
An extraction schema marks all 14 fields required, with no nullable types. Invoices that genuinely lack a field come back with plausible invented values. Which schema change removes the pressure to invent?
- Question 3
A support agent summarises ticket attachments written by third parties. Which design does the most to stop instructions embedded in an attachment from being acted on?