-
Notifications
You must be signed in to change notification settings - Fork 3
Context Hygiene
Agentic coding gets better when the model sees the right context, not the most context. CodingScaffold adds a small guardrail around this: estimate the context budget, compress optional reference material, and start a fresh session when the current one has become too loaded.
Long-context models are useful, but they do not magically make every token equally valuable. Important facts can get buried, old assumptions can keep steering the conversation, and a session that has accumulated too much history can start answering the project it remembers instead of the project in front of it.
The practical rule is:
- load task-specific context first
- keep policy and requirements uncompressed unless reviewed
- compress reference notes only as sidecars
- start a fresh session for a new task when the current context is too large or stale
This should not be left entirely to the model or the coding tool. The scaffold can catch obvious risk earlier because it knows the project layout, team knowledge folders, and generated sidecars.
coding-scaffold context budget --target ~/dev/my-project --source knowledgeDefaults:
- warn above 100,000 estimated tokens
- warn above 40% of the configured context window
- estimate original files by default and ignore
.caveman.mdsidecars - inspect
.coding-scaffold/knowledgefor--source knowledge - inspect knowledge, skills, policy, and agents for
--source team
Machine-readable output is available for CI or team checks:
coding-scaffold context budget --target ~/dev/my-project --source team --jsonUse a warning as a prompt to narrow the task, retrieve fewer files, compress support notes, or open a fresh coding session.
Estimate a sidecar-first session after compression:
coding-scaffold context budget --target ~/dev/my-project --source knowledge --prefer compressedUse --prefer both only when you intentionally want to measure the full stored corpus.
The default compressor is built into CodingScaffold and works offline:
coding-scaffold context compress --target ~/dev/my-project --source knowledgecontext compress --source team compresses knowledge, skills, and OpenCode agent notes, but skips
.coding-scaffold/policy by default because policy text is reviewed config where exact wording can
matter.
Caveman Compression is available as an optional experimental engine:
coding-scaffold setup addon --target ~/dev/my-project --addon caveman-compression
coding-scaffold context compress --target ~/dev/my-project --source knowledge --engine cavemanThis writes files like:
.coding-scaffold/knowledge/decisions/api-contract.md
.coding-scaffold/knowledge/decisions/api-contract.caveman.md
The original Markdown remains the source of truth. The .caveman.md file is optional agent input
for token-constrained sessions.
Good candidates:
- long session summaries
- background architecture notes
- decision history
- glossary material
- repeated project explanations
Avoid by default:
- security policy
- legal or compliance text
- acceptance criteria
- active code
- migration steps
- anything where exact wording matters
For shared knowledge, do not auto-promote compressed notes upward through company, unit, department, and team layers. Promote the original reviewed Markdown by pull request. Regenerate sidecars after merge.
A useful team ritual is:
coding-scaffold knowledge status --target .
coding-scaffold context budget --target . --source team
coding-scaffold context compress --target . --source knowledgeRun it before large refactors, onboarding sessions, and workflow demos. It keeps the agent’s memory useful without pretending that every old token deserves a seat at the table.