Lộ trình học›Claude API›Building with the Claude API Mở bản đồ

6.17 · Being specific — Guidelines và Process Steps

Bài viếtTrung cấp20 phút đọc

Bạn prompt: "Viết short story về nhân vật phát hiện tài năng ẩn giấu." Claude có thể output:

Sau bài này, bạn sẽ
  1. Phân biệt 2 loại specificity: Output Guidelines vs Process Steps
  2. Viết quality guidelines kiểm soát length, format, elements
  3. Viết process steps giúp Claude reason qua problem systematically
  4. Biết khi nào cần cả 2, khi nào chỉ cần 1
  5. Đo impact: case study 3.9 → 7.86 score

Mở đầu: "Viết 1 short story" — nhưng 1000 output khác nhau

  • Story 200 từ hoặc 5000 từ
  • 1 nhân vật hoặc 10
  • Chủ đề: music, sports, magic, science...
  • Tone: heart-warming, dark, comedic
  • Setting: fantasy, modern, sci-fi

Cùng prompt → vô số output khác nhau. Nếu bạn ship prompt này cho app, mỗi user thấy 1 story khác nhau về style/length → inconsistent brand.

Technique specificity giải quyết — đưa constraint cụ thể để output predictable.

2 loại specificity

Loại 1: Output Quality Guidelines

Kiểm soát WHAT output trông như thế nào.

Guidelines:
- Length: 500-800 từ
- Structure: 3-act (setup → conflict → resolution)
- Characters: protagonist + 1 supporting
- Tone: heart-warming, hopeful
- Include: pivotal scene revealing talent
- Avoid: violence, profanity

Use for: Control consistency của output.

Loại 2: Process Steps

Kiểm soát HOW Claude think through problem.

Steps:
1. Brainstorm 3 possible talents that would create dramatic tension
2. Pick most interesting one, explain why
3. Outline a pivotal scene revealing the talent
4. Draft supporting character who amplifies impact
5. Write final story with above elements

Use for: Complex reasoning, decision-making, where "jumping to answer" gives shallow result.

Case study: Meal planner tiếp tục (3.9 → 7.86)

v2 (từ bài 6.16) — Clear & direct

prompt_v2 = f"""Generate a one-day meal plan for an athlete:
- Height: {h} cm
- Weight: {w} kg
- Goal: {goal}
- Restrictions: {restrictions}"""
Score
3.9/10
Vấn đề
Claude tạo plan nhưng:
  • Không tính calories đúng
  • Không breakdown macro
  • Không timing bữa ăn
  • Portion vague ("a handful", "some")

v3 — Add Quality Guidelines

prompt_v3 = f"""Generate a one-day meal plan for an athlete:
- Height: {h} cm
- Weight: {w} kg
- Goal: {goal}
- Restrictions: {restrictions}

Guidelines:
1. Include accurate daily calorie total (based on goal)
2. Show protein/fat/carb breakdown in grams
3. Specify timing for each meal (e.g., "8:00 AM")
4. Only use foods meeting restrictions
5. List portion sizes in grams (not "a handful")
6. Keep budget-friendly if not specified otherwise"""

Score: 7.86/10 (+100%)

Chỉ 6 guidelines → score gấp đôi.

v4 — Add Process Steps (optional)

prompt_v4 = f"""Generate a one-day meal plan for an athlete:
...

Follow these steps:
1. Calculate target daily calories based on goal + physiology
2. Determine optimal macro split (protein/fat/carb)
3. Design 4 meals distributing calories (breakfast, lunch, snack, dinner)
4. Select foods respecting restrictions
5. Calculate exact portions

Guidelines:
[same as v3]"""

Score: 8.2/10

Process steps cho marginal gain (+4%). Worth khi task complex, not always.

Khi nào dùng loại nào?

Quality Guidelines — Luôn

Mọi prompt production nên có guidelines. Đây là safety net cho consistency.

Minimum guidelines:

  • Length (dài/ngắn/khoảng)
  • Format (paragraph / bullet / JSON)
  • Tone (formal / casual / technical)
  • Include (phải có gì)

Process Steps — Cho problem phức tạp

Dùng khi:

  • Troubleshooting: "Why did X fail?" — cần check multiple causes
  • Decision: "Should we do A or B?" — cần weigh tradeoffs
  • Analysis: "Explain why sales dropped" — cần examine từ nhiều angle
  • Critical thinking: "Evaluate this argument" — cần counter-consider

Không cần cho:

  • Simple tasks (translate, summarize, classify)
  • Creative writing free-form
  • Format transformation

Ví dụ thực chiến: Sales drop analysis

Not specific enough

"Why did our sales drop 20% last month?"

Claude có thể focus 1 cause (pricing), miss khác (marketing, competition).

Specific with Process Steps

prompt = f"""Analyze why sales dropped 20% last month. Examine these 5 dimensions:

1. Market: macroeconomic, seasonal, industry trends
2. Competition: new competitors, price changes, marketing
3. Internal marketing: campaign performance, channel mix
4. Product: feature changes, bugs, quality issues
5. Customer feedback: reviews, support tickets, NPS

For each dimension:
- State relevant data points (if given; otherwise "need more data")
- Assess likelihood (high/medium/low) of being root cause
- Suggest next step to investigate

Then: synthesize top 2 likely causes + recommended action.

Data:
{sales_data}
Market news:
{news_summary}
Support tickets summary:
{tickets}"""

