Start free
Guide Teach your agent your knowledge

How to teach opencode your knowledge

Updated 2 min read

The short answer

Create an AGENTS.md file for project instructions, or use ~/.config/opencode/AGENTS.md for personal rules across sessions (OpenCode rules). KnowMan's MCP server can search saved items and save URLs, but its documented setup covers Claude Desktop, Claude Code, and Cursor, not OpenCode (KnowMan MCP guide).

On this page6 sections
  1. Add project instructions with AGENTS.md
  2. Keep personal rules separate
  3. Load reusable reference files
  4. Use AGENTS.md for task-based references
  5. Where KnowMan fits
  6. Questions people ask

Add project instructions with AGENTS.md

Create AGENTS.md in your project root to give OpenCode instructions for that project and its subdirectories. These instructions enter the model context and customize its behavior (OpenCode rules).

You can create the file yourself or run /init. OpenCode says /init scans important repository files, may ask targeted questions, and creates or updates concise project guidance. If the file already exists, it improves it in place. OpenCode recommends committing a project AGENTS.md to Git (OpenCode rules).

Keep personal rules separate

For rules that should apply across your OpenCode sessions and stay personal, use ~/.config/opencode/AGENTS.md. OpenCode recommends this location because it is not committed to Git or shared with the team (OpenCode rules).

OpenCode searches local rule files upward from the current directory, then checks its global file and Claude Code files in the documented order. Within each category, the first matching file wins. If both AGENTS.md and CLAUDE.md are present, AGENTS.md takes precedence (OpenCode rules).

Load reusable reference files

OpenCode does not automatically parse file references inside AGENTS.md. The recommended way to load external reference files is the instructions field in opencode.json or the global ~/.config/opencode/opencode.json (OpenCode rules).

That field can list local files and glob patterns, such as docs/development-standards.md or packages/*/AGENTS.md. OpenCode combines configured instruction files with AGENTS.md files. It can also load instructions from remote URLs, with a five-second fetch timeout (OpenCode rules).

Use AGENTS.md for task-based references

Alternatively, write explicit instructions in AGENTS.md telling OpenCode to read referenced files with its Read tool. OpenCode documents a lazy approach: load references when relevant to the task, treat loaded content as mandatory instructions, and follow references recursively when needed (OpenCode rules).

This keeps the main instruction file concise while detailed rules load only when needed. For monorepos or shared standards, OpenCode says opencode.json glob patterns can be more maintainable (OpenCode rules).

Where KnowMan fits

KnowMan saves articles and links, reads and tags them, answers questions with citations, and keeps memories such as claims, decisions, and playbooks. Its MCP server is a local stdio server, and the documented client configurations cover Claude Desktop, Claude Code, and Cursor. OpenCode setup and the behavior of its kb_search, kb_get_item, kb_ask, and kb_save tools are not documented.

See the KnowMan MCP server guide for its documented setup, or learn how to give your AI context.

Questions people ask

How do I create project instructions for OpenCode?

Create an AGENTS.md file in the project root, or run /init to create or update one. The file gives OpenCode project-specific instructions (OpenCode rules).

Where should I put personal OpenCode rules?

Use ~/.config/opencode/AGENTS.md for personal rules across OpenCode sessions. OpenCode recommends it because the file is not committed to Git or shared with the team (OpenCode rules).

How can OpenCode load detailed reference files?

List files or glob patterns in the instructions field of opencode.json, or add explicit instructions in AGENTS.md to read references when needed. OpenCode combines configured instruction files with AGENTS.md files (OpenCode rules).

Can I connect KnowMan to OpenCode?

KnowMan's MCP server is local stdio, but its documented client configurations do not include OpenCode. OpenCode connection steps and tool behavior are not documented.

Keep your knowledge close

Try KnowMan Pro for 14 days with no credit card. Create your account

Start free

Every new account starts with 14 days of Pro. No credit card.