본문 바로가기
C.W.K.
Stream
Lesson 02 of 10 · published

Claude — 시스템 프롬프트, 긴 맥락, XML 태그

~14 min · providers, claude

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

Claude가 잘하는 것

  • 최신 Opus 등급에서 100만 토큰까지 받는 긴 맥락.
  • 예산을 명시하고 운영자가 별도 생각 블록을 볼 수 있는 Extended Thinking.
  • 태그 경계를 잘 지키도록 많이 훈련된 XML 프롬프트.
  • 병렬 호출과 풍부한 오류 의미를 가진 도구 사용.
  • 출력 구간을 근거 구간에 잇는 Citations 기능.

알아둘 특성

  • 시스템 프롬프트는 메시지가 아니라 최상위 매개변수야.
  • 마지막 메시지는 보통 사용자 역할이어야 해. 어시스턴트 메시지를 붙이면 그 뒤를 이어 쓰는 미리 채우기로 작동해.
  • 토큰은 messages.count_tokens 끝점에서 서버 쪽으로 세며 완벽한 클라이언트 토크나이저는 없어.
  • 엄격한 JSON은 원하는 출력 스키마를 input_schema로 가진 단일 도구와 tool_choice로 구현해.

구조를 또렷하게 보여줘

Claude는 번호 목록, XML 태그, 이름 붙인 절에 잘 반응해. "be helpful" 같은 막연한 말투 지시보다 형식 기준과 필드 의미가 더 중요해.

Code

Claude — 모든 기능을 쓰는 호출·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 태그, 프롬프트 캐싱, 구조화 도구 출력을 함께 쓰는 프롬프트 하나를 만들어봐. 응답의 사용량 블록에서 캐시 적중을 확인해.

Progress

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

댓글 0

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

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