<!-- GENERATED by scripts/build-docs.mjs from the live Commander tree (src/cli/program.ts). Do not edit by hand. -->

# pai audit

> Diagnostic audits: token-waste report and friends

## Synopsis

```
pai audit <subcommand> [options]
```

## Subcommands

| Command | Description |
|---------|-------------|
| [`pai audit tokens`](#pai-audit-tokens) | Token-waste audit: memory files, hooks, session usage, spawn overhead, daemon, env, schedule, skill catalogue, subagents, MCP |

### pai audit tokens

Token-waste audit: memory files, hooks, session usage, spawn overhead, daemon, env, schedule, skill catalogue, subagents, MCP

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--json` | Print JSON instead of a table |  |
| `--record <dir>` | Write a dated, numbered markdown+JSON snapshot of the combined report to <dir> |  |


### pai audit tokens files [paths...]

Token count per memory file (CLAUDE.md chain, CORE skill, whisper rules, auto-memory)

**Arguments**

| Argument | Kind | Description |
|----------|------|-------------|
| `[paths...]` | variadic | Files to count (default: the standard memory set) |


### pai audit tokens hooks

Token cost of every SessionStart / UserPromptSubmit hook


### pai audit tokens session [path]

Cache/input/output token split for a session transcript (default: newest)

**Arguments**

| Argument | Kind | Description |
|----------|------|-------------|
| `[path]` | optional | Session JSONL path (default: newest under ~/.claude/projects) |

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--ctx-threshold <n>` | Override the derived compaction trigger (default: derived from the session's own window and measured/configured trigger — see 'window'/'trigger' in the report header) |  |
| `--history [n]` | List first-turn context of the newest n sessions in this project's transcript directory (default 20) |  |
| `--turn <n>` | Attribute API call n's context growth to the transcript lines injected since the previous call |  |


### pai audit tokens spawn

Spawn-overhead comparison: Agent-tool subagents vs. pai workers

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `-n, --n <count>` | How many of the newest logs per group to read (default 10) |  |
| `--detail` | Print one row per log (first-turn ctx, prompt tokens, overhead, model, path) |  |


### pai audit tokens daemon

LLM spawns, KG-extraction parse failures, work-queue counts from the daemon log


### pai audit tokens env

ANTHROPIC_BASE_URL / model-override env on every live claude process


### pai audit tokens schedule

Launchd agents / crontab entries that outpace the measured prompt-cache TTL


### pai audit tokens skills

Token cost of the SKILL.md / command / plugin catalogue, top entries, duplicate names

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--top <n>` | How many top-by-tokens entries to show (default 15) |  |


### pai audit tokens subagents

Token cost of Claude Code subagent definitions (~/.claude/agents, <cwd>/.claude/agents) and their model pinning


### pai audit tokens mcp

MCP servers: configured vs. pinned vs. loaded-live vs. used in the last 30 days

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--connect` | Actually connect to every stdio MCP server to count exposed tools (side-effecting; never on by default) |  |


### pai audit tokens ladder

LIVE: first-turn context at increasing headless-worker configuration (spawns real claude -p calls)

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--live` | Actually spawn claude -p (billed API traffic); refuses without this flag |  |
| `--model <model>` | Model to probe with (default haiku) |  |
| `--mcp-config <path>` | MCP config for the L2 rung (default: newest *.mcp.json in the workers log dir) |  |


## See also

[`pai backup`](backup.md) · [`pai clear-names`](clear-names.md) · [`pai config`](config.md) · [`pai daemon`](daemon.md) · [`pai db`](db.md) · [`pai end`](end.md) · [`pai help`](help.md) · [`pai identity`](identity.md) · [`pai kg`](kg.md) · [`pai launch`](launch.md) · [`pai mcp`](mcp.md) · [`pai memory`](memory.md) · [`pai notify`](notify.md) · [`pai observation`](observation.md) · [`pai obsidian`](obsidian.md) · [`pai pause`](pause.md) · [`pai project`](project.md) · [`pai projects`](projects.md) · [`pai registry`](registry.md) · [`pai restore`](restore.md) · [`pai session`](session.md) · [`pai sessions`](sessions.md) · [`pai setup`](setup.md) · [`pai shell-init`](shell-init.md) · [`pai skill`](skill.md) · [`pai task`](task.md) · [`pai topic`](topic.md) · [`pai update`](update.md) · [`pai worker`](worker.md) · [`pai zettel`](zettel.md)

Run `pai help <area>` to read any of these in the terminal.