Output: Analysis có structure, cover all dimensions, không bias vào 1 cause.

Impact: CEO thấy "actionable" thay vì "this is what my gut says".

Ví dụ: Code review prompt

Generic

"Review this code"

Specific — Guidelines + Steps

Review this Python function for production readiness.

Review in this order:
1. Correctness: does it handle intended input/output correctly?
2. Edge cases: empty input, None, type mismatch, large input
3. Performance: complexity, memory
4. Security: injection, auth, data validation
5. Style: naming, comments, follow PEP 8
6. Testability: can this be unit-tested?

For each dimension, output:
- Status: ✅ pass / ⚠️ concerns / ❌ issues
- 1-2 sentences reasoning
- If issues, suggest fix

Finally, overall verdict: ship / needs revision / rewrite

Code:
{code}

Template: Specific prompt

[Action verb + object]  ← Bài 6.16 (clear & direct)

Context:
{domain-specific context}

Guidelines:  ← Bài này
- Length: [X words / X paragraphs]
- Format: [type]
- Must include: [list]
- Must NOT include: [list]
- Tone: [descriptor]

Process:  ← Bài này, optional
1. [step 1]
2. [step 2]
3. [step 3]

Output:
{expected structure}

Case studies theo ngành

Education — Graded essay feedback

prompt = """Grade this student essay on climate change.

Steps:
1. Read for overall argument
2. Check thesis statement strength
3. Evaluate evidence use (count citations, assess relevance)
4. Check structure (intro → body → conclusion)
5. Check grammar and style

Guidelines:
- Score: 0-100
- Feedback: 150-250 words
- Tone: constructive, specific
- Include: 1 strength + 2 areas to improve
- Point to specific sentences in essay

Essay:
{essay}"""

Sales — Call prep brief

prompt = """Prepare 1-page brief for sales call with {prospect}.

Guidelines:
- Length: 500-800 words, 4 sections
- Sections: Company background, Pain points, Value prop, Objection handling

Process:
1. Research company (from website and recent news)
2. Identify top 3 pain points for their industry + size
3. Map pain points → our solution features
4. Anticipate 2 common objections + prep responses
5. Format in 1-pager

Prospect info: {info}"""

Finance — Investment memo

prompt = """Write investment memo on {company}.

Guidelines:
- 1500-2000 words
- Sections: Exec summary, Thesis, Financials, Risks, Recommendation
- Include: at least 3 data points with sources
- Tone: analytical, cautious

Steps:
1. Identify primary investment thesis
2. Support with 3-5 data points
3. Identify 3 key risks + mitigants
4. Conclude: Invest / Pass / Need more research
"""

Anti-patterns

Guidelines contradict mỗi other

Guidelines:
- Concise (< 100 words)
- Include detailed analysis of 5 dimensions
Vấn đề
Impossible. Claude sẽ bias 1, miss other.
Fix
Guidelines consistent. Length match với complexity.

Too many guidelines

Guidelines (15 items):
1. Must be funny
2. Must be < 500 words
3. Must use metaphor
4. ...
Vấn đề
Claude overwhelmed, ignore một phần.
Fix
Max 6-8 guidelines. Prioritize.

Process steps quá prescriptive

Steps (20 steps):
1. Read the input
2. Look for keyword "X"
3. If found, go to step 5
...
Vấn đề
Claude không phải flowchart executor. Quá nhiều steps → output robotic.
Fix
3-6 steps, high-level. Let Claude fill in details.

Dùng Process Steps cho simple task

Task: Translate to English
Steps:
1. Read Vietnamese sentence
2. Identify vocabulary
3. Apply grammar rules
4. Output English
Vấn đề
Overkill. Thêm tokens, không cải thiện.
Fix
Simple task → chỉ clear & direct + minimal guidelines.

Áp dụng ngay

Bài tập 1: Add guidelines to your prompt (15 phút)

Lấy v2 prompt của bạn (từ bài 6.16). Thêm 5-6 guidelines. So sánh output.

Checklist:

  • Có length guideline?
  • Có format guideline?
  • Có must-include?
  • Có tone?
  • Testable?

Bài tập 2: Decision-making prompt với Process Steps (15 phút)

Viết prompt cho 1 trong:

  • "Should our startup pivot?"
  • "Is this contract fair?"
  • "Should I hire person A or B?"

Với Process Steps + Guidelines. Test với scenario.

Tóm tắt bài học

Những điều cốt lõi
  • 2 loại specificity: Output Guidelines (WHAT) và Process Steps (HOW).
  • Guidelines luôn dùng cho production prompt — length, format, must-include.
  • Process Steps dùng cho complex reasoning (troubleshoot, decide, analyze).
  • 6-8 guidelines là sweet spot. Quá nhiều → Claude ignore.
  • Case study meal plan: Clear only = 3.9. Clear + guidelines = 7.86. (+100%)

Tài liệu tham khảo

Kiểm tra nhanh2 câu hỏi · chọn đáp án để xem giải thích
    Bạn đã hoàn thành bài này chưa?Tiến độ lưu trên trình duyệt của bạn.