Fundamentals Course
Learn fundamental concepts and core principles of prompt engineering
Chapter 1: Basic Prompt Structure
Learning Content
Learn the required parameters of the Messages API: model, max_tokens, messages array. Master the user/assistant conversation format and correct usage of system prompts.
Core Concepts
Message Alternation Rule
User and Assistant messages MUST alternate, and messages MUST start with a User turn
System Prompts
System prompts provide context, instructions, and guidelines to AI models, structurally separate from user & assistant messages
Message Formatting
When using message APIs, insert newlines between each message, or AI will consider unseparated content as a single message
Multi-turn Conversations
You can include multiple User/Assistant pairs in a prompt, and have AI continue from an ending Assistant message
Value of System Prompts
Well-written system prompts improve AI performance, such as increasing AI's ability to follow rules and instructions
Key Techniques
Messages API parameters: model, max_tokens, messages
User/Assistant conversation format
System prompt configuration
Message alternation rules
Common Pitfalls
Not alternating user/assistant messages
Starting with assistant message instead of user
Mixing system prompt with conversation messages
Prompt Examples
Correct format: role='user', content='Hi Claude, how are you?'Wrong format: Missing role and content fieldsSystem prompt: You are a logical reasoning expert who specializes in solving complex logical problems