{"slug": "how-i-set-up-opencode-a-real-agent-os-config-skills-mcps-memory", "title": "How I Set Up OpenCode: A Real Agent OS (Config, Skills, MCPs, Memory)", "summary": "A developer published a detailed account of configuring OpenCode into what they call an \"agent OS,\" built from a single config file, 40+ subagents, 123 skills, 20 slash commands, and 8 MCP servers. The setup adds a two-layer plain-file memory pipeline (global and project-scoped) that persists state across context compaction, plus a learning file tracking patterns with evidence and confidence scores. All components are stored as plain files rather than a database or proprietary format, so the conventions work with any tool that can read a file.", "body_md": "You have inherited a repository.\n\n**At a glance:** `1` config file · `40+` subagents · `123` skills · `20` commands · `8` MCP servers · `2` memory layers.\n\nOpenCode becomes a real agent OS once you wire config, subagents, skills, MCP servers, commands, and a plain-file memory pipeline together. This post is my actual setup, so you can copy the shape rather than guess it. Everything is a plain file: no database, no proprietary format, no vendor lock-in.\n\nThe interesting part isn't the component count. It's the decisions behind them: what should be reusable, what should be persistent, where responsibilities should live, how much autonomy to allow, and how to keep the whole thing understandable as it grows.\n\nOut of the box, an AI coding tool is a chat window. It forgets your conventions between sessions, has no idea which model is cheap enough for bulk work, and re-learns your repo every morning. I wanted an agent OS: config that loads my rules into every tool, a roster of cheap and quality subagents, installed skills with real workflows, MCP servers for docs/search/filesystem, and a memory pipeline that survives compaction.\n\nTwo constraints shaped everything:\n\nA fully configured OpenCode environment. It includes one config file (model, instructions, plugins, MCP servers, formatter, LSP, permissions), 40+ subagents, 123 skills under the agents skills directory, and 20 commands. There is also a two-layer plain-file memory pipeline (global + project) with compaction duty, plus a separate learning file that tracks patterns with evidence and confidence scores.\n\nStack: OpenCode, superpowers plugin, a learning-memory plugin, MCP (web research, data extraction, neural search, docs lookup, filesystem, fetch, memory, sequential thinking), and a CLI config for the terminal interface.\n\n``` php\nflowchart TB\n  OC[\"OpenCode\"] --> CFG[\"config file\"]\n  CFG --> INS[\"instructions:<br/>rules + agents protocol + personality + learning file\"]\n  CFG --> PLG[\"plugins: superpowers + learning-memory\"]\n  CFG --> MCP[\"mcp.servers (8)\"]\n  CFG --> EXP[\"experimental:<br/>todo + background_compaction\"]\n  CFG --> PERM[\"permissions:<br/>path- and command-scoped allow/ask\"]\n  CFG --> COMP[\"compaction:<br/>auto, keep 20k tokens, 20% buffer\"]\n\n  INS --> AG[\"agents (40+)<br/>config + agent files\"]\n  INS --> SK[\"skills (123)<br/>agents/skills\"]\n  INS --> CM[\"commands (20)\"]\n  INS --> MEM[\"memory pipeline\"]\n\n  MEM --> G[\"global: agents/memory<br/>state · topics · sessions · compactions.log\"]\n  MEM --> P[\"project: repo/.memory<br/>index · state · topics\"]\n  MEM --> L[\"learning file:<br/>patterns · AARs · evidence · confidence\"]\n```\n\nNotice what is *not* in the config: agent definitions, skills, and memory. Those are file-system conventions, which is why they work with any tool that can read a file.\n\n```\nconfig/opencode/\n├── config file               # the only config file\n├── cli config                # terminal interface settings\n├── service config\n├── agents/                   # 12 subagent definitions (.md)\n│   ├── cheap-* (8)           # bulk, code, fast, general, nano, quality, reason, vision\n│   └── code-reviewer, planner, security-reviewer, tdd-guide\n├── commands/                 # 20 slash commands\n└── package.json              # plugin deps\n\nagents/\n├── AGENTS.md                 # universal operating protocol\n├── rules/CORE.md             # always-on rules\n├── skills/                   # 123 skills\n├── agents/  commands/  workflows/  templates/\n├── memory/\n│   ├── state.md\n│   ├── topics/  decisions/  learning/  sessions/YYYY/MM/DD.md\n│   └── compactions.log\n├── .memory/                  # project-scoped memory\n│   └── state.md\n└── kanban/BOARD.md\n```\n\n([https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/59ktn3czvkcgfbwck3vz.png](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/59ktn3czvkcgfbwck3vz.png))\n\nCompaction is the event that breaks naive agent setups: the context window fills, the harness summarises, and the agent forgets the decision it made an hour ago. The fix is a deterministic file protocol, not a bigger context window.\n\n```\nsequenceDiagram\n  participant H as Harness\n  participant M as compaction marker\n  participant A as Agent\n  participant S as .memory/state.md\n  participant T as .memory/topics/\n  participant L as learning file\n\n  H->>M: PreCompact hook appends compactions.log + drops compaction-pending.md\n  H->>A: context compacted, new turn\n  A->>M: marker exists?\n  A->>S: rewrite goal / last actions / next step\n  A->>T: append durable decisions\n  A->>L: append observation or pattern\n  A->>M: DELETE marker\n```\n\nThe `DELETE marker` step is what makes it idempotent. If the turn crashes halfway, the marker survives and the work is retried; if it completes, the marker is gone and the next turn does not redo it.\n\nTwo layers, because they answer different questions:\n\nAnd one promotion rule: a pattern observed in **2+ projects** gets promoted from observations to global. That is the difference between a journal and a learning system.\n\nI chose Markdown, JSONL, and JSON over a database for four reasons:\n\n**Trade-offs I accept:**\n\n**Alternatives I considered and rejected:**\n\nAt what point does filesystem memory stop being sufficient? I don't know yet. If retrieval latency becomes a problem, the first thing I'd try is a local SQLite index over the Markdown files, not a migration away from plain text.\n\nForty-plus agents, split by cost and purpose:\n\n| Tier | Agents | Use | \n|---|---|---|\n| Cheap (8) | `cheap-bulk` ,`cheap-code` ,`cheap-fast` ,`cheap-general` ,`cheap-nano` ,`cheap-quality` ,`cheap-reason` ,`cheap-vision` | bulk transforms, lookups, small edits, screenshot review | \n| Review (12+) | `code-reviewer` ,`python-reviewer` ,`typescript-reviewer` ,`go-reviewer` ,`rust-reviewer` ,`cpp-reviewer` ,`java-reviewer` ,`kotlin-reviewer` ,`flutter-reviewer` ,`security-reviewer` ,`database-reviewer` | language-specific and security review | \n| Build resolvers (7) | `build-error-resolver` ,`cpp-build-resolver` ,`go-build-resolver` ,`java-build-resolver` ,`kotlin-build-resolver` ,`rust-build-resolver` ,`pytorch-build-resolver` | diagnose and fix build errors | \n| Quality (4+) | `planner` ,`architect` ,`tdd-guide` ,`refactor-cleaner` ,`doc-updater` ,`docs-lookup` ,`e2e-runner` ,`harness-optimizer` ,`loop-operator` ,`chief-of-staff` | planning, architecture, testing, docs, orchestration | \n| Autonomous (1) | `autonomous` | full-autonomy mode: reads, writes, runs commands without prompts. Destructive actions still gated by core rules. | \n\nThe routing rule is simple: **route by cost, escalate by risk.** A 200-file summarisation runs on `cheap-bulk`; an auth change goes to `security-reviewer` before merge.\n\nHow many agents are useful before orchestration becomes overhead? I don't have a clean answer. The 40+ count includes many language-specific reviewers that I added because a generic reviewer kept missing language-specific issues. If I were starting over, I'd begin with 4 and add only when a real gap appears.\n\nA skill is a directory under the skills folder with a `SKILL.md` containing `name` and `description`. The description is not documentation — it is the trigger. The agent matches the task against it, so a vague description means the skill never fires.\n\nThat wording is deliberate: it names the *situation* (\"encountering a bug\"), not the capability (\"debugging help\"). Situation-shaped descriptions fire reliably; capability-shaped ones get ignored.\n\nWhat belongs in a skill versus an agent instruction? My current split: skills are reusable workflows that apply across projects (debugging, planning, TDD). Agent instructions are identity and scope (\"you are a security reviewer; do not edit files\"). If a skill grows to include identity, it probably should be an agent. If an agent accumulates workflow steps, those steps should be extracted into a skill.\n\nThe memory pipeline evolved. The original design used a separate observations-to-instincts pipeline. That was retired in favour of a single learning file that is the source of truth for preferences, patterns, and durable decisions.\n\nThe learning file carries:\n\nPatterns are treated as hypotheses, not rules. A pattern starts at low confidence and earns trust through application and verification. Promotion into a rule or skill requires 2+ confirmed applications plus explicit approval.\n\nThe capture is manual, at task boundaries — not automated. No hooks, no observers, no background writers. This was a deliberate decision: automated capture without verification produces noise, not learning.\n\nI evaluated Cursor, Copilot, Codex CLI, and Gemini CLI before settling on OpenCode. The deciding factors:\n\n**Trade-off:** OpenCode has a smaller community than Copilot or Cursor. Fewer tutorials, fewer pre-built integrations. I accept this because the file-based model gives me control that UI-based tools don't.\n\nThe learning system's CLI and test suite are written in Python. Alternatives I considered:\n\n`json` module and `pathlib` make this reliable.\nThe learning tooling has no runtime dependency on OpenCode itself. It operates on plain files. This means I can test it independently, version it separately, and replace the runtime without losing the learning data.\n\n`//` comments, which I use to document why each block exists. Plain JSON doesn't.`$schema` field gives me autocomplete and validation in my editor.\n**Alternative:** TOML or YAML. Both are more readable for deeply nested config, but OpenCode's schema is JSON-based and the ecosystem expects JSON. Using JSONC is the path of least resistance.\n\n`AGENTS.md` serves OpenCode, Copilot, Codex, Gemini CLI, Cline, Cursor, Windsurf.`ask` fallback means anything not explicitly allowed prompts for confirmation. I considered a pure deny-list (allow everything except dangerous commands), but an allow-list is safer and forces me to think about what the agent actually needs. The trade-off: I occasionally hit a permission prompt for a legitimate command, which is annoying but correct.`model`, `instructions`, `plugins`.` permissions` to least-privilege: path- and command-scoped allow/ask rules.`description`.`{env:…}`.\nRules: the core rules file, the universal protocol file\n\nRelated posts: [Wiring a Local LLM into PowerShell: Ollama, Model Tiers, and Guardrails](https://dev.to/shahriarhaqueabir/wiring-a-local-llm-into-powershell-ollama-model-tiers-and-guardrails-1nj5-temp-slug-9155722), [One Pane of Glass for Windows: Local AI, Zero Telemetry](https://dev.to/shahriarhaqueabir/one-pane-of-glass-for-windows-local-ai-zero-telemetry-402g-temp-slug-1295200)", "url": "https://wpnews.pro/news/how-i-set-up-opencode-a-real-agent-os-config-skills-mcps-memory", "canonical_source": "https://dev.to/shahriarhaqueabir/how-i-set-up-opencode-a-real-agent-os-config-skills-mcps-memory-2h60", "published_at": "2026-11-29 20:33:08+00:00", "updated_at": "2026-11-29 20:45:15.820369+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "agent-protocols", "developer-tools"], "entities": ["OpenCode", "MCP"], "also_reported_by": [], "takeaway": "Keeping agent definitions, skills and memory as plain-file conventions outside the config file lets a 40+ subagent, 123-skill OpenCode setup survive context compaction and stay portable across tools.", "recommendation": {"advice": "Store subagents, skills and memory as plain files outside your config, and add a global-plus-project memory pipeline with compaction duty so state survives context summarization.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/how-i-set-up-opencode-a-real-agent-os-config-skills-mcps-memory", "markdown": "https://wpnews.pro/news/how-i-set-up-opencode-a-real-agent-os-config-skills-mcps-memory.md", "text": "https://wpnews.pro/news/how-i-set-up-opencode-a-real-agent-os-config-skills-mcps-memory.txt", "jsonld": "https://wpnews.pro/news/how-i-set-up-opencode-a-real-agent-os-config-skills-mcps-memory.jsonld"}}