# Claude Code

> Hooks that brief Claude at session start and tell it about clashes before and after each edit.

Lanekeeper uses [Claude Code hooks](https://code.claude.com/docs/en/hooks). `lk init` writes them into
`.claude/settings.json`; the plugin installs the same hooks for everyone who installs it.

| When | What Lanekeeper does |
|---|---|
| Session start | Registers the session in its lane and briefs Claude: other lanes and what they're doing, open clashes, claims, three working rules (at most 1,500 characters). |
| Prompt submitted | Records the first 200 characters as the session's intent (kept on your machine) and mentions high clashes that appeared since the last prompt. |
| Before Edit / Write | Works out what the file would look like after the edit and checks it against every other lane. |
| After Edit / Write | Re-analyzes the lane and reports any new clash. |
| Turn end (`Stop`) | Reads the new part of the session's transcript for token usage (`lk usage`). |
| Session end | Removes the session from its lane. |

## Warn mode and block mode

In **warn** mode Claude gets the clash as context with the tool result, so it sees it right after the write and
can fix its call. It is never stopped.

In **block** mode an edit that would create a high-severity clash is denied before it is written. Claude receives
the reason, including the other lane's new signature, and changes its approach. In our test sessions Claude did
not retry the same edit; it asked how to proceed.

```yaml
# .lanekeeper/config.yml
mode: block
```

Lanekeeper never answers "allow": that would skip your own permission prompts.

## Failing open

Hooks never get in Claude's way. Each one has 250 ms to get an answer from the daemon (a check takes about 5 ms;
the hook process about 60 ms in total). If the daemon is starting, busy or missing, the hook prints nothing and
exits 0, and the next edit catches up. A missing `lanekeeper` command is ignored too.

## The plugin

Instead of project hooks, your team can install the plugin, which also adds a skill that explains Lanekeeper to
Claude:

```text
/plugin marketplace add UpwanSingh/lanekeeper
/plugin install lanekeeper@lanekeeper
```

Run `lk init --plugin` to set up the repository without the project hooks and the CLAUDE.md section. The plugin
needs the CLI on your PATH (`npm i -g lanekeeper`).
