Study guide

5.2 Best Practices for Writing Effective Prompts

Salesforce Certified Agentforce Specialist Exam

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Exam Overview & How Agentforce Agents Work

1.1 Agentforce Specialist (AI-201) Exam Facts & Spring '26 Blueprint 1.2 How an Agent Works & the Building Blocks of Agent Script 1.3 Hybrid Reasoning: Agent Script in Canvas View and Script View

2 Chapter 2: Deterministic Control, Topics (Subagents) & Actions

2.1 Deterministic Behavior: Filters, Variables & Template Expressions 2.2 Standard and Custom Topics (Subagents) 2.3 Standard and Custom Agent Actions

3 Chapter 3: Agent Types, Security Context, Channels & Agent API

3.1 When to Use an Employee Agent or a Service Agent 3.2 Security Context: Who the Agent Runs As and How It Affects Actions 3.3 Connecting Agents to Channels: Digital Experiences, Email, Voice & Slack 3.4 When to Use the Agent API

4 Chapter 4: Prompt Builder Fundamentals

4.1 When to Use Prompt Builder 4.2 Access Controls Governing Prompt Templates 4.3 Prompt Template Types: Field Generation, Flex & More 4.4 Creating, Activating & Executing Prompt Templates

5 Chapter 5: Grounding, Prompt Best Practices, Trust Layer & Model Access

5.1 Choosing the Right Grounding Technique 5.2 Best Practices for Writing Effective Prompts 5.3 Einstein Trust Layer Security and Privacy Features 5.4 Managing and Preventing Access to Specific Models

6 Chapter 6: Data 360 Fundamentals for Agentforce

6.1 Agentforce Data Library: Types and Concepts 6.2 Chunking: Breaking Content Into Retrievable Units 6.3 Indexing and Search Types: Vector, Hybrid & Keyword 6.4 Retrievers: Individual, Ensemble & Filtered Retrieval

7 Chapter 7: Testing Agents with Testing Center

7.1 Testing an Agent with Testing Center 7.2 How Testing Center Evaluations Work

8 Chapter 8: Deploying Agents and Prompt Templates

8.1 Deploying an Agent from Sandbox to Production 8.2 Deploying Prompt Templates from Sandbox to Production

9 Chapter 9: Governance and Observability

9.1 Managing and Monitoring Agents 9.2 Agent Analytics and Agent Optimization

10 Chapter 10: Multi-Agent Orchestration, MCP & A2A

10.1 When a Multi-Agent Architecture Is Appropriate 10.2 Open Multi-Agent Protocols: MCP and A2A

5.2 Best Practices for Writing Effective Prompts

Key Takeaways Explain This Topic AI

Salesforce recommends concise, jargon-free prompts that assign a role or character and define that character's goal.

Separate context from instructions by adding an Instructions: section with instructions wrapped in triple quotes.

Tell the LLM to generate only the expected content, such as only the email body, so it doesn't describe its process.

Choose one writing style and use it consistently, because word choice, intensifiers, emojis, and punctuation shape responses.

Iterate by previewing resolved prompts and responses, testing alternatives, and collecting end-user feedback.

Last updated: September 2026

5.2 Best Practices for Writing Effective Prompts

Quick Answer: Write prompts that are clear, specific, and concise . Assign a role and goal , separate instructions from context (Salesforce recommends an Instructions: section wrapped in triple quotes), ground with relevant data , state constraints and the output format , tell the model to produce only the expected content , keep a consistent style , and iterate with real records . For agents, keep instructions minimal and move business rules into logic or actions.

Salesforce's Prompt Builder Best Practices

Practice What it means Example

Be concise and plain Avoid industry jargon and technical terms; use natural language "Summarize the open cases" rather than "Aggregate CS artifacts"

Assign a role with a goal Ask the LLM to act as a character, then define the goal "You are a support lead who needs to brief an executive before a renewal call."

Iterate Try different templates for the same goal and gather end-user feedback Compare two versions in preview and Testing Center

Keep a consistent style Word choice, intensifiers, emojis, and punctuation all shape output Don't mix formal and emoji-heavy templates for the same brand

