# Claude Code setup — PsychArch Reader

> Send every completed Claude Code reply to PsychArch Reader: install the CLI, sign in, add a Stop hook, and verify.

Every completed Claude Code reply is saved to your private Reader library as Markdown. Replies expire after three days by default.

Agents: run the steps in order, one command at a time, and wait for each to finish. This page is also available as [Markdown](https://reader.psycharch.com/intro/claude-code/index.md); fetch it with `curl -fsSL` if browsing fails. No repository, source code, or OAuth registration is needed. These steps are for macOS and Linux and use `jq`.

## 1. Install the CLI

```
curl -fsSL https://reader.psycharch.com/intro/install.sh | sh
psycharch-reader version
```

This installs Reader CLI to `~/.local/bin`. If the command is not found, run `export PATH="$HOME/.local/bin:$PATH"`. Install `jq` too if `command -v jq` prints nothing.

## 2. Sign in

```
psycharch-reader auth status
```

If it reports `Logged in.` for `https://reader.psycharch.com`, go to step 3. Otherwise, sign in as the account that runs Claude Code.

On a desktop (macOS Keychain or an unlocked Linux keyring):

```
psycharch-reader doctor
psycharch-reader login --open
```

On a remote or headless Linux machine, use encrypted systemd storage (systemd 256+):

```
psycharch-reader doctor --credential-store systemd-creds
psycharch-reader login --device --credential-store systemd-creds
```

If doctor does not report `ready`, use `--credential-store file` in both commands instead. File storage keeps tokens unencrypted, readable only by your account.

**Device login prints a URL and a code.** Give the user that exact URL, keep the command running, and wait until it prints `Logged in.` Do not run other Reader commands meanwhile.

## 3. Add the hook script

Save this as `~/.claude/hooks/psycharch-reader.sh` and make it executable with `chmod +x`. If `command -v psycharch-reader` prints another path, use it for `reader`. Retention can be `1h`, `1d`, `3d`, or `7d`.

```
#!/bin/sh
# Send Claude Code's final reply to PsychArch Reader.
reader="$HOME/.local/bin/psycharch-reader"
reply=$(jq -r '.last_assistant_message // empty')
[ -n "$reply" ] || exit 0
printf '%s\n' "$reply" | "$reader" send --stdin --ttl 3d \
  --title "Claude Code · $(basename "${CLAUDE_PROJECT_DIR:-$PWD}")" >/dev/null
```

## 4. Register the hook

Add this `Stop` hook to `~/.claude/settings.json`. Back up the file first, and merge with existing settings and hooks instead of replacing them.

```
{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/psycharch-reader.sh",
            "async": true,
            "timeout": 120
          }
        ]
      }
    ]
  }
}
```

## 5. Test and restart

```
printf '%s' '{"last_assistant_message":"# Reader test"}' | ~/.claude/hooks/psycharch-reader.sh && echo sent
```

This uploads one test document titled `Claude Code · …`. Ask the user to check that it appears in their Reader library.

**Restart Claude Code**, then check that the next reply appears once in Reader. Until then, report setup as installed but not yet confirmed.

## What gets sent

Only the final reply of each turn, titled `Claude Code · project`. Prompts, transcripts, tool output, and reasoning stay local. The hook runs in the background, so Claude Code does not wait for the upload. The CLI retries transient upload failures up to three attempts within a minute; failed uploads are not queued. If delivery cannot be confirmed, check your library before sending again.

## If setup fails

- `another Reader CLI command is active`: wait for the other command, including a pending login, to finish.

- Nothing arrives: run the test command from step 5 and read its error. Check the script path and that `jq` is on PATH for Claude Code.

- Credential store errors: run `psycharch-reader doctor` as the account that runs Claude Code. A Linux keyring needs D-Bus and an unlocked Secret Service.

- Daily upload limit: the error shows when you can upload again.

## Remove the hook

Delete the Reader entry from `Stop` in `~/.claude/settings.json`, then restart Claude Code. `psycharch-reader logout` signs the CLI out.
