agentleFS
kremakrema/agent-skills/skills/context-management/SKILL.md

context-management

Skill0 starsChanged 35 days agoMITView on GitHub

Diagnose and mitigate context-related failures during long research, coding, and tool-use tasks. Use when preparing a compaction or handoff, selecting evidence for a large task, or recovering from repeated work, stale state, or lost constraints. Preserve recoverable evidence and verify continuation; do not treat every agent error as context rot.

14 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use verification.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • OpenAISkill

    verification

    Full-story verification — infers what the user is building, then verifies the complete flow end-to-end: browser → API → data → response. Triggers on dev server start and 'why isn't this working' signals.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 6 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 6

    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
  1. Distinctive:

    When progress stalls, classify the evidence before intervening:

    line 14
  2. Distinctive:

    When history actually needs to be condensed, construct a working record containing only applicable fields:

    line 43
  3. Distinctive:

    Keep task facts and concise decision rationale, not a transcript of private reasoning.

    line 54
  4. Distinctive:

    If the host exposes reversible output hiding, retain stable handles and restore the original before an exact-detail action.

    line 58
  5. Distinctive:

    When choosing a compaction trigger, treat recent errors or prior writes as unvalidated cues.

    line 66
  6. Distinctive:

    If no evidence-preserving recovery is possible, state the missing dependency and continue independent work.

    line 76

“Common” is measured: kept by at least 6 in 10 of the 13 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Context Management

Improve the next task decision while retaining the information needed to finish. This is a conditional workflow informed by 2026 research, not a guarantee of better performance or a model-independent token limit. Read evidence when assessing support or transfer to another model. Read evaluation when changing a context policy or claiming an improvement.

1. Diagnose the observable problem

Identify the current objective, binding constraints, next action, and its required evidence. For a short, progressing task, continue without adding a context-management routine.

When progress stalls, classify the evidence before intervening:

ObservationFirst response
Required information was never obtainedRetrieve it; shortening history cannot supply it.
A summary omitted a known fact, constraint, or artifactRecover the original and repair the working state.
Old and current values conflictReconstruct the current value from authoritative updates, including dependencies and scope. A historical mention is not an update.
Bulky or repetitive context obscures evidence already availableTry focused evidence selection or reversible offloading.
A command, calculation, or action is wrong despite sufficient evidenceCheck the tool contract and task logic; repair the error directly.
A remembered repository path or command no longer worksVerify against the current checkout; distinguish stale documentation from long-input degradation.

Repeated searches, user corrections, and unsupported early stopping are diagnostic cues, not proof of a mechanism. An uncertainty statement can be correct. Never force a confident answer to make a run appear recovered. [E01, E06, E08, E13]

2. Select evidence for the next decision

For a large corpus, start with relevant files or passages and retain their source locators. Expand when dependencies, contradictory evidence, or corpus-wide coverage require it. Preserve counterevidence that bears on the question even when it complicates the answer. Do not equate low lexical similarity with irrelevance.

For multi-step research with accumulating or corrected evidence, distinguish source-backed observations from your conclusions and keep links between them. Let an unresolved premise or competing explanation guide the next search. When a source is corrected, superseded or withdrawn, reassess dependent conclusions and mark obsolete support inactive; appending the correction alone is insufficient. Before finishing, check whether remaining gaps could change the requested decision. Use ordinary notes or available tools; this does not reproduce LongHarness or require a new store. [E21; engineering inference]

Before dropping history, identify what the next action and remaining obligations depend on. Review proposed omissions for failed attempts, prohibitions, and exact state that a broad plan may overlook. This is a lightweight engineering check, not an implementation of FOCUS or a requirement to simulate future actions. [E15]

For batch tasks, retain the complete item set with stable identifiers and each item’s completion status; “process all remaining items” is not sufficient if the item list disappears. Verify coverage against the original set before declaring completion. [E15]

For aggregation, absence claims, or cross-document synthesis, cover the relevant corpus rather than selecting only promising matches. Partition work with a coverage record if necessary; do not discard dependencies between parts. When splitting records, finish boundary-spanning items and assign each item once; preserve update order for stateful tasks. Check intermediate tallies or state before merging. These checks do not require delegation or reproduce a trained decomposition policy. [E02, E19; engineering inference]

Use bounded tool output where feasible, while retaining access to the original. Keep action/result associations and exact values needed for execution. Choose among full retention, selection, offloading, or summarization based on the task; no fixed percentage, token count, or number of recent turns is prescribed. [E01, E04–E06, E11]

3. Preserve state before compression or handoff