Separate instructions from context Add a line Instructions: and wrap instructions in triple quotes ( """ ) See the example below

Generate only the expected content Prevent the model from describing its process "Follow these instructions strictly to generate only the message to be sent to the customer."

Start from examples Use the Example Prompt Template Library and reuse its style language Adapt a sample sales email template

Salesforce-focused exam prep commonly adds a few general principles: be clear and specific, ground the prompt in relevant Salesforce data, set the output format, tone, and style, include guardrails (what not to do), make prompts reusable, and don't overload one prompt with too many tasks .

Anatomy of a Strong Template You are a customer success manager at {!$Input:Account.Owner.CompanyName}.

Your goal is to prepare a renewal briefing for your manager.

Instructions:

"""

Write a briefing of no more than 120 words with these three labeled parts:

Health, Risks, Next Step.

Use only the account information and open cases provided below.

If a detail isn't in the provided data, write "Not available" instead of guessing.

Use a professional, neutral tone with no emojis.

Generate only the briefing text.

  • Account tier: {!$Input:Account.Tier__c}
  • Contract end date: {!$Input:Account.Contract_End_Date__c}

Open cases:

  • {!$Flow:Get_Open_Cases_for_Account}
  • """

Why it works:

Role and goal set perspective.

An instruction block separates what to do from the data.

A length limit and a structure control format.

"Use only… write 'Not available'" reduces hallucination.

Tone guidance keeps style consistent.

"Generate only…" prevents meta commentary.

Grounding supplies exactly the needed facts.

Techniques Worth Knowing

Examples (few-shot). Show one or two short input and output pairs when format or tone is hard to describe. Keep examples representative and short.

Structured output. When the response feeds a flow, integration, or UI, configure JSON or HTML structured output so responses follow a consistent schema.

Conditional logic (beta). Prompt Builder supports conditional blocks, which evaluate a single related record and don't iterate over collections.

Language control. Configure template output languages, or request a specific language, when multilingual users run the template.

Organize complex prompts. Break large prompts into sections, or chain prompt template actions (up to five) for multi-step generation.

Reviewing and Revising

Salesforce frames revision as Review, Revise, and Repeat :

Preview the resolved prompt. Did the merge fields return the right data? Is anything missing because of permissions?

Preview the response. Is it accurate, complete, on-brand, and free of harmful content or bias?

Revise one thing at a time : instructions, grounding, or model.

Re-run. Every run is a new LLM call, so responses can differ even with the same prompt. Review every response.

Scale the test. Use Testing Center batch tests with scorers such as Completeness, Coherence, Conciseness, Factuality, and Instruction Following.

Use feedback. Audit and feedback data in Data 360 shows accepted, modified, and rejected responses.

Applying the Same Ideas to Agent Instructions

Salesforce's guidance for subagent and agent instructions overlaps with prompt best practices but adds agent-specific rules:

Agent instruction guidance Why

Put sensitive or deterministic business rules into actions or logic Instructions are nondeterministic and don't replace coded rules

  • Keep instructions as minimal as possible Long or numerous instructions cause inconsistency and latency
  • Add instructions one at a time and test for regressions Isolates the effect of each change

Define business terms and give decision criteria The agent doesn't know your vocabulary or when to choose between similar actions

  • Avoid long lists of examples Short, representative examples work better and reduce latency
  • Use absolutes (always, never) only when meant Agents tend to follow strong language strictly
  • Use terms consistently and name actions explicitly Ambiguity causes inconsistent behavior

Reference resources directly (@ mentions of variables and actions) Removes ambiguity about which tool or value to use

Context Engineering Checklist

Salesforce's context engineering guide warns about context clash (conflicting instructions), context confusion (too much irrelevant content or too many tools), and context poisoning (incorrect or outdated data). Before activating a template or agent, check:

Do any instructions contradict each other or the grounding data?

Is every included field, tool, and example necessary?

Is the grounding data current and accurate?

Is the output format explicit?

Have you tested edge cases, such as missing data or unusual records?

Exam Traps

Longer isn't better. Adding more instructions often reduces reliability.

"Never make up information" works best with grounding and an explicit fallback such as "write Not available."

Don't encode approval thresholds only in prompts. Use logic or actions.

Put instructions in their own section, not buried among data fields.