Add option to modify system prompt
I'd love the ability to edit the system prompt/toggle between system prompts. My main interest in this would be to be able to use the opencode interface for tasks other than coding. Like similar to toggling between PLAN and BUILD it'd be cool to toggle between CODE and CHAT or something like that.
you can create custom modes with custom system prompts: https://opencode.ai/docs/modes/
My fault for not checking the docs. Thanks for taking time out of your day to send that link.
The link was broken, the correct one is: https://open-code.ai/en/docs/modes which says it is deprecated now. "Caution: Modes are now configured through the agent option in the opencode config. The mode option is now deprecated. Learn more.". As I understand we can now change our defined agent's system prompt:
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"build": {
"mode": "primary",
"model": "anthropic/claude-sonnet-4-20250514",
"prompt": "{file:./prompts/build.txt}",
"tools": {
"write": true,
"edit": true,
"bash": true
}
},
"plan": {
"mode": "primary",
"model": "anthropic/claude-haiku-4-20250514",
"tools": {
"write": false,
"edit": false,
"bash": false
}
},
"code-reviewer": {
"description": "Reviews code for best practices and potential issues",
"mode": "subagent",
"model": "anthropic/claude-sonnet-4-20250514",
"prompt": "**You are a code reviewer. Focus on security, performance, and maintainability.**",
"tools": {
"write": false,
"edit": false
}
}
}
}
Even though this example does not showcase, we should change the plan and the build agent's system prompts.
@cbarkinozer those are docs: https://opencode.ai/docs
@cbarkinozer doesn't seem work in 2.2.4, unless I misconfigured something.
Have this opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"enabled_providers": ["llamacpp"],
"provider": {
"llamacpp": {
"npm": "@ai-sdk/openai-compatible",
"name": "llama-server (local)",
"options": { "baseURL": "http://127.0.0.1:9931/v1" },
"models": {
"local": {
"name": "local llm"
}
}
}
},
"model": "llamacpp/local",
"small_model": "llamacpp/local",
"agent": {
"build": {
"mode": "primary",
"model": "llamacpp/local",
"prompt": "hello world",
}
}
}
I launch opencode in Build plan, send a hi, then I look at the text being sent, and I see a bunch of unrelated junk like:
hello world\\n# Your Model\\n- Name: local llm\\n- Provider ID: llamacpp\\n- Model ID: local\\n# Code Mode\\n\\nThe tools listed below cannot be called directly. I did write the "hello world" but why would I ever want to spend tokens on useless information like "Model ID: local".
There's a lot of content, none of which I want to see for my local coding agent and the solution suggested doesn't work.
I'm assuming this functional has regressed, so I created an issue describing how to reproduce it
Update from the linked issue — turns out, the text I see in the prompt isn't considered part of the prompt by OpenCode, but instead kinda an additional info. I guess that turns that into an RFE… Edited the issue accordingly.