agentleFS
xingfanxiaxingfanxia/AX-skills/context-infrastructure/SKILL.md

context-infrastructure

Skill4 starsChanged 54 days agoMITView on GitHub

Design, audit, or improve durable context and memory systems for AI agents using layered observations, reflection, conservative promotion, progressive disclosure, and replayable boundary artifacts. Use when building long-running agent memory, deciding what belongs in sessions versus rules or skills, preventing context bloat, or turning repeated corrections and workflows into durable assets. Do not use it to copy another person's private axioms or automatically promote one-off observations.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    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:

    Treat context as a compounding system, not a giant prompt.

    line 8
  2. Distinctive:

    Do not skip layers. Keep a new signal in L1 until reflection shows that it is repeated, stable, useful outside the original task, and …

    line 27
  3. Distinctive:

    Keep automatic promotion off by default unless the domain has deterministic validation, rollback, and an explicitly authorized policy.

    line 42
  4. Distinctive:

    Keep the global entrypoint as a routing table, not the whole memory system.

    line 63
  5. Distinctive:

    Use indexes to tell agents when to load focused rules, skills, or knowledge.

    line 64
  6. Distinctive:

    Put triggering information in skill metadata and detailed procedure in the skill body or directly linked references.

    line 65
  7. Distinctive:

    Prefer sparse, high-density context over broad dumps and repeated summaries.

    line 69
  8. Distinctive:

    Do not add another agent when a fixed-contract parser, index, or API call can route the context deterministically.

    line 71
  9. Distinctive:

    Test the parts that future agents rely on:

    line 91

≈ “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.

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

Context Infrastructure

Treat context as a compounding system, not a giant prompt. Route, filter, test, and promote experience so future agents receive the smallest useful context.

This AX adaptation is inspired by the public grapeot/context-infrastructure reference implementation and the Observer/Reflector pattern described by Mastra Observational Memory. Reuse the architecture, not another person's accumulated axioms, preferences, or private data.

Define four layers

LayerPurposeTypical contents
L0 SessionExecute the current taskPrompt, active diff, command output, current plan
L1 ObservationsPreserve selected raw signalsUser corrections, repeated friction, notable failures, explicit preferences
L2 ReflectionDistill and discardDeduplicated patterns, contradictions, counterexamples, promotion proposals
L3 Durable assetsChange future behaviorAxioms, reusable skills, global methodology, technical knowledge, project memory

Do not skip layers. Keep a new signal in L1 until reflection shows that it is repeated, stable, useful outside the original task, and routed to the right scope.

Separate observation from promotion

Make the Observer append concise evidence. Make the Reflector merge, discard, or propose promotion.

  • Record only explicit corrections, preferences, retractions, and recurring workflow lessons worth reconsidering. Most tasks should produce no memory.
  • Preserve source, date, scope, and counterexamples needed to evaluate a signal.
  • Merge duplicates and flag contradictions during reflection.
  • Generate a reviewable promotion proposal before changing durable rules, axioms, skills, or shared memory.
  • Keep automatic promotion off by default unless the domain has deterministic validation, rollback, and an explicitly authorized policy.

This split prevents one intense session from rewriting long-term behavior.

Route promotion by scope

Repeated signalDurable target
Stable personal preferencePersonal axiom or preference profile
Repeated cross-project workflowReusable skill
Global operating methodologyFocused rule or policy
Reusable technical lessonKnowledge entry
Project-specific decision or constraintProject memory or source-of-truth documentation
One-off task factKeep ephemeral or discard

Promote only claims that change future decisions. Preserve dissent and edge conditions; a rule without boundaries is usually too broad.

Design for progressive disclosure

  • Keep the global entrypoint as a routing table, not the whole memory system.
  • Use indexes to tell agents when to load focused rules, skills, or knowledge.
  • Put triggering information in skill metadata and detailed procedure in the skill body or directly linked references.
  • Retrieve project-specific context before global history when the task depends on current source truth.
  • Prefer sparse, high-density context over broad dumps and repeated summaries.

Do not add another agent when a fixed-contract parser, index, or API call can route the context deterministically.

Make boundaries inspectable

For every context-producing workflow, define:

  1. Input boundary: source records, time window, permissions, and freshness.
  2. Selection boundary: inclusion, exclusion, deduplication, and privacy rules.
  3. Artifact boundary: an inspectable observation or reflection record before AI judgment becomes durable.
  4. Promotion boundary: owner, threshold, review, target, and rollback.
  5. Consumption boundary: which task shape loads which durable asset.

Store AI-facing inputs and AI-produced intermediate outputs when they affect visible or durable behavior. Debug bad output by inspecting freshness, timestamps, filters, ordering, and fallbacks before changing the model or prompt.

Protect integrity

Test the parts that future agents rely on:

  • parser and schema shape;
  • time-window and freshness filtering;
  • deduplication and contradiction handling;
  • fallback and retry signals;
  • privacy, secret, and retention scans;
  • deterministic replay from saved boundary artifacts;
  • promotion thresholds and rollback behavior.

Minimize collection. Do not inspect private stores, upload records, or broaden retention without authorization. Redact secrets before an observation becomes a shared or durable artifact.

Completion contract

Return a compact system design or audit containing:

  • the L0–L3 stores and owners;
  • Observer and Reflector contracts;
  • the signal-to-target promotion table and review threshold;
  • progressive-disclosure routing;
  • privacy, freshness, replay, and rollback checks;
  • remaining manual decisions.

Complete only when a new observation can be traced from source to consumption without silent promotion or an uninspectable context jump.

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.