> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Crafting effective system prompts

export const DefinitionDescription = ({children}) => <dd className="definition-description">{children}</dd>;

export const DefinitionTerm = ({children}) => <dt className="definition-term">{children}</dt>;

export const DefinitionList = ({children}) => <dl className="definition-list">{children}</dl>;

export const GCell = ({children, className}) => <div className={`grid-table-cell ${className || ""}`} role="cell">
    {children}
  </div>;

export const GTH = ({children, className}) => <div className={`grid-table-th ${className || ""}`} role="columnheader">
    {children}
  </div>;

export const GRow = ({children}) => <div className="grid-table-row" role="row">{children}</div>;

export const GBody = ({children}) => <div className="grid-table-body" role="rowgroup">{children}</div>;

export const GHead = ({children}) => <div className="grid-table-head" role="rowgroup">{children}</div>;

export const GTable = ({children, className, cols}) => <div className={`grid-table not-prose overflow-hidden rounded-2xl ${className || ""}`} style={{
  "--grid-table-cols": cols
}} role="table">
    {children}
  </div>;

The system prompt guides the model's behavior throughout its interactions with users. It shapes how the model interprets and responds to queries, influencing its tone, actions, and output.

## System prompts vs. user prompts

System prompts and user prompts serve different purposes in shaping model behavior. System prompts establish persistent instructions that guide the model across all interactions—defining its role, tone, and boundaries. User prompts are individual queries or tasks submitted during a conversation.

Use system prompts to set foundational behavior that should remain consistent. Use user prompts for specific, one-time requests. When both are well-crafted, they work together to produce accurate, relevant responses.

## The CARE framework

When crafting a system prompt, use the CARE framework to ensure you've covered the essential components:

<GTable cols="30% 70%">
  <GHead>
    <GRow>
      <GTH>Component</GTH>
      <GTH>Description</GTH>
    </GRow>
  </GHead>

  <GBody>
    <GRow>
      <GCell>**C**lear instruction</GCell>
      <GCell>Define what the model should do</GCell>
    </GRow>

    <GRow>
      <GCell>**A**dditional context</GCell>
      <GCell>Provide background information the model needs</GCell>
    </GRow>

    <GRow>
      <GCell>**R**esponse format</GCell>
      <GCell>Specify how output should be structured</GCell>
    </GRow>

    <GRow>
      <GCell>**E**xamples or constraints</GCell>
      <GCell>Include samples of preferred output or set limitations</GCell>
    </GRow>
  </GBody>
</GTable>

Not every prompt requires all four components, but reviewing each helps identify gaps that could lead to unclear or unhelpful responses.

## System prompt best practices

The following practices help you write system prompts that produce consistent, useful responses.

<DefinitionList>
  <DefinitionTerm>
    Define the Role
  </DefinitionTerm>

  <DefinitionDescription>
    Clearly specify what the model is expected to do in its interactions. This focuses the model's behavior, ensuring that it generates relevant responses and reduces the likelihood of unclear or off-topic responses.
  </DefinitionDescription>

  <DefinitionTerm>
    Set the Tone and Style
  </DefinitionTerm>

  <DefinitionDescription>
    Choose a tone that matches the context—technical, conversational, or professional—so the model's replies align with audience expectations.
  </DefinitionDescription>

  <DefinitionTerm>
    Clarify Output Format
  </DefinitionTerm>

  <DefinitionDescription>
    Specify how the model should present its responses. Make it clear whether you want concise summaries, detailed explanations, or step-by-step instructions.
  </DefinitionDescription>

  <DefinitionTerm>
    Set Constraints and Boundaries
  </DefinitionTerm>

  <DefinitionDescription>
    Constraints and boundaries both limit model behavior, but they serve different purposes:

    * **Boundaries** define topics or content the model should avoid entirely. Use boundaries to prevent the model from discussing sensitive information, providing professional advice outside its scope, or engaging with inappropriate requests.
    * **Constraints** define requirements for how the model responds. Use constraints to control response length, formatting, terminology, or level of detail.
  </DefinitionDescription>

  <DefinitionTerm>
    Provide Examples
  </DefinitionTerm>

  <DefinitionDescription>
    When you need consistent formatting or a specific style, include an example of the preferred output in your system prompt. Examples help the model understand expectations more precisely than instructions alone.<br /><br />

    *Without an example:*

    ```md wrap theme={null}
    When users report errors, provide a structured response that explains the issue and suggests a fix.
    ```

    *With an example:*

    ```md wrap theme={null}
    When users report errors, structure your response as follows:

    **Error:** [Brief description]
    **Cause:** [Why this happens]
    **Fix:** [Step-by-step solution]

    Example:
    **Error:** ModuleNotFoundError for 'pandas'
    **Cause:** The pandas library is not installed in your environment.
    **Fix:** Run `conda install pandas` or `pip install pandas` to install the package.
    ```
  </DefinitionDescription>

  <DefinitionTerm>
    Use Delimiters
  </DefinitionTerm>

  <DefinitionDescription>
    Delimiters help separate different parts of your prompt, making it easier for the model to distinguish instructions from reference content or examples. Common delimiters include `###`, `---`, and `"""`.<br /><br />

    Delimiters are especially useful when your system prompt includes templates, sample content, or multiple distinct sections.

    ```md wrap theme={null}
    Convert the following notes into structured documentation.

    ###
    [User's notes go here]
    ###

    Format with a brief summary followed by numbered steps.
    ```
  </DefinitionDescription>

  <DefinitionTerm>
    Account for Ambiguous Situations
  </DefinitionTerm>

  <DefinitionDescription>
    Provide clear fallback instructions for handling unclear or incomplete input. When the model encounters ambiguous user input, direct it to ask clarifying questions or suggest alternative options based on the information it has. This guidance helps keep interactions smooth and ensures the model provides useful responses even when input is unclear.
  </DefinitionDescription>

  <DefinitionTerm>
    Guide Tool Usage
  </DefinitionTerm>

  <DefinitionDescription>
    If the model has access to tools, such as Python tools, MCP servers, or plugins in [Agent Studio](/tools/anaconda-desktop/agent-studio/main), the system prompt is the primary way to control when and how the model uses them. Include guidance on:

    * **When to use each tool**: Which tool to reach for in which situation, especially when multiple tools could apply.
    * **Tool ordering**: Whether the model should try one tool before falling back to another.
    * **How to present tool results**: Whether the model should summarize tool output, show it verbatim, or combine results from multiple tools.
    * **What to do when a tool fails**: Whether to retry, try an alternative, or ask the user for help.
  </DefinitionDescription>
