self-managed-context

self-managed-context is a skill for Claude Code from muratcankoylan/Agent-Skills-for-Context-Engineering. It costs 149 tokens per session (5,042 once invoked), scanned A, original, MIT.

A method for an AI agent to manage its own working conversation by editing, keeping, or removing information in a file. It replaces an automatic system decision about when to shorten the conversation.

In plain words
What is it for?
Use it when designing or evaluating agents that work across long research, coding, or repository tasks and need to retain selected information while removing other parts.
Why use it?
It gives the agent control over what context remains during long tasks. It also addresses the risks of a full conversation, costly edits, and information being stored in a model-writable file.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions subagents.

Part of the context-engineering plugin — 18 skills shipped together

Good fit Use it when designing or evaluating agents that work across long research, coding, or repository tasks and need to retain selected information while removing other parts.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/muratcankoylan/agent-skills-for-context-engineering/self-managed-context
About the project

Agent Skills for Context Engineering is a collection of reusable instructions that teach AI agents how to manage their context, coordinate multi-agent systems, and evaluate behavior. Developers use it when building or debugging production agent systems, and the catalogue entries are skills, agents, instructions, and a plugin from this collection.

muratcankoylan/Agent-Skills-for-Context-Engineering · 18,180 stars · on GitHub

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 muratcankoylan/Agent-Skills-for-Context-Engineering --skill self-managed-context
Clone the repo
git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering

Made for: Claude Code.

Or install context-engineering, the plugin that ships this one along with the rest of its 18 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 self-managed-context

README.md
[![agentmods](https://agentmods.dev/badge/skills/muratcankoylan/agent-skills-for-context-engineering/self-managed-context/github.svg)](https://agentmods.dev/skills/muratcankoylan/agent-skills-for-context-engineering/self-managed-context)
Your own site
<a href="https://agentmods.dev/skills/muratcankoylan/agent-skills-for-context-engineering/self-managed-context"><img src="https://agentmods.dev/badge/skills/muratcankoylan/agent-skills-for-context-engineering/self-managed-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 self-managed-context

Your own site · 80×15
<a href="https://agentmods.dev/skills/muratcankoylan/agent-skills-for-context-engineering/self-managed-context"><img src="https://agentmods.dev/badge/skills/muratcankoylan/agent-skills-for-context-engineering/self-managed-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 149 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,042 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.00149 $0.05042
Opus 5.5 $0.00060 $0.02017
Sonnet 5.5 $0.00030 $0.01008
Haiku 4.5 $0.00015 $0.00504

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

Security

Grade A, and why

self-managed-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 19d 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.

Origin

Copies of this mod

2 near-identical copies found in the catalogue:

skills/self-managed-context/SKILL.md · 277 lines

How it starts

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

Self-Managed Context

This skill covers agents that manage their own context window: the model, not the harness, decides what stays in the live context, what is compacted, what is evicted, and what is rewritten in place. The reference implementation is Context Language Models (CLMs), which mirror the editable part of the conversation into a file that the model edits with ordinary code tools, then re-parse that file into the next prompt. Applied zero-shot to existing models on a shared agent backbone, this matched or beat harness-scheduled and action-based context management on accuracy and compute across deep-research, terminal-coding, and multi-hour repository-optimization tasks (claim-self-managed-context-zero-shot-results, claim-self-managed-context-long-horizon-results).

The controlling trade-off: model control buys adaptivity (verbatim retention, surgical in-place updates, eviction on demand) and creates three problems the harness must absorb. Edits break prefix caching, so a badly placed edit can cost more compute than the tokens it frees. Models do not know how full their context is. And a model-writable context is a persistence channel for whatever the model writes into it, including instructions. Most of this skill is the harness contract that makes the first property worth the other three.

When to Activate

Activate this skill when:

  • Giving a model write access to its own live context instead of compacting on a fixed schedule
  • Designing a context-as-a-file protocol: turn headers, parse-back, pinned prefix, edit receipts
  • An agent must keep exact values, update state in place, or evict offloaded material, and fixed summarization loses or duplicates it
  • Pricing mid-context edits under prefix caching, or evaluating suffix cache reuse
  • Budget readouts, tiered nudges, or rollback for an agent that times its own compaction
  • Steering, evolving, or training a model's context-editing strategy
  • Diagnosing a self-editing agent that never edits, wipes useful state, livelocks after overflow, or carries injected instructions in its own notes

Read the full file on GitHub · 277 lines

Files

What ships with it

2 files 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. 19d ago First seen · 277 lines · 149 tokens per session scan A 0b077da6d772

Subscribe to this mod's changes

self-managed-context is a skill published in the GitHub repository muratcankoylan/Agent-Skills-for-Context-Engineering (18,180 stars, last pushed 9d ago), licensed MIT. It adds 149 tokens to every session and 5,042 once invoked, about $0.0006 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-10-02.

Related

Other skills, from other repositories

mem0-oss-to-platform

Plan, then execute, a migration of a project from the mem0 open-source / self-hosted SDK (local Memory class) to the mem0 Platform / hosted SDK (MemoryClient). TRIGGER when: the developer wants to move, switch, or migrate mem0 off OSS/self-hosted to the hosted API, e.g. "migrate my mem0 setup to the platform", "switch…

mem0ai/mem0 · 217 tokens

forget

Remove a personal fact, preference, relationship detail, topic, or prior event from Muse's active memory and stop existing copies or automations from bringing it back. Use for explicit requests such as 'forget that', 'don't remember this about me', or 'remove that from your memory'. Do not use when 'forget it' merely…

asgeirtj/system_prompts_leaks · 74 tokens

Cortex

Operate Cortex, the LifeOS memory system — the typed Knowledge Archive (People, Companies, Ideas, Research with typed related: links) plus recall of prior work sessions, ISAs, and conversations. Search, add, harvest, develop, ingest, distill, graph-navigate, recall. USE WHEN cortex, knowledge, knowledge base, search…

danielmiessler/LifeOS · 196 tokens

memory

Use when the user asks to remember, recall, forget, update, search, or inspect durable OpenSquilla memory, including profile facts in USER.md and long-term notes in MEMORY.md or memory//.md.

opensquilla/opensquilla · 44 tokens

ha-data-stores

Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger…

shiwenwen/hope-agent · 115 tokens

establishing-project-context

Use when the user asks to establish shared project language, or project work exposes a conflicting, renamed, or deprecated domain term that needs active semantic modeling. Routine small tasks stay on the fast path.

GanyuanRan/Aegis · 45 tokens