CAI Principles and Critique Prompts
Anthropic's Constitutional AI: self-critique based on harmlessness principles.
CAI Principles and Critique Prompts is a free AI Prompt Engineering lesson on CoddyKit — lesson 1 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.
What Is Constitutional AI?
Constitutional AI (CAI) is Anthropic's method for training AI systems to be helpful, harmless, and honest using a set of written principles — a constitution.
Rather than relying solely on human labelers to flag harmful outputs, CAI has the model critique and revise its own responses against the constitution. This is both more scalable and more consistent.
The Constitution: Written Principles
The CAI constitution is a list of principles the model must follow. Anthropic's published constitution includes principles derived from:
- The UN Declaration of Human Rights
- Apple's App Store guidelines
- Anthropic's internal guidelines on harm avoidance
Example principle: "Choose the response that is least likely to contain harmful, unethical, racist, sexist, toxic, dangerous, or illegal content."
The Three-Step CAI Loop
Constitutional AI uses a three-step process to improve responses:
- Generate: The model produces an initial response (possibly harmful)
- Critique: The model evaluates the response against a principle
- Revise: The model rewrites the response to address the critique
This loop can run once or multiple times. Each iteration makes the response more aligned with the constitution.
Step 1: Generate an Initial Response
The first step is simply generating a response to the user's request — without any special constraints. This response might be helpful but also potentially harmful, biased, or inaccurate.
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-...')
# Step 1: Generate initial response
def generate_initial(user_request):
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=512,
messages=[
{'role': 'user', 'content': user_request}
]
)
return response.content[0].text
initial = generate_initial('How do I pick a lock?')
print('Initial response:', initial[:200])Step 2: Critique Against a Principle
In the critique step, the model receives its own initial response and a specific principle, then identifies how the response violates or could better satisfy that principle.
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-...')
PRINCIPLE = (
'Choose the response that is least likely to provide instructions '
'that could enable illegal activity or harm to others.'
)
def critique_response(user_request, initial_response, principle):
critique_prompt = (
f'Human: {user_request}\n\n'
f'Assistant: {initial_response}\n\n'
f'Critique the assistant response using this principle: {principle}\n'
f'Identify specific problems and explain why they violate the principle.'
)
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=256,
messages=[{'role': 'user', 'content': critique_prompt}]
)
return response.content[0].text
critique = critique_response('How do I pick a lock?', initial, PRINCIPLE)
print('Critique:', critique[:200])Step 3: Revise Based on Critique
In the revision step, the model receives the critique and produces a new, improved response that addresses the identified issues while remaining as helpful as possible.
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-...')
def revise_response(user_request, initial_response, critique_text):
revise_prompt = (
f'Human: {user_request}\n\n'
f'Original assistant response: {initial_response}\n\n'
f'Critique of that response: {critique_text}\n\n'
f'Please rewrite the assistant response to address the critique '
f'while still being as helpful as possible to the user.'
)
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=512,
messages=[{'role': 'user', 'content': revise_prompt}]
)
return response.content[0].text
revised = revise_response('How do I pick a lock?', initial, critique)
print('Revised response:', revised[:300])Choosing Which Principles to Apply
The CAI constitution has many principles. You don't apply all of them to every response — that would be slow and redundant.
In practice, you select principles relevant to the domain or risk level:
- High-risk domains: apply 3-5 safety principles
- General assistant: apply 1-2 broadly applicable principles
- Creative writing: apply principles about legality and explicit content
# Example principles from Anthropic's published constitution
PRINCIPLES = [
'Choose the response that is least likely to contain harmful, '
'unethical, racist, sexist, toxic, dangerous, or illegal content.',
'Choose the response that a thoughtful, senior Anthropic employee '
'would consider optimal given the context.',
'Choose the response that is most likely to be true and accurate, '
'even if it requires acknowledging uncertainty.',
'Choose the response that would be most appropriate for children '
'if the context is ambiguous about the audience.',
]
# For a medical advice context, apply principles 1 and 3
medical_principles = [PRINCIPLES[0], PRINCIPLES[2]]
# For a general chat context, apply principle 2
general_principles = [PRINCIPLES[1]]CAI in RLHF: SL-CAI and RLCAI
Anthropic uses CAI in two phases of training:
- SL-CAI: Supervised Learning — generates critique-revise pairs, uses revised responses to fine-tune the model
- RLCAI: Reinforcement Learning — uses a CAI-trained preference model as the reward signal instead of human preference labels
As a prompt engineer, you apply CAI principles at inference time in your applications — the same critique-revise logic, without the training infrastructure.
Helpful, Harmless, and Honest — The HHH Framework
Anthropic's training goal is the HHH framework:
- Helpful: Genuinely assists the user with their request
- Harmless: Avoids causing harm to users, third parties, or society
- Honest: Doesn't deceive, doesn't claim certainty it doesn't have
These three goals sometimes conflict — and CAI's critique-revise process is designed to find responses that satisfy all three simultaneously.
CAI Critique Prompt Template
A reliable critique prompt template that you can adapt for your applications:
CRITIQUE_TEMPLATE = (
'Review the following conversation and critique the assistant response.\n\n'
'Conversation:\n'
'Human: {user_message}\n'
'Assistant: {assistant_response}\n\n'
'Critique Request: Identify specific ways the assistant response could be '
'improved to be more {principle_goal}. '
'If the response is already excellent, say so briefly.\n\n'
'Critique:'
)
# Example: critique for harmlessness
harmless_critique = CRITIQUE_TEMPLATE.format(
user_message='How do I make someone angry at a party?',
assistant_response='Here are some classic pranks you can try...',
principle_goal='harmless and considerate of all people involved'
)
print(harmless_critique[:300])When to Apply CAI Loops
Not every response needs a critique-revise cycle. Apply CAI when:
- The request is in a high-risk domain (health, legal, safety)
- The initial response seems evasive or potentially harmful
- Your application has strict content requirements
- You want a quality gate before showing output to users
For low-risk, routine queries — skip CAI to save latency and cost.
Knowledge Check: CAI Three-Step Loop
What is the correct order of steps in the Constitutional AI critique loop?
Recap: CAI Principles and Critique Prompts
Constitutional AI uses a three-step loop: generate an initial response, critique it against a written principle, and revise it to produce a better output. The constitution is a list of principles prioritizing helpfulness, harmlessness, and honesty. Anthropic applies CAI in both supervised fine-tuning and RLHF phases. At the application level, you implement the same critique-revise logic at inference time using API calls. Apply CAI selectively for high-risk domains to balance safety with latency and cost.
Frequently asked questions
Is the “CAI Principles and Critique Prompts” lesson free?
Yes — the full text of “CAI Principles and Critique Prompts” 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 “CAI Principles and Critique Prompts”?
Anthropic's Constitutional AI: self-critique based on harmlessness principles. 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 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “CAI Principles and Critique Prompts” 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
- CAI Principles and Critique Prompts
- Self-Critique and Revision Patterns
- Harmlessness vs Helpfulness Tension
- Implementing CAI in Applications