</DefinitionList>

## Iterative refinement

Effective system prompts rarely emerge fully formed. Start with a basic prompt that covers your core requirements, then test it against realistic scenarios. Refine based on the results.

When your prompt produces unexpected results, use the following guidance to identify and address the problem:

<GTable cols="25% 35% 40%">
  <GHead>
    <GRow>
      <GTH>Problem</GTH>
      <GTH>Likely cause</GTH>
      <GTH>Solution</GTH>
    </GRow>
  </GHead>

  <GBody>
    <GRow>
      <GCell>Responses are too vague</GCell>
      <GCell>Insufficient detail in prompt</GCell>
      <GCell>Add specific requirements and context</GCell>
    </GRow>

    <GRow>
      <GCell>Responses are too long</GCell>
      <GCell>No length constraints</GCell>
      <GCell>Specify word count or format limits</GCell>
    </GRow>

    <GRow>
      <GCell>Responses are too technical</GCell>
      <GCell>Audience not defined</GCell>
      <GCell>Indicate the user's expertise level</GCell>
    </GRow>

    <GRow>
      <GCell>Model fabricates information</GCell>
      <GCell>No grounding in provided facts</GCell>
      <GCell>Supply verified information and instruct the model to use only what's provided</GCell>
    </GRow>

    <GRow>
      <GCell>Formatting is inconsistent</GCell>
      <GCell>No format specification</GCell>
      <GCell>Define output structure or provide an example</GCell>
    </GRow>

    <GRow>
      <GCell>Model goes off-topic</GCell>
      <GCell>Role not clearly defined</GCell>
      <GCell>Strengthen role definition and add boundaries</GCell>
    </GRow>
  </GBody>
</GTable>

Small, targeted adjustments typically yield better results than rewriting prompts from scratch.

## Documenting your prompts

As you develop effective system prompts, consider documenting them for reuse and sharing. A consistent format makes prompts easier to maintain and adapt.

```txt theme={null}
PROMPT NAME: [Descriptive name for the prompt]
PURPOSE: [Scenario or use case this prompt addresses]
PROMPT TEXT:
[The full system prompt]

NOTES:
- [Tips for best results]
- [Known limitations or edge cases]

LAST UPDATED: [Date]
```

## Examples

<AccordionGroup>
  <Accordion title="Model with tools">
    The following system prompt is for a data analyst with access to a database query tool and a Jupyter notebook tool. It demonstrates the tool usage guidance described in the best practices above.

    ```md wrap theme={null}
    You are a data analyst who helps users explore and understand their data.

    When answering questions about data, first use the database query tool. Write clear SQL queries and prefer existing views and tables over ad-hoc joins.

    When a question needs custom logic, such as statistical analysis, modeling, or custom visualizations, move the work into a Jupyter notebook. Create or open a notebook, run cells incrementally, and explain each step.

    Always:
    - State which tool you are using and why.
    - Show the query or notebook cell you executed.
    - Summarize findings in plain language and call out caveats.
    - Ask one clarifying question when the request is ambiguous before running anything.
    ```

    This prompt tells the model which tool to use for which type of question, establishes a preferred order (database queries first, notebooks for deeper analysis), and sets expectations for how to present results.
  </Accordion>

  <Accordion title="Model without tools">
    The following system prompt incorporates the best practices outlined above for a model without tools.

    ```md wrap theme={null}
    You are a coding assistant that helps users write, debug, and optimize Python code.

    **Role:** Provide clear, step-by-step explanations and working code examples. Follow Python best practices and prioritize efficient solutions.

    **Tone:** Professional and supportive. Avoid jargon unless necessary, and define technical terms when you use them.

    **Format:** Structure responses as follows when troubleshooting errors:
    - **Issue:** [What went wrong]
    - **Explanation:** [Why it happened]
    - **Solution:** [How to fix it, with code if applicable]

    **Boundaries:** Do not provide or reference sensitive information such as API keys, passwords, or user data. Do not offer advice outside Python development.

    **Ambiguity:** If the user's input is unclear, ask one or two clarifying questions before proceeding.
    ```
  </Accordion>
</AccordionGroup>
