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:

  1. #VARIABLES#
  2. #CONTEXT#
  3. #INSTRUCTIONS#
  4. #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: 

  1. Identify which columns you want to use in your prompt (e.g., social profile URLs, full names, company names)
  2. Assign each column to a variable using curly brackets 
  3. Add the column by typing forward slash (“/”), then selecting the column from the dropdown
  4. 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: 

  1. Check for awards received in the last year
    • If found, reference the award in the subject line
  2. Look for promotions or job changes within the last year
    • If found, mention the career move
  3. 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.

Claygent: AI Web Scraper
Course Completed
Intro to Clay 101: FETE Framework
4 mins
Watch lesson
Current Lesson
Jigsaw Framework
4 mins
Watch lesson
Current Lesson
Find Companies
3 mins
Watch lesson
Current Lesson
Enrich Companies (Waterfalls)
4 mins
Watch lesson
Current Lesson
Enrich People (Waterfalls)
5 mins
Watch lesson
Current Lesson
Prompt Engineering Crash Course
8 mins
Watch lesson
Current Lesson
Claygent: AI Web Scraper
7 mins
Watch lesson
Current Lesson
AI Formulas + Conditional Runs
8 mins
Watch lesson
Current Lesson
Data Cleaning + Normalization
3 mins
Watch lesson
Current Lesson
Intro to Al Snippets (Copywriting)
4 mins
Watch lesson
Current Lesson
Lead Scoring
7 mins
Watch lesson
Current Lesson
Push Data To Your CRM
5 mins
Watch lesson
Current Lesson
Push Data To Your Email Sequencer
4 mins
Watch lesson
Current Lesson
Download as a CSV
3 mins
Watch lesson
Current Lesson
Import from CRM
3 mins
Watch lesson
Current Lesson
Google Sheets
6 mins
Watch lesson
Current Lesson
Find Local Businesses Using Google Maps
3 mins
Watch lesson
Current Lesson
Find Company Lookalikes
7 mins
Watch lesson
Current Lesson
Find Jobs Source + Enrichment
5 mins
Watch lesson
Current Lesson
Write to Table
6 mins
Watch lesson
Current Lesson
Closing Remarks
2 mins
Watch lesson
Current Lesson

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.

Clay branded illustration of a wall made out of 3D, colourful, clay bricks and a whimsical person opening a door in the wall to access a new world of opportunities.

Clay University

Master Clay in a few core lessons. Uplevel your data enrichment, craft better outbound messages, and book more meetings.

Learn with Clay

Go to market blog

Our best content on growing your GTM motion, from outbound sales automation to AI lead generation.

Explore our blog
Clay branded illustration made out of 3D clay objects showing  whimsical operators connecting cables to 3D Clay table

Integrations

Browse through all the integrations you can connect to Clay in seconds and discover what you can do!

Explore integrations
Clay branded illustration of a Clay table with colourful, 3D connectors made out of Clay around it

Templates

Power your outbound campaigns with our best templates.

Visit clay templates
Clay branded illustration of a messy tangle of 3D, colourful strings made out of clay being untangled into one, colourful, twisted string

Clay Experts

Hire a Clay Enterprise expert or find a Clay partner to help with your next project

Explore Clay experts

Clay's Chrome extension

Clay’s Chrome Extension makes it wicked easy to find leads almost anywhere on the internet

Explore Chrome Extension