Agent Guide

How to implement OpenContext in your AI agents.

System Prompt Instructions

Add these instructions to your agent's system prompt to enable OpenContext usage:

system prompt
Always use read_context before making code changes.
First list available topics, then read any topic
relevant to the task.

Use save_context whenever you learn a durable
project rule, architectural decision, convention,
API contract, or debugging note that future agents
should know.

Prefer small, focused context topics in snake_case
or kebab-case. Keep the content concise, factual,
and written in markdown.

Recommended Workflow

1

Analyze & Save Context

Ask an architect agent to analyze the project and save durable decisions with save_context.

2

Read Before Coding

Ask build agents to call read_context before making changes.

3

Update When Learning

Let agents update context when they discover something that should survive the current chat.

4

Review Like Docs

Review .opencontext/ files like normal project documentation.

Common Patterns

Architecture Decisions

Topic: architecture
Content: "We use Next.js App Router with server components
by default. Client components only when interactions
require useState/useEffect."

API Contracts

Topic: api-contracts
Content: "All API routes return { data, error } format.
Use 400 for validation, 401 for auth, 500 for server
errors. Pagination uses cursor-based approach."

Coding Rules

Topic: coding_rules
Content: "- Use const over let when possible
- Prefer early returns over nested ifs
- Name booleans with is/has/can prefix
- Keep functions under 30 lines"

Pre-built Agents

We provide ready-to-use agent prompts for common workflows: