Skip to content

AGENTS.md & Context ​

/init analyzes your project and creates an AGENTS.md file. This file gives OpenCode persistent context about your codebase: architecture, conventions, and dependencies. Every session loads this context automatically.

What you'll learn

  • /init scans the project and generates an AGENTS.md context file
  • AGENTS.md persists across sessions and is loaded automatically
  • Packed with LSP diagnostics for deep codebase understanding

Build it ​

Initialize OpenCode in your project to establish the necessary context. This process scans your codebase and produces an AGENTS.md file that models your architecture and conventions.

bash
cd /path/to/project
opencode
/init
# AGENTS.md is created in the project root

What goes wrong ​

MistakeHow you notice itThe fix
AGENTS.md outdatedAgent uses old patterns after refactorRun /init after major architecture changes
AGENTS.md too largeContext window overflowEdit AGENTS.md to keep only essential information

Next: Desktop & IDE