Practical Patterns
Role-play, Constraints, Step-Back & more
The Problem: You know Chain-of-Thought and Few-Shot, but everyday tasks often need simpler, more targeted patterns — role assignment, constraints, or reframing the question.
The Solution: 8 Practical Patterns for Every Day
These patterns are the building blocks of prompt engineering. Each solves a specific problem: Role-Playing gives expertise, Constraints control output, Negative Instructions prevent mistakes, and Step-Back improves understanding. Master them individually, then combine for maximum effect.
Think of it like a toolkit where each tool has its purpose:
- 1. Role-Playing: Assign expertise — "You are a senior engineer"
- 2. Constraints: Set boundaries — length, format, style
- 3. Step-Back: Start from principles, then solve
- 4. Rephrase & Respond: Let AI reinterpret for better accuracy
Where Are These Used?
- Daily prompting: Quick, targeted improvements to any prompt
- Content creation: Roles + Constraints for consistent quality
- Code review: Persona + Negative Instructions for thorough analysis
- Research: Step-Back + Emotion Prompting for deeper insights
Fun Fact: Research shows that adding emotional appeals like "This is very important to my career" can improve LLM performance by 8-10% on some tasks! This is called EmotionPrompt.
Try It Yourself!
Explore each pattern in the interactive example below and try the prompt templates.
8 simple but powerful patterns for everyday work with LLMs. Each solves a specific problem — select a pattern to learn more!
Role-Playing / Persona
Ask the model to "become" an expert in the relevant field
Model takes on a role and answers from that character's perspective, using relevant knowledge and style.
"You are a senior developer with 15 years of experience. Conduct a code review..."
SQL queries can be optimized in many ways. Use indexes, avoid SELECT *, optimize JOINs... (generic advice without depth)
As a DBA with 15 years experience: 1) EXPLAIN ANALYZE — profile first. 2) Covering indexes reduce IO by 80%. 3) For N+1 use batch loading. Example: CREATE INDEX idx_orders_user ON orders(user_id) INCLUDE (total);
| Pattern | When to use | Complexity |
|---|---|---|
| Role-Playing / Persona | Expert tasks, consulting | 1/3 |
| Constraint Prompting | Formatting, brevity | 1/3 |
| Negative Instructions | Style control, error avoidance | 1/3 |
| Step-Back Prompting | Learning, conceptual understanding | 2/3 |
| Directional Stimulus | Content steering, key topics | 2/3 |
| Graph Prompting | Dependency analysis, systems thinking | 3/3 |
| Emotion Prompting | Quality boost, detail increase | 1/3 |
| Rephrase and Respond | Ambiguous questions, accuracy | 2/3 |
These patterns are the building blocks of prompting. Master each one individually, then combine them for maximum effect (see the "Combining Techniques" lesson).
Try it yourself
Interactive demo of this technique
Explain Docker for a beginner developer
Sure! Great question! Docker is a containerization platform that uses OS-level virtualization via cgroups and namespaces. It allows packaging applications into isolated containers for deployment...
Docker is a "box" for your application. Imagine: you're moving and pack an entire room into one container — furniture, clothes, everything stays in place. At the new location you open the container and everything works as before.
Docker works the same way: it packages your code, libraries, and settings into one container. This container works identically on your laptop, your colleague's machine, and the server.
Try it: docker run -d -p 5432:5432 postgres — database ready in 3 seconds.
Negative Instructions ("DON'T") are often more effective than positive ones — they prevent specific mistakes that LLMs make by default (jargon, verbosity, template phrases).
Create a free account to solve challenges
4 AI-verified challenges for this lesson
This lesson is part of a structured LLM course.
My Learning Path