context-optimization
Skill19 starsChanged 8 months agoMITView on GitHub
This skill should be used when context-mem is available in the project. Guides efficient use of context-mem's 29 MCP tools: observe large outputs, search before re-reading files, restore sessions, manage token budget, save knowledge with contradiction detection, promote knowledge to global cross-project store, search across all projects, execute code safely, emit events, time travel through project history, ask natural language questions, coordinate multi-agent sessions. Triggers on: large tool outputs, repeated file reads, session start, budget warnings, context window filling up, knowledge management, cross-project knowledge transfer, global search, code execution requests, time travel, show project state, ask question, natural language query, register agent, claim files, agent status, knowledge graph, graph query, entity relationships, add relationship, graph neighbors.
14 other projects use a version of this.
Adopted by
Most recently taken up by
- AbdullahMalik17/Digital-FTEtheir own version, first seen Sep 26, 2026
- SkotAlexsander/skillstheir own version, first seen Sep 16, 2026
- docxology/templatetheir own version, first seen Aug 29, 2026
- VoDaiLocz/kilo-kit-mcptheir own version, first seen Aug 21, 2026
- muratcankoylan/Agent-Skills-for-Context-Engineeringtheir own version, first seen Aug 10, 2026
- Fandry96/k3-agentic-skillstheir own version, first seen May 12, 2026
Used with
Projects with it also use bdi-mental-states, filesystem-context and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Downey6689Skillbdi-mental-states
Transforms external RDF context into BDI mental states. Invoke when modeling beliefs, desires, and intentions.
Also in 4 projects that use this
Downey6689Skillfilesystem-context
Uses filesystem for dynamic context discovery. Invoke when organizing docs or loading information just-in-time.
Also in 4 projects that use this
AbdullahMalik17Skillconfiguring-dapr-pubsub
Configures Dapr pub/sub components for event-driven microservices with Kafka or Redis. Use when wiring agent-to-agent communication, setting up event subscriptions, or integrating Dapr sidecars. Covers component configuration, subscription patterns, publishing events, and Kubernetes deployment. NOT when using direct Kafka clients or non-Dapr messaging patterns.
Also in 3 projects that use this
AbdullahMalik17Skillcontainerizing-applications
Containerizes applications with Docker, docker-compose, and Helm charts. Use when creating Dockerfiles, docker-compose configurations, or Helm charts for Kubernetes. Includes Docker Hardened Images (95% fewer CVEs), multi-stage builds, and 15+ battle-tested gotchas.
Also in 3 projects that use this
xfstudioSkillconversation-memory
Persistent memory systems for LLM conversations including short-term, long-term, and entity-based memory Use when: conversation memory, remember, memory persistence, long-term memory, chat history.
Also in 3 projects that use this
muratcankoylanSkilllong-horizon-prompting
This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.
Also in 3 projects that use this
- +6 more from AbdullahMalik17
Other versions14 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 14
- muratcankoylan/Agent-Skills-for-Context-Engineering★ 18ksame name
- Fandry96/k3-agentic-skills★ 27same name
- VoDaiLocz/kilo-kit-mcp★ 27same name
- docxology/template★ 20same name
- AbdullahMalik17/Digital-FTE★ 12same name
- AbdullahMalik17/Hacathan_5★ 9same name
- AbdullahMalik17/My_skills★ 9same name
- xfstudio/skills★ 9same name
- rohunvora/my-claude-skills★ 6same name
- VersoXBT/claude-initial-setup★ 4same name
4 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 4 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 47
Search knowledge entries by query with optional category filter.
- Distinctive: line 54
Update the 3-5 line project summary shown at every session start.
- Distinctive: line 61
Check token usage. If over 80%, save work and call restore_session.
- Distinctive: line 119
When multiple agents work on the same project simultaneously:
- Very specific: line 123
Check agent_status to see what others are doing before starting work
- Very specific: line 128
ALWAYS search before get — never guess observation IDs
- Very specific: line 129
ALWAYS observe outputs over 500 tokens — keep context clean
- Very specific: line 130
NEVER call get without first finding the ID via search or timeline
- Very specific: line 131
When budget_status shows >80%: save work, call restore_session
- Very specific: line 132
When save_knowledge returns contradictions — review before proceeding, do NOT silently overwrite
- Very specific: line 133
Use source_type when saving knowledge — trust: explicit > inferred > observed
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
restore_session(session_id?: "<optional-specific-session>")save_knowledge — For reusable patterns (with contradiction detection)
Store decisions, error fixes, API patterns. Auto-checks for contradictions via keyword overlap AND semantic vector similarity (when available). Note that knowledge entries decay in search ranking (14-day half-life) unless actively accessed. Explicit entries decay slower.
save_knowledge(category: "decision|error|pattern|api|component", title: "...", content: "...", tags: ["..."], source_type: "explicit|inferred|observed")search_knowledge — Search the knowledge base
Search knowledge entries by query with optional category filter.
search_knowledge(query: "auth pattern", category?: "pattern", limit?: 10)update_profile — Project quick profile
Update the 3-5 line project summary shown at every session start. Auto-generates from knowledge if no content provided.
update_profile(content?: "Tech: React Native\nFocus: insurance app")budget_status — When context feels heavy
Check token usage. If over 80%, save work and call restore_session.
budget_status()execute — Run code snippets
Execute code in 11 languages (JS, TS, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, Elixir). Sandboxed with env sanitization.
execute(code: "console.log('hello')", language: "javascript")emit_event / query_events — Event tracking
Log and query priority events (P1-P4) for session analysis.
emit_event(event_type: "error", data: { file: "auth.ts", message: "token expired" })
query_events(event_type?: "error", priority?: 1, limit?: 50)time_travel — View/compare project state at any point in time
Parse relative dates ("3 days ago", "last week") or absolute timestamps. Compare then vs now to see what changed.
time_travel(target: "3 days ago")
time_travel(target: "2025-12-01", compare: true)ask — Natural language questions about the project
Intent classification (what/when/who/why/how) with parallel search across knowledge, observations, events, and graph.
ask(question: "why did we switch from REST to GraphQL?")
ask(question: "what changed in the auth module last week?")Additional Tools
summarize— Compress content and return the summary without storing. Use when the result is needed inline but not for later retrieval (unlikeobservewhich stores).timeline— Browse observations chronologically. Useanchorparam to see context before/after a specific observation. Prefer oversearchwhen exploring what happened in sequence.stats— Token economy stats for the current session (observations stored, savings percentage, searches performed).configure— Update runtime config (e.g.,configure(key: "privacy.strip_tags", value: false)). Changes persist for the session.index_content— Chunk and index source code for later search. Use on large files before searching them. Pairs withsearch_content.search_content— Search code previously indexed withindex_content. Returns matching chunks with file context.budget_configure— Set session token limits and overflow strategy (warn,truncate, orblock). Use at session start to set budget constraints.promote_knowledge— Promote a project knowledge entry to the global cross-project store. Privacy engine auto-redacts secrets before storing. Use for patterns that apply across multiple projects.global_search— Search the global cross-project knowledge store. Returns entries promoted from any project, with source project tracking.agent_register— Register current session as a named agent for multi-agent coordination. Provides identity for file claims and broadcasts.agent_status— List all active agents, their current tasks, and claimed files. Use to see what other agents are working on before starting a task.claim_files— Claim files being worked on to prevent conflicts with other agents. Detects and reports conflicts if another agent already claimed the same file.agent_broadcast— Send priority messages to all active agents via the event system. Use for important findings, blockers, or coordination signals.graph_query— Query entities and their relationships. Filter by entity type, relationship type, direction (in/out/both), and traversal depth (1-5).add_relationship— Create a relationship between two entities. Auto-creates entities if missing. Accepts optional weight (0-1).graph_neighbors— Find all entities connected to a given entity. Faster thangraph_queryfor simple one-hop lookups.
Multi-Agent Coordination
When multiple agents work on the same project simultaneously:
- Register as a named agent when working on a specific task (
agent_register) - Claim files before editing to prevent conflicts (
claim_files) - Check
agent_statusto see what others are doing before starting work - Broadcast important findings to all agents (
agent_broadcast)
Rules
- ALWAYS
searchbeforeget— never guess observation IDs - ALWAYS
observeoutputs over 500 tokens — keep context clean - NEVER call
getwithout first finding the ID viasearchortimeline - When
budget_statusshows >80%: save work, callrestore_session - When
save_knowledgereturnscontradictions— review before proceeding, do NOT silently overwrite - Use
source_typewhen saving knowledge — trust: explicit > inferred > observed - Expect knowledge entries to have relevance decay — frequently accessed entries stay relevant longer
Activity Journal
The PostToolUse hook automatically logs every edit, command, and file read to .context-mem/journal.md. This journal persists across sessions and is injected at session start for continuity.
Background Processes
The Dreamer background agent runs automatically (separate from the 14-day relevance-decay half-life used in search ranking):
- Marks knowledge entries as stale after 30 days without access
- Auto-archives non-explicit entries after 90 days
- Detects potential contradictions between entries in the same category
- Explicit (
source_type: 'explicit') entries are never auto-archived
Dashboard 2.0
The dashboard now includes: knowledge graph visualization, timeline explorer, agent panel for monitoring multi-agent sessions, and dark theme support.
Priority Order
restore_session+budget_configure— at session startsearch— before reading filesobserve— after large outputssave_knowledge— for decisions and patternsupdate_profile— when project context changes significantlybudget_status— periodically when context grows
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.

