# Claude Code

> The StateJar plugin for Claude Code recalls the memory each prompt needs, captures your prompts with secrets removed, and adds StateJar's tools and six commands. Install it from the open-source marketplace with two commands.

## What it does

- **Recall.** Claude gets the memory each moment needs, at the start of every session and before each prompt. StateJar sends the whole state while it is small, and only the fields a question needs once it is large. Every recall names the handle it came from (`shm_…`) and is written to your audit log.
- **Capture.** Your prompts are queued on your machine with secrets removed: API keys and tokens, private keys, passwords and card numbers. The queue is sent in batches: after a few prompts, at compaction and at the end of a session. StateJar extracts typed facts from them, refuses a value that fails its type, and keeps a fact said once in a weak form until it is said again. It stores no transcript.
- **Tools.** Claude gets the ten tools of StateJar's [MCP server](/docs/mcp.html): `search`, `remember`, `get`, `list`, `update`, `delete`, `history`, `audit`, `verify` and `export`.
- **Commands.** `/statejar:search`, `/statejar:status`, `/statejar:remember`, `/statejar:forget`, `/statejar:pause` and `/statejar:resume`.

The plugin is open source (MIT) in [statejar-integrations](https://github.com/KING-OF-FLAME/statejar-integrations).

## Install

```bash
claude plugin marketplace add KING-OF-FLAME/statejar-integrations
claude plugin install statejar@statejar
```

Or, inside Claude Code: `/plugin marketplace add KING-OF-FLAME/statejar-integrations`, then `/plugin install statejar@statejar`.

The hooks need Python 3.8 or later as `python3`. They use the standard library only.

## Set it up

Make a developer key on the [API keys page](/api-keys). Then run `/plugin configure statejar@statejar` in Claude Code, or this from a shell:

```bash
echo '{"api_key": "sj_live_…"}' | claude plugin configure statejar@statejar --values-stdin
```

Claude Code keeps the key in your system's secure credential store. The other options:

| Option | Default | What it does |
|---|---|---|
| `scope` | `claude-code` | The scope in your account the plugin reads and writes. A new scope builds on your newest memory. |
| `auto_capture` | `true` | Queue your prompts and send them in batches. |
| `recall_each_prompt` | `true` | Add the memory each prompt needs, as one audited query per prompt. |
| `api_url` | `https://api.statejar.com/api/v1` | The REST API the hooks call. |
| `mcp_url` | `https://statejar.com/mcp` | The MCP server Claude's tools use. |

If you already ran `statejar login` (the `statejar` package on PyPI), the hooks use that key while the option is empty.

## Check it works

1. `claude mcp list` shows `plugin:statejar:statejar: https://statejar.com/mcp (HTTP) - ✓ Connected`.
2. In a session, say "I'm Kavya, I live in Bengaluru and my laptop budget is 80000 rupees." Then end the session.
3. In a new session, run `/statejar:search what is my budget?` or ask about laptops. The answer uses the budget and names the handle it came from.
4. `/statejar:status` shows the scope, what is queued, and the last batch's status (202 when accepted).

## What it sends

- **Leaves your machine:** each recall sends the question (your prompt) to StateJar's query endpoint. Each batch sends your queued prompts, with secrets already removed. Nothing goes anywhere else.
- **Stays on your machine:** the queue, in the plugin's data folder (mode 600). Its `state.json` holds only counts, times and the last status code.
- **What StateJar stores:** typed facts, never your messages. Every disclosure is in your [audit log](/audit), and deleting your account deletes all of it.
- **What the plugin never reads:** Claude's replies, your code and your files.
- `/statejar:pause` stops recall and capture until `/statejar:resume`.

## Troubleshooting

- **"no developer key yet" at session start:** the `api_key` option is empty and there is no `statejar login` key.
- **`! Needs authentication` or `401` from the tools:** the key is wrong or revoked. Make a new one and configure it again.
- **`429` in `/statejar:status`:** your plan's per-minute or monthly limit ([what each limit counts](/docs/pricing-and-payments.html)). The batch stays queued and is sent later.
- **Nothing is captured:** `/statejar:status` says whether memory is paused. Prompts of under three words and slash commands are not captured.
- **Python not found:** the hooks run `python3`. Install Python 3.8 or later, or put it on `PATH`.
