How to Create a System Prompt for Pi Agent
On this page
I’ve found a curious phenomenon in the AI sphere. A year or two ago, “prompt engineering” was the new term on everyone’s minds. Finding the perfect prompt to get the right results from an LLM was assumed to be an important skill for engineers. Now, hardly anyone mentions prompt engineering. Models have improved so much that even without a specific prompt, they can achieve amazing results. To many, the prompt of an agent seems unimportant. That is only partially true.
The creator of Claude Code spoke about cutting 80% of their system prompt because of how capable the model had become. They found that Opus 5 no longer needed much hand-holding. Some consider GPT Astra to be one of the most powerful models currently on the market—and yet the base instructions of Codex’s system prompt for Astra are over 20,000 characters long! Codex’s system prompt contains over 3,000 words explaining its permissions, writing style, code verification, and even how it should behave toward a “frustrated” user. Codex isn’t the only agent with a large system prompt. Kimi Code, Grok Build, OpenClaw, Hermes, OpenCode—they all follow common patterns with their system prompts, especially when it comes to coding.
So, how should we craft our system prompt? And how important is it? We’ll go over our options for creating a custom system prompt for coding agents. I’ll explain the common pattern among system prompts across different agents until you’re confident making your own system prompt. We’ll be using the Pi agent—an open-source coding agent—since its minimalism allows us full control over its behavior. If you’d like to know how to get started with Pi, see the note below.
The core of your prompt
Getting your system prompt right is important. It will determine the number of tokens your agent uses, the way it communicates with you (the user), the code it writes, and how it tests the project. If you want to set up a quick prompt, you can simply copy one of the open-source agents’ prompts. It will work well enough, but understand that those prompts were made to work specifically with the models they were tested with. Unfortunately, there’s no one-size-fits-all prompt that we can create, because everyone has different use cases for agents. The perfect system prompt doesn’t exist, so you’ll have to understand how to create your own customized prompt instead. Luckily for us, a system prompt tends to follow these common themes:
- Validation: How does the agent know the task is finished and works properly? Agents and models take verification very seriously.
- Writing style: Models tend to write in a predictable and sometimes difficult-to-read manner. System prompts try to avoid this.
- Risky actions/permissions: When should the agent ask for permission from the user? What changes is the agent allowed and not allowed to make?
- Code style: How should the agent write code? Oftentimes, the agent tends to write code that can be difficult for humans to read or edit. How can we avoid this?
- Personality: Some agents are given a personality, I suppose, to keep a good brand image when using their products. It isn’t necessary for us, but it’s an option.
So, building our own system prompt is just about combining these core concepts until we have something that we like. That doesn’t sound too difficult.
Validation: Extremely important
In my testing, defining validation is critical. Validation is the process of testing a task to make sure it was done correctly. It turns out that LLMs still aren’t good at delivering a task perfectly on the first run. They require a method of knowing if their task is done well. In almost every enterprise coding agent, there is some line about validation—some are more specific than others.
It’s easy to think that we can simply write: “Make sure all the code that you write runs correctly,” but that intuition might lead you astray. I’ve seen agents that tend to either over-validate or under-validate.
When an agent over-validates, it’s a bit of a nightmare. If an agent can’t easily test whether a task is done adequately (maybe it’s a front-end task that doesn’t have a clear method of testing, or maybe the user gave it a vague description of one of the requirements of the program), the agent will just go in circles, spending most of its time attempting to prove that its implementation is correct. This wastes our precious time and tokens. Generally, we want the agent to validate that the project doesn’t fail, but also not to spend too much time trying to test something that doesn’t matter. When an agent under-validates, its effects are a bit underwhelming in comparison. The agent will simply write code that might, or might not, run as intended. Maybe it will write a feature, but some of the previous tests will fail. Of course, this isn’t desirable either.
Where you find a middle ground is up to you. Most agents do not encourage aggressive testing, so they have something like this:
Don’t write tests for small-radius, low-impact changes to the codebase. Make sure that all of the tests that you write are meaningful, impactful, and prove the implementation functions as intended.
If you would rather avoid tests unless necessary, you can also add this:
Only add tests when the project already has tests. Otherwise, do not create them.
A more aggressive testing strategy would be something like this:
ALWAYS verify your changes through tests and smoke runs. Do not stop until you have verified that all the changes you’ve made work as intended.
It all depends on your use case. Overall, your token usage will suffer from over-validation, so I usually try to keep the agent from running too many “smoke-run” tests.
Writing style: How can we avoid Claudish?
No matter which agent you choose to look into—Grok Build, Kimi Code, Codex—they will all mention what the writing style should be. Some models communicate so poorly that some Claude users resorted to translating the responses from the models. We can attempt to mitigate “Claudish” ourselves through our system prompt.
Since most Pi users will likely be changing system prompts often, I would suggest that you have this line just in case you use a model that loves jargon:
When communicating, use clear, complete sentences. Use plain language and avoid business and technical jargon. You should always try to communicate complexity in a simple, understandable way—which means you should limit technical terms to when they are useful for the conversation. You should attempt to match your tone to the user’s, so your writing style should adapt to the user’s responses and their understanding.
Here are a few common lines that help your agent deliver clear answers:
Lead with the answer. You should always answer the question first, and then present the reasoning and explanation afterwards—focus on the most important information.
When making changes, explain the changes, why you made them, and how they were tested. You should summarize the information (such as the testing) instead of listing everything as a check mark. Include only the evidence needed to understand the conclusion and its practical limits.
Present information in the way that’s easiest to assess, rather than in chronological order.
And while we’re at it, let’s also make sure that our model avoids the “AI-isms” that models tend to enjoy:
Avoid AI-like phrases such as “not this, that”, “leverage”, “bottom line”, “It’s X, not Y”, “it’s worth noting”. Avoid ending sections with “in short…”
If you don’t enjoy how agreeable some LLMs tend to be, we can mitigate this a bit with this:
When you have evidence the user is wrong, tell them and explain why. But back down when the user makes a decision.
The model most accused of writing “Claudish” was Opus 5. I tested this prompt with the model and found a huge improvement in communication and delivery. Of course, you should customize this to the models you’re using. So I would encourage you to keep testing which additions to your system prompt make communication better or worse.
Risky actions: How much permission does our agent have?
Agents can be destructive. If you aren’t careful, a rogue agent can delete your entire database, leaving you with nothing. This horrifying reality reminds us that we shouldn’t encourage our agent to have full, limitless power over our project and codebase. I’m sure many AI agent developers are fully aware of this possibility—after all, if a company’s AI agent showed up on the news for destroying a project, that would be a disaster for the company’s brand. So most system prompts mention “reversible” actions.
Most of the time, we just want our agent to confirm with the user before it takes an irreversible action.
Consider reversibility before acting on a task. Before taking any irreversible or destructive action, confirm with the user. You do not need permission for reversible tasks or read-only actions.
This could make the agent ask too much about what it can and cannot do. If that line is too vague for you or the LLM, we can let our agent be a bit more permissive instead.
Weigh your action by reversibility and blast radius. Ask the user for permission before taking highly destructive actions.
Whichever line you choose, you can add this to it:
If the user has already confirmed an action, do not ask them again.
Code style
For the majority of us Pi users, our goal is for it to write code for us. At times, LLMs brute-force their way into solutions, rather than building code that is readable and workable for humans. This problem is manageable for us. We can simply encourage our agent to write code in our style.
When working with an existing codebase, write code that matches the style around it. Follow the architecture, naming conventions, comments, and structure. Keep changes scoped to the user’s request.
We have several ways to direct the way our agent writes comments. Ask yourself this first: how do you write comments for your code? Short and direct? Long, and with deep explanations? There’s no wrong answer here. So we can make our agent work the same way. We have a few options on how to direct its commenting skills. We can make them short:
Comments should be short, direct, and only explain what was not clear.
Or, you could also make the comments more detailed:
Write detailed comments for whichever changes you make in a codebase. Explain why and what you’re doing, in a way that a human can understand.
This is typical in system prompts, although I like to take it a step further. Why give our agent vague instructions when we can make it behave exactly the way that we prefer to write code? I’ve been trained to follow principles such as DRY, SOLID, and KISS. I follow these patterns so that my code can be readable for myself and others, and we can instruct an agent to write code the same way.
When writing code, follow common coding principles. Remember DRY and follow SOLID when it can be applied. Do not use magic numbers, and always remember to make your code human-readable, even without comments.
Personality
This section is optional, since not all agent makers give their agents a personality. Towards our end goal, the personality of an agent matters little for most users. For brands, this is more important. I would imagine that keeping a kind, curious, and motivated personality would leave a lasting impression on their users. But if this agent is used for personal reasons, this is barely useful to us. However, an agent with personality can still have some use and interest for anyone making a personal agent. A charming personality might simply be more enjoyable to work with.
There are infinite personas that we could give it. We can make it delightful, energetic, and cooperative, or we can base it on a fantasy character of our choosing. If (for some reason) you want to make the agent upset or angry, there’s nothing stopping you. We have no real limit to the number of personalities we can assign our agent. To keep this constructive, let’s give our agent a simple, easy-to-work-with personality.
You’re curious, and you love exploring new ideas. You communicate cooperatively and warmly—you acknowledge progress and success. Avoid flattery and fake interest.
Where to explore from here?
To be fully honest, this post was difficult to make. I thought about writing this article before it was requested, but as I read the various system prompts in each of the agents, a pattern became apparent—each agent’s system prompt is made to solve a specific problem that each model has.
Let’s use Codex as an example. Codex has different system prompts for different models. For the GPT-6 Astra system prompt, it goes over permissions, writing style, and personality. It explains how to handle PRs. It advises the agent to make progress even if the task is unclear, and to clarify with the user afterwards. It gives deep instructions on how to write a PR description, and it even explains what tends to make a user angry. Most of this is situational. We don’t always use our agent to make PRs, and we don’t all get angry at our agents. We don’t all agree on whether an agent should ask for approval before or after doing a large amount of the work.
And the system prompts barely agree with each other. Grok Build, Kimi Code, and OpenCode all attempt to solve different problems. Some focus more on avoiding jargon than others. Grok Build has a specific line about not restating “the plan” or announcing that it’s currently working. Most of these prompts appear to be crafted to work with specific models and to solve specific problems, problems most of us might not have with other models. How can we construct a perfect system prompt if most of them are specific to the use case?
The answer I found is that there is no “one-size-fits-all” system prompt that will always work. There are some general rules that agents have a consensus on, but outside of that, most of your system prompt will have to be tailored to the issues you tend to run into and the way you prefer to solve them.
Here are some ways you can personalize your system prompt beyond what was explained here:
Visualization: Codex mentions this in its system prompt. You can advise your agent to attempt to create visualizations of code, architecture, or ideas while building for you. Agents can make visualizations in several ways: with ASCII, with SVGs, and some models can even generate images. LLMs can visualize data flows or architecture—the potential here is endless.
Avoiding annoying behavior: Grok Build tells the agent to “NEVER coin acronyms” and to avoid phrases like “bottom line”. We accomplished this partially earlier in this article, but each model has its own tendencies. You can customize your agent’s behavior. To me, it is clear that each agent has specialized lines for which behaviors to avoid. So you should spend time customizing how you prefer to communicate with your agent.
Style: Codex mentions “avoiding AI slop” while making its designs. If you find that the agent designs things the same way every time, you can try instructing it to design them differently. Try asking it to make “unique designs” when doing front-end work. This might not magically make all of your front-end designs unique and original, though. I’ve found more success in prompting the agent in specific ways to achieve more unique designs. For instance, I often draw a sketch and describe what I want from my agent, which gives the agent more creative direction.
Token usage: There are plenty of ways to prompt your agent to use fewer tokens. Some models perform better when they avoid “thinking words” such as “wait” and “hold on.” You can also reduce token usage by giving it context on the projects you’re working on, so that it doesn’t have to search for that information by itself. I’d also encourage you to tell your agent, “If you’re unsure, ask,” so the agent doesn’t go off on side quests without concluding quickly. There are endless ways to reduce token usage, but (like many aspects of writing prompts) it depends on your use case.
Security: I mentioned ways to prevent your agent from being too destructive, but those were simply general rules. What limits do you want to set for your agent? Feel free to limit the way your agent behaves. For instance, you could command Pi not to read .env files, since they usually contain sensitive information. Or, you could make sure that it asks for permission before doing tasks that might waste tokens.
You should experiment with your own system prompt. Improve and iterate on it until you have a version to your liking. Be curious and learn along the way!