Skip to main content

context-handoff

ci release license: MIT

A Claude Code plugin that keeps long sessions from getting expensive: it shows what each turn costs, writes a handoff note when the session grows, and resumes from it after /clear.

/plugin marketplace add YauhenBichel/context-handoff
/plugin install context-handoff@context-handoff

Python 3.10+ as python3, nothing else. Details in Install.

context-handoff report and check on real Claude Code sessions

Real sessions, project names changed: about $1,070 in 14 days at API list prices, 24 of 34 sessions past 150K context, and one session, open for weeks, past the 400K block limit.

Every Claude Code turn re-sends the whole conversation. While the prompt cache is warm that re-read is cheap; after a pause the whole context is written to the cache again at up to 2× the input price. A 400K-token session on Claude Opus 5.5 pays about $3.20 for one such cold turn, before Claude writes a word. Long sessions also get slower and lose focus.

context-handoff watches what each turn costs. When a session gets too big or too expensive, Claude writes a short handoff note at the end of the current task. You run /clear, type go, and a fresh, small session continues from the note.

What you see above a prompt once a session is past the warn limit:

[context-handoff] 182K context, last turn $0.61, session $14.20, a cold turn would cost $1.46
(claude-opus-5-5 prices). Claude will write a handoff note after this task; then /clear and type go.

How it works

  1. Meter (UserPromptSubmit hook). Before each prompt it reads the session transcript and computes, at API list prices:
    • the context the next turn will re-send,
    • what the last turn cost,
    • what the whole session cost,
    • what one cold turn would cost now.
  2. Auto handoff. Over a warn limit, it asks Claude (once per session) to write a handoff note when the current task is done.
  3. Block. Over a block limit, it holds the prompt until you type handoff or add #override.
  4. Resume (SessionStart hook, after /clear). It loads the project's newest unused note into the new session, so you type go instead of pasting a prompt. Each note is loaded once.

Install

In Claude Code:

/plugin marketplace add YauhenBichel/context-handoff
/plugin install context-handoff@context-handoff

Or from a terminal:

claude plugin marketplace add YauhenBichel/context-handoff
claude plugin install context-handoff@context-handoff

Restart Claude Code (or start a new session) to load the hooks. The meter line appears from the second prompt of a session.

Requires Python 3.10 or newer on PATH as python3. No other dependencies.

Without Claude Code plugins

The same code is on PyPI. It gives the context-handoff command for reports and checks, for example in a shell or on a machine where you don't use the plugin:

pipx install context-handoff        # or: uv tool install context-handoff
context-handoff report 14

The hooks still come from the plugin above; the package does not install them.

Update or remove:

claude plugin marketplace update context-handoff
claude plugin update context-handoff@context-handoff
claude plugin uninstall context-handoff@context-handoff

Use

  • Normal flow: keep working. When the meter asks, Claude writes the note after the current task and tells you. Run /clear, then type go.
  • By hand: /context-handoff:handoff, then /clear and go.
  • Past a block: start the prompt with handoff, or add #override.
  • Check a session: python3 bin/context-handoff check <transcript.jsonl>.
  • Report of the last N days (default 7): python3 bin/context-handoff report 14.

Settings

Defaults, then ~/.claude/context-handoff.json, then environment variables (CONTEXT_HANDOFF_ + the key in upper case). A limit of 0 turns it off.

Key Default Meaning
warn_k 150 context size (thousands of tokens) that triggers a handoff
block_k 400 context size that blocks prompts
warn_turn_usd 0.50 cost of the last turn that triggers a handoff
block_turn_usd 3.00 cost of the last turn that blocks prompts
warn_session_usd 20 session total that triggers a handoff
auto_handoff true Claude writes the note itself; false = only a warning
max_age_min 180 notes older than this are not resumed
handoff_dir ~/.claude/handoffs where notes go
state_dir ~/.claude/context-handoff log (meter.jsonl) and per-session markers
prices see prices.py {"model-prefix": [input, output, cache_read]} per million tokens

