AI Tips, Tricks & Thoughts by Terry Peterson investingengine.ai

Hit the brakes at 60% context

Sep 4, 2026 · by Terry Peterson · claudeworkflowhabitscli

Who this is for: People who use Claude Code in the terminal (CLI). Browser-only AI users: the idea carries over, but use your AI to re-write the steps.

Claude Code has a context window, the amount of conversation it can hold before it starts forgetting. If you run it to the end usually before starting a new convo, try hitting the brakes at 60% remaining, write the /handoff, and start fresh next time.

The first thing I did was make the number visible. I had Claude Code modify its own status line so the context percentage sits in the footer of every session. Always visible, impossible to blow-past it without noticing.

I started doing this to save tokens, and it does save some. Every message you send re-sends the whole conversation, so a session at 80% full costs about twice as much per turn as one at 40%. On a 1M window, it’s a minor thing but an added benefit.

The real benefit is quality. A full session is a worse session:

Stopping at 60% means none of that happens. The handoff gets written while the AI still has everything sharp, and the next session (/handoff) starts clean with a good note instead of a fuzzy memory.

Two things to keep straight:

This is probably the easiest path to higher-quality AI session runs.

Example of my Claude Code footer:

Claude Code status line showing the project, model, and "context: 91% left"

Add a status line to Claude Code that shows how much of the context window is left.

Claude Code supports a custom status line. In `~/.claude/settings.json`, set
`"statusLine": { "type": "command", "command": "bash ~/.claude/statusline-command.sh" }`.
Claude Code runs that command after every response and pipes session info to it as
JSON on stdin. Check the current status line docs to confirm the field names before
you write anything.

Write `~/.claude/statusline-command.sh` so that it:

- Reads the JSON from stdin and pulls out three fields: the current working
  directory (`workspace.current_dir`), the model's display name (`model.display_name`),
  and the percentage of context remaining (`context_window.remaining_percentage`).
- Uses plain bash, grep and sed only. No jq or other dependencies, so it works on any
  machine I copy it to.
- Prints one line: the project folder name (the last part of the directory path) in
  cyan, the model name in yellow, then `context: NN% left` in bold, colored green
  above 50%, yellow from 20% to 50%, and red below 20%.
- Shows `?` for any field it can't find, and leaves the context part out entirely if
  the percentage isn't in the JSON, so it never crashes.

Back up `settings.json` before editing it. When you're done, show me the script and
tell me to restart Claude Code to see the new footer.
Update my Claude Code status line so it reminds me about `/handoff`.

The status line is the script at `~/.claude/statusline-command.sh`, run by the
`statusLine` setting in `~/.claude/settings.json`. Read it first. If I don't have one
yet, say so and stop; I'll set one up before we continue.

Make two changes:

1. Add a second line under the existing one, in dim text, as a cheat sheet:
   `type / for command menu · /handoff · Ctrl+= / Ctrl+- = text size`.
   Look in `~/.claude/skills/` and list any other skills I have there after `/handoff`,
   in the same style, so the line shows everything I can type.

2. When context remaining is 20% or less, append `→ time to /handoff` in red to the
   end of the first line, right after the context percentage.

Keep it plain bash with no dependencies, keep the colors consistent with what's
already there, and don't change anything else about the output. Show me the diff and
tell me to restart Claude Code to see it.