0Pricing
AI Prompt Engineering · Lesson

Self-Critique and Revision Patterns

Prompting models to evaluate and rewrite their own outputs against a constitution.

Self-Critique and Revision Patterns is a free AI Prompt Engineering lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Prompt Engineering learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Self-Critique as a Prompting Technique

Even without a formal CAI training process, you can prompt any capable LLM to critique and improve its own outputs. This self-critique pattern dramatically improves quality for tasks where accuracy, completeness, or safety matters.

The key insight: models have more knowledge than they show in a first pass. A critique prompt surfaces that knowledge.

Basic Accuracy Critique Pattern

The simplest self-critique: ask the model to review its response for factual accuracy and fix any errors.

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-...')

def generate_and_self_critique(question):
    # Step 1: Generate
    r1 = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=512,
        messages=[{'role': 'user', 'content': question}]
    )
    initial = r1.content[0].text

    # Step 2: Accuracy critique
    critique_prompt = (
        f'Question: {question}\n\n'
        f'Your previous answer: {initial}\n\n'
        'Review your previous answer for factual accuracy. '
        'Identify any errors, unsupported claims, or missing important nuances. '
        'Then provide a corrected, improved answer.'
    )
    r2 = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=512,
        messages=[{'role': 'user', 'content': critique_prompt}]
    )
    return r2.content[0].text

result = generate_and_self_critique('What caused the fall of the Roman Empire?')
print(result[:300])

Completeness Check Pattern

A completeness critique asks the model to verify that its response fully answers every part of the question. This is especially useful for multi-part questions where first-pass responses often miss sub-questions.

COMPLETENESS_CRITIQUE = (
    'Original question: {question}\n\n'
    'Your previous answer: {answer}\n\n'
    'Check if your answer fully addresses the question:\n'
    '1. List each part or sub-question in the original question.\n'
    '2. For each part, indicate whether your answer addressed it.\n'
    '3. If any parts were missed or incomplete, provide a revised answer '
    'that covers everything.'
)

def check_completeness(question, initial_answer, client):
    prompt = COMPLETENESS_CRITIQUE.format(
        question=question,
        answer=initial_answer
    )
    response = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=600,
        messages=[{'role': 'user', 'content': prompt}]
    )
    return response.content[0].text

Harm and Safety Critique Pattern

A harm critique asks the model to review its response for potential negative consequences before showing it to users. This is the core of applying CAI principles in production.

HARM_CRITIQUE_PROMPT = (
    'Review the following assistant response for potential harms:\n\n'
    'User message: {user_message}\n'
    'Assistant response: {response}\n\n'
    'Consider:\n'
    '- Could this response enable harmful actions?\n'
    '- Could it be misused by someone with bad intentions?\n'
    '- Does it respect the privacy and dignity of individuals?\n'
    '- Could it cause psychological harm to vulnerable users?\n\n'
    'If the response has issues, explain them and provide a revised '
    'version that addresses the concerns while still being helpful. '
    'If the response is fine, say "Response is appropriate" and quote it back.'
)

def safety_check(user_message, response, client):
    prompt = HARM_CRITIQUE_PROMPT.format(
        user_message=user_message,
        response=response
    )
    result = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=600,
        messages=[{'role': 'user', 'content': prompt}]
    )
    return result.content[0].text

Multi-Criteria Critique

For high-stakes outputs, critique against multiple criteria in a single pass by listing them explicitly. This is more efficient than separate critique calls for each criterion.

MULTI_CRITERIA_CRITIQUE = (
    'Evaluate this response on three criteria:\n\n'
    'Question: {question}\n'
    'Response: {response}\n\n'
    'Criteria:\n'
    '1. ACCURACY: Are all facts correct and claims well-supported?\n'
    '2. COMPLETENESS: Does it fully address the question?\n'
    '3. CLARITY: Is it easy to understand for the target audience?\n\n'
    'For each criterion, rate it Good/Fair/Poor and explain why.\n'
    'Then provide an improved response that scores Good on all three.'
)

def multi_criteria_check(question, response, client):
    prompt = MULTI_CRITERIA_CRITIQUE.format(
        question=question,
        response=response
    )
    result = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=800,
        messages=[{'role': 'user', 'content': prompt}]
    )
    return result.content[0].text

The Revision Step: Best Practices

The revision prompt should do three things:

  1. Remind the model of the original request (context)
  2. Present the critique findings
  3. Ask for a revised response that addresses the issues

Don't ask the model to explain the critique again in the revision — just fix it. Keeping the revision prompt action-oriented produces better results.

# Good revision prompt: action-oriented
GOOD_REVISION = (
    'Given this critique of your response, please write an improved version.\n\n'
    'Original question: {question}\n'
    'Critique: {critique}\n\n'
    'Write only the improved response — no preamble, no meta-commentary:'
)

# Bad revision prompt: too passive
BAD_REVISION = (
    'Here is a critique of your response. Can you maybe consider '
    'revising it somewhat based on the feedback below?\n'
    'Critique: {critique}'
    # Missing original question context!
    # Wishy-washy language reduces revision quality
)

Chaining Multiple Revision Rounds

One round of critique-revise often isn't enough for very complex quality requirements. You can chain multiple rounds, each applying a different principle or checking remaining issues.

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-...')