Example ~/.claude/context-handoff.json:

{ "warn_turn_usd": 1.0, "warn_session_usd": 50, "prices": { "claude-opus-5-5": [4.0, 20.0, 0.20] } }

Prices

The default table holds Anthropic's first-party API list prices as of November 2026. Cache writes are priced at 1.25× input (5-minute TTL) or 2× input (1-hour TTL). On a Claude subscription you do not pay per token, but the same numbers show how fast a session uses your limits. Prices change: override them in the config file.

Limits

  • A plugin cannot run /clear for you. That one step stays manual.
  • Notes are matched by the project folder's name, and only those newer than max_age_min are loaded.
  • The meter reads the transcript, so the first prompt of a session is not metered.
  • Costs are estimates from the transcript's usage fields, not your bill.

Privacy

Everything runs locally. The plugin reads your transcripts in ~/.claude and writes notes and a log there. Nothing is sent anywhere. Do not put secrets in handoff notes.

FAQ

How do I reduce Claude Code costs?

Keep sessions small. Most of the cost of a long session is re-reading its own context: every turn re-sends the whole conversation. Finish a task, write a handoff note, run /clear, and continue in a fresh session. context-handoff tells you when to do it and writes the note for you. Run context-handoff report 14 to see where your own cost goes.

Why does Claude Code get expensive after a pause?

The prompt cache expires. Claude Code caches the conversation for one hour; after a longer pause the next turn writes the whole context into the cache again at 2× the input price. On a 400K-token session that is about $3.20 for one turn on Claude Opus 5.5. The meter shows this "cold turn" cost before each prompt.

How do I continue a Claude Code session after /clear?

Ask Claude for a handoff note before /clear (/context-handoff:handoff, or let the plugin ask automatically). After /clear, the SessionStart hook loads the project's newest unused note, so you type go and the new session continues from it.

How big should a Claude Code session get?

The defaults warn at 150K tokens of context, $0.50 for one turn or $20 for a session, and block at 400K or $3 for one turn. Change them in ~/.claude/context-handoff.json; see Settings.

Does it work in VS Code and the desktop app?

Yes. Installed at user scope, the plugin's hooks run in every Claude Code client that reads ~/.claude: the terminal, the VS Code extension and the desktop app.

Does it work on a Claude subscription?

Yes. You don't pay per token, but the numbers show how fast a session uses your plan's limits, and smaller sessions stretch them.

Does it send my code or transcripts anywhere?

No. It reads local transcripts and writes local notes. See Privacy.

Development

python3 -m unittest discover -s tests

See CONTRIBUTING.md.

License

MIT, see LICENSE.

Metadata

Release files for context-handoff 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for context-handoff 0.1.3
File Size Uploaded Provenance Actions
context_handoff-0.1.3.tar.gz 19.2 kB With provenance Details for context_handoff-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for context-handoff 0.1.3
File Interpreter ABI Platform Actions
context_handoff-0.1.3-py3-none-any.whl Python 3 none any Details for context_handoff-0.1.3-py3-none-any.whl

Total release size: 34.7 kB

Release files / context_handoff-0.1.3.tar.gz

Download URL context_handoff-0.1.3.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
374f0ba7d33898d9c4dccfe4bfeb09cd65c346593571ce992f6e7b881ef1fc6a
BLAKE2b-256 checksum
How to use checksums
e4241689c56e235952c81e877d6725503cd3744db382bfa3e108a320ed406498
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / context_handoff-0.1.3-py3-none-any.whl

Download URL context_handoff-0.1.3-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6a3e2f422c01d0b5a13643d4ac1f38c05f9acd31745ca3d5b2004b7084ed878
BLAKE2b-256 checksum
How to use checksums
2aac83f34ff0b85adf74b066ceee685d814f66bfd9a029f69f81b8c1da663f48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for context-handoff 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for context_handoff-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page