# Prior Art Research — Sidecar Context Window Management Erstellt: 2026-03-05 | Query: "Sidecar Kontext Window" ## Top Repos | Repo | Stars | Kernidee | Link | |------|-------|----------|------| | hesreallyhim/awesome-claude-code | 26.358 | Kuratierte Liste: Skills, Hooks, Plugins, Agent-Orchestrators | https://github.com/hesreallyhim/awesome-claude-code | | trailofbits/claude-code-config | 1.484 | Opinionated Defaults + Workflows fuer Claude Code (Security-Fokus) | https://github.com/trailofbits/claude-code-config | | disler/claude-code-hooks-mastery | ~500+ | Alle 13 Hook-Events dokumentiert + Meta-Agent + Team-Validation | https://github.com/disler/claude-code-hooks-mastery | | ovachiever/total-recall | neu | Tmux-Scrollback Capture bei Compaction → Re-Injection via additionalContext | https://github.com/ovachiever/total-recall | | MacroMan5/macromanatlas | neu | Auto-Codebase-Index + per-Module READMEs, auto-synced via Hooks | https://github.com/MacroMan5/macromanatlas | | nightshift2k/claude-code-hooks | neu | Safety Guardrails + Standard Enforcement + Context Injection | https://github.com/nightshift2k/claude-code-hooks | | jcmrs/thinking-tools-framework | - | Session Handoff, Context Preservation, Process Memory | https://github.com/jcmrs/thinking-tools-framework | ## Architektur-Patterns ### Pattern 1: PreCompact + SessionStart Re-Injection (total-recall) - PreCompact Hook → `tmux capture-pane` → speichert Scrollback in `~/.claude/compact-snapshots/{session_id}.txt` - SessionStart Hook (matcher: "compact") → liest Snapshot → injiziert als `additionalContext` - Terminal-Output ist natuerlich komprimiert (Tool-Calls collapsed) → nur 3-5% des Context Windows - **Relevanz fuer uns:** Unser Sidecar macht das bereits aehnlich, aber gezielter (Rules statt Scrollback) ### Pattern 2: UserPromptSubmit Context Injection (unser Sidecar v1) - Hook feuert bei jedem User-Prompt → Daemon entscheidet was relevant ist → injiziert - Vorteil: Situativ, phasenabhaengig, regelbasiert - Nachteil: Sieht nur den aktuellen Prompt, nicht die Session-History - **Unser session_watcher.py loest genau diesen Nachteil** ### Pattern 3: Meta-Agent / Team-Based Validation (disler) - Hooks orchestrieren SubAgents fuer Validation - PreToolUse → Agent prueft ob Tool-Call sinnvoll ist - PostToolUse → Agent validiert Output - **Relevanz:** Unsere PreToolUse Gates sind eine leichtere Version davon ### Pattern 4: Codebase Auto-Index (macromanatlas) - Hooks nach File-Edits → automatisch Module-READMEs updaten - Claude bekommt immer aktuelle Codebase-Uebersicht - **Relevanz:** Unser context_selector.py koennte aehnlich arbeiten — aber fuer Memory-Files statt Code ### Pattern 5: Context Distillation (Anthropic Engineering Blog) - "Context Rot": Mehr Tokens → schlechtere Recall-Qualitaet - LLMs haben ein "Attention Budget" — jeder Token verbraucht davon - Loesung: Weniger, dafuer relevantere Tokens injizieren - **Kern-Validierung fuer unseren Ansatz:** Situatives Laden > Bulk-Loading ## Bekannte Probleme & Loesungen | Problem | Quelle | Loesung | |---------|--------|---------| | additionalContext wird mehrfach injiziert | [#14281](https://github.com/anthropics/claude-code/issues/14281) | Bug in Claude Code — workaround: Deduplizierung im Hook | | SessionStart hooks feuern nicht bei neuen Conversations | [#10373](https://github.com/anthropics/claude-code/issues/10373) | Bekannter Bug, Workaround: UserPromptSubmit statt SessionStart | | PreToolUse hat KEIN additionalContext | [#15345](https://github.com/anthropics/claude-code/issues/15345) | Design-Limitation — nur Block/Allow, kein Context-Inject | | Context Buffer frisst 33-45K Tokens | [claudefa.st](https://claudefa.st/blog/guide/mechanics/context-buffer-management) | System-Overhead, nicht beeinflussbar — umso wichtiger: eigenen Context minimieren | | Compaction verliert spezifische Details | total-recall README | Scrollback-Capture + Re-Injection nach Compaction | ## Vergleich: Ansaetze fuer Context-Management | Aspekt | Sidecar-Daemon (unser Weg) | total-recall (Scrollback) | RAG-Pipeline | Groesseres Context Window | |--------|---------------------------|--------------------------|--------------|--------------------------| | Praezision | Hoch (regelbasiert) | Mittel (alles oder nichts) | Hoch (semantic search) | Niedrig (Context Rot) | | Kosten | ~0 (lokal) | ~0 (lokal) | Embedding-Kosten | Hoehere Token-Kosten | | Komplexitaet | Mittel (Daemon + Hooks) | Niedrig (2 Shell-Scripts) | Hoch (Vector DB + Embedding) | Keine (aber Problem nicht geloest) | | Session-Awareness | Voll (JSONL-Tailing) | Partial (nur bei Compaction) | Keine | Keine | | Phase-Awareness | Ja (phase_tracker) | Nein | Moeglich aber aufwaendig | Nein | | Skaliert mit Regeln | Ja (Plugin-System) | Nein | Nein | Nein | ## Kern-Insights aus der Recherche ### 1. "Context Rot" validiert unseren Ansatz Anthropics eigener Engineering-Blog bestaetigt: Mehr Context ≠ besser. LLMs haben ein Attention Budget. Unser Sidecar-Ansatz (wenig, aber relevant) ist der richtige Weg. ### 2. total-recall ist clever aber grob Scrollback-Capture ist ein guter Trick fuer Compaction-Recovery, aber nicht fuer situatives Context-Management. Unser Ansatz ist praeziser. ### 3. Session-JSONL-Tailing ist ein Alleinstellungsmerkmal Kein anderes Projekt tailed die Session-JSONL in Echtzeit. Die meisten arbeiten mit Hooks (reaktiv auf einzelne Events). Unser session_watcher waere der erste der die gesamte Session versteht. ### 4. Hook-Oekosystem waechst schnell awesome-claude-code hat 26K Stars. Das Oekosystem explodiert. Aber die meisten Hooks sind einfach (Format, Lint, Block). Komplexe Context-Management-Daemonen wie unser Sidecar sind selten. ### 5. 33K Token System-Buffer ist fix Claude Code reserviert 33-45K Tokens fuer System-Overhead. Das ist nicht beeinflussbar. Umso wichtiger: eigenen injizierten Context minimal halten. ## Empfehlung fuer unser Projekt **Unser Sidecar v2.0 mit session_watcher ist der richtige Weg.** Kein bestehendes Tool macht das was wir brauchen: - total-recall loest nur Compaction-Recovery (nicht situatives Loading) - macromanatlas indexiert Code (nicht Memory/Rules) - disler's Hooks sind Demos (nicht produktiver Daemon) **Konkret uebernehmen:** 1. Von **total-recall**: PreCompact Hook fuer Scrollback-Capture als Fallback (2 Shell-Scripts, trivial) 2. Von **disler**: Hook-Lifecycle-Diagramm als Referenz fuer unsere Architektur-Docs 3. Von **Anthropic Blog**: "Context Rot" als Argument fuer minimale Injections **Vermeiden:** - RAG-Pipeline (Overkill fuer unser Use-Case, zu komplex) - Auf groessere Context Windows warten (loest das Problem nicht — Context Rot) ## Quellen - [Effective Context Engineering for AI Agents — Anthropic](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents) - [Claude Code Hooks Reference](https://code.claude.com/docs/en/hooks) - [Claude Code Hooks Guide](https://code.claude.com/docs/en/hooks-guide) - [Context Engineering for Multi-Agent LLM Code Assistants — arXiv](https://arxiv.org/html/2508.08322v1) - [Claude Code Context Buffer: 33K-45K Token Problem](https://claudefa.st/blog/guide/mechanics/context-buffer-management) - [Claude Code Session Hooks: Auto-Load Context](https://claudefa.st/blog/tools/hooks/session-lifecycle-hooks) - [Hook-driven dev workflows — Nick Tune](https://nick-tune.me/blog/2026-02-28-hook-driven-dev-workflows-with-claude-code/) - [Context Management Optimization — SFEIR](https://institute.sfeir.com/en/claude-code/claude-code-context-management/optimization/) - [Auto-Refresh Context Every N Prompts — Gist](https://gist.github.com/johnlindquist/23fac87f6bc589ddf354582837ec4ecc) - [54% Context Reduction — Gist](https://gist.github.com/johnlindquist/849b813e76039a908d962b2f0923dc9a)