How to Use Claude
Anthropic's Claude for chat, Projects, API, and long-context reasoning.
Interview tip Claude strengths: long context, careful reasoning, structured output. Use Projects for persistent knowledge.
① What you must know (30 sec)
Claude (by Anthropic) excels at long-context reasoning, careful analysis, and structured writing. Surfaces: claude.ai (chat, Projects, Artifacts), API (Messages API, tool use, batch), and Claude Code (terminal agent for repositories). Models: Opus (best), Sonnet (balance), Haiku (fast/cheap).
Analogy: Claude Projects are like giving the assistant a permanent filing cabinet for one client or codebase — not re-uploading docs every chat.
② How it works
claude.ai — browser chat, Artifacts (live docs/code), Projects with persistent knowledge
API — Messages API with system/user/assistant roles, streaming, tool_use blocks
Claude Code — CLI agent that reads, edits, and commits in your git repo
Long context — 200K+ tokens for full codebases or document sets in one prompt
Structured output — XML tags, JSON mode, and tool schemas for reliable parsing
API message flow
System prompt→User + context→Claude response→Tool result (optional)→Final answer
Put critical instructions at the beginning AND end of long system prompts — Claude weighs both positions heavily.
③ Step-by-step (hands-on)
Step 1 — Pick the right surface
Quick questions → claude.ai. Automation → API. Large repo refactor → Claude Code. Batch jobs → Batch API (50% cost).
Step 2 — Choose model tier
Haiku for classification/speed; Sonnet for daily dev; Opus for architecture and hard reasoning.
Step 3 — Structure prompts with XML
Step 4 — Use Projects for persistence
Upload specs, style guides, API docs once. Every chat in the Project inherits that knowledge.
Step 5 — API integration
anthropic SDK, messages.create with model, max_tokens, system. Handle stop_reason for tool_use.
Step 6 — Evaluate outputs
For critical work, ask Claude to critique its own answer against a rubric before you accept.
④ Code / config patterns
| Technique | When | Example |
|---|---|---|
| XML tags | Long or multi-part prompts | |
| Chain of thought | Math, logic, debugging | "Think step by step, then answer" |
| Few-shot | Fixed output format | 2 examples of input → JSON output |
| Tool use | Agents, API actions | Define tools in API call |
| Projects | Repeat work same domain | Client docs always in context |
import anthropic
client = anthropic.Anthropic()
msg = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
system="You are a code reviewer. Be concise.",
messages=[{"role":"user","content":"Review this diff: ..."}]
)
print(msg.content[0].text)⑤ Production & pitfalls
| Pitfall | Why it hurts | Fix |
|---|---|---|
| Wall of text prompts | Missed constraints | Use XML sections and bullet constraints |
| Wrong model for task | Slow or shallow answers | Haiku for simple; Opus only when needed |
| Ignoring context limits | Truncated middle of huge paste | Use Projects or file references; summarize first |
| No output format specified | Unparseable responses in pipelines | Request JSON, markdown table, or max words |
| Skipping API streaming | Poor UX for long answers | Use stream=True for chat interfaces |
| Assuming web access | Stale facts unless tools enabled | Use search tools or RAG for current data |
Production tips:
- Batch API for offline eval and bulk processing
- Rate limit handling with retries on 529/overloaded
- Log request IDs for Anthropic support escalation
- Enterprise for SSO, audit logs, and data retention controls
⑥ Interview / on-the-job Q&A
| Question | Answer |
|---|---|
| Opus vs Sonnet vs Haiku? | Opus: hardest tasks. Sonnet: best balance. Haiku: speed and cost. |
| What are Projects? | Workspaces with persistent uploaded knowledge applied to every chat. |
| What are Artifacts? | Side-panel live documents/code Claude generates you can edit and export. |
| Claude Code vs Cursor? | Claude Code is terminal-first autonomous repo agent; Cursor is IDE-integrated. |
| How long is context? | 200K+ tokens on recent models — full books or large codebases. |
| What is tool use? | API feature where Claude returns structured tool calls your app executes. |
⑦ Tools & ecosystem
- Surfaces: claude.ai, Anthropic API, Claude Code CLI
- SDKs: anthropic (Python/TS)
- Integrations: Amazon Bedrock, Google Vertex (Claude models)
- Features: Batch API, tool use, prompt caching
⑧ Revision checklist
- Model tier matched to task complexity
- Prompts use XML or clear sections for long context
- Projects set up for recurring domain work
- Output format specified for pipeline use
- API keys in env vars, not client-side
- Streaming enabled for user-facing chat
- Tool use for actions requiring fresh data
- Self-check step for high-stakes outputs
- Data policy reviewed for sensitive content