When history actually needs to be condensed, construct a working record containing only applicable fields:

  • Current objective and completion condition.
  • User constraints and authorization boundaries, preserving their scope, exceptions, and explicit revocations separately from progress.
  • Verified current state: exact identifiers, values, units, paths, dates and time zones when consequential; provenance and update order.
  • Completed actions and observed results, including pending operations and whether external effects already occurred.
  • Unresolved questions, conflicting evidence, rejected approaches and the reason they failed.
  • Next action, prerequisites, and precise locations of supporting originals.

When extracting facts for a reusable record, check the original statement before stripping context: retain consequential conditions, attribution and temporal scope, and distinguish observation from inference. Do not discard a temporary fact solely for being temporary when a pending action or linked fact depends on it. If a proposed omission breaks a needed evidence chain, retain the dependency or a verified recovery path. The memory-filtering results do not establish that stable facts alone suffice for task continuation. [E22; engineering inference]

Keep task facts and concise decision rationale, not a transcript of private reasoning. Preserve temporal anchors when chronology matters. Do not promote guesses into facts or turn provisional conclusions into settled ones. [E03, E04, E07, E08, E10, E12; record layout is an engineering choice]

Before relying on an offloaded artifact, verify that its locator resolves and that the needed contents can be recovered. Use an authorized workspace or existing store. If retrieval is unavailable, retain essential source material inline and narrow the task if necessary. Raw storage is not a guarantee that the agent will find or use it. [E04, E05]

If the host exposes reversible output hiding, retain stable handles and restore the original before an exact-detail action. Use this selectively: model-dependent results do not justify hiding every old output. Without such a host capability, use ordinary source pointers and focused future reads. [E16]

When evaluating or configuring an exposed context-editing policy, account for cache invalidation, rewrite calls and restoration alongside task correctness. Compare less frequent edits if repeated rewrites increase total cost; do not adopt a fixed interval from a paper. If cache telemetry is unavailable, report that limit rather than infer savings from a shorter prompt. [E17, E18; engineering inference]

Compare the proposed record with the original constraints and consequential state before replacement when both are available. If the host compacts automatically, perform this check against surviving originals when resuming. Use only capabilities actually exposed by the host: writing a summary file does not clear earlier model context. Preserve ongoing authorization; compaction grants no new permission. [E12; environment constraint; engineering inference]

4. Verify continuation and recover

When choosing a compaction trigger, treat recent errors or prior writes as unvalidated cues. Compare both harm frequency and total recovery burden at matched opportunities; observe runtime limits. [E20; engineering inference]

For open-ended optimization with an automatic evaluator, if measured progress stalls and proposals repeat or shrink, consider a bounded fresh-session comparison from the best verified candidate. First preserve the objective, evaluator, observed score, remaining budget, constraints, authorization and needed dependencies; archive history recoverably outside the active input. Exclude obsolete search narrative only if it is unnecessary for correctness. Require actual host support for a fresh session and existing authorization; otherwise continue with focused reads. Compare valid candidate quality and total cost with continuation, and keep the better verified result. This is an untested engineering adaptation of a narrow study, not a reset schedule, permission to delete records, or a reason to add agents. [E23; E15 is the dependency counterweight]

At a compaction boundary, check that the next action’s prerequisites and unresolved obligations remain available. Track unnecessary reacquisition and repeated actions as well as completion; a successful result can still hide recovery overhead. [E04, E07]

Resume the next useful action and check its result against the task's completion condition. Look specifically for lost constraints, outdated values, duplicated external actions, missing evidence, and unnecessary retrieval of information already obtained.

If a detail is missing, retrieve the relevant original and patch that detail. If a checkpoint is stale, update it from verified state. If an action may already have happened, inspect the external state before retrying. Avoid cycling through broader summaries when targeted repair is possible. [E04, E07, E08; engineering inference]

If no evidence-preserving recovery is possible, state the missing dependency and continue independent work; ask for essential unavailable information. Do not label absence of access as absence of evidence. Finish when the original task is complete, not merely when the context is smaller.

For an authorized transcript-review task, keep exact action evidence and consider checks at meaningful intermediate states; do not rely solely on a final compressed narrative. This specialized precaution is supported by monitoring studies, not proof that periodic reminders improve all tasks. [E09]

Deliverable

Return the requested task result. When intervention materially affects confidence or continuity, briefly identify the state preserved, the check performed, and any unresolved limitation. Provide a handoff record only when useful or requested. Do not add installation, new chats, delegation, or recurring monitoring as an automatic consequence of this skill.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.