Skip to content
Agentmart
Submit a tool

get-context

Report the current Claude Code session's context-window usage percentage, computed locally from the session JSONL usage metadata

Skill by koteitan

IndexedMIT★ 1
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/koteitan-get-context

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Report the current Claude Code session's context-window usage percentage, computed locally from the session JSONL usage metadata

Use cases: documents, agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/get-context

What's inside

Skill name
get-context
Description
Report the current Claude Code session's context-window usage percentage, computed locally from the session JSONL usage metadata
License
MIT
Instructions
50 lines in SKILL.md · view on GitHub

Files (4)

  • README-ja.md
  • README.md
  • SKILL.md
  • get-context · scripts/

SKILL.md (first lines)

# get-context

Print how much of the context window the current session is using, as a
percentage.

## When to invoke

- User asks how full the context is ("今どれくらいコンテキスト使ってる?",
  "context 残量", "how much context is left").
- Before a long task, to decide whether compaction is near.

## How to get it

Run the bundled script and report its stdout:

```bash
skills/get-context/scripts/get-context
```

It prints e.g. `12.4%`. For the raw token count too:

```bash
GET_CONTEXT_RAW=1 skills/get-context/scripts/get-context   # -> 12.4% (123977/1000000 tokens)
```

## How it works

1. Locate the current session JSONL strictly via `$CLAUDE_CODE_SESSION_ID`
   (`~/.claude/projects/**/<session-id>.jsonl`). If the variable is unset,
   exit with an error instead of guessing — picking the wrong session would be
   worse than failing.
2. Read the **last** `usage` field — the token metadata auto-attached to each
   assistant message. The latest entry reflects the whole conversation because
   the prior context is re-read from cache every turn.
3. `context_tokens = input + cache_creation + cache_read + output`, then
   `pct = context_tokens / CONTEXT_WINDOW * 100`.

## Env overrides

- `CONTEXT_WINDOW` — context window size in tokens (default `1000000`).
- `GET_CONTEXT_RAW` — set to `1` to also print the raw token count.

## Note

This is a local estimate from the session log, not the value Claude itself
sees. It matches the `/context` figure closely (e.g. 11.9% computed vs 12%
shown). The exact `context_window.used_percentage` is only available to the
status line via Claude Code's stdin payload, not to a standalone script.

From koteitan/my-skills, MIT.

More from koteitan/my-skills

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
May 20, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from koteitan

Cite this page

get-context skill. Agent Mart. https://agentmart.dev/skills/koteitan-get-context (last updated 2026-10-24)