opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: allow custom system prompts in global, project or custom directories

Open dan-and opened this issue 1 week ago • 2 comments

Fixes #7101

This PR adds support for a priority overrule of the opencode bundled system prompts in global, project or custom directory (via Env Setting)

Why is it helpful? In a reddit post, someone started creating very compact system-prompts to free up capacity in the context window. This patch allows using tailored system prompts instead of the bundled prompts. I hope this will increase creative and productive evolution on the system prompts for opencode and make it even more awesome.

How does it works: opencode (currently) uses the following system prompt files:

Modelname -> Filename anthropic / claude -> anthropic.txt gpt-5 -> codex.txt
gpt-, o1, o3 -> beast.txt
gemini- -> gemini.txt Fallback, if nothing matches -> qwen.txt

With this PR, opencode codes will load the matching system prompt file in following order (highest priority to lowest priority):

  • Environment: $OPENCODE_PROMPTS_DIR (e.g. OPENCODE_PROMPTS_DIR=/home/coder/my-custom-prompts)
  • In the project-directory (e.g. : /home/coder/source/awesome-project/.opencode/prompt/.txt )
  • Global system prompts at ~/.config/opencode/prompt/<name.txt>
  • Opencode's bundled system prompts inside opencode deployment

Q&A: Why not use AGENTS.md?

  • AGENTS.md will append to the bundled system prompt, not replace it. So it won't help building tailored system prompts for new or low-spec coding models.

Why are the prompts under the /prompt/ directory?

  • It follows the same directory structure as opencode's code to prevent confusing standards

How to start with a custom system prompt?

  • Start by using a copy of the original prompts from opencode (see: https://github.com/anomalyco/opencode/tree/dev/packages/opencode/src/session/prompt ) and put them into one of the mentioned directories. Look into https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/session/system.ts to check the current model-matching algorithm.

dan-and avatar Jan 07 '26 23:01 dan-and