DEV Community

Cover image for The `/context` Command: X-Ray Vision for Your Tokens
Rajesh Royal
Rajesh Royal

Posted on

The `/context` Command: X-Ray Vision for Your Tokens

Stop guessing where your tokens go. Start seeing the invisible tax on your context window.

From: x.com/adocomplete


Introduction

Every AI model has a context window—a finite amount of information it can consider at once. Think of it like working memory. For Claude, this window is substantial, but it's not infinite. And here's the thing most developers don't realize: your actual prompt is often just a fraction of what's consuming that precious context space.

There's a hidden world of system prompts, MCP server configurations, memory files, and accumulated conversation history—all silently eating into your token budget. Until now, this was a black box. You'd hit limits without understanding why, or notice degraded responses without knowing the cause.

Welcome to Day 8 of our series. Today, we're pulling back the curtain with the /context command—your personal X-ray machine for understanding exactly what's happening inside your Claude Code session.


The Problem

Token management in AI tools is frustrating for several reasons:

Invisibility: You can see your prompt, but you can't see the system prompt, the injected context from tools, or the accumulated history. It's like budgeting without knowing your fixed expenses.

Mysterious limits: You're mid-conversation, everything's flowing, and suddenly responses get truncated or Claude starts "forgetting" earlier context. What happened? Without visibility, you're left guessing.

Inefficient optimization: Maybe you're loading files that aren't relevant. Maybe your MCP servers are injecting verbose configurations. Maybe your memory files have grown bloated. How would you know?

Cost implications: More tokens = more cost. If there's unnecessary context being loaded, you're literally paying for waste you can't see.

The context window is arguably the most important resource in AI-assisted development. Operating blind is not a strategy—it's a gamble.


The Solution

The /context command gives you complete visibility into your context window consumption.

How to Use It

Simply type:

/context
Enter fullscreen mode Exit fullscreen mode

That's it. Claude Code will display a detailed breakdown of everything consuming tokens in your current session.

What You'll See

The output provides a comprehensive view:

📊 Context Window Usage
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Total Capacity:    200,000 tokens
Currently Used:     47,832 tokens (24%)
Available:         152,168 tokens

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

BREAKDOWN:

System Prompt           3,247 tokens   (6.8%)
├─ Base instructions      892 tokens
├─ Tool definitions     1,455 tokens
└─ Safety guidelines      900 tokens

MCP Servers             8,921 tokens  (18.6%)
├─ filesystem           2,341 tokens
├─ github               3,892 tokens
└─ database             2,688 tokens

Memory Files            5,443 tokens  (11.4%)
├─ CLAUDE.md            2,156 tokens
├─ project-context.md   3,287 tokens

Conversation History   28,104 tokens  (58.8%)
├─ Turn 1               4,521 tokens
├─ Turn 2               8,932 tokens
├─ Turn 3               6,221 tokens
└─ Turn 4               8,430 tokens

Pending Files           2,117 tokens   (4.4%)
└─ src/utils.ts         2,117 tokens

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Enter fullscreen mode Exit fullscreen mode

Reading the Output

System Prompt: The base instructions Claude receives. This is relatively fixed.

MCP Servers: Each connected Model Context Protocol server adds context for its capabilities. More servers = more tokens.

Memory Files: Your CLAUDE.md and other memory files loaded into context. Large memory files can be costly.

Conversation History: Every message you've sent and every response Claude has generated accumulates here.

Pending Files: Files currently loaded for analysis or editing.


Pro Tips

1. Run /context early and often

Check your context at the start of complex tasks. If you're already at 60% capacity before doing anything, you might want to start a fresh session or compact your history.

2. Audit your MCP servers

If a particular MCP server is consuming a lot of tokens but you're not using its features, consider disconnecting it for the current session:

/mcp disconnect database
Enter fullscreen mode Exit fullscreen mode

3. Keep memory files lean

Your CLAUDE.md should contain essential project context, not everything about the project. Trim the fat:

# Good: Essential context
- TypeScript + React project
- Uses Zustand for state
- API base: /api/v2/

# Bad: Excessive detail
- Complete API documentation (500 lines)
- Full component inventory
- Historical decisions log
Enter fullscreen mode Exit fullscreen mode

4. Use /compact when history bloats

If conversation history is the main consumer, the /compact command can summarize and reduce it while preserving essential context.

5. Start fresh for new tasks

Don't hesitate to begin a new session for unrelated tasks. Carrying irrelevant history is pure waste.


Real-World Use Case

You're deep into a debugging session. Claude's responses were great at first, but now they seem to miss obvious context you mentioned earlier. Frustrating.

You run /context:

Total Capacity:    200,000 tokens
Currently Used:    187,432 tokens (94%)
Available:          12,568 tokens
Enter fullscreen mode Exit fullscreen mode

Aha! You're nearly maxed out. The breakdown shows:

  • Conversation History: 142,000 tokens
  • Pending Files: 28,000 tokens (you loaded several large files)

Armed with this knowledge, you:

  1. Use /compact to summarize conversation history
  2. Close files you no longer need with /clear files
  3. Run /context again: now at 45% usage

Claude's responses immediately improve—it has room to think again.

Without /context, you'd have blamed the model. With it, you diagnosed and fixed the real problem in under a minute.


Conclusion

The /context command transforms token management from guesswork into science. It's the difference between driving with a fuel gauge and driving blind, hoping you don't run out.

Understanding your context consumption isn't just about avoiding limits—it's about optimization. Every unnecessary token is latency you didn't need, cost you didn't have to pay, and capacity you could have used for actual work.

Make /context a regular part of your Claude Code workflow. Your sessions will be more efficient, your responses will be more accurate, and you'll finally understand the true shape of your AI conversations.

Coming up tomorrow: What if you could start a task on your desktop and finish it on your laptop? Or kick off a long-running job and pick it up later? Day 9 introduces Claude Code Remote—seamless session mobility across devices. Your work, anywhere.


This is Day 8 of the "31 Days of Claude Code Features" series. Follow along to discover a new powerful feature every day.

Top comments (0)