Back to Blog
AI Agents April 20, 2025 7 min read

Prompt Engineering Patterns That Actually Work in 2025

Chain-of-thought, few-shot, system prompts, JSON mode, and 5 more patterns with real examples from production LLM applications.

Pattern 1: Chain-of-Thought (CoT)

Add "Let's think step by step" to complex reasoning tasks. Improves accuracy by 20-40% on math and logic.

Pattern 2: Few-Shot with Negative Examples

Correct: "The product arrived damaged" → NEGATIVE
Correct: "Excellent quality, fast shipping" → POSITIVE
Incorrect: "It's okay I guess" → [CLASSIFY]

Pattern 3: JSON Mode

response = client.chat.completions.create(
    model='gpt-4o',
    response_format={'type': 'json_object'},
    messages=[{'role': 'user', 'content': 'Extract entities from: ...' }]
)

Pattern 4: Persona + Constraint

"You are a senior ML engineer. Explain gradient descent in under 3 sentences. Use no math notation."

Pattern 5: Self-Consistency

Run the same prompt 5 times, take majority vote. Reduces error rate by ~30% on reasoning tasks.

Prompt EngineeringLLMGPT-4Chain-of-ThoughtProduction
O

Ossama Elhakki

AI Engineer & ML Systems Builder — Morocco