# Deep Agents CLI Skills

A curated pack of skills designed to empower your agent's **long-term memory** and **autonomy**. These skills act as middleware, letting your main session's agent decide when to delegate sub-tasks or manage its own context.

---

## Core Skill: `autosubagents` (Sub-Agent Orchestrator)

Delegate complex, one-off tasks to a persistent sub-agent (often called the "Admin" or "Runner" session).

**Trigger:** User sends a direct message or spawns a session.
**Outcome:** Agent creates an isolated sub-agent session (`runtime="subagent"`) and sends it the task.

### When to Use
- When the current session gets too chatty and you need to "offload" work.
- For tasks that need multiple tools or a dedicated context window.

**Example Flow:**
1. User sends: "Let's do that."
2. Agent triggers: `deepagents autosubagent "That's the task."`
3. Agent listens: Spawns sub-agent, waits for response.
4. User gets: The sub-agent's finished summary.

### Skills Packaged
- **`context-compress`** (Autonomous Context Compression): Automatically summarize past messages when the session gets heavy.
- **`session-history`** (Text-Based Fetch): Quickly grab the last N messages from another session.

### How It Works
```bash
deepagents autosubagent --task "Summarize the last 5 chats"
```

---

## Core Skill: `compact` (Context Compactor)

A standalone tool that takes a "summary" session and injects its condensed message back into the parent session, effectively **compressing** the parent's history.

**Trigger:** The parent session has received 3+ sub-agent responses.
**Action:** Fetches the sub-agent's history, pulls out the "summary" payload, and pings it back.

### How It Works
1. **Parent** sends a task to **Sub-Agent**.
2. **Sub-Agent** runs and uses `context-compress` to condense the chat.
3. **Parent** receives the summary via a new message.

### CLI Usage
```bash
deepagents compact --parent "main-session" --target "sub-session-name"
```

---

## Setup Instructions

### 1. Install the CLI
```bash
npm install -g deepagents
```

### 2. Configure in OpenClaw
Point your OpenClaw `runtime` to a path where the CLI lives:
```yaml
# ~/.openclaw/env.d/
deepagents:
  runtime: acp
  cwd: /path/to/deepagents-bin
```

### 3. Link the Skills Folder
```bash
ln -s ~/.openclaw/workspace/skills/deepagents ~/.deepagents/deep-organizer
```

---

## Usage Patterns

### Pattern A: "Set and Forget" (Best for one-off tasks)
```bash
deepagents autosubagent --task "Research this topic"
```
*The Agent will spawn a sub-agent, let it run its course, and return the results.*

### Pattern B: "The Deep Work Loop"
1. **Setup Phase:** Have the sub-agent pre-loaded with its own skills (`context-compress` + `session-history`).
2. **Task Phase:** Spawn a new `autosubagent` instance for the day's main task.
3. **Compression Phase:** Let the sub-agent do its thing. If the conversation gets long, have the sub-agent call `context-compress` automatically.

---

*Version: 1.0 — *Refined for OpenClaw's sub-agent ecosystem*.*