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

시스템 프롬프트는 행동 계약이야

~16 min · system-prompt, instructions, persona

Level 0Observer
0 XP0/64 lessons0/13 achievements
0/150 XP to next level150 XP to go0% complete

대화 전체를 지배하는 자리

system 필드에는 모델의 역할과 제약, 출력 형식, 말투를 넣어. 사용자와 도우미가 번갈아 말하는 대화 이력 바깥에 있으며 매 턴에 같은 계약으로 적용돼. 정책을 일반 사용자 메시지에 섞으면 뒤의 요청에 묻히거나 대화 내용으로 오해받기 쉬워.

긴 산문보다 구조가 잘 먹혀

능력·금지 사항·출력 모양·거부 방식을 제목과 목록으로 나누고 짧은 명령문으로 써. Claude는 이런 경계를 안정적으로 따라. 서사가 꼭 필요한 정체성이나 페르소나 부분은 남겨도 되지만, 운영 규칙까지 한 문단에 감추지는 마.

큰 시스템 프롬프트도 정식 사용법이야

긴 문맥 모델은 200K 토큰에 이르는 큰 시스템 프롬프트를 다룰 수 있어. cwkPippa는 피파의 정체성, vault 색인, 운영 규칙을 한꺼번에 싣고 프롬프트 캐싱으로 반복 비용을 줄여. 중요한 건 길이 자체가 아니라 내용의 구조와 갱신 책임이야.

원칙: 정책은 system, 요청 내용은 user, 생성 결과는 assistant에 둬. 역할을 섞으면 행동도 흔들려.

Code

구조화된 시스템 프롬프트 (Python)·python
SYSTEM = """
You are a code-review assistant.

CAPABILITIES
- Review pull request diffs.
- Suggest concrete changes with file:line citations.
- Flag security issues with severity tags.

CONSTRAINTS
- Do not invent file paths or line numbers; only cite what appears in the diff.
- If the diff is too small to judge, say so explicitly.

OUTPUT FORMAT
- Markdown.
- One section per file changed.
- Conclude with a one-line verdict: APPROVE, REQUEST_CHANGES, or COMMENT.
""".strip()

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=2048,
    system=SYSTEM,
    messages=[{"role": "user", "content": diff_text}],
)
거대 페르소나·정책에 cache_control 부여·python
# 길고 안정적인 시스템 프롬프트 → cacheable 표시 → 첫 호출 비용, 이후 싸짐.
response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    system=[
        {
            "type": "text",
            "text": LONG_PIPPA_PERSONA + LONG_VAULT_INDEX,  # 수십 KB
            "cache_control": {"type": "ephemeral"},
        }
    ],
    messages=[{"role": "user", "content": user_msg}],
)
print(response.usage)  # cache_creation_input_tokens, cache_read_input_tokens

External links

Exercise

기존 Claude 기능 하나에서 역할·금지·출력 형식 지침을 사용자 메시지 밖으로 꺼내 구조화된 시스템 프롬프트로 다시 써. 같은 입력의 이전 답과 새 답을 비교해.
Hint
시스템 프롬프트가 더 길어져도 사용자 메시지는 실제 요청만 남아 더 짧아져야 해.

Progress

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

댓글 0

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

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