Automatically load AGENTS.md context from subdirectories in pi coding agent
npm install pi-subdir-contextAutomatically load AGENTS.md context from subdirectories in pi coding agent.
When you read a file in a subdirectory (e.g., src/components/Button.tsx), this extension automatically discovers and injects any AGENTS.md files found in the path hierarchy (src/components/AGENTS.md, src/AGENTS.md), giving pi the relevant local context without manual loading.
``bash`
pi install npm:pi-subdir-context
Or try it temporarily:
`bash`
pi -e npm:pi-subdir-context
1. When you use the read tool, the extension checks the file's directory pathAGENTS.md
2. It walks up the tree looking for files
3. Found files are loaded in order (closest to root first)
4. Content is injected into the tool result as additional context
5. Already-loaded files are deduplicated per session
Project structure:
``
my-project/
├── AGENTS.md # project-wide rules
├── src/
│ ├── AGENTS.md # src-specific conventions
│ └── components/
│ ├── AGENTS.md # component-specific rules
│ └── Button.tsx
When you read src/components/Button.tsx, the extension automatically loads subdirectory context (the root AGENTS.md is already loaded by pi):src/AGENTS.md
1. (src-specific)src/components/AGENTS.md` (component-specific — closest to file)
2.
- Context loading stops at the project root (current working directory)
- Files outside the project or home directory are ignored
- Files are loaded once per session and deduplicated
MIT