Global instructions not loading across sessions #777

Closed
opened 2026-02-16 17:28:14 -05:00 by yindo · 3 comments
Owner

Originally created by @MatejBransky on GitHub (Jul 17, 2025).

Hi, I’m having trouble loading global instructions in opencode v0.3.17.

From the logs, it looks like opencode does read the instructions, but they are not picked up in any session, regardless of the current directory. I’ve tested this with both Sonnet 4 and GPT-4.1, but the model doesn’t seem to follow any instructions unless they are located in the current working directory.

When I place an opencode.json in the directory I open opencode from, and it directly references an instructions file, everything works fine. (see screenshot)

Image

However, when I try to set up global instructions via ~/.config/opencode/opencode.json like this:

{
  "instructions": [
    "bmad-role-loader.md"
  ]
}
{
  "instructions": [
    "./bmad-role-loader.md"
  ]
}
{
  "instructions": [
    "{file:./bmad-role-loader.md}"
  ]
}
{
  "instructions": [
    "{file:~/.config/opencode/bmad-role-loader.md}"
  ]
}
{
  "instructions": [
    "{file:/Users/matej.bransky/.config/opencode/bmad-role-loader.md}"
  ]
}
{
  "instructions": [
    "/Users/matej.bransky/.config/opencode/bmad-role-loader.md"
  ]
}

none of them seem to take effect.

Screenshot of opencode session in some project folder without any local instructions.

Image

Did I misunderstand how global instructions are supposed to work? Are they meant to be loaded automatically across all sessions regardless of the working directory?

Thanks in advance for any clarification! If I’m misusing the feature, I appreciate the guidance. If this should work, happy to help debug further.

Here is related part of the log:

Log
INFO  2025-07-17T08:29:55 +40ms service=app cwd=/Users/matej.bransky creating
INFO  2025-07-17T08:29:55 +0ms service=default version=0.3.17 args= opencode
INFO  2025-07-17T08:29:55 +0ms service=app cwd=/Users/matej.bransky creating
INFO  2025-07-17T08:29:55 +2ms service=app git
INFO  2025-07-17T08:29:55 +0ms service=app git
INFO  2025-07-17T08:29:55 +1ms service=bus type=storage.write subscribing
INFO  2025-07-17T08:29:55 +0ms service=app name=bus registering service
INFO  2025-07-17T08:29:55 +0ms service=format init
INFO  2025-07-17T08:29:55 +0ms service=bus type=file.edited subscribing
INFO  2025-07-17T08:29:55 +0ms service=config.hooks init
INFO  2025-07-17T08:29:55 +0ms service=bus type=file.edited subscribing
INFO  2025-07-17T08:29:55 +0ms service=bus type=session.idle subscribing
INFO  2025-07-17T08:29:55 +0ms service=app name=lsp registering service
INFO  2025-07-17T08:29:55 +0ms service=app name=provider registering service
INFO  2025-07-17T08:29:55 +1ms service=app name=config registering service
INFO  2025-07-17T08:29:55 +0ms service=app name=config registering service
INFO  2025-07-17T08:29:55 +2ms service=config $schema=https://opencode.ai/config.json autoupdate=true instructions=# BMad Role Loader

When user types `#{role}`, immediately load that role's instructions:

- `#analyst` → `~/.config/opencode/bmad/.bmad-core/agents/analyst.md`
- `#architect` → `~/.config/opencode/bmad/.bmad-core/agents/architect.md`
- `#dev` → `~/.config/opencode/bmad/.bmad-core/agents/dev.md`
- `#pm` → `~/.config/opencode/bmad/.bmad-core/agents/pm.md`
- `#po` → `~/.config/opencode/bmad/.bmad-core/agents/po.md`
- `#qa` → `~/.config/opencode/bmad/.bmad-core/agents/qa.md`
- `#sm` → `~/.config/opencode/bmad/.bmad-core/agents/sm.md`
- `#ux-expert` → `~/.config/opencode/bmad/.bmad-core/agents/ux-expert.md`
- `#bmad-master` → `~/.config/opencode/bmad/.bmad-core/agents/bmad-master.md`
- `#bmad-orchestrator` → `~/.config/opencode/bmad/.bmad-core/agents/bmad-orchestrator.md`

