# Connect Claude Code

A one-time setup in Claude Code's `settings.json` turns on exact limits and real-time session activity.

**Shows:** exact 5-hour and weekly limits, real-time session status, pending permissions/questions waiting for you, and optional 30-day **Anthropic API** spend.

## Reading sources

1. **Claude Code `statusLine` in the terminal (exact):** after each terminal reply, Claude Code passes exact account limits to QuotaDesk's script, valid as exact for 30 minutes.
2. **Claude desktop app history:** when `statusLine` is unconfigured or over 30 minutes old, QuotaDesk uses local desktop history as a fallback and marks numbers with `~` (estimated).
3. **Local hooks:** report in real time whether a session is working, waiting for you or idle.
4. **Anthropic API (optional):** configured in **Settings › Connections › + Add** with your own Admin/Analytics key to track 30-day USD spend separately.

## 1. Locate QuotaDesk's `statusLine` script

When you launch QuotaDesk **v0.5.0**, it automatically writes and maintains the script inside its local profile folder:

```text
%LOCALAPPDATA%\com.quotadesk.opensource.dev\claude-statusline.ps1
```

- Replace `<your-user>` with your Windows username for the full path (`C:\Users\<your-user>\AppData\Local\com.quotadesk.opensource.dev\claude-statusline.ps1`).
- If you upgraded from an earlier release (`.NET 10.0` / `0.4.0`), make sure `settings.json` **does not still point** to a legacy folder (`Desktop\Git Projects\...` or `%LOCALAPPDATA%\Programs\QuotaDesk`), otherwise the new app will not receive exact statusLine readings.

## 2. Edit Claude Code's `settings.json`

1. Close active Claude Code sessions.
2. Back up `%USERPROFILE%\.claude\settings.json` (create `{}` if missing).
3. Add or update the `statusLine` entry pointing to the v0.5.0 script (doubling backslashes `\\`):

```json
"statusLine": {
  "type": "command",
  "command": "powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"C:\\Users\\<your-user>\\AppData\\Local\\com.quotadesk.opensource.dev\\claude-statusline.ps1\""
}
```

If you also want live pending-request alerts and typing/thinking animation, merge the `hooks` section from `claude-settings-additions.template.json` (loopback port `127.0.0.1:32871`) into your existing hooks. Claude Code supports one `statusLine`.

## 3. Verify it works

1. With QuotaDesk running, open Claude Code **in the terminal** and send any message.
2. The Claude card displays exact limits without `~`, saving only timestamp, percentage and reset window in `%LOCALAPPDATA%\com.quotadesk.opensource.dev\claude-limits.json`.
3. When Claude asks for permission or input, the bell icon shows the pending count and Windows displays a notification.

## Troubleshooting

| Symptom | What to do |
|---|---|
| *No quota data* or `~` values | Verify `statusLine` in `%USERPROFILE%\.claude\settings.json` points to `%LOCALAPPDATA%\com.quotadesk.opensource.dev\claude-statusline.ps1` and send one terminal message. |
| Legacy path after upgrading | Replace any old `.NET 10.0` / repo script path in `settings.json` with `%LOCALAPPDATA%\com.quotadesk.opensource.dev\claude-statusline.ps1`. |
| *Local port 32871 busy* | Another process uses the hooks port or another instance is running. Close duplicate instances and reopen. |
| Activity state never updates | Ensure `hooks` is merged into `settings.json` and restart your Claude Code session. |

## Privacy

`claude-statusline.ps1` records only reading timestamp, percentage used and reset time for the 5-hour and weekly windows. Hooks send only session id, tool name, notification type and folder name — QuotaDesk never reads Claude credentials or prompts/responses.
