Major Changes: - Simplified OpenAgent execution philosophy (universal agent, delegate sparingly) - Reorganized context into 3-tier structure: standards/, workflows/, system/ - Improved approval gate wording for clarity - Enhanced .gitignore with comprehensive Node.js patterns - Added comprehensive plugin development guide Context Reorganization: - Consolidated scattered files into organized structure with Quick Reference sections - Emphasis on lazy loading for token efficiency (60-80% token savings) - New standards: code.md, docs.md, tests.md, patterns.md, analysis.md - New workflows: delegation.md, sessions.md, task-breakdown.md, review.md - New system: context-guide.md (master reference) Delegation Improvements: - Removed complex XML-style routing rules - Simplified to clear when/how structure with 7 delegation criteria - Added Perspective and Simulation as delegation triggers - Clearer delegation template and process Documentation Enhancements: - Added building-plugins.md (1,274 lines - comprehensive plugin guide) - Updated how-context-works.md with research-backed architecture - Enhanced slash-commands-and-subagents.md with path resolution findings Content Preservation: - context-discovery.md → system/context-guide.md + workflows/sessions.md - context-management.md → workflows/sessions.md - essential-patterns.md → standards/patterns.md - session-management.md → workflows/sessions.md
4.3 KiB
Context System Guide
Quick Reference
Golden Rule: Fetch context when needed, not before (lazy loading)
Key Principle: Reference files WITHOUT @ symbol - agent fetches only when needed
Structure: standards/ (quality + analysis), workflows/ (process + review), system/ (internals)
Session Location: .tmp/sessions/{timestamp}-{task-slug}/context.md
Overview
Context files provide guidelines and templates for specific tasks. Use lazy loading (fetch when needed) to keep prompts lean.
Available Context Files
All files are in .opencode/context/core/ with organized subfolders:
Standards (Quality Guidelines + Analysis)
.opencode/context/core/standards/code.md- Modular, functional code principles.opencode/context/core/standards/docs.md- Documentation standards.opencode/context/core/standards/tests.md- Testing standards.opencode/context/core/standards/patterns.md- Core patterns (error handling, security).opencode/context/core/standards/analysis.md- Analysis framework
Workflows (Process Templates + Review)
.opencode/context/core/workflows/delegation.md- Delegation template.opencode/context/core/workflows/task-breakdown.md- Complex task breakdown.opencode/context/core/workflows/sessions.md- Session lifecycle.opencode/context/core/workflows/review.md- Code review guidelines
Lazy Loading (Recommended)
Reference files WITHOUT @ symbol - agent fetches only when needed:
"Write code following .opencode/context/core/standards/code.md"
"Review using .opencode/context/core/workflows/review.md"
"Break down task using .opencode/context/core/workflows/task-breakdown.md"
Benefits:
- No prompt bloat
- Fetch only what's relevant
- Faster for simple tasks
- Agent decides when to load
When to Use Each File
.opencode/context/core/standards/code.md
- Writing new code
- Modifying existing code
- Following modular/functional patterns
- Making architectural decisions
.opencode/context/core/standards/docs.md
- Writing README files
- Creating API documentation
- Adding code comments
.opencode/context/core/standards/tests.md
- Writing new tests
- Running test suites
- Debugging test failures
.opencode/context/core/standards/patterns.md
- Error handling
- Security patterns
- Common code patterns
.opencode/context/core/standards/analysis.md
- Analyzing codebase patterns
- Investigating bugs
- Evaluating architecture
.opencode/context/core/workflows/delegation.md
- Delegating to general agent
- Creating task context
- Multi-file coordination
.opencode/context/core/workflows/task-breakdown.md
- Tasks with 4+ files
- Estimated effort >60 minutes
- Complex dependencies
.opencode/context/core/workflows/sessions.md
- Session lifecycle
- Cleanup procedures
- Session isolation
.opencode/context/core/workflows/review.md
- Reviewing code
- Conducting code audits
- Providing PR feedback
Temporary Context (Session-Specific)
When delegating, create focused task context:
Location: .tmp/sessions/{timestamp}-{task-slug}/context.md
Structure:
# Task Context: {Task Name}
Session ID: {id}
Created: {timestamp}
Status: in_progress
## Current Request
{What user asked for}
## Requirements
- {requirement 1}
- {requirement 2}
## Decisions Made
- {decision 1}
## Files to Modify/Create
- {file 1} - {purpose}
## Static Context Available
- .opencode/context/core/standards/code.md
- .opencode/context/core/standards/tests.md
## Constraints/Notes
{Important context}
## Progress
- [ ] {task 1}
- [ ] {task 2}
---
**Instructions for Subagent:**
{Specific instructions}
Session Management
Session Structure
.tmp/sessions/{session-id}/
├── context.md # Task context
├── notes.md # Working notes
└── artifacts/ # Generated files
Session ID Format
{timestamp}-{random-4-chars}
Example: 20250119-143022-a4f2
Cleanup
- Ask user before deleting session files
- Remove after task completion
- Keep if user wants to review
Best Practices
✅ Use lazy loading (no @ symbol) ✅ Fetch only relevant context ✅ Create temp context when delegating ✅ Clean up sessions after completion ✅ Reference specific sections when possible ✅ Keep temp context focused and concise
Golden Rule: Fetch context when needed, not before.