Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

self-managed-context

Skill by muratcankoylan

Guides agents that get read-write control over their own live context window. It covers the editable context file, the harness safeguards that keep self-editing safe, and the prefix-cache cost of mid-context edits. Written for developers building model-managed context.

  • Score 94
  • 18k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install self-managed-context

Built from the published package, never by AI.

git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering /tmp/Agent-Skills-for-Context-Engineering && mkdir -p ~/.claude/skills && cp -r /tmp/Agent-Skills-for-Context-Engineering/skills/self-managed-context ~/.claude/skills/self-managed-context

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install self-managed-context in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

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, evicted, or rewritten in place. The reference implementation, Context Language Models, mirrors the editable part of the conversation into a file. The model edits that file with ordinary code tools, and the harness parses it back into the next prompt.

The skill describes the harness invariants that make self-editing safe. These include a pinned prefix, an edit gate, edit receipts, budget readouts, and rollback on overflow. It also covers how edit position affects prefix-cache cost, how models can be steered or trained on context editing, and when to use related skills instead. It is for developers designing self-managing context protocols.

Written from the project's SKILL.md and checked against it.

What it can do

  • Editable context fileRenders the editable part of the context to a file the model rewrites with code tools.
  • Pinned prefixKeeps system and task messages out of the file so the model cannot rewrite them.
  • Edit gateUses fit or shrink rules to reject edits that grow the context beyond the budget.
  • Edit receiptsReports each file-changing command as applied, grown, rejected, failed, or matched nothing.
  • Budget readoutsCounts tokens locally and shows the current size on every tool result.
  • Tiered nudgesSends low, mid, and near-limit fill prompts with different instructions for each tier.
  • Rollback on overflowRolls back the newest turns to free room for one compaction when the budget overflows.
  • Edit cost guidanceExplains how edit position affects prefix-cache reuse and advises batching edits.
  • Strategy steeringShows how one instruction sentence can set a compaction threshold or backup-before-edit rule.

Try asking

  • Set up an editable context file the model can rewrite in place
  • Add a pinned prefix and edit receipts to my self-managing agent
  • Design budget nudges that warn my agent before its context overflows

Good to know

  • Mid-context edits break prefix caching, and an early edit can cost more compute than it frees.
  • Models estimate their own context length poorly, so the harness must supply a budget readout.
  • A model-writable context can carry injected instructions, so the harness must guard it.
  • Gains depend on model capability. Smaller models edited less often and may need a harness-scheduled fallback.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: skills/self-managed-context/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

  • SKILL.md25 KB
  • references/evidence.md10 KB
  • references/harness-protocol.md12 KB

Alternatives to self-managed-context

All alternatives →

Compare with agent-reproduce-align, google_contacts or m06-error-handling

self-managed-context: common questions

What is self-managed context for an AI agent?

It is a design where the model, not the harness, decides what stays in its live context, what is compacted, and what is rewritten. The source calls the reference implementation Context Language Models.

Why does editing context affect cost?

Prefix caching reuses computation only up to the first changed token. An edit forces everything after it to be processed again, so its cost scales with the text that follows.

Which skill handles fixed-threshold summarization?

The source routes replacement-note content and fixed-threshold summarization to the context-compression skill, not to this one.

How do I install self-managed-context?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is self-managed-context free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is self-managed-context safe to use?

It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to self-managed-context?

Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.

self-managed-context Install

Add to stack

Loading.