Prompt Engineering: The S.P.I.C.E. Framework
Most prompt engineering guides focus on chat-style interfaces where you can refine your prompts through multiple iterations. However, when working with Clay, you'll need to create one prompt that works effectively the first time across hundreds or thousands of rows.
In this course, we’ll introduce our S.P.I.C.E. framework: a proven approach to writing successful prompts at scale.
What is S.P.I.C.E.?
S.P.I.C.E. stands for:
- Sections: The structural components of your prompt, clearly separated by hashtags, that organize different types of information and requirements.
- Prompt Variables: Placeholder values in curly brackets that reference your data columns, making prompts dynamic and reusable across different datasets.
- Instructions: Clear, step-by-step directions that tell the AI exactly what to do, including formatting requirements, tone guidelines, and specific tasks to complete.
- Context: Background information that focuses the AI on your specific use case and desired outcome, helping prevent irrelevant or off-topic responses.
- Examples: Sample outputs that demonstrate the exact format and style you want, wrapped in HTML tags to distinguish them from other prompt elements.
Let's walk through creating a LinkedIn subject line prompt using the S.P.I.C.E. framework.
How It Works: Watch The Guided Demo
Watch the guided demo to learn how to use the S.P.I.C.E framework, or skip ahead for a step-by-step breakdown.
Step 1: Structure Prompt Sections
Start by creating four essential sections in your prompt, each surrounded by hashtags:
- #VARIABLES#
- #CONTEXT#
- #INSTRUCTIONS#
- #EXAMPLES#
While examples are less important for web scraping prompts, they’re valuable for traditional AI prompts like our subject line generator.
Section 2: Define Prompt Variables
Next, to streamline prompt editing and triaging, add prompt variables to the #VARIABLES# section.
Here’s how to create variables:
- Identify which columns you want to use in your prompt (e.g., social profile URLs, full names, company names)
- Assign each column to a variable using curly brackets
- Add the column by typing forward slash (“/”), then selecting the column from the dropdown
- Reference these variables throughout your prompt using the curly bracket notation
For example, imagine we’ve scraped social profile URLs, full names, and company names in our table and want to use them as variables in our prompt. This is the syntax we would use:
- {SocialProfile} = /Enrich Person From Profile
- {FullName} = /Full Name
- {Companyname} = /Company Name
Section 3: Create clear instructions
Third, we'll create explicit instructions, ideally step-by-step, that we want the AI to follow in executing our objective or task.
In this case, we'll instruct the AI to personalize the subject line based on different elements of the scraped social profile and include instructions on tone and formatting criteria as well.
More specifically, we’ll ask AI to format the subject line as follows:
- Always start with "Congrats on"
- Limit to 10 words
- Use second-person pronouns
Then, we’ll give it step-by-step instructions on how to make decisions:
- Check for awards received in the last year
- If found, reference the award in the subject line
- Look for promotions or job changes within the last year
- If found, mention the career move
- Search for other notable achievements
- Consider job anniversaries, certifications, skills, or volunteer work
- Use these to craft a personalized subject line
The final instructions look like this:
Always start the subject line with "Congrats on ". Keep the final subject line to no more than 10 words. Always use second person pronouns. We are drafting a subject line to {FullName} who works at {CompanyName}. We have more profile information about {FullName} in {ProfileInfo}.
Complete the sentence using the steps below:
1. Check if the profile has any awards in the last year. If yes, then complete the sentence with context on the award won.
2. If there are no awards, check if the profile has any promotions or new jobs in the last year. If yes, then complete the sentence with context on the job change or promotion.
3. If there are no awards or job changes, then check the profile for any other accolades. You could use job anniversaries, certifications, skills, volunteer experience, or anything else you deem relevant to craft a personalized subject line.
Section 4: Establish context
Next, add context to focus the AI on your specific task. For copywriting prompts:
- Avoid mentioning "cold email" or "outbound" terminology
- Focus on concise, friendly writing
For example, we’ve established context in our prompt with the following: “You are an expert writer skilled at writing short, succinct, personalized congratulations to people based on their work profile and history. “
Section 5: Provide examples
Last, include clear examples using HTML tags to distinguish them from other prompt text.
For example, we added four examples in our prompt:
- <award_example>Congrats on making it to president's club this year!</award_example>
- <new_job_example>Congrats on the new role at OpenAI!</new_job_example>
- <promotion_example>Congrats on the promotion to Director last quarter!</promotion_example>
- <other_example>Congrats on your leadership at OpenAI!</other_example>
Congrats!
Congrats, prompt engineer!
Now that you've learned the prompt engineering fundamentals, it's also worth mentioning that if you ever need help creating a prompt, you can use the “Help me” button in the bottom right corner of the prompt pop-out. Clay's very own meta prompter will help you get a jump start on formatting your prompt like a pro.
Connect, explore and learn together
Read our GTM blog, or try out our top Claybooks and templates to transform your growth ideas into outreach in minutes.