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
Context files provide guidelines and templates for specific tasks. Use lazy loading (fetch when needed) to keep prompts lean.
All files are in .opencode/context/core/ with organized subfolders:
.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.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 guidelinesReference 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:
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}
.tmp/sessions/{session-id}/
├── context.md # Task context
├── notes.md # Working notes
└── artifacts/ # Generated files
{timestamp}-{random-4-chars}
Example: 20250119-143022-a4f2
✅ 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.