C.W.K.
Stream
Lesson 02 of 10 · published

Claude — System prompt, long context, XML tag

~14 min · providers, claude

Level 0수련생
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

Claude가 잘하는 것

  • Long context (latest Opus tier에 1M 토큰).
  • Extended thinking (explicit budget, operator-visible thinking block).
  • XML-tagged prompt — 모델이 tag boundary 존중하게 heavily train.
  • Parallel call과 rich error semantics 박힌 tool use.
  • Span-level traceability 박힌 grounded 답에 Citation feature.

알 quirk

  • System prompt가 top-level parameter, message 아니야 — 안 섞어.
  • 마지막 message가 user message여야 (또는 모델이 응답할 거 없음). assistant message append해서 모델 continue로 prefill.
  • Token counting이 server-side via messages.count_tokens endpoint — 완벽한 client-side tokenizer 없어.
  • JSON 모드가 tool 통해 (tool_choice로 단일 output tool, 그 input_schema = 너의 output schema).

Style preference

Claude가 explicit structure에 잘 응답: numbered list, XML tag, named section. Vague tone instruction ("be helpful")이 format anchor와 field semantics보다 덜 중요.

Code

Claude — full-feature call·python
import anthropic

client = anthropic.Anthropic()
resp = client.messages.create(
    model="claude-opus-4-7",
    system=[
        {"type": "text", "text": LARGE_REF, "cache_control": {"type": "ephemeral"}},
        {"type": "text", "text": "You are a contract analyst. Cite sources from <docs>."}
    ],
    thinking={"type": "enabled", "budget_tokens": 6_000},
    tools=[{"name": "emit_findings", "input_schema": SCHEMA}],
    tool_choice={"type": "tool", "name": "emit_findings"},
    max_tokens=2048,
    messages=[{"role": "user", "content": question}]
)

External links

Exercise

XML tag, prompt caching, structured tool output 동시에 쓰는 prompt 한 개 build. response usage block에서 cache hit verify.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.