Skip to main content
statuslinesSource-backedReview first Safety Privacy

Context Pressure Statusline

Claude Code statusline that estimates context pressure from local session token counts and a configurable context limit, then prints a compact risk tier.

by MkDev11·added 2026-06-04·
Claude Code
HarnessClaude Code
Language:bash
Review first review before installing

Open the source and read safety notes before installing.

Safety notes

  • Context percentage is only as accurate as the configured limit and the usage fields available in the statusline input.
  • Use the warning as a cue to summarize or checkpoint work before context pressure affects reasoning quality.
  • Do not treat a low percentage as proof that all relevant files, instructions, or tool results are still in scope.

Privacy notes

  • The script reads local session counters and does not inspect prompt text, files, or transcript contents.
  • Token counts and configured limits can still reveal workload size in screenshots or shared terminal logs.
  • Teams should avoid placing customer names or project identifiers in shell variables that appear in debugging output.

Prerequisites

  • Claude Code statusline support with local JSON input.
  • jq available for reading session usage fields.
  • Optional CLAUDE_CONTEXT_LIMIT set to the model or workflow limit your team wants to track.

Schema details

Install type
config
Troubleshooting
No
Runtime and command metadata
Script language
bash
Script body
#!/usr/bin/env bash
set -u

main() {
read -r input || input=""
limit="${CLAUDE_CONTEXT_LIMIT:-200000}"
used=$(printf '%s' "$input" | jq -r '.session.totalTokens // .usage.input_tokens // .cost.total_tokens // 0')

if ! printf '%s' "$limit" | grep -Eq '^[0-9]+$'; then
  limit=200000
fi
if ! printf '%s' "$used" | grep -Eq '^[0-9]+$'; then
  used=0
fi

if [ "$limit" -le 0 ]; then
  limit=200000
fi

pct=$((used * 100 / limit))
if [ "$pct" -ge 85 ]; then
  state="compress"
elif [ "$pct" -ge 65 ]; then
  state="watch"
else
  state="ok"
fi

printf 'context: %s/%s | %s%% | %s\n' "$used" "$limit" "$pct" "$state"
}

case $- in
  *n*) ;;
  *) main "$@" ;;
esac
Full copyable content
{
  "statusLine": {
    "type": "command",
    "command": "$CLAUDE_PROJECT_DIR/.claude/statuslines/context-pressure-statusline.sh"
  }
}

About this resource

Source notes

  • Claude Code statusline documentation defines command-based statuslines with JSON passed on stdin.
  • Anthropic model documentation explains that models have context windows; this entry leaves the exact limit configurable so teams can track the model and workflow they use.

Duplicate check

Checked existing statuslines, the live HeyClaude statuslines index, open pull requests, and repository content for context-pressure-statusline, context window, token pressure, and context budget statuslines. Existing model and token entries are adjacent, but this file is specifically a configurable context-pressure gauge.

Disclosure

Editorial statusline recipe. No paid placement or affiliate link is used.

#context#tokens#model#claude-code

Source citations

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.