📘 Basics

Prompt Engineering: From Zero to Reliable Outputs

The skill behind 80% of LLM success. From zero-shot to chain-of-thought, system prompts, and structured output.

📅 June 30, 2026 📊 Level: beginner 📦 GitHub: anthropics/prompt-eng-interactive-tutorial

Sponsored

Prompt Engineering: From Zero to Reliable Outputs

Prompt engineering is the single most leveraged skill in LLM work. A great prompt beats a great model 80% of the time.

Levels of prompting

Level 1: Zero-shot

response = llm("Translate to French: Hello world")

Level 2: Few-shot (give examples)

prompt = """Translate English to French:
English: Hello
French: Bonjour

English: Goodbye
French: Au revoir

English: Thank you
French:"""
response = llm(prompt)

Level 3: System + Instructions

messages = [
    {"role": "system", "content": "You are a professional translator. Always output in the target language only, no explanations."},
    {"role": "user", "content": "Thank you"}
]

Level 4: Chain-of-thought (CoT)

prompt = """Solve step by step.

Q: A store sells 3 shirts at $15 each and 2 pants at $25 each. What's the total?
A: Let me calculate:
- Shirts: 3 × $15 = $45
- Pants: 2 × $25 = $50
- Total: $45 + $50 = $95

Q: 5 books at $12 each and 3 pens at $4 each. Total?
A:"""

Level 5: Structured output

import json
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "List 3 fruits with their colors"}],
    response_format={"type": "json_object"}
)
data = json.loads(response.choices[0].message.content)
# {"fruits": [{"name": "apple", "color": "red"}, ...]}

The 5 principles

  1. Be specific — “Write a 100-word summary” > “Summarize”
  2. Give examples — show, don’t tell
  3. Use delimiters"""...""" or XML tags
  4. Specify format — “Output as JSON with keys: …”
  5. Chain-of-thought — for reasoning tasks

The “garbage in, garbage out” rule

Bad: “Write a story” Good: “Write a 500-word cyberpunk story set in 2099 Tokyo, featuring a hacker named Mira. Style: dark, fast-paced, sensory. End on a twist.”

Key takeaways

📦 开源项目

本教程基于开源项目 anthropics/prompt-eng-interactive-tutorial 整理。

⭐ View on GitHub →

Sponsored

🛠️ Related Tools & Resources

Mechanical Keyboards →
For coding & writing tutorials
USB-C Hubs →
Multi-monitor dev setup
Noise-Cancelling Headphones →
Focus while learning
Laptop Stands →
Ergonomics for long tutorials