context

A command for inspecting and managing how much of the conversation context is being used. Context is the information the coding agent can keep available while working.

In plain words
What is it for?
Use it to view context usage, analyse or optimise it, set token-budget rules, and create or restore named checkpoints.
Why use it?
It helps prevent important information from being lost when a conversation grows too large and lets you save or restore working checkpoints.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/thelobbi/claude/context
Clone the repo
git clone --depth 1 https://github.com/TheLobbi/claude

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,792 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01792
Opus 5 $0.00000 $0.00896
Sonnet 5 $0.00000 $0.00358
Haiku 4.5 $0.00000 $0.00179

Measured yesterday against content hash c7f71ab5eb89, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/context.md · 301 lines

How it starts

The opening of the file, as written. The whole thing — 301 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context Optimization Command

Manage and optimize context window usage for maximum efficiency.

Usage

/context <action> [options]

Actions

  • status - Show current context usage breakdown
  • optimize - Run optimization strategies
  • checkpoint - Save context checkpoint
  • restore - Restore from checkpoint
  • analyze - Deep analysis of context usage
  • budget - Configure token budget allocation

Options

Option Description Default
--strategy <s> Optimization strategy balanced
--threshold <n> Warning threshold % 75
--name <name> Checkpoint name Auto-generated
--force Force optimization even below threshold false
--dry-run Preview optimization without applying false
--verbose Show detailed breakdown false

Examples

View Context Status

# Show current usage
/context status

# Detailed breakdown
/context status --verbose

Optimize Context

# Run balanced optimization
/context optimize

# Aggressive optimization
/context optimize --strategy aggressive

# Preview without applying
/context optimize --dry-run

Checkpointing

# Save checkpoint
/context checkpoint --name "before-refactor"

# List checkpoints
/context checkpoint --list

# Restore checkpoint
/context restore --name "before-refactor"

Budget Configuration

# Set overall budget
/context budget --total 100000

# Set section budgets
/context budget --system 5000 --conversation 60000 --tools 35000

# Set warning threshold
/context budget --threshold 80

Status Output

Context Window Status
══════════════════════════════════════════════════════════════
Total Budget:     100,000 tokens
Current Usage:    67,432 tokens (67.4%)
Available:        32,568 tokens

Breakdown by Section:
├── System Instructions    5,000 tokens (5.0%)  ████░░░░░░
├── Conversation History  42,000 tokens (42.0%) ████████░░
│   ├── Recent (keep)     28,000 tokens
│   └── Old (compressible) 14,000 tokens
├── Tool Results          18,432 tokens (18.4%) ████░░░░░░
│   ├── Active            12,000 tokens
│   └── Cached            6,432 tokens
└── Metadata              2,000 tokens (2.0%)   █░░░░░░░░░

Status: ✅ HEALTHY (below 75% threshold)

Recommendations:
• 14,000 tokens in old conversation could be summarized
• 6,432 tokens in tool cache could be evicted
• Potential savings: ~18,000 tokens (18%)
══════════════════════════════════════════════════════════════

Read the full file on GitHub · 301 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 301 lines · 0 tokens per session scan A c7f71ab5eb89

Subscribe to this mod's changes

context is a command published in the GitHub repository TheLobbi/claude (21 stars, last pushed 5d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,792 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.