Get the FREE Ultimate OpenClaw Setup Guide →

lembas

npx machina-cli add skill justinjdev/fellowship/lembas --openclaw
Files (1)
SKILL.md
4.2 KB

Lembas — Intentional Context Compression

Overview

Compresses the current conversation into a structured summary to keep the context window in the "smart zone." This is the intentional compaction pattern from context engineering — proactively trimming context between phases rather than waiting for overflow.

The ~40% context utilization mark is where reasoning quality starts to degrade. This skill is the mechanism for staying under that threshold.

When to Use

  • Between phases of the quest workflow (invoked automatically by /quest)
  • When a conversation feels bloated after verbose output (build logs, long file reads, exploratory searches)
  • Before switching focus within a session
  • Standalone via /lembas

Process

Step 1: Identify Current Phase

Determine what just completed:

  • Research: Understanding the system, identifying files
  • Plan: Outlining steps, getting approval
  • Implement: Writing code, running tests
  • Review: Checking against conventions
  • Ad hoc: No formal phase — general work

Step 2: Extract Essentials

Review the conversation and extract only what matters for the next phase. Be aggressive about discarding noise:

Keep:

  • Decisions made and their rationale
  • Files identified with specific line ranges
  • Constraints discovered
  • Open questions that still need answers
  • Test results (pass/fail, not full output)

Discard:

  • Raw grep/search output (keep only the conclusions)
  • Full file contents (keep only relevant line ranges)
  • Verbose build/test output (keep only the verdict)
  • Exploratory dead ends (keep only what was learned)
  • Repeated information

Step 3: Produce Compacted Context Block

Output in this exact format:

## Compacted Context

### Phase Completed: [Research | Plan | Implement | Review | Ad hoc]

### Task
[one-line description, carried forward from Session Context]

### Package(s)
[package name(s) and path(s), carried forward from Session Context]

### Key Findings
- [decisions made this phase]
- [constraints discovered]
- [patterns identified]

### Files
- [file:lines] — [what's relevant and why]
- [file:lines] — [what's relevant and why]

### Current State
- [what's been done so far]
- [what's working / what's broken]

### Next Phase
- [what needs to happen next]
- [open questions to resolve]

Step 4: Persist Checkpoint

Write the Compacted Context block to tmp/checkpoint.md (repo root) so it survives session crashes and context exhaustion:

  1. Create tmp/ directory in repo root if it doesn't exist
  2. Write the Compacted Context block to tmp/checkpoint.md with a timestamp header:
<!-- Checkpoint: YYYY-MM-DD HH:MM -->
<!-- Phase: [completed phase] -->
<!-- Branch: [current git branch] -->

[Compacted Context block from Step 3]

The tmp/ directory is gitignored — checkpoints are developer-local ephemeral state, not shared via git. They only need to survive a session crash, not persist across machines.

Step 5: Trigger Built-in Compaction

After persisting the checkpoint, instruct:

"Checkpoint saved to tmp/checkpoint.md. Now run /compact to compress the conversation window. The Compacted Context block above will be preserved as the key context. If this session dies, the next session will find the checkpoint and offer to resume."

Key Principles

  • Aggressive compression. If in doubt about whether to keep something, discard it. You can always re-read a file; you can't un-bloat a context window.
  • Structured format. The template ensures nothing critical is lost while everything noisy is dropped.
  • Phase awareness. What you keep depends on what's coming next, not what just happened.
  • Frequency over perfection. Compact often with a good-enough summary rather than rarely with a perfect one.
  • Persist to survive. Always write the checkpoint to tmp/. Sessions are ephemeral; the filesystem outlasts them. If context fills up or a session crashes, the checkpoint is the lifeline.

Source

git clone https://github.com/justinjdev/fellowship/blob/main/skills/lembas/SKILL.mdView on GitHub

Overview

Lembas compresses the current conversation into a structured summary to keep the context window in the smart zone. This intentional compaction preserves reasoning quality by proactively trimming context between workflow phases instead of waiting for overflow.

How This Skill Works

It identifies the completed phase (Research, Plan, Implement, Review, or Ad hoc), extracts essentials such as decisions with rationale, files and line ranges, constraints, open questions, and test verdicts, and discards noise. It then outputs a fixed-format Compacted Context block and persists it to tmp/checkpoint.md, after which you can trigger /compact.

When to Use It

  • Between quest workflow phases (auto-invoked by /quest)
  • When a conversation feels bloated after verbose output (logs, file reads, exploratory searches)
  • Before switching focus within a session
  • Standalone via /lembas
  • After exploratory work to lock in learnings and next steps

Quick Start

  1. Step 1: Identify the current phase (Research, Plan, Implement, Review, or Ad hoc)
  2. Step 2: Extract essentials (decisions, rationale, relevant files/line ranges, constraints, open questions, test verdicts) and discard noise
  3. Step 3: Persist to tmp/checkpoint.md and then run /compact as prompted

Best Practices

  • Be aggressive about discarding noise when unsure; you can re-read sources later
  • Keep decisions and their rationale to preserve context
  • Record only relevant files with specific line ranges, not full contents
  • Note open questions and the test results verdicts (pass/fail) only
  • Avoid repeating information and trim verbose outputs

Example Use Cases

  • Between Research and Plan phases in a software integration quest, compressing task, findings, and candidate files with line ranges
  • After a verbose log dump, create a compact summary capturing conclusions and next steps
  • Before switching to a new subsystem within the same session, prune prior context to the essentials
  • Prior to code implementation, lock in decisions, constraints, and unresolved questions
  • Standalone use: run /lembas to generate a lean context block for the next phase

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers