# how it works
Handoff records
Monot writes one handoff record per branch. This page says when Monot injects the record into a new session.
A task is one branch of one repo. main and master are never tasks.
At the end of each turn, Monot updates the handoff record of the task in the background. A turn is one prompt and Claude's full answer to it. The record is the file ~/.monot/repos/<host>/<owner>/<repo>/handoffs/<branch>.md. In the example on the Introduction page, <host>/<owner>/<repo> is github.com/acme/exporter. A / in the branch name becomes -- in the file name.
Before Monot writes a record, it replaces each secret with [REDACTED:<rule-id>]. It finds secrets with the rules of gitleaks, a secret scanner.
When Monot injects a record
Monot injects a handoff record only when the new session shows which task it is on. To inject means to add text to Claude's context before Claude reads your prompt. The session shows its task in one of five ways:
- A prompt names one of the tickets in the record. Monot injects the record with that prompt. The ticket can be in upper case, such as
ABC-12. It can also be in lower case inside a path or a file name, such asdocs/handoff-abc-12.md, but only when a record already has the ticket. - Before the session finishes a turn on the branch, a prompt names one of the paths, PR numbers or commits in the record of the branch. Monot injects the record with that prompt. A path must include its folder, such as
src/export.pyor@src/export.py. A prompt of 2,000 characters or more does not count, because it is usually pasted text. - The session finishes one turn on the branch of the record, without a switch to another branch. Monot injects the record with the next prompt. The second and third ways have one exception. If a prompt names a ticket that the record of the branch does not have, Monot does not inject that record with the prompt.
- A prompt names a ticket that no eligible record of this repo has, and an eligible record of another repo with the same owner has it. A record is eligible when this context window did not get it yet, it is not retired, and it is not a record that only this session wrote. For example, a session in
github.com/acme/webgets a record ofgithub.com/acme/api. Monot injects that record with the prompt. Its header names the other repo and its folder, because the paths in the record are paths of that repo. - None of the first four ways injects a record, and a prompt of under 2,000 characters names a document (
.md,.txt,.rst,.orgor.adoc) that the record of another branch also names. That record can be in this repo or in another repo with the same owner. Monot injects the newest such record with the prompt. Its header says that the record belongs to another task.
The fourth and fifth ways have a risk. When one owner has a public repo and a private repo, a record of the private repo can reach a session of the public repo. Claude could then repeat private text in a commit, a PR or an issue of the public repo. Monot cannot see which repo is public.
Rules for records
The rest of the rules for handoff records:
- Monot injects each record at most once per context window. The context window is all the text that Claude sees at one time: the conversation so far and the text that hooks add.
- Claude gets at most about 800 tokens of the record. If the record is longer, Monot cuts it and ends it with
[...]. - The record is plain Markdown. You can add your own section to it by hand. Monot keeps your section when it updates the record.
- If no session updates a record for 7 days, Monot retires the record. It moves the record to
handoffs/retired/.
Branches and worktrees
Monot follows the branch that a worktree is on. So you can use one worktree for many tasks, one after the other:
- When you switch to a new branch, Monot starts a new record for it at the end of the next turn. The record of the old branch does not change.
- When you come back to an old branch, Monot injects its record again. The first three ways above apply: a prompt that names one of its tickets, a prompt that names one of its paths, PR numbers or commits, or one finished turn on the branch.
- A session does not get a record that only it wrote, because its context already holds that work. After
/clearor a compaction, the session gets the record again. In a compaction, Claude Code replaces the earlier part of the conversation with a summary, so that the context window has room again. - If the record of a branch retired before you come back, Monot starts a new record for the branch.
- Facts and Claude Code's built-in memory belong to the repo, not to a branch. Every branch and every worktree of the repo can recall them.
- A worktree is on one branch at a time. All sessions that are open in the worktree follow that branch. When one session switches the branch, the other sessions move to the new task too.
A rename keeps the record. If the old branch does not exist when Monot sees the switch, Monot treats the switch as a rename, such as git branch -m. It then moves the old record to the new branch name. Monot sees a switch at the end of the next turn. So delete an old branch only after one turn finishes on the new branch.