Context Efficiency

August 12, 2026 · View on GitHub

DocFlow reduces the documentation placed in an agent's initial context. It does not claim to compress Markdown or guarantee a fixed token bill for an entire task.

Loading Contract

StageLoaded contentBound
Session routingNon-empty lines from docs/INDEX.md30 lines by default
Recent historyHeader, summary, and newest detailed entry from the newest valid monthly changelog20 lines by default
Task workExact documents selected through the index and repository guidanceUnbounded; driven by task scope

DOCFLOW_INDEX_LINES and DOCFLOW_LOG_LINES override the two automatic limits with positive integers.

Claude receives the bounded routing/history payload through the SessionStart hook. Codex, Gemini, Cursor, and other repo-aware agents use the same index-first workflow through AGENTS.md, but their automatic loading behavior depends on the host product.

Measurement Method

The reproducible comparison uses words rather than model-specific tokens:

repo=/path/to/repo

find "$repo/docs" -type f -name '*.md' -print0 \
  | xargs -0 wc -w \
  | tail -n 1

CLAUDE_PROJECT_DIR="$repo" \
  bash /path/to/docflow/hooks/docflow-context.sh \
  | wc -w

Initial context avoided is:

$\text{text} (1 - \text{automatic\_context\_words} / \text{all\_docs\_words}) \times 100 $

This measures the text boundary controlled by the hook. It does not include system instructions, conversation history, source code, tool results, docs/README.md, or task-specific documents opened later.

Observed Results

Measured on 2026-08-13 using the default limits:

RepositoryDocs filesFull docs wordsINDEX.md wordsHook wordsInitial context avoided
Repository A117127,42473860599.53%
Repository B105129,86572748199.63%

The hook output can be smaller than INDEX.md because only the first 30 non-empty index lines are emitted. The bounded changelog excerpt contributes the remaining recent-history context.

Interpretation

ClaimSupported?Reason
DocFlow greatly reduces automatic documentation contextYesBoth measured repositories avoid more than 99% of the full docs corpus initially
Every task costs 99% fewer tokensNoAgents still load source code and task-specific documentation
Word reduction equals exact token reductionNoTokenization varies by model and content
Large audits always stay smallNoWhole-product reviews may legitimately require many documents
Route-first work is cheaper than scanning all docsYesThe index selects a small relevant subset before full documents are opened

Guardrails

  • Keep each INDEX.md entry to one path and one short purpose.
  • Put the current outcome at the start of the monthly changelog summary.
  • Put the newest detailed changelog entry before older entries.
  • Open full changelog history only when the task needs historical detail.
  • Measure again when hook defaults or repository documentation size changes.

Update Log

DateChangeRef
2026-08-13Documented the context-loading contract and two-repository measurements.context-efficiency