agentleFS
myths-labsmyths-labs/muse/skills/core/layered-context/SKILL.md

layered-context

Skill35 starsChanged 8 months agoMITView on GitHub

L0/L1/L2 three-layer context loading protocol — reduces token consumption during /resume boot

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every .muse/*.md file MUST have an L0 comment as the first line:

    line 25
  2. Distinctive:

    After syncing the role file content

    line 86
  3. Distinctive:

    Keep within 120 char limit

    line 88
  4. Very specific:

    If the L0 comment's version doesn't match the latest tag, the /resume boot should flag it:

    line 92

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

Layered Context Loading Protocol

Inspired by OpenViking (ByteDance) L0/L1/L2 architecture. Adapted for MUSE's on-demand Markdown context loading.

Why

Full-loading all .muse/*.md files during /resume wastes tokens when the Agent only needs one role's context. The layered approach loads minimum context first, then deepens on demand.

Three Layers

LayerToken BudgetContentWhen to Load
L0~100 tokensOne-line HTML comment at top of each .muse/*.mdAlways — scan ALL role files
L1~2K tokensFull role file contentOn demand — only the CURRENT role's file
L2Unboundedmemory/*.md + code files + docsOn demand — grep search when needed

L0 Format

Every .muse/*.md file MUST have an L0 comment as the first line:

<!-- L0: v2.10.1 | P0=竞品技术吸收, P1/P2全清, QA PASS, S036已接收 -->

L0 Content Rules

  1. Max 120 characters (excluding <!-- L0: and -->)
  2. Must include: current version + top priority + blocking issues
  3. Pipe-separated sections: version | priorities | status
  4. Updated every /bye — when the role file is synced

L0 Examples

<!-- L0: v2.10.1 | P0=竞品技术吸收(mem0/OpenViking), P1全清, QA 10/10 PASS -->
<!-- L0: 9/9渠道已发, Show HN暂缓, S040梗图排期中, Stars=2 -->
<!-- L0: 最近QA全PASS(10/10 v2.3), 无待修FAIL, QA清洁状态 -->

Boot Sequence with Layered Loading

/resume [role]
  │
  ├─① Read CLAUDE.md + MEMORIES.md (constitutional layer, always)
  │
  ├─② Scan ALL .muse/*.md L0 lines (grep "<!-- L0:" .muse/*.md)
  │   → Get one-liner status of every role in ~400 tokens total
  │
  ├─③ Deep-read CURRENT role's .muse/*.md (L1, full file)
  │   → Only the file matching /resume [role]
  │
  ├─④ Scan memory/ for unfinished items (L2, on demand)
  │   → grep 🔲 and [ ] in recent memory files
  │
  └─⑤ grep strategy.md for 🟡 directives (L2, on demand)
      → Only if non-strategy role

Decision Tree: When to Upgrade

Agent receives a question/task
  │
  ├─ Can answer from L0? → Answer immediately
  │   (e.g., "What version is MUSE?" → L0 has it)
  │
  ├─ Need role details? → Load L1 (full role file)
  │   (e.g., "What's the P0 task?" → need build.md details)
  │
  └─ Need historical context? → Load L2 (memory/grep)
      (e.g., "What did we decide about X last week?" → grep memory/)

Maintaining L0

Who Updates L0

The /bye workflow updates L0 as part of Step 3.5 (role file sync):

  1. After syncing the role file content
  2. Rewrite the L0 comment to reflect current state
  3. Keep within 120 char limit

L0 Staleness Detection

If the L0 comment's version doesn't match the latest tag, the /resume boot should flag it:

⚠️ L0 stale: build.md says v2.10.1 but latest tag is v2.11.0

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.