# pi-auto-context-files

A pi extension that automatically discovers and injects `AGENTS.md` and `CLAUDE.md` context files into read tool results.

## How it works

When the agent reads any file, this extension walks up the directory tree from that file's location looking for `AGENTS.md` or `CLAUDE.md` files, and prepends them to the read tool result. The model sees the local instructions before the file contents it requested.

Walking stops at the git repository root (or your working directory if not inside a git repo).

Context files are injected once per session — deduplicated to avoid cluttering the context window with the same instructions repeatedly.

## Installation

```bash
pi install npm:pi-auto-context-files
```

## Configuration

No configuration needed. The extension automatically activates when pi starts.

## Commands

- `/auto-context` — Show extension status (discovered, injected, and pending context files)

## Details

The extension searches for context files in this order (closest file wins):

1. `CLAUDE.md`
2. `AGENTS.md`

If multiple context files exist at different directory levels (e.g., one at the repo root and another in a subdirectory), all are collected with closer files taking precedence.

## Changelog

### 1.0.0

- Initial release