Load the file, follow its activation instructions, adopt the persona immediately. username=matej.bransky layout=auto loaded
Originally created by @MatejBransky on GitHub (Jul 17, 2025). Hi, I’m having trouble loading global instructions in opencode v0.3.17. From the logs, it looks like opencode does read the instructions, but they are not picked up in any session, regardless of the current directory. I’ve tested this with both Sonnet 4 and GPT-4.1, but the model doesn’t seem to follow any instructions unless they are located in the current working directory. When I place an opencode.json in the directory I open opencode from, and it directly references an instructions file, everything works fine. (see screenshot) <img width="754" height="673" alt="Image" src="https://github.com/user-attachments/assets/4079b378-1238-4360-a145-7f2425060f7d" /> However, when I try to set up global instructions via `~/.config/opencode/opencode.json` like this: ```json { "instructions": [ "bmad-role-loader.md" ] } { "instructions": [ "./bmad-role-loader.md" ] } { "instructions": [ "{file:./bmad-role-loader.md}" ] } { "instructions": [ "{file:~/.config/opencode/bmad-role-loader.md}" ] } { "instructions": [ "{file:/Users/matej.bransky/.config/opencode/bmad-role-loader.md}" ] } { "instructions": [ "/Users/matej.bransky/.config/opencode/bmad-role-loader.md" ] } ``` none of them seem to take effect. Screenshot of opencode session in some project folder without any local instructions. <img width="750" height="320" alt="Image" src="https://github.com/user-attachments/assets/93d63f5c-cc48-4ac6-9057-d7bcdccdc84e" /> Did I misunderstand how global instructions are supposed to work? Are they meant to be loaded automatically across all sessions regardless of the working directory? Thanks in advance for any clarification! If I’m misusing the feature, I appreciate the guidance. If this should work, happy to help debug further. Here is related part of the log: <details> <summary>Log</summary> ``` INFO 2025-07-17T08:29:55 +40ms service=app cwd=/Users/matej.bransky creating INFO 2025-07-17T08:29:55 +0ms service=default version=0.3.17 args= opencode INFO 2025-07-17T08:29:55 +0ms service=app cwd=/Users/matej.bransky creating INFO 2025-07-17T08:29:55 +2ms service=app git INFO 2025-07-17T08:29:55 +0ms service=app git INFO 2025-07-17T08:29:55 +1ms service=bus type=storage.write subscribing INFO 2025-07-17T08:29:55 +0ms service=app name=bus registering service INFO 2025-07-17T08:29:55 +0ms service=format init INFO 2025-07-17T08:29:55 +0ms service=bus type=file.edited subscribing INFO 2025-07-17T08:29:55 +0ms service=config.hooks init INFO 2025-07-17T08:29:55 +0ms service=bus type=file.edited subscribing INFO 2025-07-17T08:29:55 +0ms service=bus type=session.idle subscribing INFO 2025-07-17T08:29:55 +0ms service=app name=lsp registering service INFO 2025-07-17T08:29:55 +0ms service=app name=provider registering service INFO 2025-07-17T08:29:55 +1ms service=app name=config registering service INFO 2025-07-17T08:29:55 +0ms service=app name=config registering service INFO 2025-07-17T08:29:55 +2ms service=config $schema=https://opencode.ai/config.json autoupdate=true instructions=# BMad Role Loader When user types `#{role}`, immediately load that role's instructions: - `#analyst` → `~/.config/opencode/bmad/.bmad-core/agents/analyst.md` - `#architect` → `~/.config/opencode/bmad/.bmad-core/agents/architect.md` - `#dev` → `~/.config/opencode/bmad/.bmad-core/agents/dev.md` - `#pm` → `~/.config/opencode/bmad/.bmad-core/agents/pm.md` - `#po` → `~/.config/opencode/bmad/.bmad-core/agents/po.md` - `#qa` → `~/.config/opencode/bmad/.bmad-core/agents/qa.md` - `#sm` → `~/.config/opencode/bmad/.bmad-core/agents/sm.md` - `#ux-expert` → `~/.config/opencode/bmad/.bmad-core/agents/ux-expert.md` - `#bmad-master` → `~/.config/opencode/bmad/.bmad-core/agents/bmad-master.md` - `#bmad-orchestrator` → `~/.config/opencode/bmad/.bmad-core/agents/bmad-orchestrator.md` Load the file, follow its activation instructions, adopt the persona immediately. username=matej.bransky layout=auto loaded ``` </details>
yindo closed this issue 2026-02-16 17:28:14 -05:00
Author
Owner

@rekram1-node commented on GitHub (Jul 17, 2025):

@MatejBransky have you tried using the global AGENTS.md? Instructions should probably be tweaked so it isn't always relative to cwd but if you want global rules you can use AGENTS.md.

@rekram1-node commented on GitHub (Jul 17, 2025): @MatejBransky have you tried using the global AGENTS.md? Instructions should probably be tweaked so it isn't always relative to cwd but if you want global rules you can use AGENTS.md.
Author
Owner

@MatejBransky commented on GitHub (Jul 17, 2025):

Hi, I ended up rewriting it into AGENTS.md, where I route to the corresponding instruction files. It works perfectly! I consider this resolved, so I think we can go ahead and close it.

@MatejBransky commented on GitHub (Jul 17, 2025): Hi, I ended up rewriting it into AGENTS.md, where I route to the corresponding instruction files. It works perfectly! I consider this resolved, so I think we can go ahead and close it.
Author
Owner

@rekram1-node commented on GitHub (Jul 17, 2025):

Sounds good, you may have already seen this in docs but just adding here just in cases, this seems related to your use case: https://opencode.ai/docs/rules/#referencing-external-files

@rekram1-node commented on GitHub (Jul 17, 2025): Sounds good, you may have already seen this in docs but just adding here just in cases, this seems related to your use case: https://opencode.ai/docs/rules/#referencing-external-files
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#777