Golden Rule: Fetch context when needed, not before (lazy loading)
Key Principle: Use context index for discovery, load specific files as needed
Index Location: .opencode/context/index.md - Quick map of all contexts
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 the index system for efficient discovery and lazy loading to keep prompts lean.
Central Index: .opencode/context/index.md - Ultra-compact map of all contexts
The index provides:
All files are in .opencode/context/core/ with organized subfolders:
standards/code-quality.md - Modular, functional code principles [critical]standards/documentation.md - Documentation standards [critical]standards/test-coverage.md - Testing standards [critical]standards/security-patterns.md - Core patterns (error handling, security) [high]standards/code-analysis.md - Analysis framework [high]workflows/task-delegation.md - Delegation template [high]workflows/feature-breakdown.md - Complex task breakdown [high]workflows/session-management.md - Session lifecycle [medium]workflows/code-review.md - Code review guidelines [high]Step 1: Check Quick Map (for common tasks)
standards/code-quality.mdstandards/documentation.mdworkflows/code-review.mdStep 2: Load Index (for keyword matching)
.opencode/context/index.mdStep 3: Load Dependencies
deps: in indexBenefits:
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-quality.md
- .opencode/context/core/standards/test-coverage.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 index for context discovery ✅ Load only relevant context files ✅ Check dependencies in index ✅ 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.