Lesson 32 of 46 ~25 min
Course progress
0%

Prompting Opus 4.6 Effectively

Learn prompt engineering patterns specific to Opus 4.6 — system prompts, thinking guidance, structured output, and the patterns that extract maximum value.

Opus 4.6 responds differently to prompts than Sonnet or Haiku. Its deeper reasoning capabilities mean it benefits from different techniques — and some patterns that work well with smaller models actually reduce quality with Opus.

The Opus Prompting Mindset

Opus 4.6 is like a senior expert. You do not need to micromanage it:

❌ Bad: "Think step by step. First, identify the variables.
         Then, trace each variable through the code.
         Then, check for null references..."

✅ Good: "Find all potential null reference bugs in this code.
          Explain the root cause and fix for each."

The model’s adaptive thinking handles the reasoning steps internally. Over-specifying the process actually constrains the model and reduces output quality.

System Prompts That Work

A well-crafted system prompt sets the entire conversation on the right trajectory:

system_prompt = """You are a principal software architect with 20 years of
experience in distributed systems. You review code with the mindset of
someone who has debugged production outages at 3 AM.

When analyzing code:
- Prioritize correctness over style
- Flag race conditions, resource leaks, and error handling gaps
- If you find nothing critical, say so — do not invent issues
- Provide concrete fixes, not abstract advice

When uncertain, state your confidence level explicitly."""

System Prompt Principles for Opus 4.6

  1. Define expertise, not process. Tell the model who it is, not how to think.
  2. Set quality standards. Opus will meet them. Sonnet might not.
  3. Include anti-patterns. “Do not invent issues” prevents hallucinated problems.
  4. Request calibrated confidence. Opus 4.6 has better calibration than previous models.

Structured Output Patterns

Opus 4.6 introduces new structured output requirements. Use them:

response = client.messages.create(
    model="claude-opus-4-6-20260205",
    max_tokens=4096,
    system="Respond with valid JSON only. No markdown wrapping.",
    messages=[{
        "role": "user",
        "content": """Analyze this function for bugs. Return JSON:
        {
          "bugs": [{"line": int, "severity": "critical|high|medium|low",
                     "description": str, "fix": str}],
          "overall_quality": "good|acceptable|poor",
          "confidence": float  // 0.0-1.0
        }

        ```python
        def transfer(from_account, to_account, amount):
            if from_account.balance >= amount:
                from_account.balance -= amount
                to_account.balance += amount
                return True
            return False
        ```"""
    }]
)

Multi-Turn Conversation Patterns

Opus 4.6 excels at multi-turn conversations where each message builds on previous context:

messages = [
    {"role": "user", "content": "Here is our database schema: [schema]. "
     "Identify the three most critical performance bottlenecks."},
]
# First response identifies bottlenecks

messages.append({"role": "assistant", "content": response.content[0].text})
messages.append({"role": "user", "content": "For bottleneck #1, design a "
     "migration plan that can be executed with zero downtime. "
     "Include rollback steps."})
# Second response provides migration plan with full schema context

What Not to Do

Patterns that reduce Opus 4.6 quality:

Anti-PatternWhy It HurtsBetter Approach
Chain-of-thought promptingConstrains adaptive thinkingState the goal, let the model reason
Few-shot examples for simple tasksWastes context on patterns Opus already knowsUse few-shot only for novel output formats
”Be concise” for analysis tasksCuts off valuable reasoningSpecify output format instead
Role-playing fictional charactersMisaligns the model’s expertiseUse professional role definitions
Repeating instructionsWastes tokens, confuses priorityState instructions once, clearly

Temperature and Top-P for Opus

# Factual analysis — deterministic
response = client.messages.create(
    model="claude-opus-4-6-20260205",
    max_tokens=4096,
    temperature=0.0,  # Most deterministic
    messages=[...]
)

# Creative writing — varied
response = client.messages.create(
    model="claude-opus-4-6-20260205",
    max_tokens=4096,
    temperature=0.7,  # More creative variation
    messages=[...]
)

General guidance:

  • Code analysis, debugging, security review: temperature=0.0
  • General technical work: temperature=0.2–0.3
  • Creative content, brainstorming: temperature=0.6–0.8
  • Never use temperature=1.0 with Opus — the model is already creative enough

You now have the prompting foundation. In the next module, we dive deep into Opus 4.6’s architecture and how to select the right model for every task.