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

# The psychiatrist SDK

> Script coding agents from TypeScript with the bot’s own engine: sessions you send turns, steer, fork and resume, behind the guard.

Use the SDK to run AI coding agents from your own code: give one a task, watch what it does, step in while it works, and pick the conversation up later. Every agent stays behind the same safety check the bot uses.

The psychiatrist SDK is `@psychiatrist/core`, the engine the bot itself runs on ([ADR 0003](https://github.com/psychiatrist/psychiatrist/blob/main/docs/adr/0003-bot-built-on-its-own-library.md)): the bot starts every agent through the same `start()`. A session is one agent's conversation on a harness; you send it turns, steer it while a turn runs, interrupt, fork, close and resume it. Terms follow [GLOSSARY.md](https://github.com/psychiatrist/psychiatrist/blob/main/GLOSSARY.md).

```
npm install @psychiatrist/core ai ai-sdk-provider-claude-code @anthropic-ai/claude-agent-sdk zod
```

The SDK's packages are optional peers of `@psychiatrist/core`: install them beside it, as above (zod is also how you write a turn's report schema). It needs Node 22.13 or later and Claude Code, installed and signed in (`claude`): sessions run on your own install, and `start()` rejects, saying what to run, when it is missing or signed out; a failed check is tried again on the next `start()`. The package is ESM with type declarations.

```ts theme={null}
import { claudeCode, start } from "@psychiatrist/core";
import { z } from "zod";

const session = await start({ agent: claudeCode("claude-opus-5-5", { effort: "medium" }), branch: { name: "try/cache" } });
const plan = await session.send("Plan a cache for the config loader. Don't change files yet.", { effort: "high" });
const built = await session.send("Build it, test-first, and commit.", { output: z.object({ summary: z.string() }) });
if (built.output?.ok) console.log(built.output.report.summary, built.commits);
session.close();
```

## What's available and what's planned

These guides describe the SDK as it is designed, ahead of the code ([ADR 0010](https://github.com/psychiatrist/psychiatrist/blob/main/docs/adr/0010-the-sdk-guide-leads-the-code.md)). A page or section marked Planned · #n describes an API its ticket builds: the shape is settled, but it is not in the package yet. Everything else works today.

| Page | Status |
| - | - |
| [Agents and providers](https://psychiatrist.sudo.la/sdk/agents.md) | `claudeCode()` available; `codex()`, `opencode()`, `pi()` planned (#8, #9, #10) |
| [Sessions](https://psychiatrist.sudo.la/sdk/sessions.md) | available |
| [run(), resume() and fork()](https://psychiatrist.sudo.la/sdk/run.md) | available |
| [Branches and worktrees](https://psychiatrist.sudo.la/sdk/branches.md) | available |
| [Structured output](https://psychiatrist.sudo.la/sdk/structured-output.md) | available |
| [The guard and MCP servers](https://psychiatrist.sudo.la/sdk/guard.md) | available |
| [Sandboxes](https://psychiatrist.sudo.la/sdk/sandboxes.md) | planned (#14–#17) |
| [Memory](https://psychiatrist.sudo.la/sdk/memory.md) | planned (#18) |
| [Embedding the bot](https://psychiatrist.sudo.la/sdk/practice.md) | available |
| [The server client](https://psychiatrist.sudo.la/sdk/server-client.md) | planned (#34) |
| [Like sandcastle](https://psychiatrist.sudo.la/sdk/sandcastle.md) | available |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.