Context Control

The right information.At the right depth.

Turn available sources into deliberate model input. Choose relevant material, set the read depth and work within your context budget. Keep references to the original.

Available materialDeliberate selectionTask-ready context

The approach

Choose what reaches your model.

A task needs evidence, not every available file. LeanCTX gathers permitted candidates, preserves their origin and prepares a context plan within the requested budget.

Task & budget

Give every read a reason.

Describe the question and the space available for context. A coding task may need one implementation; a support task may need a current procedure. The plan selects for that task, within its permitted source scope.

Scope
Choose the project and available sources.
Selection
Rank candidates and deduplicate shared content references.
Context budget
Limit the information prepared for a request; this is distinct from a spending limit.

Search & provenance

Find it. Know where it came from.

Start with the evidence selected for your task. Keep each source reference attached as LeanCTX compiles the chosen material into model context. Follow the source trail when a result needs more explanation.

Files & code
Text search, structure and source locations.
Indexed knowledge
BM25 and configured semantic search use the available indexes.
Connected sources
Provider access depends on configured credentials and permissions.

Detail & recovery

Choose how much to read.

Use signatures to locate code, line ranges to inspect it and full text for exact edits. Further reads follow the same access rules.

signatures
Locate functions and types with source references.
lines / full
Read the required implementation at the needed detail.
Recovery
Available source and archived output determine what can be recovered.
Recorded product output
src/lib/roi.ts257 lines
fn pub fmtInt(value:n) → string @L78-80fn pub fmtUsd(value:n) → string @L83-89fn pub fmtDay(iso:s) → string @L92-96

Excerpt from the captured signature view

Source referencefmtUsd · L83–89

The implementation is one targeted read away.

Inspect the exact implementation
export function fmtUsd(value: number): string {
  const n = Number(value) || 0;
  return (
    '$' +
    n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
  );
}

Exact implementation from the same source file.

The read-mode toolkit

One source. The view your task needs.

Go from orientation to exact lines, compare changes or choose a more compact representation. Open a group to find the mode and its trade-off.

Find your bearingsauto · map · signatures · reference
auto
Let the runtime select a read strategy from the available file and task context. Explicit aggressiveness can select a target density.
map
See a structural outline before choosing which part deserves a closer read.
signatures
Inspect the API surface of supported code: declarations and source positions, with implementation detail omitted.
reference
Keep a compact file reference with size and type metadata, without loading its body into the response.
Read precisely. Edit confidently.full · raw · anchored · lines
full
Read the source with its normal display framing. Use a complete view when omitted detail could change the edit.
raw
Return source text without display framing. This output mode does not bypass source permissions or enabled filters.
anchored · anchored:72-92
Read full source or a line window with per-line hash anchors for targeted ctx_patch edits.
lines:72-92 · lines:5,10-20 · lines:-20
Select an inclusive range, several locations or the last lines. lines:72 reads from line 72 to the end; -20 is also accepted as a tail shorthand.
Choose what to retaintask · aggressive · entropy · density
task
Keep material relevant to the active task. Without usable task hints, or for a small file, the current implementation returns full content.
aggressive
Use a stronger, lossy summary when an overview is sufficient. Recover the original before making an edit that needs exact detail.
entropy
Reduce repetitive, low-information material with entropy-based compression. The result is a selected view, not a lossless copy.
density:0.40
Aim for a chosen proportion of the original tokens. The target is approximate; quality guards and source structure affect the delivered size.
Return to what changeddiff
diff
Compare with the session’s cached read. This needs a previous read; it is not a comparison against an arbitrary Git commit.
Explore advanced representationscognitive · mdl
cognitive
Select a budgeted set of detected chunks. Requires the corresponding science setting; otherwise the implementation falls back to map.
mdl
Generate a compact structural description. Requires the corresponding science setting; otherwise it falls back to map.
A compact full-text variantfull-compact
full-compact
The redirect-oriented variant removes framing and trailing whitespace while retaining line structure. Choose raw when exact byte preservation matters.

A read mode shapes the response; it does not grant access. Summaries omit detail. Use the original when the task requires exact source, and check the documented runtime behavior for your integration.

Read the mode reference

Format-aware preparation

Different material. The right treatment.

Code has structure. Command output has results, errors and repeated noise. LeanCTX uses the appropriate view or output filter for supported formats, with references for recovering detail when needed.

Code structure
Keep relevant declarations and source locations in a structural read.
Command output
Surface useful results and failures through supported output filters.
Recoverable detail
Follow source references or an available output archive when more evidence is needed.

In your workflow

Read less again. Recover more when needed.

The first read is only part of the workflow. LeanCTX also manages repeated reads, source references and archived output.

Cached reads

An unchanged repeat may return a compact reference. Use fresh when you need to bypass the read cache; fresh does not itself select an exact-text mode.

Explore this capability

Output recovery

Recover a retained source or shell archive when a shortened result is not enough. Availability and retention determine what can be recovered.

Explore this capability

Questions & answers

Read modes explained.

Does every search use an index?

Exact text search and indexed retrieval are different paths. Semantic search depends on configured indexes; a direct text match can be a better starting point when you already know a symbol or phrase.

Is every shorter view enough for the task?

No. Signatures help locate code; changing it can require the exact implementation. Choose a more detailed read when needed and verify the result of the task.

Does context preparation need a private model?

No. The public Engine works deterministically. Optional intelligence can propose better selections or routes after verification, but your host and policy retain authority. If it is unavailable or rejected, the deterministic path remains usable.

Next: Security & Governance

Add rules to your context flow.

See how source boundaries and configured text filters control supported reads.

Start with LeanCTX

Try a focused read.

Try a signature view on a familiar file. Follow the reference and read the implementation when you need it.

Local-first. Model-agnostic. Your context.