프롬프트를 생성하는 프롬프트
시스템 프롬프트 생성기, 페르소나 생성기, 작업별 프롬프트 생성 공장을 다룹니다.
프롬프트를 생성하는 프롬프트은(는) CoddyKit의 무료 AI Prompt Engineering 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 AI Prompt Engineering 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. AI Prompt Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
프롬프트 공장
프롬프트 공장은 주어진 작업을 위한 여러 프롬프트 변형을 generate하는 메타 프롬프트입니다. 프롬프트 하나를 작성하는 대신 작업과 제약 조건을 지정하면, 공장이 테스트하고 선택할 수 있는 후보 모음을 생성합니다.
시스템 프롬프트 변형 생성
모델에 동일한 역할에 대해 서로 다른 시스템 프롬프트 변형 N개를 생성하도록 요청합니다. 각 변형은 서로 다른 어조나 의사소통 방식을 사용해야 합니다. 이것이 시스템 프롬프트를 A/B 검증하는 출발점입니다.
import anthropic
client = anthropic.Anthropic(api_key='YOUR_API_KEY')
VARIANT_FACTORY_PROMPT = '''Generate {num_variants} different system prompt variants
for a coding assistant targeting junior developers.
Each variant should have a distinctly different approach:
- Variant 1: Friendly and encouraging mentor style
- Variant 2: Concise and technical style
- Variant 3: Socratic method (asks guiding questions instead of giving answers)
- Variant 4: Game-based, uses analogies and rewards
- Variant 5: Strict teacher who corrects mistakes firmly but fairly
For each variant output:
{{"id": 1, "style": "<style name>", "prompt": "<full system prompt>"}}
Return as a JSON array.'''
def generate_prompt_variants(num_variants=5):
import json
response = client.messages.create(
model='claude-opus-4-5', max_tokens=3000,
messages=[{'role': 'user', 'content':
VARIANT_FACTORY_PROMPT.format(num_variants=num_variants)}]
)
return json.loads(response.content[0].text)
variants = generate_prompt_variants(5)
for v in variants[:2]:
print(f'Variant {v["id"]} ({v["style"]}): {v["prompt"][:80]}...')작업별 프롬프트 템플릿 생성기
프롬프트 템플릿 생성기는 특정 작업 유형에 맞는 매개변수화된 템플릿을 생성합니다. 출력은 한 번만 사용하는 프롬프트가 아니라 재사용 가능한 템플릿입니다.
TEMPLATE_FACTORY_PROMPT = '''Create a production-ready prompt template for the following task.
Task type: {task_type}
Domain: {domain}
Target audience: {audience}
Requirements for the template:
1. Use {{variable}} placeholders for all input values
2. Include role/persona definition
3. Specify exact output format
4. Add quality constraints
5. Include a worked example using {{example_input}} placeholder
Also output:
- variables: list of all {variable} placeholders and their descriptions
- suggested_model: which Claude/GPT model tier is appropriate
- estimated_tokens: rough estimate of output token count
Return as JSON: {{template, variables, suggested_model, estimated_tokens}}'''
def generate_task_template(task_type, domain, audience):
import json
response = client.messages.create(
model='claude-opus-4-5', max_tokens=1500,
messages=[{'role': 'user', 'content':
TEMPLATE_FACTORY_PROMPT.format(
task_type=task_type,
domain=domain,
audience=audience
)}]
)
return json.loads(response.content[0].text)
template = generate_task_template(
task_type='summarization',
domain='legal contracts',
audience='non-lawyer business executives'
)
print('Template preview:', template['template'][:200], '...')
print('Variables:', template.get('variables', [])[:3])페르소나 프롬프트 생성기
페르소나 생성기는 시스템 프롬프트, 예시 대화, 안티패턴(페르소나가 절대 말하거나 행동해서는 안 되는 내용)을 포함한 완전한 페르소나 정의를 생성합니다.
PERSONA_FACTORY_PROMPT = '''Design a complete AI assistant persona for: {application}.
Output a JSON object with these keys:
- name: persona name
- tagline: one-sentence description
- system_prompt: full system prompt (150-250 words)
- communication_style: 4-5 sentences describing how this persona communicates
- example_good_response: example of an ideal response to a typical user question
- example_bad_response: example of a response that would break character or violate guidelines
- persona_rules: list of 5 behavioral rules specific to this persona
- forbidden_phrases: list of 5 phrases this persona would never use
Make the persona distinct, consistent, and aligned with the application context.'''
def generate_persona(application):
import json
response = client.messages.create(
model='claude-opus-4-5', max_tokens=2000,
messages=[{'role': 'user', 'content':
PERSONA_FACTORY_PROMPT.format(application=application)}]
)
return json.loads(response.content[0].text)
persona = generate_persona('a mental wellness check-in app for university students')
print('Persona:', persona['name'])
print('Tagline:', persona['tagline'])
print('System prompt preview:', persona['system_prompt'][:150], '...')검증 사례 생성기
메타 프롬프팅을 사용하면 프롬프트 품질을 평가하기 위한 다양한 검증 사례를 생성할 수 있습니다. 검증 사례 생성기는 일반적인 사용 사례, 극단적인 사례, 적대적 입력을 포괄하는 사용자 입력을 생성합니다.
TEST_CASE_FACTORY = '''Generate {num_cases} test cases for evaluating an AI assistant.
Assistant description: {assistant_description}
For each test case provide:
- id: number
- category: one of [typical, edge_case, adversarial, off_topic, ambiguous]
- user_message: the input message
- expected_behavior: what a good response should do (not the response itself)
- failure_modes: what wrong responses might look like
Distribution: 5 typical, 3 edge cases, 2 adversarial, 2 off-topic, 3 ambiguous.
Return as JSON array.'''
def generate_test_cases(assistant_description, num_cases=15):
import json
response = client.messages.create(
model='claude-opus-4-5', max_tokens=3000,
messages=[{'role': 'user', 'content':
TEST_CASE_FACTORY.format(
num_cases=num_cases,
assistant_description=assistant_description
)}]
)
return json.loads(response.content[0].text)
test_cases = generate_test_cases(
'A Python coding tutor for beginners that explains errors in simple language'
)
for tc in test_cases[:3]:
print(f'[{tc["category"]}] {tc["user_message"][:60]}...')퓨샷 예시 생성기
퓨샷 예시를 수작업으로 작성하려면 상당한 시간이 걸립니다. 퓨샷 예시 생성기는 작업 설명과 선택적인 시드 예시를 바탕으로 예시를 생성합니다.
FEW_SHOT_FACTORY = '''Generate {num_examples} high-quality few-shot examples for:
Task: {task_description}
Each example must:
- Be realistic and representative of the actual task
- Show the exact input-output format
- Cover different sub-types or difficulty levels
- Be labeled: [Easy], [Medium], or [Hard]
Format exactly as:
---EXAMPLE {n}---
Input: <input>
Output: <output>
[Difficulty: Easy/Medium/Hard]
Make examples progressively more complex from first to last.'''
def generate_few_shot_examples(task_description, num_examples=5):
response = client.messages.create(
model='claude-opus-4-5', max_tokens=2000,
messages=[{'role': 'user', 'content':
FEW_SHOT_FACTORY.format(
task_description=task_description,
num_examples=num_examples
)}]
)
return response.content[0].text
examples = generate_few_shot_examples(
'Classify customer emails into: Complaint, Question, Praise, Refund Request'
)
print(examples[:500], '...')사고 과정 프롬프트 생성기
사고 과정(CoT) 프롬프트를 생성하려면 생성기가 추론 구조와 예시 추론 체인을 모두 만들어야 합니다. 이는 완전히 구조화된 CoT 프롬프트를 출력하는 더 복잡한 메타 프롬프트입니다.
COT_PROMPT_FACTORY = '''Design a chain-of-thought prompt for solving: {problem_type}
The prompt must:
1. Define the step-by-step reasoning process specific to this problem type
2. Include a worked example showing the full reasoning chain
3. Use "Think step by step" or equivalent CoT trigger phrase
4. End with a clear output specification
Output format:
{
"cot_trigger": "the trigger phrase",
"reasoning_steps": ["step 1 description", "step 2 description", ...],
"worked_example": {
"problem": "...",
"reasoning": "Step 1: ... Step 2: ... etc.",
"answer": "..."
},
"full_prompt_template": "the complete template with {problem} placeholder"
}'''
def generate_cot_prompt(problem_type):
import json
response = client.messages.create(
model='claude-opus-4-5', max_tokens=1500,
messages=[{'role': 'user', 'content':
COT_PROMPT_FACTORY.format(problem_type=problem_type)}]
)
return json.loads(response.content[0].text)
cot = generate_cot_prompt('debugging Python runtime errors')
print('CoT steps:', cot['reasoning_steps'][:3])
print('Trigger:', cot['cot_trigger'])프롬프트 변형 선택 및 점수 매기기
여러 프롬프트 변형을 생성한 후, 점수 매기기 메타 프롬프트를 사용하여 실제로 검증하기 전에 품질순으로 순위를 매깁니다. 이렇게 후보를 사전 필터링하면 실제 API 호출 횟수를 줄일 수 있습니다.
SCORING_PROMPT = '''You are evaluating prompt variants for quality.
Rate each variant on these criteria (1-5):
1. Clarity: Is the task and output format clearly defined?
2. Completeness: Are all necessary instructions present?
3. Constraints: Are appropriate constraints and guardrails in place?
4. Conciseness: Is there unnecessary length that dilutes the prompt?
5. Robustness: Would this handle edge cases and adversarial inputs?
For each variant output:
{"id": <id>, "scores": {clarity: N, completeness: N, constraints: N,
conciseness: N, robustness: N}, "total": N, "rationale": "<2 sentences>"}
Return JSON array sorted by total score descending.
Variants to evaluate:
{variants_json}'''
def rank_prompt_variants(variants):
import json
response = client.messages.create(
model='claude-opus-4-5', max_tokens=2000,
messages=[{'role': 'user', 'content':
SCORING_PROMPT.format(
variants_json=json.dumps(variants, indent=2)
)}]
)
return json.loads(response.content[0].text)
ranked = rank_prompt_variants(variants)
print('Top variant:', ranked[0]['id'], '| Score:', ranked[0]['total'])
print('Rationale:', ranked[0]['rationale'][:100])프롬프트 다양성: 최대한 다양한 변형 생성
프롬프트 변형을 생성할 때는 품질만큼 다양성도 중요합니다. 모델이 거의 동일한 변형을 생성하지 않도록 명시적인 다양성 지침을 사용합니다.
DIVERSITY_FACTORY = '''Generate 5 MAXIMALLY DIVERSE prompt variants for:
Task: {task_description}
Diversity requirements:
- Each variant must use a DIFFERENT cognitive approach:
1. Direct instruction approach
2. Role-based persona approach
3. Example-first (few-shot) approach
4. Constraint-based (tell what NOT to do) approach
5. Output-format-first approach (start by defining desired output)
- No two variants should share more than 20% of their wording
- Each variant should be completable without reference to the others
For each variant tag it with its approach name.
Return as JSON array: [{"approach": "...", "prompt": "..."}]'''
def generate_diverse_variants(task_description):
import json
response = client.messages.create(
model='claude-opus-4-5', max_tokens=3000,
messages=[{'role': 'user', 'content':
DIVERSITY_FACTORY.format(task_description=task_description)}]
)
return json.loads(response.content[0].text)
diverse = generate_diverse_variants('Answering customer questions about product returns')
for v in diverse:
print(f'Approach: {v["approach"]} | Prompt: {v["prompt"][:60]}...')프롬프트 생성기 파이프라인 구축
완전한 프롬프트 생성기 파이프라인은 생성, 점수 매기기, 다양성 확인, 출력을 결합하여 바로 사용할 수 있는 프롬프트 후보 집합을 만듭니다.
def prompt_factory_pipeline(task_description, num_candidates=5, top_k=3):
print(f'[1/4] Generating {num_candidates} diverse prompt variants...')
variants = generate_diverse_variants(task_description)
print('[2/4] Scoring prompt quality...')
ranked = rank_prompt_variants(variants)
print('[3/4] Selecting top candidates...')
top_candidates = ranked[:top_k]
print('[4/4] Generating test cases for evaluation...')
test_cases = generate_test_cases(task_description, num_cases=10)
output = {
'task': task_description,
'candidates': top_candidates,
'test_cases': test_cases,
'recommendation': (
f'Start A/B testing with top 3 candidates. '
f'Run each against {len(test_cases)} test cases. '
f'Promote the highest-scoring candidate to production.'
)
}
print('Pipeline complete.')
return output
# result = prompt_factory_pipeline(
# 'Summarizing customer support tickets for a priority queue'
# )
# print(result['recommendation'])프롬프트 생성의 안티패턴
프롬프트 생성기에는 여러 실패 방식이 있습니다. 이러한 안티패턴을 이해하면 더 나은 메타 프롬프트와 더 나은 후보 프롬프트를 만들 수 있습니다.
PROMPT_FACTORY_ANTIPATTERNS = {
'Generic variants': {
'problem': 'All variants say the same thing in slightly different words',
'cause': 'No diversity instruction in the meta-prompt',
'fix': 'Explicitly specify different approaches or styles for each variant'
},
'Hallucinated instructions': {
'problem': 'Generated prompt references APIs, rules, or facts that do not exist',
'cause': 'Model fills gaps in its knowledge with plausible-sounding content',
'fix': 'Review all domain-specific claims; add validation step'
},
'Missing edge case coverage': {
'problem': 'Generated prompts only handle happy path, not failures',
'cause': 'Meta-prompt did not specify adversarial/edge case requirements',
'fix': 'Explicitly ask for edge case handling in the meta-prompt'
},
'Over-length inflation': {
'problem': 'Generated prompts are verbose and repetitive',
'cause': 'Model padds output without conciseness constraint',
'fix': 'Add word count constraint: "between 100-200 words"'
}
}
for pattern, info in PROMPT_FACTORY_ANTIPATTERNS.items():
print(f'{pattern}:')
print(f' Fix: {info["fix"]}')빠른 확인
코딩 도우미를 A/B 검증하기 위해 시스템 프롬프트 변형 5개가 필요합니다. 변형들이 실제로 서로 다르도록 하려면 어떤 메타 프롬프트 지침이 가장 좋을까요?
프롬프트 생성기 요약
프롬프트 생성기는 메타 프롬프팅을 사용하여 대규모로 후보 프롬프트를 생성합니다:
- 변형 생성기: A/B 검증을 위해 다양한 변형 N개 생성
- 템플릿 생성기: 작업 설명에서 매개변수화된 템플릿 생성
- 페르소나 생성기: 시스템 프롬프트와 예시를 포함한 완전한 페르소나 정의 생성
- 검증 사례 생성기: 일반 사례, 극단적 사례, 적대적 검증 입력 생성
- 퓨샷 생성기: 지정된 난이도 수준에 맞는 입력-출력 예시 쌍 생성
- 점수 매기기 메타 프롬프트: 실제 검증 전에 생성된 후보의 순위 지정
- 다양성 요구 사항: 거의 동일한 변형이 생성되지 않도록 서로 다른 접근 방식 지정
자주 묻는 질문
“프롬프트를 생성하는 프롬프트” 강의는 무료인가요?
네 — “프롬프트를 생성하는 프롬프트” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 AI Prompt Engineering 강의 전체를 잠금 해제할 수 있습니다. AI Prompt Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
“프롬프트를 생성하는 프롬프트”에서 뭘 배우나요?
시스템 프롬프트 생성기, 페르소나 생성기, 작업별 프롬프트 생성 공장을 다룹니다. 브라우저에서 직접 실행하는 실습 코드로 AI Prompt Engineering을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
AI Prompt Engineering을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 AI Prompt Engineering은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“프롬프트를 생성하는 프롬프트” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 AI Prompt Engineering 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 AI Prompt Engineering 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 메타 프롬프트란 무엇인가요?
- 프롬프트를 생성하는 프롬프트
- 스스로 개선하는 프롬프트 시스템
- 자기 개선에서의 평가와 선택