long-context

long-context is a skill for Claude Code from latestaiagents/agent-skills. It costs 129 tokens per session (1,479 once invoked), scanned A, original, MIT.

A guide to working with very large amounts of text, code, or conversation history in Claude. It covers context windows, which are the limits on how much input a model can handle at once, along with token counting, caching, and ways to shorten growing conversations.

In plain words
What is it for?
Use it for whole-repository reviews, cross-document questions, long-running agents, and deciding between a large context window and RAG, a method that retrieves relevant passages from stored documents.
Why use it?
Sending more information does not always make answers cheaper or more accurate, and long conversations can outgrow the model's limit. This helps you decide what to include and when to use retrieval instead.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the messages-api-features plugin — 7 skills shipped together , and of latestaiagents

Good fit Use it for whole-repository reviews, cross-document questions, long-running agents, and deciding between a large context window and RAG, a method that retrieves relevant passages from stored documents.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/latestaiagents/agent-skills/long-context
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.

Any agent
npx skills add latestaiagents/agent-skills --skill long-context
Clone the repo
git clone --depth 1 https://github.com/latestaiagents/agent-skills

Made for: Claude Code.

Or install messages-api-features, the plugin that ships this one along with the rest of its 7 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for long-context

README.md
[![agentmods](https://agentmods.dev/badge/skills/latestaiagents/agent-skills/long-context/github.svg)](https://agentmods.dev/skills/latestaiagents/agent-skills/long-context)
Your own site
<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/long-context"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/long-context/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for long-context

Your own site · 80×15
<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/long-context"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/long-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 129 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,479 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00129 $0.01479
Opus 5.5 $0.00052 $0.00592
Sonnet 5.5 $0.00026 $0.00296
Haiku 4.5 $0.00013 $0.00148

Measured 26d ago against content hash 6726a3f1ae8c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

long-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 26d ago.

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.

skills/messages-api-features/long-context/SKILL.md · 133 lines

How it starts

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

Long Context

A large context window lets you send a lot; it does not make sending a lot free or accurate. Count first, structure the input, cache what repeats, and actively manage context as it grows.

When to Use

  • Cross-document reasoning over a corpus that fits in the window
  • Whole-repository review or refactoring where relevance is hard to predict
  • Long-running agents whose history keeps growing
  • Deciding between long context, retrieval (RAG), or both

Workflow

Step 1: Check the window for your model

Context window size depends on the model. The docs list which current models have a 1M-token window and which have 200K, and state that for models with a 1M window, 1M is the default with no beta header. Older guidance that required a context-1m-... beta header applies only to the models it was written for.

Do not hard-code the number. Read it at runtime:

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();
const MODEL = process.env.ANTHROPIC_MODEL!; // a current model ID

const info = await client.models.retrieve(MODEL);
console.log(info.max_input_tokens, info.max_tokens); // context window, output cap

Pricing for very long prompts also varies by model; check the pricing page's long-context section rather than assuming a flat rate.

Step 2: Count tokens before you send

const { input_tokens } = await client.messages.countTokens({
  model: MODEL,
  system,
  messages,
});
if (input_tokens > info.max_input_tokens! * 0.9) {
  // trim, retrieve instead, or compact first
}

Everything counts: system prompt, every message (tool results, images, documents), tool definitions, and the output including thinking. If the input alone exceeds the window, the API returns 400 invalid_request_error ("prompt is too long"). On recent models, if input plus max_tokens would exceed the window, the request is accepted and generation can stop with stop_reason: "model_context_window_exceeded"; handle that stop reason.

Read the full file on GitHub · 133 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. 26d ago First seen · 133 lines · 129 tokens per session scan A 6726a3f1ae8c

Subscribe to this mod's changes

long-context is a skill published in the GitHub repository latestaiagents/agent-skills (6 stars, last pushed 26d ago), licensed MIT. It adds 129 tokens to every session and 1,479 once invoked, about $0.0005 per session on Opus 5.5. 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-11-04.

Related

long-context compared with skills from other repositories

long-context next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
long-contextlatestaiagents/agent-skillsSkill626d agoMITA129Claude Code
agent-v3-memory-specialistruvnet/rufloSkill83ktodayMITA25Claude Code
mem0-integrationa5c-ai/babysitterSkill1.9k28d agoMITA27Claude Code
vector-memorya5c-ai/babysitterSkill1.9k28d agoMITA31Claude Code
embeddingsruvnet/rufloSkill83ktodayMITA62Claude Code
install-openviking-memoryvolcengine/OpenVikingSkill43ktodayAGPL-3.0A191Claude Code, Codex
rag-hybrid-searcha5c-ai/babysitterSkill1.9k28d agoMITA28Claude Code