# pi-subagent

A [pi](https://github.com/mariozechner/pi) extension for delegating tasks to subagents. Each subagent runs as an in-process SDK session with its own isolated context window — ideal for parallel work, specialist prompts, or keeping noisy subtasks out of your main session.

## Install

```bash
pi install npm:@chaotic1988/pi-subagent
```

## Quick Start

**1. Define an agent** (e.g. `~/.pi/agent/agents/reviewer.md`):

```yaml
---
name: reviewer
description: Reviews code for quality and correctness
---

You are a thorough code reviewer. Focus on correctness, clarity, and edge cases.
Respond with a brief summary followed by a bullet list of specific issues.
```

**2. Use it in a task**

Single agent:
```json
{
  "agent": "reviewer",
  "task": "Review src/auth.ts for security issues"
}
```

Parallel agents:
```json
{
  "tasks": [
    { "agent": "reviewer", "task": "Review src/auth.ts" },
    { "agent": "reviewer", "task": "Review src/api.ts" },
    { "agent": "reviewer", "task": "Review src/utils.ts" }
  ]
}
```

For full documentation — agent configuration, discovery rules, frontmatter reference, and more — see the [User Guide](docs/user-guide.md).
