Advanced Prompting
The techniques that separate basic Claude usage from expert-level results.
Why prompting matters more than people think
Claude's output quality varies dramatically based on how you prompt it. The same question phrased differently can produce a generic answer or a precisely tailored, expert-level response. Understanding what Claude responds to β and why β is the core skill this lesson builds.
The RRCF framework
For any complex prompt, think through four components:
- Role β who is Claude in this conversation?
- Requirements β exactly what output do you need?
- Context β what does Claude need to know to answer well?
- Format β how should the response be structured?
Weak: "Review my SQL query."
Strong: "You are a senior data engineer. Review this PostgreSQL query for correctness, performance, and adherence to our naming conventions (snake_case, no reserved words as column names). We're running on Postgres 15 with ~10M rows in the orders table. Point out: (1) any correctness issues, (2) missing indexes, (3) naming violations, (4) any simpler rewrites. Format your response as a numbered list."
XML tags for structured prompts
Claude is trained to recognize XML-style tags as semantic markers. Use them to clearly delineate sections of complex prompts:
<role>You are a senior data modeling architect</role> <context> We are building a SaaS billing system for a B2B company. - Multiple customers (tenants) - Each customer has multiple users and multiple subscriptions - Subscriptions have plans (monthly/annual) and add-ons - We need to track usage events and generate invoices </context> <task> Design a Logical Data Model for this billing system. List the entities, their key attributes, and the relationships between them. Identify all many-to-many relationships and how to resolve them. </task> <format> For each entity: name, primary key, 5-7 key attributes Relationships: entity1 β relationship β entity2 (cardinality) Flag any M:N relationships </format>
Chain-of-thought prompting
For complex reasoning tasks, ask Claude to think through the problem step by step before giving you the final answer. This dramatically improves accuracy on multi-step problems.
- Add: "Think through this step by step before giving your final answer"
- Or: "Before writing the code, outline your approach in pseudocode"
- Or: "First identify all the edge cases, then write the solution"
Few-shot examples
If you want Claude to produce output in a specific format or style, show it two or three examples first:
Document each table in this format: Example 1: Table: customer Purpose: Stores all registered customers. Key columns: customer_id (PK), email (unique), created_at Business rules: email must be verified before orders allowed. Example 2: Table: order Purpose: Tracks each purchase transaction. Key columns: order_id (PK), customer_id (FK), order_date, status Business rules: status transitions: PendingβShippedβDelivered only. Now document these tables in the same format: [your tables]
Iterative refinement
Don't try to write the perfect prompt on the first try. Claude conversations are iterative:
- Start broad: "Write a Python class for database connection management"
- Refine: "Add context manager support so it works with `with` statements"
- Add edge cases: "Handle connection timeouts and automatic reconnection with exponential backoff"
- Test it: "Now write pytest tests for the reconnection logic"
What to avoid
- Vague requests β "make it better" gives Claude nothing to work with
- Too many tasks in one message β split complex asks into sequential messages
- Ignoring format instructions β always specify if you want code, prose, a table, a list
- Not providing context β Claude can't know your stack, your conventions, or your constraints unless you tell it