borghei/Claude-Skills / engineering/context-engine
context-engine
VerifiedContext management engine for AI coding agents. Use when building agent memory systems, optimizing context windows, allocating token budgets, designing RAG pipelines for code, or managing persistent multi-session agent state.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.6 KB |
| references/code-retrieval-patterns.md | markdown | 2.8 KB |
| references/context-window-strategies.md | markdown | 3.1 KB |
| references/long-context-strategies.md | markdown | 6.2 KB |
| references/memory-and-context-editing.md | markdown | 9.0 KB |
| references/memory-architecture-guide.md | markdown | 4.0 KB |
| references/workflows-and-quality.md | markdown | 6.7 KB |
| scripts/context_analyzer.pyexecutable | script | 13.3 KB |
| scripts/context_budget_planner.py | script | 9.6 KB |
| scripts/context_pruner.pyexecutable | script | 16.1 KB |
| scripts/memory_indexer.pyexecutable | script | 16.0 KB |
references/memory-architecture-guide.md
View on GitHub# Memory Architecture Guide
Read this when designing multi-layer agent memory, deciding what to persist across sessions, tracking staleness, or coordinating context between multiple agents.
## Memory Architecture
### Three-Layer Memory Model
```
┌─────────────────────────────────────────────────┐
│ Layer 1: Working Memory (Context Window) │
│ Scope: Current conversation/task │
│ Lifetime: Single session │
│ Storage: In-context tokens │
│ Update: Every turn │
├─────────────────────────────────────────────────┤
│ Layer 2: Session Memory (Persistent Store) │
│ Scope: Project-level learnings │
│ Lifetime: Across sessions │
│ Storage: MEMORY.md, .claude/rules/, CLAUDE.md │
│ Update: End of session or on discovery │
├─────────────────────────────────────────────────┤
│ Layer 3: Knowledge Base (Indexed Corpus) │
│ Scope: Full codebase + documentation │
│ Lifetime: Persistent, versioned │
│ Storage: Vector store, graph DB, file index │
│ Update: On commit / scheduled reindex │
└─────────────────────────────────────────────────┘
```
### Memory Promotion Protocol
Knowledge flows upward through layers based on recurrence and value:
| Signal | Action | Example |
|--------|--------|---------|
| Pattern seen 1x | Working memory only | "This file uses tabs" |
| Pattern seen 2-3x | Candidate for session memory | "Project uses pnpm everywhere" |
| Pattern confirmed across sessions | Promote to CLAUDE.md/rules | "Always use pnpm, never npm" |
| Pattern is domain knowledge | Add to knowledge base | "Auth flow uses JWT + refresh tokens" |
### Staleness Detection
Context has a shelf life. Stale context causes hallucinations.
```
Freshness Score = f(last_verified, change_frequency, confidence)
Fresh (< 7 days, file unchanged): Use directly
Aging (7-30 days, file changed): Re-verify before using
Stale (> 30 days): Flag, re-retrieve, or discard
Unknown (never verified): Treat as low-confidence
```
## Multi-Agent Context Sharing
When multiple agents collaborate, context synchronization becomes critical.
### Shared Context Bus
```
┌──────────┐ ┌──────────────────┐ ┌──────────┐
│ Agent A │────▶│ Shared Context │◀────│ Agent B │
│ (Planner) │ │ - Task state │ │ (Coder) │
└──────────┘ │ - Decisions log │ └──────────┘
│ - File changes │
┌──────────┐ │ - Constraints │ ┌──────────┐
│ Agent C │────▶│ - Artifacts │◀────│ Agent D │
│ (Reviewer)│ └──────────────────┘ │ (Tester) │
└──────────┘ └──────────┘
```
### Context Handoff Protocol
When Agent A passes work to Agent B:
1. **State Summary**: What was done, decisions made, current state
2. **Relevant Artifacts**: Files created/modified, with paths
3. **Constraints**: What must not be changed, invariants
4. **Open Questions**: Unresolved decisions that need Agent B's input
5. **Next Steps**: Explicit instructions for what Agent B should do
Anti-pattern: Passing the entire conversation history. Always summarize.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |