contextweaver
CLAUDE.md9 starsChanged 5 months agoApache-2.0View on GitHub
AGENTS.md is the single source of truth for shared rules, conventions, module map, and architectural guidance. This file contains only Claude-specific operating behavior. Do not use this file as a standalone repo handbook. Do not duplicate a second hard-rule list here. Read the canonical classifications and enforcement status in AGENTS.md and docs/agent-context/invariants.md. If this file and the canonical files disagree, the canonical files win and this projection must be corrected. - Read AGENTS.md for the module map, conventions, and pipeline…
- Installs packages
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- llms-full.txtllms.txt
- llms.txtllms.txt
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
25 rules. About 0 are common, 13 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Do not duplicate a second hard-rule list here.
- Distinctive: line 11
If this file and the canonical files disagree, the canonical files win and this projection must be corrected.
- Distinctive: line 16
Read AGENTS.md for the module map, conventions, and pipeline summary before modifying any source file.
- Very specific: line 18
Read docs/agent-context/invariants.md before proposing structural changes, simplifications, or consolidations.
- Very specific: line 22
Check .claude/rules/ for scoped rules relevant to the files you are editing.
- Distinctive: line 23
Prefer canonical docs and repository evidence over assumptions or cached patterns.
- Very specific: line 29
Do not invent conventions.
- Very specific: line 31
Use authoritative commands from docs/agent-context/workflows.md and the Makefile.
- Very specific: line 33
Before consolidating protocols, serialization, pipeline stages, or other architectural seams, check docs/agent-context/invariants.md.
- Very specific: line 37
Treat ContextManager's public behavior/API as the contract.
- Very specific: line 42
Run make ci as the repository validation gate.
- Very specific: line 44
Check whether your change triggers a doc update.
- Distinctive: line 47
Verify scoped impact: if you touched sensitivity, store protocols, pipeline stages, layer boundaries, or public API, check the …
- Distinctive: line 50
If a hard invariant lacks the test/gate claimed by its docs, fix the docs or add the gate rather than treating prose as proof.
- Distinctive: line 59
Follow the actual contracts and tests in the touched subsystem.
- Distinctive: line 70
If Claude-specific rules contradict canonical docs, fix/flag the projection.
- Distinctive: line 72
If canonical docs contradict shipped code, surface and reconcile the mismatch instead of training future agents to copy whichever side they …
- Distinctive: line 74
When uncertain, preserve existing behavior and make the uncertainty explicit.
- Distinctive: line 85
Do not promote a fresh observation into durable guidance after one occurrence.
- Distinctive: line 87
If a Claude-specific rule becomes clearly shared and durable, propose promoting it to canonical docs and then reducing it here.
- Very specific: line 97
Check BuildStats fields to understand what the context engine dropped and why.
- Very specific: line 98
Use ContextManager.artifact_store.list_refs() to inspect intercepted tool outputs.
- Very specific: line 113
Check .claude/rules/ for path-triggered rules.
- Distinctive: line 136
If a new lesson is incident-specific, do not promote it into durable docs yet.
- Distinctive: line 137
If a Claude rule becomes shared and durable, promote it to canonical docs, then reduce or remove it here.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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.
Files
contextweaver — Claude Operating Guide
AGENTS.mdis the single source of truth for shared rules, conventions, module map, and architectural guidance. This file contains only Claude-specific operating behavior. Do not use this file as a standalone repo handbook.
Hard Rules
Do not duplicate a second hard-rule list here. Read the canonical classifications
and enforcement status in AGENTS.md and docs/agent-context/invariants.md.
If this file and the canonical files disagree, the canonical files win and this
projection must be corrected.
Explore Before Acting
- Read
AGENTS.mdfor the module map, conventions, and pipeline summary before modifying any source file. - Read
docs/agent-context/invariants.mdbefore proposing structural changes, simplifications, or consolidations. - Inspect the specific area of the repo you plan to change. Do not infer repo-wide conventions from a single local example.
- Check
.claude/rules/for scoped rules relevant to the files you are editing. - Prefer canonical docs and repository evidence over assumptions or cached patterns.
Implement Safely
- Preserve mechanically enforced invariants and documented review-policy contracts. Do not claim a prose-only rule is mechanically enforced.
- Do not invent conventions. If a rule is not in
AGENTS.mdordocs/agent-context/, it does not exist. - Use authoritative commands from
docs/agent-context/workflows.mdand theMakefile; do not guess alternative targets. - Before consolidating protocols, serialization, pipeline stages, or other
architectural seams, check
docs/agent-context/invariants.md. - Respect layer direction: adapter-specific integration code belongs at the
boundary; core code must not import
contextweaver.adaptersto hide a cycle. - Treat
ContextManager's public behavior/API as the contract. Its private mixin composition is an implementation detail, not an invariant.
Validate Before Completing
- Run
make cias the repository validation gate. Do not hard-code a target count here; the Makefile is the ground truth and the gate evolves. - Check whether your change triggers a doc update. PRs that change the pipeline,
public API, module map, conventions, or workflows must update
AGENTS.mdordocs/agent-context/. - Verify scoped impact: if you touched sensitivity, store protocols, pipeline stages, layer boundaries, or public API, check the corresponding invariant and its stated enforcement mechanism.
- If a hard invariant lacks the test/gate claimed by its docs, fix the docs or add the gate rather than treating prose as proof.
Async/sync guidance
The context build/selection core is synchronous computation. Public/runtime integration may provide sync/async entry points and store bridges where I/O requires them; routing remains synchronous pure computation. Do not make new core context logic async merely to satisfy an obsolete "async-first" slogan. Follow the actual contracts and tests in the touched subsystem.
Handle Contradictions
AGENTS.mdis authoritative for shared agent guidance;docs/agent-context/invariants.mdis authoritative for invariant status;Makefileis ground truth for commands; source plus tests are ground truth for shipped implementation behavior.docs/architecture.mdanddocs/agent-context/architecture.mdprovide design explanation, but neither silently overrides a newer explicit invariant or the shipped behavior.- If Claude-specific rules contradict canonical docs, fix/flag the projection; do not silently pick the easier instruction.
- If canonical docs contradict shipped code, surface and reconcile the mismatch instead of training future agents to copy whichever side they happened to read.
- When uncertain, preserve existing behavior and make the uncertainty explicit.
Lessons Learned and Promotion
- During work, note candidate lessons — patterns where the obvious approach was wrong or a constraint was non-obvious.
- A candidate lesson is reusable only if a different agent would make the same mistake on a different change. One-off incidents are not lessons.
- Promotion order: update canonical docs (
AGENTS.md,docs/agent-context/) first. Update Claude-specific files second, only if Claude needs an operational overlay. - Do not promote a fresh observation into durable guidance after one occurrence. Wait for a pattern to recur or for a clear generalizable rule.
- If a Claude-specific rule becomes clearly shared and durable, propose promoting it to canonical docs and then reducing it here.
- See
docs/agent-context/lessons-learned.mdfor the failure-capture workflow and existing durable lessons.
Debugging
make lint— style and import errors.make type— type errors.make test— test suite.- Check
BuildStatsfields to understand what the context engine dropped and why. - Use
ContextManager.artifact_store.list_refs()to inspect intercepted tool outputs. - Enable
logging.DEBUGoncontextweaver.contextto trace pipeline stages. - Enable
logging.DEBUGoncontextweaver.routingto trace beam search.
Running Tests
pip install -e ".[dev]" # one-time setup
pytest --cov=contextweaver --cov-report=term-missing -q # all tests
pytest tests/test_<mod>.py # single module
pytest -k "test_name" # single testScoped Rules
Check .claude/rules/ for path-triggered rules. Currently:
| File | Scope | Purpose |
rules/sensitivity.md | context/sensitivity.py | Security-grade code caution |
Canonical References
| Topic | File |
| Shared rules, conventions, module map | AGENTS.md |
| Architecture and tradeoffs | docs/agent-context/architecture.md |
| Invariants and enforcement status | docs/agent-context/invariants.md |
| Workflows and definition of done | docs/agent-context/workflows.md |
| Lessons learned | docs/agent-context/lessons-learned.md |
| Review checklist | docs/agent-context/review-checklist.md |
| Full pipeline and module detail | docs/architecture.md |
| Core concepts | docs/concepts.md |
Update Order
- Shared durable knowledge → canonical docs first (
AGENTS.md,docs/agent-context/). - Claude-specific projections → this file and
.claude/rules/second. - If a new lesson is incident-specific, do not promote it into durable docs yet.
- If a Claude rule becomes shared and durable, promote it to canonical docs, then reduce or remove it here.
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
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.

