context-optimization

context-optimization is a skill for Claude Code from atretyak1985/swarmery. It costs 38 tokens per session (841 once invoked), scanned A, original, Apache-2.0.

A context-management plan for coding tasks that touch at least three files or more than one repository. It decides what to inspect, in what order, and when to clear no-longer-needed context.

In plain words
What is it for?
It is for planning repository discovery, focused file reads, phase boundaries, and delegation during larger coding tasks.
Why use it?
It prevents unnecessary file loading from using up the agent's working context and makes multi-file work easier to manage.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions subagents.

Part of the core plugin — 37 skills, 8 commands, 13 agents shipped together

Good fit It is for planning repository discovery, focused file reads, phase boundaries, and delegation during larger coding tasks.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/atretyak1985/swarmery/context-optimization
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 atretyak1985/swarmery --skill context-optimization
Clone the repo
git clone --depth 1 https://github.com/atretyak1985/swarmery

Made for: Claude Code.

Or install core, the plugin that ships this one along with the rest of its 37 skills, 8 commands, 13 agents.

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 context-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/atretyak1985/swarmery/context-optimization/github.svg)](https://agentmods.dev/skills/atretyak1985/swarmery/context-optimization)
Your own site
<a href="https://agentmods.dev/skills/atretyak1985/swarmery/context-optimization"><img src="https://agentmods.dev/badge/skills/atretyak1985/swarmery/context-optimization/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 context-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/atretyak1985/swarmery/context-optimization"><img src="https://agentmods.dev/badge/skills/atretyak1985/swarmery/context-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 841 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.00038 $0.00841
Opus 5.5 $0.00015 $0.00336
Sonnet 5.5 $0.00008 $0.00168
Haiku 4.5 $0.00004 $0.00084

Measured 1mo ago against content hash f76dee09cae2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

context-optimization 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 1mo 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.

plugins/core/skills/context-optimization/SKILL.md · 84 lines

How it starts

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

Purpose

Plan what to read before reading it. On a task spanning several files or repos, turn "open everything and hope" into a short ordered context plan: which files, which line ranges, in which phase, and where to /clear between them. It changes no code — it governs loading so the skills that do the work keep room to think.

Rules (never violate)

  1. Run codebase-retrieval before any full-file read; discovery precedes loading.
  2. Read with offset/limit — never whole files when one function is the target.
  3. Keep files loaded ≤ 3× files actually edited; record the ratio in the plan.
  4. Suggest /clear at every repo switch and at every phase boundary that frees files.
  5. At ≥40% window usage, delegate any isolatable read (one whose product is a digest) to a leaf subagent at depth-1 — never leaf → leaf.
  6. Confidence LOW after discovery means stop and ask, not a plan you half-trust.

Resources

  • Read resources/planning-procedure.md before planning: the 7-step procedure, the repo/glob map, the step-7 delegation decision table (40% / 60% thresholds), the plan template, self-check, escalation triggers, failure modes, and a worked two-phase example.

How to use

What it does

Produces a context plan: targeted reads in phases, /clear decisions with reasons, and a loaded-versus-edited budget with a confidence rating. It runs discovery first, so the plan names real files rather than guesses.

When to use it

  • The task touches 3 or more files, in one repo or across several.
  • The task crosses a repo boundary — apps/<mainApp> plus <device>, say.
  • Your window is already past 40% and more reads are coming.
  • You are about to load a large module tree just to extract a verdict or a list.

Not for: single-file edits (just make them); a read-only question about one function (code-search); or work already running inside a scoped subagent — that isolation is what this skill would have bought you.

How to invoke

Skill(skill: "core:context-optimization")
Task: fix telemetry latency between the device/edge repo and the main app
Repos: apps/<mainApp>, <device>

Read the full file on GitHub · 84 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 1mo ago First seen · 84 lines · 38 tokens per session scan A f76dee09cae2

Subscribe to this mod's changes

context-optimization is a skill published in the GitHub repository atretyak1985/swarmery (7 stars, last pushed today), licensed Apache-2.0. It adds 38 tokens to every session and 841 once invoked, about $0.0002 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-09-03.