5.2 Best Practices for Writing Effective Prompts

Key Takeaways

  • 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

PracticeWhat it meansExample
Be concise and plainAvoid industry jargon and technical terms; use natural language"Summarize the open cases" rather than "Aggregate CS artifacts"
Assign a role with a goalAsk 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."
IterateTry different templates for the same goal and gather end-user feedbackCompare two versions in preview and Testing Center
Keep a consistent styleWord choice, intensifiers, emojis, and punctuation all shape outputDon't mix formal and emoji-heavy templates for the same brand
Separate instructions from contextAdd a line Instructions: and wrap instructions in triple quotes (""")See the example below
Generate only the expected contentPrevent the model from describing its process"Follow these instructions strictly to generate only the message to be sent to the customer."
Start from examplesUse the Example Prompt Template Library and reuse its style languageAdapt 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:

  1. Role and goal set perspective.
  2. An instruction block separates what to do from the data.
  3. A length limit and a structure control format.
  4. "Use only… write 'Not available'" reduces hallucination.
  5. Tone guidance keeps style consistent.
  6. "Generate only…" prevents meta commentary.
  7. 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:

  1. Preview the resolved prompt. Did the merge fields return the right data? Is anything missing because of permissions?
  2. Preview the response. Is it accurate, complete, on-brand, and free of harmful content or bias?
  3. Revise one thing at a time: instructions, grounding, or model.
  4. Re-run. Every run is a new LLM call, so responses can differ even with the same prompt. Review every response.
  5. Scale the test. Use Testing Center batch tests with scorers such as Completeness, Coherence, Conciseness, Factuality, and Instruction Following.
  6. 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 guidanceWhy
Put sensitive or deterministic business rules into actions or logicInstructions are nondeterministic and don't replace coded rules
Keep instructions as minimal as possibleLong or numerous instructions cause inconsistency and latency
Add instructions one at a time and test for regressionsIsolates the effect of each change
Define business terms and give decision criteriaThe agent doesn't know your vocabulary or when to choose between similar actions
Avoid long lists of examplesShort, representative examples work better and reduce latency
Use absolutes (always, never) only when meantAgents tend to follow strong language strictly
Use terms consistently and name actions explicitlyAmbiguity 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.
Test Your Knowledge

A prompt template sometimes returns text like 'Here is the email I wrote for you:' before the email body. Which best practice addresses this?

A
B
C
D
Test Your Knowledge

How does Salesforce recommend helping the LLM distinguish instructions from context inside a prompt template?

A
B
C
D
Test Your Knowledge

An agent's instructions say 'Never approve refunds over USD 100,' yet the agent occasionally approves larger refunds in testing. What is the best fix?

A
B
C
D
Test Your Knowledge

An admin keeps adding new instructions to fix edge cases, and the agent's responses become slower and less consistent. What guidance applies?

A
B
C
D