Skip to main content
commandsSource-backedReview first Safety Privacy

Inspect Claude Code Context Usage with /context

Use the built-in /context command to inspect Claude Code's context-window usage, plus a custom .claude/commands recipe for repeatable codebase-context analysis before refactors.

by JSONbored·added 2025-10-25·
HarnessClaude Code
Invocation:/context
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Source URLs
https://code.claude.com/docs/en/context-window, https://github.com/JSONbored/awesome-claude/blob/main/content/commands/context-analyzer.mdx
Safety notes
The custom /analyze-context command makes Claude read files across your repository; scope it with a path argument to limit how much is pulled into context., Analysis output reflects Claude's reading of the code in that session, not a deterministic static-analysis tool — verify any load-bearing metrics or recommendations against the actual source.
Privacy notes
Both /context and a custom analysis command operate on whatever files and project memory are loaded in the session; no data leaves your machine beyond the normal Claude Code model request, but file contents you ask Claude to read become part of the conversation context sent to the model.
Author
JSONbored
Claim status
unclaimed
Last verified
2025-10-25

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

78

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Complete

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    Registry metadata indicates a reviewed listing.

    Done

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

Copy & paste

Copy-ready — paste the snippet to get started.

Install command

Not provided

Config snippet

Not provided

Copy snippet

Provided

Prerequisites

None

Platforms

1 listed

Difficulty

100/100

Adoption plan

Balanced adoption plan

Current risk score 16/100. Use staged verification before broader rollout.

Risk 16

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    Listing has review metadata.

    Done
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Required evidence gates are covered (5/6 signals complete).

Risk 15

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Present

Review metadata is present.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required evidence gates are covered for this preset.

Decision timeline

Decision timeline · balanced

5/6 steps complete with no blocking gaps for this preset.

Risk 14

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is available.

Done

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

No required blockers for this timeline preset.

Safety & privacy surface

Safety & privacy surface

2 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.

2 areas
  • SafetyPermissions & scopesThe custom /analyze-context command makes Claude read files across your repository; scope it with a path argument to limit how much is pulled into context.
  • SafetyCredentials & tokensAnalysis output reflects Claude's reading of the code in that session, not a deterministic static-analysis tool — verify any load-bearing metrics or recommendations against the actual source.
  • PrivacyCredentials & tokensBoth /context and a custom analysis command operate on whatever files and project memory are loaded in the session; no data leaves your machine beyond the normal Claude Code model request, but file contents you ask Claude to read become part of the conversation context sent to the model.

Safety notes

  • The custom /analyze-context command makes Claude read files across your repository; scope it with a path argument to limit how much is pulled into context.
  • Analysis output reflects Claude's reading of the code in that session, not a deterministic static-analysis tool — verify any load-bearing metrics or recommendations against the actual source.

Privacy notes

  • Both /context and a custom analysis command operate on whatever files and project memory are loaded in the session; no data leaves your machine beyond the normal Claude Code model request, but file contents you ask Claude to read become part of the conversation context sent to the model.

Schema details

Install type
copy
Reading time
8 min
Difficulty score
100
Troubleshooting
Yes
Breaking changes
No
Skill and platform metadata
Retrieval sources
https://code.claude.com/docs/en/context-windowhttps://code.claude.com/docs/en/slash-commandshttps://code.claude.com/docs/en/common-workflows
Runtime and command metadata
Command syntax
/context
Full copyable content
/context

About this resource

Claude Code gives you two practical ways to understand what is filling your context window and to gather codebase context before a big change:

  1. The built-in /context command, for inspecting Claude Code's context window.
  2. A custom /analyze-context command you create yourself, for repeatable codebase analysis before a refactor or feature.

The built-in /context command

/context shows a live breakdown of what is currently filling your context window, grouped by category, along with optimization suggestions. It takes no arguments or flags.

/context

It accounts for the things that consume the window, including:

  • System prompt — the always-loaded core instructions (you never see these directly).
  • CLAUDE.md / memory — project and user memory files loaded at startup. Use /memory to see exactly which files loaded.
  • MCP tools — tool names (and, depending on ENABLE_TOOL_SEARCH, schemas) from connected MCP servers.
  • Skill / command listings — one-line descriptions of skills Claude can invoke.
  • Conversation messages and file reads — your prompts, Claude's responses, and the contents of files Claude has read (file reads typically dominate usage).

Use it when responses start to feel sluggish, when you are deciding whether to run /compact or /clear, or when you want to understand why a session is approaching its limit. For the underlying model of how the window fills and compacts, see the context window documentation.

Related built-ins

  • /compact — summarizes the conversation to free space while preserving startup content (CLAUDE.md, memory, MCP tools reload automatically; the skill listing is the one exception). Claude Code also compacts automatically as you approach the limit.
  • /clear — resets the conversation.
  • /memory — shows which CLAUDE.md and auto-memory files loaded at startup.

Building a custom codebase-analysis command

Claude Code does not ship a command that auto-generates architecture reports, dependency graphs, or quality metrics. You can, however, create your own custom slash command that asks Claude to analyze a codebase the same way every time. Custom commands are user-created Markdown files — they are not built-in, and the quality of the output depends entirely on the prompt you write and what Claude can read in your repo.