def multi_round_revision(question, n_rounds=2):
    # Round 0: Initial generation
    response = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=512,
        messages=[{'role': 'user', 'content': question}]
    ).content[0].text

    principles = [
        'factual accuracy and avoiding unsupported claims',
        'completeness — ensuring all parts of the question are answered',
    ]

    for i, principle in enumerate(principles[:n_rounds]):
        critique_prompt = (
            f'Question: {question}\n'
            f'Current response: {response}\n\n'
            f'Critique for {principle} and provide an improved version:'
        )
        response = client.messages.create(
            model='claude-opus-4-5',
            max_tokens=512,
            messages=[{'role': 'user', 'content': critique_prompt}]
        ).content[0].text
        print(f'Round {i+1} complete')

    return response

Self-Critique for Code Generation

Self-critique is particularly effective for code generation. The model first writes code, then reviews it for bugs, edge cases, and security issues — often catching errors it missed the first time.

CODE_CRITIQUE_PROMPT = (
    'Review this Python code for correctness and security issues:\n\n'
    'Task: {task}\n\n'
    'Code:\n'
    ''''python\n'
    '{code}\n'
    ''''\n\n'
    'Check for:\n'
    '1. Logic errors or off-by-one mistakes\n'
    '2. Unhandled edge cases (empty input, None, division by zero)\n'
    '3. Security issues (SQL injection, path traversal, etc.)\n\n'
    'If issues exist, list them and provide a corrected version. '
    'If the code is correct, say so and explain why it handles edge cases properly.'
)

def critique_code(task, code, client):
    prompt = CODE_CRITIQUE_PROMPT.format(task=task, code=code)
    result = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=800,
        messages=[{'role': 'user', 'content': prompt}]
    )
    return result.content[0].text

Self-Consistency as an Alternative

Self-consistency is a different approach: generate the same response N times, then take a majority vote or ask the model to synthesize the best answer from multiple drafts.

Use self-consistency for questions with clear correct answers. Use critique-revise when quality is multi-dimensional (accuracy + tone + safety).

import anthropic
from collections import Counter

client = anthropic.Anthropic(api_key='sk-ant-...')

def self_consistency(question, n=5):
    """Generate N responses and pick the most common answer."""
    responses = []
    for _ in range(n):
        r = client.messages.create(
            model='claude-haiku-4-5',
            max_tokens=100,
            temperature=0.7,
            messages=[{'role': 'user', 'content': question}]
        )
        responses.append(r.content[0].text.strip())

    # Pick most common answer
    vote = Counter(responses)
    winner, count = vote.most_common(1)[0]
    print(f'Consensus ({count}/{n}): {winner}')
    return winner

result = self_consistency('What is the sum of angles in a triangle?')

When Critique Hurts: Over-Critique Risk

Self-critique isn't always beneficial. Watch for these failure modes:

  • Sycophantic critique: The model says its answer is great even when it's wrong
  • Over-caution: The model removes helpful information during revision because it seems risky
  • Hallucinated corrections: The revision introduces new errors not in the original

Mitigate by: using a different model for critique, grounding critiques in specific facts, and validating revised outputs against known-good answers.

Measuring Critique Effectiveness

Track whether critique actually improves outputs by comparing initial and revised responses against a gold standard. This tells you if the extra LLM calls are worth the cost.

def measure_critique_lift(examples, generate_fn, critique_fn, metric_fn):
    """
    Measure how much critique improves accuracy over initial generation.
    """
    initial_scores = []
    revised_scores = []

    for ex in examples:
        initial = generate_fn(ex.question)
        revised = critique_fn(ex.question, initial)

        initial_scores.append(metric_fn(ex.answer, initial))
        revised_scores.append(metric_fn(ex.answer, revised))

    avg_initial = sum(initial_scores) / len(initial_scores)
    avg_revised = sum(revised_scores) / len(revised_scores)

    print(f'Initial: {avg_initial:.1%}')
    print(f'Revised: {avg_revised:.1%}')
    print(f'Lift:   +{avg_revised - avg_initial:.1%}')
    return avg_revised - avg_initial

Knowledge Check: Self-Critique Timing

Which pattern is most appropriate for catching factual errors in a response before showing it to users?

Recap: Self-Critique and Revision Patterns

Self-critique prompts ask the model to review its own output against specific criteria — accuracy, completeness, safety, or clarity — and then produce an improved revision. Effective patterns: accuracy critique (review for factual errors), completeness check (did you address all parts?), harm critique (could this enable harmful actions?), and code review (check for bugs and edge cases). Chain multiple rounds for high-stakes outputs. Measure actual lift to confirm the extra cost is justified.

Frequently asked questions

Is the “Self-Critique and Revision Patterns” lesson free?

Yes — the full text of “Self-Critique and Revision Patterns” is free to read here on the web, and the AI Prompt Engineering course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Prompt Engineering course, upgrade to CoddyKit PRO.

What will I learn in “Self-Critique and Revision Patterns”?

Prompting models to evaluate and rewrite their own outputs against a constitution. You practise AI Prompt Engineering with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AI Prompt Engineering?

No prior experience is required. AI Prompt Engineering on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Self-Critique and Revision Patterns” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AI Prompt Engineering lesson?

Yes. Every AI Prompt Engineering lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. CAI Principles and Critique Prompts
  2. Self-Critique and Revision Patterns
  3. Harmlessness vs Helpfulness Tension
  4. Implementing CAI in Applications
← Back to AI Prompt Engineering