Introduction to Claude Models
Nikhil Rangarajan
Data Scientist


system_msg = "Be helpful." # Weaksystem_msg = "You are a technical writer. Use active voice, under 100 words, actionable advice only." # Strongmessages = [{"role": "user", "content": "How do I improve documentation?"}] response = client.messages.create(model="claude-sonnet-4-20250514", max_tokens=150, system=system_msg, messages=messages)
$$
$$
$$
# Role-based
"You are a customer service rep."
# Constraint-based  
"Respond in exactly 3 bullet points,
max 50 words."
# Tone-based
"Use enthusiastic, encouraging tone."
# Task-specific
"Debug Python code. Always ask for 
error messages first."
# System message causing issues
"Be concise and helpful."
# Problem: Responses too short, 
# missing context
"Provide helpful responses in 2-3 
sentences. Include relevant context 
but avoid unnecessary details."
# Test with various prompts 
$$
system_msg = """Code reviewer. 
Priority: 1) Security 2) Performance 
3) Style
If no issues: "Code looks good" 
+ suggest improvement
Example: "Security: No issues. 
Performance: Consider caching here."
"""
messages = [{"role": "system", 
             "content": system_msg},
    {"role": "user", 
     "content": "Review: [code]"}]
Introduction to Claude Models