BACK TO GUIDES

How to write a system prompt for AI agents

Learn the four components that turn a generic AI tool into a specialist that actually understands your role, your context, and how you want it to work.

About this guide

AI tools perform best when they receive clear instructions about their role, responsibilities, and expected outputs. Without that guidance, responses often become inconsistent, generic, or disconnected from the context that matters most. A well-designed system prompt helps establish those expectations before any conversation begins.

This guide explores the core building blocks of effective AI system prompts, including defining roles, setting goals, establishing rules, and creating useful output formats. It also explains how role definitions shape an AI persona, allowing an agent to reflect a specific expertise, perspective, and way of working. Whether you're building a custom AI agent for yourself or creating tools for a wider team, the objective is to produce more reliable, consistent, and context-aware results.

Download
Obsidian logo

This resource is a Markdown file. It opens in any text editor, but we recommend Obsidian for the best editing and visualization experience.

TRY KRELLIX FOR FREE

Get more done with your team of AI copilots

Solo or with a team, Krellix gives you the collaborators you need to move faster and ship better work.

Learn more

What is a system prompt?

A system prompt is a set of instructions that defines how an AI should behave before a conversation begins. It provides context about the role, goals, rules, and output style that guide future responses.

How do AI system prompts work?

AI system prompts work by providing background instructions that remain active throughout a conversation. They influence how an AI prioritizes information, applies rules, follows formats, and responds to different types of requests.

How do you write a good system prompt?

Writing a good system prompt starts with clearly defining the AI's role, goals, rules, and desired output format. Effective prompts provide enough structure to guide behavior while allowing the AI to adapt to different situations and user needs.

Can a system prompt improve AI responses?

Yes. A well-written system prompt can help an AI ask better questions, follow instructions more consistently, stay within its area of expertise, and produce outputs that are more relevant to a specific role or task.