What is a system prompt?

A system prompt is a way to provide context, instructions, and guidelines to Claude before presenting it with a question or task. By using a system prompt, you can set the stage for the conversation, specifying Claude’s role, personality, tone, or any other relevant information that will help it better understand and respond to the user’s input.

System prompts can include:

  • Task instructions and objectives
  • Personality traits, roles, and tone guidelines
  • Contextual information for the user input
  • Creativity constraints and style guidance
  • External knowledge, data, or reference material
  • Rules, guidelines, and guardrails
  • Output verification standards and requirements

Benefits of using system prompts

Incorporating well-crafted system prompts can significantly enhance Claude’s performance and output quality. Some key benefits include:

  1. Improved role-playing and character consistency: When assigning Claude a specific role or personality through a system prompt, it can maintain that character more effectively throughout the conversation, exhibiting more natural and creative responses while staying in character.
  2. Increased adherence to rules and instructions: System prompts can help Claude better understand and follow guidelines, making it less likely to perform prohibited tasks, output restricted content, or deviate from the given instructions.
  3. Enhanced context understanding: By providing relevant background information or reference material in the system prompt, you can improve Claude’s comprehension of the user’s input and enable it to generate more accurate and context-aware responses.
  4. Customized output formatting: System prompts can be used to specify desired output formats, such as headers, lists, tables, or code blocks, ensuring that Claude’s responses are structured and presented in a way that best suits your needs.

It’s important to note that while system prompts can increase Claude’s robustness and resilience against unwanted behavior, they do not guarantee complete protection against jailbreaks or leaks. However, they do provide an additional layer of guidance and control over Claude’s output.

How to use system prompts

To use system prompts with the Messages API, set the system parameter to your desired system prompt text. Here’s an example API call:

import anthropic

client = anthropic.Client(api_key="YOUR_API_KEY")

response = client.messages.create(
    system="Respond only in Spanish.", # <-- system prompt
        {"role": "user", "content": "Hello, Claude!"} # <-- user prompt


For more information, refer to our Messages API documentation.

Note: You can also use system prompts in the Console, but not on claude.ai.

Prompting techniques

You can apply the same prompting techniques you would use in a user prompt to a system prompt instead. For example, you can:

  1. Specify output formatting: Provide example responses or instructions for desired output patterns within the system prompt to guide Claude’s behavior.
  2. Provide documents, guides, and reference material: Include relevant information or RAG content in the system prompt to help Claude generate more informed and accurate responses.
  3. Use XML tags, especially to structure long documents: Use XML tags to organize your system prompt into sections to improve clarity. When incorporating multiple or lengthy documents in the system prompt, you can use use the multi-document XML format to help Claude better understand and utilize the provided information.

Frequently asked questions

How do I know when to use a system prompt vs. a user prompt?

Prompting is all experimentation, so we recommend that you try it both ways! But in general, you can think about system prompts as a space to provide guidance about the overall interaction with Claude, and the user turn as part of the interaction itself, or when you have only a one-off task you want to accomplish.

How can I convert my existing user-only prompts to use system prompts?

To convert your user-only prompts to system prompts, simply move any content that is not part of the user’s input to the system parameter in the Messages API. This can include task instructions, personality guidelines, reference material, or any other contextual information that helps set the stage for the conversation. We encourage you to experiment to see what works best in which field.

Where can I use system prompts?

System prompts are currently available for use with Claude 3 models and Claude 2.1 through our API, Console, Amazon Bedrock’s API, and Google Cloud Vertex AI’s API. They are not supported on claude.ai at this time.

Do system prompts make my prompts jailbreak-proof or leak-proof?

While Claude is already highly resilient to jailbreaks and unwanted behavior due to its training methods (e.g., RLHF and Constitutional AI), system prompts can further enhance Claude’s ability to adhere to instructions and guidelines. However, they do not guarantee complete protection against jailbreaks or leaks.