What filesystem does an opencode server use?
based on how u implement skills (https://forums.basehub.com/anomalyco/opencode/10) and how to implement an opencode server (https://forums.basehub.com/anomalyco/opencode/9), question: if i implement an opencode server, what's my filesystem? the server's fs? is the recommended setup to run opencode inside a sandbox, which has the skill files there? is there a way to "seed" skills directory? thinking about how to leverage this
Now I have a complete picture. Let me summarize everything for you:
##Answer: Filesystem & Skills in an OpenCode Server
###Which Filesystem?
The server's filesystem. When you run an OpenCode server (via opencode serve or createOpencodeServer()), all filesystem operations happen on the machine where the server process runs. This includes:
-
Skills discovery — scans the server's filesystem at:
~/.config/opencode/skill/(global XDG config)~/.config/opencode/skills/~/.claude/skills/(Claude-compatible global).opencode/skill/or.opencode/skills/(project-level).claude/skills/(Claude-compatible project-level)
-
Working directory — determined per-request via:
- Query param:
?directory=/path/to/project - Header:
x-opencode-directory: /path/to/project - Falls back to
process.cwd()of the server
- Query param:
From the server code:
let directory = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd()
return Instance.provide({
directory,
init: InstanceBootstrap,
async fn() { return next() },
})
###Recommended Setup: Sandbox with Pre-seeded Skills
Yes! Running OpenCode inside a sandbox with skills pre-loaded is a great pattern. Here's how the paths work:
| Path Type | Source |
|---|---|
| Global config/skills | ~/.config/opencode/ (XDG data dir) |
| Global Claude skills | ~/.claude/skills/ |
| Project skills | <working_directory>/.opencode/skill/ |
| Project Claude skills | <working_directory>/.claude/skills/ |
###How to Seed Skills
You have a few options:
####Option 1: Use OPENCODE_CONFIG_DIR (Best for custom skills location)
Set the environment variable to add an extra config/skills directory:
const proc = spawn('opencode', ['serve'], {
env: {
...process.env,
OPENCODE_CONFIG_DIR: '/sandbox/my-skills-config'
}
})
This directory gets added to Config.directories(), which is scanned for skills:
/sandbox/my-skills-config/skill/my-skill/SKILL.md
/sandbox/my-skills-config/skills/another-skill/SKILL.md
####Option 2: Pre-populate the sandbox's ~/.config/opencode/
Before starting the server, create the global config directory:
~/.config/opencode/
└── skill/
├── my-custom-skill/
│ └── SKILL.md
└── another-skill/
└── SKILL.md
####Option 3: Pre-populate the project's .opencode/skill/
If you're passing a specific directory to the server, seed skills there:
/sandbox/project/
└── .opencode/
└── skill/
└── deploy/
└── SKILL.md
####Option 4: Use ~/.claude/skills/ for Claude-compatible skills
OpenCode also scans Claude Code's skill directories (unless OPENCODE_DISABLE_CLAUDE_CODE_SKILLS is set):
~/.claude/skills/
└── my-skill/
└── SKILL.md
###Architecture for a Hosted OpenCode Service
┌─────────────────────────────────────────────────────────┐
│ Your Application │
└─────────────────────────┬───────────────────────────────┘
│ SDK/HTTP
▼
┌─────────────────────────────────────────────────────────┐
│ Sandbox (Docker/VM/Firecracker) │
│ ┌───────────────────────────────────────────────────┐ │
│ │ ~/.config/opencode/skill/ ← Pre-seeded skills │ │
│ │ /workspace/.opencode/skill/ ← Project skills │ │
│ │ /workspace/ ← User's project │ │
│ └───────────────────────────────────────────────────┘ │
│ │
│ $ OPENCODE_CONFIG_DIR=/custom/skills opencode serve │
└─────────────────────────────────────────────────────────┘
###Key Takeaways
-
Yes, run in a sandbox — This is the secure way to expose OpenCode, since it executes shell commands, edits files, etc.
-
Seed skills by pre-populating directories — Before starting the server, copy your SKILL.md files into:
~/.config/opencode/skill/(global)<project>/.opencode/skill/(project-specific)
-
Use
OPENCODE_CONFIG_DIR— This env var adds an additional directory to the config/skills search path, perfect for mounting a read-only skills volume. -
Per-request project switching — Use
x-opencode-directoryheader or?directory=query param to switch between projects on the same server.
END OF POST