Create a file at .claude/commands/analyze-context.md (project-scoped) or ~/.claude/commands/analyze-context.md (personal). The file name becomes the command name, so this file creates /analyze-context. Custom commands have merged into skills; a file under .claude/commands/ still works and supports the same frontmatter, while skills add optional features like supporting files and automatic invocation.

---
description: Analyze the architecture, patterns, and dependencies of a codebase area
argument-hint: [path]
---

Analyze the code under `$ARGUMENTS` (default to the repo root if empty).

Read the relevant files and report:
1. Tech stack and frameworks actually present (cite package manifests).
2. The architecture / layering you observe, with key directories.
3. Recurring patterns and conventions, with file references.
4. Internal coupling and any obvious refactor risks.
5. Where tests exist and where coverage looks thin.

Cite real files and line ranges. Do not invent metrics or numbers
you cannot derive from the code you actually read.

Invoke it with an optional path:

/analyze-context src/auth

The $ARGUMENTS placeholder is replaced with everything you type after the command name. You can also target a single argument with $0/$ARGUMENTS[0], or declare named arguments in frontmatter. See the arguments reference for the full substitution rules.

When to use which

  • Reach for /context to understand and manage token usage in the current session.
  • Reach for a custom /analyze-context command when you want a consistent, repeatable codebase walk-through before a refactor, when onboarding to an unfamiliar area, or before scoping a large change.

Because the custom command is just a prompt, its findings are Claude's reading of your code in that session — not a deterministic static-analysis tool. Treat metrics and recommendations it produces as Claude's assessment, and verify anything load-bearing against the actual source.

Source citations

Add this badge to your README

Show that Inspect Claude Code Context Usage with /context is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/commands/context-analyzer.svg)](https://heyclau.de/entry/commands/context-analyzer)

How it compares

Inspect Claude Code Context Usage with /context side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

Next steps differ across entries — use the actions in the table below to copy install commands and source links per resource.

Field

Use the built-in /context command to inspect Claude Code's context-window usage, plus a custom .claude/commands recipe for repeatable codebase-context analysis before refactors.

Open dossier

A user-created custom slash command that runs a red-green-refactor TDD loop in Claude Code: write failing tests first, implement until they pass, then refactor. Built with the documented custom-command frontmatter and $ARGUMENTS substitution, not a built-in feature.

Open dossier

A user-created custom slash command for Claude Code that turns a file or function into a test suite. You create .claude/commands/generate-tests.md and invoke it with /generate-tests; it is a prompt recipe, not a built-in command, and uses no CLI flags.

Open dossier

Intelligent code refactoring command that analyzes code structure and applies best practices for improved maintainability and performance

Open dossier
Next stepsDiffers
Trust
Review statusReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceSource-backedSource-backedSource-backedSource-backed
Submitter
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Brand
Categorycommandscommandscommandscommands
Sourcesource-backedsource-backedsource-backedsource-backed
AuthorJSONboredJSONboredJSONboredJSONbored
Added2025-10-252025-10-252025-09-162025-09-16
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesThe custom /analyze-context command makes Claude read files across your repository; scope it with a path argument to limit how much is pulled into context. Analysis output reflects Claude's reading of the code in that session, not a deterministic static-analysis tool — verify any load-bearing metrics or recommendations against the actual source.The base recipe does not pre-approve Bash commands. Review the project's test scripts first, then approve the exact test command when Claude Code prompts or add a narrowly scoped command only after you trust it. Claude may create and edit test and source files as part of the loop (Read/Edit/Write). Run it in version control so changes are reviewable and reversible. If you extend the prompt with auto-commit or deploy steps, add explicit safety review; the base recipe does not commit or push.The recipe asks Claude to run the test suite, which executes project code and test commands locally; review the source and tests before running, especially in an unfamiliar repository. If you add an allowed-tools field (e.g. Bash(npm test:*)), Claude can run those tool calls without a per-use permission prompt while the command is active. Scope it narrowly. Project-level .claude/commands files are shared via git and run for anyone who trusts the workspace; treat a checked-in command as executable content and review it before trusting the repo.Review generated changes and commands before applying them; slash commands can ask the agent to read, write, edit, or run tools in the current project. Limit scope to the intended files and run in a trusted checkout when the command analyzes code, tests, security findings, or generated output.
Privacy notesBoth /context and a custom analysis command operate on whatever files and project memory are loaded in the session; no data leaves your machine beyond the normal Claude Code model request, but file contents you ask Claude to read become part of the conversation context sent to the model.The command body can read project files via @ references and !`command` injection if you add them; only reference files you are comfortable sending to the model as prompt context. The base recipe asks you to inspect project test scripts instead of injecting package.json automatically.Dynamic-injection lines (!`...`) and @file references send the output of shell commands and the contents of referenced files into the model context; avoid pointing them at files containing secrets, credentials, or other sensitive data.Prompts, source files, logs, errors, dependency metadata, and generated reports may be sent to the configured AI model during command execution. Redact secrets, customer data, private repository details, and proprietary code before sharing command output outside the workspace.
Prerequisites— none listed— none listed— none listed— none listed
Install
/refactor [options] <file_or_selection>
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Related guides

Signals

Loading live community signals…

More like this, weekly

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