Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/jubakitiashvili/context-mem/context-optimizationnpx skills add JubaKitiashvili/context-mem --skill context-optimizationgit clone --depth 1 https://github.com/JubaKitiashvili/context-memWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/jubakitiashvili/context-mem/context-optimization)<a href="https://agentmods.dev/skills/jubakitiashvili/context-mem/context-optimization"><img src="https://agentmods.dev/badge/skills/jubakitiashvili/context-mem/context-optimization.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00167 | $0.02084 |
| Opus 5 | $0.00084 | $0.01042 |
| Sonnet 5 | $0.00033 | $0.00417 |
| Haiku 4.5 | $0.00017 | $0.00208 |
Grade A, and why
context-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 160 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Use context-mem to compress large tool outputs, search stored observations before re-reading files, and persist knowledge across sessions. Leverage its 14 content-aware summarizers (plus community plugins), 4-layer hybrid search (BM25 + Trigram + Levenshtein + Vector) with intent-aware adaptive reranking and block-level memory attention, cross-session memory, and cross-project knowledge transfer through 29 MCP tools. Dashboard receives real-time updates via WebSocket. Optional LLM enhancement (Ollama / OpenRouter / Claude API) is available when enabled — adds query expansion, smarter title/tag generation, contradiction explanation, and LLM summarization, all with deterministic fallback.
Core Tools
observe — After any large output (500+ tokens)
Store and compress content for later retrieval. Auto-summarizes based on content type. Built-in privacy engine auto-redacts secrets (AWS keys, GitHub tokens, JWTs, etc.) before storage.
observe(content: "<large output>", type: "log|code|error|test|commit|decision|context", source: "tool-name")
search — Before re-reading files
Search stored observations first. Adaptive reranking selects intent-specific weight vectors (causal / temporal / lookup / general) so results are scored differently based on what the query is asking. Block-level memory attention searches across four scope-based blocks (session, project, global, archive) using softmax attention to allocate the result budget, with per-block score normalization. Canonically identical queries return cached results (30s TTL).
search(query: "authentication error handler", type_filter: ["code", "error"], limit: 5)
get — After finding results via search
Retrieve full observation content by ID. Never guess IDs — always get them from search or timeline first.
get(id: "<observation-id-from-search>")
restore_session — At session start
Recover context from previous sessions. Session ID is optional — defaults to current session.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 6d ago First seen · 160 lines · 167 tokens per session scan A 4b012cad4702
context-optimization is a skill published in the GitHub repository JubaKitiashvili/context-mem (18 stars, last pushed 4mo ago), licensed MIT. It adds 167 tokens to every session and 2,084 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
geminiignore-finops
Configure and optimize .geminiignore files for AI context window efficiency and token cost reduction (FinOps).
establishing-project-context
Use when the user asks to establish shared project language, or project work exposes a conflicting, renamed, or deprecated domain term that needs active semantic modeling. Routine small tasks stay on the fast path.
chronicle-skysight
Use when recent Linux desktop activity memory would help answer a question or when the user asks to inspect or control Chronicle or Skysight.
context-engineering
项目级上下文工程框架:通过 PROJECT / REQUIREMENTS / ROADMAP / STATE 四层文档 为每个任务建立结构化上下文,控制 token 预算,防止上下文腐烂, 确保跨会话连续性。与 context-lifecycle 的 L0-L3 层互补。.
error-experience-library
错误经验库:自动捕获错误模式、根因和解决方案,支持查询和反馈更新。 当遇到 build error、runtime error 或需要查找历史错误解决方案时使用。.
moai-foundation-context
Manages context window optimization, session state persistence, and token budget allocation for multi-agent workflows. Use for token budget management, context limits, or session handoff across agents.