---
title: Claude Code
description: How Hindsight hooks into Claude Code, what it sees there, and how to check it or take it out.
sidebar:
  order: 2
---

Claude Code is connected through its hooks. You don't have to do anything: if you've run Claude Code at least once,
Hindsight adds its hooks the next time it starts.

## What gets installed

Hindsight edits `~/.claude/settings.json` (on Windows, `C:\Users\you\.claude\settings.json`). If you set
`CLAUDE_CONFIG_DIR`, it uses `settings.json` in that folder instead. If the folder doesn't exist, Claude Code isn't
installed as far as Hindsight can tell, and nothing is written.

It adds one hook to each of five events:

| Event | When it fires |
| --- | --- |
| `UserPromptSubmit` | You send a prompt |
| `PostToolUse` | A tool call finished |
| `PostToolUseFailure` | A tool call failed |
| `Stop` | The agent finished its run |
| `SessionStart` | A session starts, resumes, clears or compacts |

Each one is a command hook with a timeout of 5, pointing at the daemon's full path:

```json
"UserPromptSubmit": [
  {
    "hooks": [
      {
        "type": "command",
        "command": "\"C:/Users/you/AppData/Local/Hindsight/hindsight-daemon.exe\" emit --source claude-code",
        "timeout": 5
      }
    ]
  }
]
```

Slashes are forward ones even on Windows, because Claude Code runs hooks in a POSIX shell (Git Bash there).

If the file already existed, Hindsight copies it to `settings.json.before-hindsight` in the same folder before the first
change, and never overwrites that copy. Your own hooks and settings are left as they are. If an older Hindsight hook or a
hand-written `hindsight-daemon emit` is already there, it's replaced rather than added to, so a prompt is never
recorded twice.

Hooks go in your user settings, so they apply to every project. A project's own `.claude/settings.json` isn't touched.

## What Hindsight sees

- **Your prompts.** The length, and a keyed hash so repeats can be spotted. Claude Code can't say whether you typed or
  pasted a prompt, so that part is left blank.
- **The run.** A prompt starts it, `Stop` ends it.
- **Each tool call.** Which tool, how long it took, whether it failed (never why). For edits (`Write`, `Edit`,
  `MultiEdit`) it also counts lines added and removed, notes the language from the file's extension, and keeps a
  keyed hash of the path. The daemon also remembers, as a hash and for 24 hours, which files the agent edited. That's
  how reading one of them in an editor with the Hindsight extension counts as reviewing it.
- **Tokens.** When a run finishes, the daemon reads the new part of the session transcript for token counts, the
  model name and how much text the agent showed you, and keeps only those numbers. That length is how long reading the
  answer is allowed to count.
- **Runs you stop.** Pressing Esc fires no hook. The daemon finds it in the transcript at your next prompt (or the
  next `Stop`) and dates the end of the run to when you pressed it. An Esc it finds more than 10 minutes late isn't
  dated, but the tokens still count.

Prompt text, file contents, file paths, tool output and error messages are not stored. The daemon reads them on your
computer to get a length or a count and drops them.

## Things to know

- **Headless runs aren't you.** `claude -p` and other unattended sessions start runs, but their prompts don't count as
  yours. Claude Code says whether a session is attended through `CLAUDE_CODE_SESSION_ATTENDED`, and the agent SDK
  entry points (`sdk-ts`, `sdk-py`) still count, because a person may be typing into them. Claude Code running inside
  Zed is one.
- **Prompts Claude Code writes itself aren't yours either.** A finished background task or a message from another
  session starts a run, but it isn't a prompt.
- **Cursor's CLI runs these hooks too.** It reads `~/.claude/settings.json`. Hindsight spots that (Cursor sets
  `CURSOR_VERSION` for its hooks) and records nothing, since Cursor's own hooks already did. Claude Code started from a
  Cursor terminal still counts.
- **Commits.** A commit made from Claude Code's shell is recorded as Claude's. See
  [Commits](/docs/tools#commits).
- **Hindsight's own summaries.** When Hindsight asks an agent CLI to write a day summary, it sets
  `HINDSIGHT_SKIP_EMIT` so those runs don't record anything.

## Check that it's working

Send Claude Code a prompt, then look at the timeline on your [Today page](/docs/dashboard/today). The quick version from a
terminal is `hindsight-daemon status`, which prints a count of stored events. Run it before and after a prompt and the
number goes up.

If nothing arrives, open `settings.json` and look for hooks whose command ends in `emit --source claude-code`. If
they're missing, [reconnect](/docs/tools#reconnect).

## Disconnect

```powershell
hindsight-daemon disconnect
```

This removes the Hindsight hooks from `settings.json`, and any hook group or event they leave empty. Your other hooks
stay. The `settings.json.before-hindsight` copy is left where it is. Remember that Hindsight reconnects at its next
start unless you uninstall it.
