Build Your First Modular Prompt
Learning Objectives
By the end of this chapter, you'll be able to:
- Understand the core components of modular prompting
- Identify and select the right modules for your needs
- Assemble your first working modular prompt from scratch
Introduction
Modular prompting works like building blocks. Instead of writing a new prompt from scratch each time, you create reusable components that slot together in different ways. Think of it as having a toolkit where each tool has a specific job, but you can combine them to tackle various tasks.
This approach saves time and keeps your prompts consistent. You'll build a library of modules that work well together, then mix and match them based on what you need to achieve.
Lessons
Lesson 1: The Five Essential Modules
Every modular prompt needs these core components:
Context Module: Sets the scene and defines the AI's role
Task Module: Explains exactly what you want the AI to do
Format Module: Specifies how you want the output structured
Constraints Module: Sets boundaries and rules
Examples Module: Shows the AI what good output looks like
Here's how they work together:
- Context gives the AI its bearings
- Task provides clear direction
- Format ensures consistent output
- Constraints prevent unwanted results
- Examples guide quality
This is the bit most people miss: Each module should work independently. You might not need all five every time, but each one you use should be complete on its own.
Lesson 2: Writing Your First Context Module
The context module is your foundation. It tells the AI who it should be and what situation it's operating in.
Step 1: Define the AI's role
Write "You are a [specific role]" rather than something vague. Instead of "You are helpful," try "You are a copywriter specialising in email marketing."
Step 2: Set the scenario
Add context about the situation: "You're helping a small business owner write their first newsletter to customers."
Step 3: Test your context
A good context module should immediately focus the AI's responses. If you're still getting generic answers, make your context more specific.
Lesson 3: Creating Clear Task Modules
Your task module does the heavy lifting. It explains exactly what you want to happen.
Step 1: Use action words
Start with verbs like "Write," "Analyse," "Create," or "Review." Avoid wishy-washy language like "help me think about."
Step 2: Be specific about scope
Instead of "write some content," try "write three email subject lines for a 20% discount offer."
Step 3: Include success criteria
Add what makes a good result: "Each subject line should be under 50 characters and create urgency without being pushy."
Lesson 4: Assembling Your Modules
Now you'll put your modules together into a working prompt.
Step 1: Start with context
Place your context module first. The AI needs to know its role before it can act on instructions.
Step 2: Add your task
Follow with clear, specific instructions about what you want.
Step 3: Include format requirements
Specify how you want the output structured, especially if you need it formatted for a particular use.
Step 4: Test and refine
Run your prompt and see what happens. Good modules should produce consistent results each time you use them.
Practice
Time to build your first modular prompt. Here's your challenge:
Create a prompt that helps write social media posts for a local bakery. You'll need:
- Context Module: Define the AI as a social media manager for a family-run bakery
- Task Module: Ask for three Instagram post ideas promoting fresh bread
- Format Module: Request posts with captions under 100 words plus relevant hashtags
Write each module separately, then combine them. Test your prompt and note what works well and what needs tweaking.
Roll your sleeves up and give it a go. The best way to learn modular prompting is by doing it.
FAQs
Do I always need all five modules?
No. Use what you need for each situation. Simple tasks might only need context and task modules, while complex outputs benefit from the full set.
How long should each module be?
Keep modules concise but complete. Most effective modules are 1-3 sentences. If you're writing paragraphs, you're probably trying to do too much in one module.
Can I reuse modules across different prompts?
Absolutely. That's the whole point. A well-written context module for "email copywriter" can work in dozens of different prompts.
What if my modules don't work well together?
This usually means your modules aren't independent enough. Each module should make sense on its own and not rely on information from other modules.
Jargon Buster
Context Module: The opening section that establishes the AI's role and the situation it's working in
Task Module: The core instructions that tell the AI exactly what action to take
Format Module: Specifications for how the output should be structured or presented
Constraints Module: Rules and boundaries that prevent unwanted results or keep the AI focused
Examples Module: Sample inputs and outputs that show the AI what quality looks like
Wrap-up
You've built your first modular prompt using the five essential components. The key is starting simple and building complexity as you get comfortable with how modules work together.
Your next step is practicing with different combinations. Try using the same context module with different tasks, or apply one task module to various contexts. This experimentation will show you how flexible modular prompting can be.
Ready to explore more advanced techniques? The next chapter covers how to create conditional modules that adapt based on different inputs.