> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ref.tools/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code /plan Hook

> Automatically create a Ref Plan when you exit plan mode in Claude Code.

The Claude Code `/plan` hook automatically creates a Ref Plan when you exit plan mode in Claude Code. Your plan opens in the browser, ready to share, refine, and send to agents.

## Install

Run the install script:

```
curl -fsSL https://api.plan.ref.tools/plugins/install/ref-plan-hook | bash
```

## Configuration

The hook authenticates with your Ref API key. You can configure it in two ways:

**Environment variable:**

```
export REF_API_KEY=your-api-key
```

**Config file** (`~/.ref/config.json`):

```json theme={null}
{
  "apiKey": "your-api-key"
}
```

You can find your API key at [ref.tools/keys](https://ref.tools/keys).

## How it works

1. You enter `/plan` mode in Claude Code as usual
2. When you exit plan mode, the hook fires
3. A new Ref Plan is created with your plan content
4. The plan opens in your default browser

**Note:** If you are at the limit number of plans for your tier, the hook will fail silently.

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/JtC-hWGnHEI" title="Demo of Claude Code /plan hook" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
