LearnCen Docs
Guides 2 min read

5. Context Engineering

5.1 What is context engineering?

Prompt engineering focuses on the instruction.

Context engineering focuses on the broader information and capabilities available to an AI system.

Prompt
+
Project instructions
+
Relevant files
+
Skills
+
Tools
+
Retrieved information
+
Previous decisions

5.2 Why it matters

Suppose an agent is asked to modify an API.

Useful context:

API implementation
API tests
Database model
Authentication rules
Project instructions

Potentially unnecessary context:

Old build logs
Unrelated frontend components
Generated files
Large dependency directories

5.3 Persistent context

Project instructions can encode stable rules:

AGENTS.md

Examples:

  • How to run tests
  • Architecture rules
  • Coding conventions
  • Security requirements
  • Git rules

5.4 On-demand context

Skills are useful when knowledge is specialized.

General project rules
       +
Relevant skill
       +
Relevant files

This is preferable to putting every procedure into one giant instruction file.


5.5 Context hierarchy

A practical hierarchy:

Global guidance
      |
      v
Project guidance
      |
      v
Directory-specific guidance
      |
      v
Relevant skill
      |
      v
Task-specific context

OpenCode supports AGENTS.md discovery at global and project/directory scopes. See the official instructions documentation for the exact discovery behavior.


Exercise

Design the context for an API testing task.

List:

  1. Persistent rules
  2. Relevant files
  3. Relevant skill
  4. Required tools
  5. Information that should not be included