Context Management
Understanding how Opencode manages context is key to getting the best results.
The Context Window
Every LLM has a limit on how much text it can process at once (the context window). Opencode uses smart algorithms to maximize this space.
File Selection
Opencode does not send your entire codebase to the model. Instead, it selects relevant files based on:
- Active Files: Files you have open or explicitly reference.
- Semantic Search: (Optional) Embeddings search for relevant snippets.
- Import Graph: Files related to the ones you are editing.
Token Optimization
To save tokens, Opencode may:
- Strip comments from non-critical files.
- Outline classes instead of including full implementations.
- Ignore large generated files (like
package-lock.json).