context-guard
Skill1 starsChanged 13 days agoMITView on GitHub
Monitor Codex context window and token usage, suggest new chats for context rot, and create, validate, check or resume session handoffs.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- CorvusWing/CorvusWingtheir own version, first seen Oct 25, 2026
- freema/ai-skillstheir own version, first seen Oct 13, 2026
- iAstroUnicorn/astro-skillstheir own version, first seen Jul 29, 2026
- littlebearapps/contextdocstheir own version, first seen May 6, 2026
- shivae372/claude-bootstraptheir own version, first seen Apr 8, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- freema/ai-skills★ 5same name
- littlebearapps/contextdocs★ 5same name
- CorvusWing/CorvusWing★ 1same name
- shivae372/claude-bootstrap★ 1same name
- iAstroUnicorn/astro-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- llms.txtllms.txt
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Keep long work restartable without interrupting unfinished operations.
- Distinctive: line 29
If a fresh chat already exceeds the budgets because of fixed instructions or required source material, suggest reducing that fixed payload …
- Distinctive: line 39
Read only the latest relevant brief when resuming, then verify live files and repository state.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Guard
Keep long work restartable without interrupting unfinished operations. This skill provides turn-time checks, not a background alarm or automatic chat switching.
Check
At the start of substantive work, after unusually large tool output, or at a major task boundary, run the bundled script using its absolute installed path:
python <skill-dir>/scripts/check_context.pyIt uses CODEX_THREAD_ID (or CODEX_SESSION_ID) to locate only this session under $CODEX_HOME/sessions / ~/.codex/sessions. It emits small JSON, never the transcript. Do not read entire logs or choose the newest session across unrelated chats. If local telemetry is unavailable, use task-boundary judgment and say usage is unknown; do not invent a percentage.
last_input_percent is the last reported request's input tokens divided by its reported context window, rounded. It is a proxy, not a live meter, quality score, bill, or cumulative session total. Cached tokens still occupy context. Stale or malformed telemetry must not trigger a numeric alarm.
Default policy (workflow preferences, not measured quality limits): the watch level is reached at 35% OR 128,000 input tokens; the high level at 50% OR 192,000 input tokens. Either condition suffices. Budgets use decimal tokens and can be disabled with --warn-tokens 0 --urgent-tokens 0. For evidence and limitations, read references/context-quality.md only when explaining or calibrating thresholds.
- At the normal level: continue without mentioning the check.
- At the watch level: if
should_notify, briefly recommend wrapping the current phase and preparing a handoff. - At the high level: if
should_notify, recommend a fresh chat after the next safe stopping point and prepare the handoff for substantial unfinished work. - A separate project or independent major objective is a fresh-chat boundary even below those percentages. A small related follow-up is not.
- Repeated loss of accepted requirements or a large backlog of superseded attempts can justify an earlier suggestion; identify the observed reason, not an invented usage figure.
- If a fresh chat already exceeds the budgets because of fixed instructions or required source material, suggest reducing that fixed payload or configuring task-specific budgets. Do not send the user into repeated restarts that cannot remove it.
Finish the current safe unit first. Never cancel a render, deployment, download, edit, or ongoing task merely to switch chats. If the user chooses to continue, keep working. A warning is advisory, not a permission gate.
After actually giving a numeric reminder, run the same check with --record to suppress repeats at that level. Re-check before recording; if usage changed, use the returned result. State is local, session-specific metadata. Compaction or a large input drop permits a new reminder. Do not acknowledge reminders silently without telling the user.
Handoff and resume
When a new chat would help, or the user asks to save/resume state, read references/handoff.md. The bundled scripts/handoff.py provides create, list, validate, check, and resume. Use it for substantial file-based handoffs; a small task can use a brief directly in chat. It supports non-Git work, selected artifact hashes, Git metadata, lineage pointers, and secret/placeholder checks. Validation is structural, not proof of truth or secret-free content. Save UTF-8 files under the project's .codex/handoffs/ only when creation is authorized. Link the file and give a paste-ready new-chat prompt.
Read only the latest relevant brief when resuming, then verify live files and repository state. Use older records only for a specific missing detail. Do not re-import the whole conversation or every prior handoff. Do not treat a brief as authorization for new external actions.
The script requires Python 3.10+ and uses the standard library only. A short global AGENTS.md routing rule is needed for regular checks; skill discovery alone does not guarantee checks on every turn. Local JSONL telemetry is an implementation detail and can change. Without it, the qualitative handoff workflow still works.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

