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.
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-contextRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering /tmp/Agent-Skills-for-Context-Engineering && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/Agent-Skills-for-Context-Engineering/skills/self-managed-context ~/.gemini/antigravity-cli/skills/self-managed-contextAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install self-managed-context in Antigravity CLI
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
ANo 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 →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
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.
