Home

Learn OpenCode

Understand AI coding agent design from scratch, one mechanism at a time

The Core Pattern

Every AI coding agent shares the same loop: call the model, execute tools, feed results back. Production systems add policy, permissions, and lifecycle layers on top.

Agent Loop Diagram

System Architecture

Five layers compose into a complete AI coding agent. Each layer builds on the one below it.

OpenCode System Architecture

Architectural Layers

Five orthogonal concerns that compose into a complete agent

Comparison: Claude Code

Both agents share the same core loop architecture, differing in policy layers

MechanismClaude CodeOpenCode
Core Loopwhile(model responds)while(tool_use) via Effect/Stream
Tool DispatchFunction calling APITOOL_MAP registry + Schema
Permission ModelUser confirmation promptWildcard patterns · allow/deny/ask · Deferred
ExtensibilityCLI flags + env varsPlugin SDK · Hooks API · Skill system
Subagents@mentionsNamed agents · clean context · task_id resume
Skill SystemCustom instructionsSKILL.md · priority chain · YAML frontmatter
ConfigCLAUDE.md + envopencode.jsonc · deepMerge · JSON Schema

Reference: learn.shareai.run — Claude Code learning site

Learning Path

10 progressive sessions, from a simple loop to a complete agent system