[BUG] claude-api reinvocation duplicates ~350K-token payload; later turns read ~778K and force >1M compaction

Status Open
Reported on v2.1.224
Maintainer reply None cached
Activity 0 comments · opened Aug 15, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Summary

The bundled claude-api skill can add roughly 350K cache-creation tokens to a Claude Code session in a single invocation.

If it is invoked again in the same session, another similarly large payload is added, after which ordinary follow-up turns can read roughly 778K cached input tokens per request.

In the captured session this eventually pushed the conversation above 1,000,000 tokens and triggered auto-compaction.

This is particularly costly on Max-plan rolling usage limits because the skill load is not merely a one-time event: once inserted into conversation history, the payload becomes part of subsequent requests. Reinvocation can add another large copy.

This report is related to the existing oversized / over-triggering claude-api issues, but focuses specifically on same-session reinvocation, duplicated large payloads, and the resulting repeated cache-read amplification.

Environment

  • Claude Code: 2.1.224
  • OS: Windows
  • Model: claude-opus-5
  • Context: Opus 5 1M
  • Plan: Max
  • Entrypoint: CLI

A second Max user on a separate machine has also independently observed the same sudden rapid-usage behavior.

Observed sequence from the session transcript

1. Claude automatically invokes claude-api

The user did not initially type /claude-api.

Claude was investigating a Claude Code usage question and autonomously decided to invoke the skill:

{
  "type": "tool_use",
  "name": "Skill",
  "input": {
    "skill": "claude-api",
    "args": "1M context window pricing multiplier and plan limit consumption for Opus"
  }
}

### What Should Happen?

Claude code should NOT invoke /claude-api skill itself, which then recursively invokes the same skill again, destroying the context window and the user's session usage

Expected behavior
Loading a bundled knowledge/reference skill should use progressive disclosure rather than inserting hundreds of thousands of tokens into the main conversation.
If an identical skill has already been loaded in the current session, invoking it again should not append another full copy of the same large reference material.
A product / usage question that happens to mention Claude or Opus should not cause an API-development skill to inject a massive SDK reference unless that reference is genuinely needed.
Large knowledge-skill payloads should not silently raise the context/token floor of every subsequent request by hundreds of thousands of tokens.
Ideally, already-consumed reference-skill content should be evictable or isolated from the main conversation rather than remaining in every later turn.

### Error Messages/Logs

```shell

Steps to Reproduce

Prompting anything caused this issue. But to be clear:

  1. Use Claude Code 2.1.224 with Opus 5 / 1M context.
  1. Start a fresh Claude Code session.
  1. Ask a Claude Code product/usage question that causes Claude to automatically invoke the bundled claude-api skill. For example:

"Does the 1M context window affect Opus 5 usage limits or pricing?"

  1. Observe Claude invoking:

Skill(claude-api)

  1. Inspect the session JSONL at:

~/.claude/projects/.../<session-id>.jsonl

On the request immediately following the skill load, observe a very large increase in cache_creation_input_tokens.

In my reproduction:

cache_creation_input_tokens: 349649

  1. Continue the same conversation for one or two turns.
  1. Invoke /claude-api again in the same session, or cause Claude to invoke the skill a second time.
  1. Inspect the JSONL again. In my reproduction the second invocation produced:

cache_creation_input_tokens: 350803
cache_read_input_tokens: 427739

  1. Send another ordinary follow-up message that does not require the Claude API documentation.
  1. Observe that the request now carries an extremely large cached history. In my reproduction:

cache_read_input_tokens: 778542

  1. Continue the conversation.
  1. Observe Claude Code eventually auto-compacting the session after exceeding the 1M context window:

preTokens: 1016824
postTokens: 250888
cumulativeDroppedTokens: 765936

Expected

Repeated invocation of the same bundled skill should not append another hundreds-of-thousands-token copy of substantially identical reference documentation. Subsequent ordinary turns should not need to process ~778K cached tokens because the same reference skill was loaded multiple times.

Actual

Each invocation can add roughly 350K cache-creation tokens. Reinvoking the skill in the same session causes context to grow dramatically, subsequent requests read hundreds of thousands of cached tokens, and the session can exceed 1M tokens and trigger forced compaction.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

unkown

Claude Code Version

2.1.224 to latest

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

PowerShell

Additional Information

_No response_

View original on GitHub ↗