context-surgeon
Skill0 starsChanged 4 months agoMITView on GitHub
Continuous budget-aware context policy for agentloop. Use on long runs, before/after heavy tool bursts, when approaching context limits, at slice boundaries, and whenever handoff continuity matters. Not an occasional cleanup — this is harness policy.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- SAY-5/context-surgeontheir own version, first seen Apr 17, 2026
- Feli2arias/context-surgeontheir own version, first seen Apr 7, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- Feli2arias/context-surgeon★ 0same name
- SAY-5/context-surgeon★ 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 repository138 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/context-budget.mdcCursor rule
- .cursor/rules/delegation-law.mdcCursor rule
- .cursor/rules/harness-doctrine.mdcCursor rule
- .cursor/rules/verification-law.mdcCursor rule
- agent-interface-designSkill
- agentloop-coreSkill
- agent-loopSkill
- blindspot-passSkill
- brainstorm-prototypesSkill
- change-quizSkill
- conductor-planSkill
- context-auditSkill
- context-compactSkill
- contrastingSkill
- deployment-auditSkill
- doctorSkill
- harness-designSkill
- humaniseSkill
- implementation-notesSkill
- implementation-planSkill
- interview-meSkill
- no-ai-slopSkill
- optional-ponytailSkill
- opus-promptingSkill
- persistent-memorySkill
- pev-cycleSkill
- pitch-packagerSkill
- progressive-disclosureSkill
- quality-composeSkill
- reference-huntSkill
- seo-copywritingSkill
- ship-gateSkill
- subagent-swarmSkill
- ui-ux-auditSkill
- warroom-councilSkill
- writer-verifierSkill
- agent-interface-designSkill
- agentloop-coreSkill
- agent-loopSkill
- blindspot-passSkill
- brainstorm-prototypesSkill
- change-quizSkill
- conductor-planSkill
- context-auditSkill
- context-compactSkill
- context-surgeonSkill
- contrastingSkill
- deployment-auditSkill
- doctorSkill
- harness-designSkill
- humaniseSkill
- implementation-notesSkill
- implementation-planSkill
- interview-meSkill
- no-ai-slopSkill
- optional-ponytailSkill
- opus-promptingSkill
- persistent-memorySkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Prefer file-backed state (.agentloop/*) over chat archaeology.
- Distinctive: line 29
Keep failing gate logs verbatim
- Distinctive: line 31
Never compact away the current failing test/lint output.
- Distinctive: line 32
Keep always-on instructions short.
- Very specific: line 37
Read .agentloop/stop.yaml when present.
- Very specific: line 44
If stop.yaml is missing on a multi-step task, create it from templates/.agentloop/stop.yaml before continuing heavy work.
- Very specific: line 67
Before discarding chat detail that encodes a decision/preference/lesson, upsert or supersede it into native memory, then compact.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Surgeon (policy)
Context management is continuous and budget-aware. Do not wait for the window to explode.
Always-on triggers (run compact / handoff when any fire)
| Trigger | Action |
| Slice complete (PEV) | Update .agentloop/plan.md progress; refresh .agentloop/handoff.md |
| External gate failure captured | Keep failing log verbatim; compact prior successful tool noise |
| ~40%+ of host context used (or host warns) | Staged compact via context-compact |
Turn count hits 50% of max_turns | Mid-run handoff + progress summary |
| Switching mode (PEV ↔ warroom ↔ swarm) | Full handoff artifact before switch |
| User says “continue later” / session end | Write .agentloop/handoff.md (required); upsert durable facts via scripts/memory.sh |
| Swarm worker returns | Fold structured return into plan; drop raw worker chat |
| Durable decision extracted mid-run | scripts/memory.sh upsert (or supersede); add key to handoff memory_keys |
Policy loop
- Prefer file-backed state (
.agentloop/*) over chat archaeology. - Compact in stages (see
context-compact):- Drop raw successful tool noise
- Summarize completed slices into plan progress
- Keep failing gate logs verbatim
- Emit / refresh handoff
- Never compact away the current failing test/lint output.
- Keep always-on instructions short; push procedures into skills.
- Optimize for stable prompt prefixes when the host caches them.
Budget awareness
Read .agentloop/stop.yaml when present. Treat these as hard:
max_turns— stop and hand off with escalate noteno_progress— stop, do not “try differently” forever- Context pressure high — compact before new exploration
- Cost/token abort band from Conductor plan — stop and ask
If stop.yaml is missing on a multi-step task, create it from templates/.agentloop/stop.yaml before continuing heavy work.
Handoff minimum (every meaningful run)
Write .agentloop/handoff.md with:
- goal + done-definition
- pointer to
.agentloop/plan.md - verify command
- progress (done / in-progress / blocked)
- open risks
- next concrete action
- memory keys touched (if any)
Another session must be able to continue without re-explanation.
Relationship to other skills
context-compact— mechanical stagesconductor-plan— sets per-run compaction cadencepersistent-memory— durable store via.agentloop/memory+scripts/memory.sh(promote before dropping chat detail)implementation-notes— dense mid-build notes (complementary)
Before discarding chat detail that encodes a decision/preference/lesson, upsert or supersede it into native memory, then compact.
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.

