# ADR-0005: Project Context — Auto-Load Documentation

**Status:** Accepted
**Date:** 2026-05-13
**Extension:** `extensions/project-context/index.ts` (205 lines)

## Problem

Agent enters a project with zero knowledge of conventions, architecture, or file patterns. Either guesses wrong, asks excessive questions, or wastes tokens rediscovering what's documented.

## Decision

On `before_agent_start` and directory change:

1. Walk from `cwd` to git root (`getGitRoot`)
2. Match known context file names: `AGENTS.md`, `CONTEXT.md`, `.cursorrules`, `.opencode`
3. Inline content verbatim into agent context

## Alternatives

| Approach          | Why Rejected                       |
| ----------------- | ---------------------------------- |
| Manual loading    | Error-prone, slow startup          |
| Index everything  | Wastes tokens on irrelevant files  |
| RAG/vector search | Overhead, requires embedding model |

## Trade-offs

Fixed file name list misses non-standard doc names. Extensible but adds maintenance. Acceptable — convention files are stable.

## References

- [pi-coding-agent ExtensionAPI](https://github.com/badlogic/pi-mono) — `before_agent_start` lifecycle hook
- arXiv 2604.18071: "deeper coordination pairs with more explicit context services"
