The open-source AI coding agent with self-evolving capabilities.
OpenCode is an AI coding agent designed to remember, learn, and improve over time. Unlike traditional AI assistants that start fresh each session, OpenCode builds persistent memory across sessions, enabling true long-term consistency and continuous self-improvement.
| Feature | Traditional AI Assistants | OpenCode |
|---|---|---|
| Session Memory | Lost after conversation | Permanent, searchable |
| Pattern Learning | None | Auto-detects reusable patterns |
| Skill Development | Manual setup only | Auto-generates skills |
| Failure Learning | Repeats mistakes | Negative memory prevents repetition |
| Project Understanding | Starts fresh each time | Hierarchical code memory |
| Self-Improvement | None | Continuous evolution |
A three-layer evolution system that continuously improves:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Self-Evolving Agent β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Layer 1: Prompt Self-Optimization β
β β’ Analyzes session interactions β
β β’ Generates prompt improvements β
β β’ Stores optimized prompts for future use β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Layer 2: Skill Dynamic Generation β
β β’ Detects reusable task patterns β
β β’ Auto-generates SKILL.md files β
β β’ Requires approval before activation β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Layer 3: Memory Enhancement β
β β’ Extracts learnings from sessions β
β β’ Cross-session pattern recognition β
β β’ Relevance-based memory retrieval β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Session Memory: Ephemeral context for current session
- Evolution Memory: Long-term skills, constraints, learned patterns
- Project Memory: Knowledge graph with code entities and relationships
Prevents repeated failures by tracking what didn't work:
negativeMemory.recordFailure({
failure_type: "install_failed",
description: "npm install timeout",
context: { url: "..." },
severity: 3,
})- Web search, arXiv papers, GitHub integration
- Auto-scoring and tag extraction
- High-value items become skills automatically
- SKILL.md format with metadata
- Auto-discovery across multiple directories
- Approval workflow for new skills
- build: Full-access agent for code execution
- plan: Read-only agent for review
- explore: Fast agent for codebase exploration
- custom: User-defined agents with permissions
- QQ Bot (Tencent messaging)
- Slack integration
- iMessage support (macOS)
- Plugin SDK for custom platforms
- TUI: Rich terminal interface
- Desktop: Native app (Tauri)
- Web: Browser-based access
- Console: Server management
20+ AI providers including:
- Anthropic (Claude)
- OpenAI (GPT-4/4o)
- Google (Gemini)
- Azure OpenAI
- Amazon Bedrock
- And more...
# Quick install
curl -fsSL https://opencode.ai/install | bash
# Package managers
npm i -g opencode-ai@latest # npm
bun add -g opencode-ai@latest # bun
pnpm add -g opencode-ai@latest # pnpm
brew install anomalyco/tap/opencode # macOS/Linux
scoop install opencode # Windows# Run with a prompt
opencode "Create a REST API for user management"
# Continue a conversation
opencode -c
# Start ACP server (Agent Client Protocol)
opencode acp
# List MCP servers
opencode mcp list
# Evolution commands
opencode evolve list # List skills
opencode evolve status # Show system status
opencode evolve approve <id> # Approve skill proposalpackages/
βββ opencode/ # Core CLI application
βββ app/ # Main SolidJS web application
βββ desktop/ # Tauri desktop application
βββ console/ # Console web application
βββ enterprise/ # Enterprise features
βββ ui/ # Shared UI components
βββ plugin/ # Plugin SDK
βββ plugin-qqbot/ # QQ Bot plugin
βββ slack/ # Slack integration
βββ sdk/ # JavaScript/TypeScript SDK
βββ function/ # Cloud functions
βββ util/ # Utilities
βββ identity/ # Logos and assets
βββ web/ # Documentation site
βββ containers/ # Docker configurations
Session Complete
β
βΌ
βββββββββββββββ
β Integration β βββ Extracts tool calls & success status
βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Evolution Layers β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Prompt β Analyzes β Generates suggestions β Saves β
β Skill β Detects patterns β Creates drafts β Approves β
β Memory β Extracts learnings β Stores β Retrieves β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
Vector Store (sqlite-vec)
β
βΌ
Semantic Search for Future Sessions
- Sessions: Messages, parts (text, tool calls, reasoning)
- Knowledge Graph: Nodes + Edges (relationships)
- Vector Memory: content, code, constraint, character, scene
- Negative Memory: failure_type, severity, blocked_items
- Evolution Store: prompts.json, skills.json, memories.json
Create opencode.jsonc in your project:
# Install dependencies
bun install
# Build all packages
bun turbo build
# Run tests
bun test # From package directory
bun test src/foo.test.ts # Single file
# Type checking
bun typecheck # Root or per package
# Development
bun run dev # CLI
bun run dev:desktop # Desktop app
bun run dev:web # Web appOpenCode includes an X-Ray Mode observability system for debugging:
cd deploy/observability
docker-compose up -d- Jaeger UI: http://localhost:16686
- Grafana: http://localhost:3000
Features:
- Distributed tracing with OpenTelemetry
- Data lineage tracking (trace memory origins)
- Smart span truncation (prevent bloat)
- Background task context propagation
OpenCode focuses on long-term consistency and self-improvement:
- Persistent Memory: Remembers context across all sessions
- Self-Evolution: Improves prompts, skills, and memories over time
- Negative Memory: Learns from failures to avoid repeated mistakes
- Codebase Index: Understands project structure semantically
- Plugin Ecosystem: Extensible to any platform
20+ providers including Anthropic, OpenAI, Google, Azure, Bedrock, and more via the SDK.
MIT License - see LICENSE for details.
Built with β€οΈ by the OpenCode community
{ "model": "claude-sonnet-4-20250514", "agent": "build", "mcp": { "server-name": { "type": "remote", "url": "https://example.com/mcp" } }, "evolution": { "enabled": true, "directions": ["code quality", "performance optimization"], "sources": ["web", "github"] } }