/slm-cache
KV cache for repeated reads — call slm_cache_get(key) first; on a miss do the expensive operation then slm_cache_set(key, value, ttl_seconds) to store it; on a hit use the returned value directly; always fail-open (hit:false on any error, never raises); saves tokens when the
$ npx -y skills add qualixar/superlocalmemory --skill slm-cache --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/slm-cache
Context preview
The summary Claude sees to decide when to auto-load this skill.
KV cache for repeated reads — call slm_cache_get(key) first; on a miss do the expensive operation then slm_cache_set(key, value, ttl_seconds) to store it; on a hit use the returned value directly; always fail-open (hit:false on any error, never raises); saves tokens when the
SKILL.md
slm-cache.SKILL.mdname: slm-cache
description: KV cache for repeated reads — call slm_cache_get(key) first; on a miss do the expensive operation then slm_cache_set(key, value, ttl_seconds) to store it; on a hit use the returned value directly; always fail-open (hit:false on any error, never raises); saves tokens when the same file, query result, or tool output is read more than once in a session.
when_to_use: "cache file, avoid re-reading, repeated read, cache result, cache tool output, save re-read, reuse across session, cache check, cache hit, cache miss"
allowed-tools: slm_cache_set, slm_cache_get, Bash
slm-cache — KV Cache for Repeated Reads (Surface B)
Purpose
When the same file, query result, or expensive tool output is needed more than once in a session, fetching it again wastes tokens and time. `slm_cache_set` stores a result under a stable key; `slm_cache_get` retrieves it on subsequent calls. The cache is agent-scoped (automatically namespaced by tenant/agent ID), TTL-bounded, and fail-open.
This is an agent-routed cache — it caches results the agent explicitly routes through SLM. It cannot cache Claude conversation turns.
Tool: slm_cache_set
slm_cache_set(
key: str, # required — cache key (max 512 chars)
value: str, # required — value to store (max 1 MB)
ttl_seconds: int = 86400, # time-to-live in seconds (default 24 h)
) -> dictReturn dict
| Key | Type | Meaning | |-----|------|---------| | `ok` | bool | `True` on success; `False` on validation error or internal error | | `stored` | bool | `True` when the value was written to the cache | | `note` | str \| None | Error detail or `None` on success |
Keys are SHA-256-hashed internally per agent so they do not collide across agents. The raw key string you supply is the only handle you need.
Tool: slm_cache_get
slm_cache_get(
key: str, # required — same key used in slm_cache_set
) -> dictReturn dict
| Key | Type | Meaning | |-----|------|---------| | `ok` | bool | `True` on clean execution (including miss); `False` on internal error | | `hit` | bool | `True` when the key exists and has not expired | | `value` | str \| None | The stored value on a hit; `None` on miss | | `note` | str \| None | Error detail or `None` |
A miss returns `{"ok": true, "hit": false, "value": null, "note": null}`. `ok: false` means something went wrong internally but the miss behaviour is the same — treat both as a cache miss and proceed with the real fetch.
Standard Pattern: Cache-Aside
Always check the cache first, then fill on miss:
# 1. Check cache
cached = await slm_cache_get(key="file:/absolute/path/to/config.json")
if cached["hit"]:
content = cached["value"]
else:
# 2. Expensive operation (file read, search, API call)
content = read_file("/absolute/path/to/config.json")
# 3. Store for the rest of the session
await slm_cache_set(
key="file:/absolute/path/to/config.json",
value=content,
ttl_seconds=3600, # 1 h — adjust to data volatility
)
# 4. Use contentKey Naming Convention
Use a stable, human-readable prefix so keys are recognisable in stats and won't collide accidentally:
| Content type | Suggested prefix | Example | |---|---|---| | File read | `file:` | `file:/repo/src/config.py` | | Search result | `search:` | `search:recall:session_init_context` | | Tool output | `tool:` | `tool:build_code_graph:/repo` | | External fetch | `url:` | `url:https://api.example.com/v1/data` |
Key length cap: 512 characters. Keys longer than that are rejected (`ok: false`).
When Caching Pays Off
**Cache when:**
- You will read the same file more than once in a session.
- A search or recall result is reused across multiple reasoning steps.
- An expensive MCP tool call (graph build, semantic search) produces output that is stable for the session duration.
**Do NOT cache:**
- Volatile data (live API responses that change minute-to-minute, current timestamps, streaming output).
- Secrets, credentials, tokens, or `ccr_id` values (CCR already handles its own storage).
- Data that must be fresh for correctness — a stale cache is worse than a cache miss.
- Intermediate scratchpad text you will discard.
Fail-Open Guarantee
Neither tool raises an exception. On any internal error:
- `slm_cache_get` returns `{"ok": false, "hit": false, "value": null, ...}` — treat as a miss and proceed with the real fetch.
- `slm_cache_set` returns `{"ok": false, "stored": false, ...}` — log the note if useful, but continue; the value is still available in memory this step.
Never block a task on a cache failure.
TTL Guidance
| Data type | Suggested TTL | |---|---| | Static config / generated file | 86400 s (24 h — the default) | | Session-specific tool output | 3600 s (1 h) | | Rapidly changing API data | Do not cache, or 60–300 s |
Set `ttl_seconds` to match how long the data remains valid. After expiry `slm_cache_get` returns a miss automatically.
Secondary CLI (fallback when MCP is unavailable)
The `slm cache` subcommand exists but has known pre-existing parse-test failures. Prefer the MCP tools above. If you must use CLI:
slm cache status [--json] [--tenant default]
slm cache clear [--json] [--tenant default]
slm cache invalidate --tag <tag> [--json] [--tenant default]
slm cache ttl --set <seconds> [--semantic <seconds>] [--json] [--tenant default]
slm cache semantic on|off [--json] [--tenant default]
These subcommands control daemon-level cache settings. They do not read or write individual cache entries — use the MCP tools for that.
---
Related skills
- `slm-compress` — for large content reduction; cache and compress work together
- `slm-status` — view `cache_kv_hits`/`cache_kv_misses` counters from `slm_optimize_stats`
- `slm-profile` — cache entries are namespaced per profile; switching profiles gives a fresh cache namespace
---
SuperLocalMemory v4.0.0 · Qualixar · AG
Read more
name: slm-cache description: KV cache for repeated reads — call slm_cache_get(key) first; on a miss do the expensive operation then slm_cache_set(key, value, ttl_seconds) to store it; on a hit use the returned value directly; always fail-open (hit:false on any error, never raises); saves tokens when the same file, query result, or tool output is read more than once in a session. when_to_use: "cache file, avoid re-reading, repeated read, cache result, cache tool output, save re-read, reuse across session, cache check, cache hit, cache miss" allowed-tools: slm_cache_set, slm_cache_get, Bash
slm-cache — KV Cache for Repeated Reads (Surface B)
Purpose
When the same file, query result, or expensive tool output is needed more than once in a session, fetching it again wastes tokens and time. `slm_cache_set` stores a result under a stable key; `slm_cache_get` retrieves it on subsequent calls. The cache is agent-scoped (automatically namespaced by tenant/agent ID), TTL-bounded, and fail-open.
This is an agent-routed cache — it caches results the agent explicitly routes through SLM. It cannot cache Claude conversation turns.
Tool: slm_cache_set
slm_cache_set(
key: str, # required — cache key (max 512 chars)
value: str, # required — value to store (max 1 MB)
ttl_seconds: int = 86400, # time-to-live in seconds (default 24 h)
) -> dictReturn dict
| Key | Type | Meaning | |-----|------|---------| | `ok` | bool | `True` on success; `False` on validation error or internal error | | `stored` | bool | `True` when the value was written to the cache | | `note` | str \| None | Error detail or `None` on success |
Keys are SHA-256-hashed internally per agent so they do not collide across agents. The raw key string you supply is the only handle you need.
Tool: slm_cache_get
slm_cache_get(
key: str, # required — same key used in slm_cache_set
) -> dictReturn dict
| Key | Type | Meaning | |-----|------|---------| | `ok` | bool | `True` on clean execution (including miss); `False` on internal error | | `hit` | bool | `True` when the key exists and has not expired | | `value` | str \| None | The stored value on a hit; `None` on miss | | `note` | str \| None | Error detail or `None` |
A miss returns `{"ok": true, "hit": false, "value": null, "note": null}`. `ok: false` means something went wrong internally but the miss behaviour is the same — treat both as a cache miss and proceed with the real fetch.
Standard Pattern: Cache-Aside
Always check the cache first, then fill on miss:
# 1. Check cache
cached = await slm_cache_get(key="file:/absolute/path/to/config.json")
if cached["hit"]:
content = cached["value"]
else:
# 2. Expensive operation (file read, search, API call)
content = read_file("/absolute/path/to/config.json")
# 3. Store for the rest of the session
await slm_cache_set(
key="file:/absolute/path/to/config.json",
value=content,
ttl_seconds=3600, # 1 h — adjust to data volatility
)
# 4. Use contentKey Naming Convention
Use a stable, human-readable prefix so keys are recognisable in stats and won't collide accidentally:
| Content type | Suggested prefix | Example | |---|---|---| | File read | `file:` | `file:/repo/src/config.py` | | Search result | `search:` | `search:recall:session_init_context` | | Tool output | `tool:` | `tool:build_code_graph:/repo` | | External fetch | `url:` | `url:https://api.example.com/v1/data` |
Key length cap: 512 characters. Keys longer than that are rejected (`ok: false`).
When Caching Pays Off
**Cache when:**
- You will read the same file more than once in a session.
- A search or recall result is reused across multiple reasoning steps.
- An expensive MCP tool call (graph build, semantic search) produces output that is stable for the session duration.
**Do NOT cache:**
- Volatile data (live API responses that change minute-to-minute, current timestamps, streaming output).
- Secrets, credentials, tokens, or `ccr_id` values (CCR already handles its own storage).
- Data that must be fresh for correctness — a stale cache is worse than a cache miss.
- Intermediate scratchpad text you will discard.
Fail-Open Guarantee
Neither tool raises an exception. On any internal error:
- `slm_cache_get` returns `{"ok": false, "hit": false, "value": null, ...}` — treat as a miss and proceed with the real fetch.
- `slm_cache_set` returns `{"ok": false, "stored": false, ...}` — log the note if useful, but continue; the value is still available in memory this step.
Never block a task on a cache failure.
TTL Guidance
| Data type | Suggested TTL | |---|---| | Static config / generated file | 86400 s (24 h — the default) | | Session-specific tool output | 3600 s (1 h) | | Rapidly changing API data | Do not cache, or 60–300 s |
Set `ttl_seconds` to match how long the data remains valid. After expiry `slm_cache_get` returns a miss automatically.
Secondary CLI (fallback when MCP is unavailable)
The `slm cache` subcommand exists but has known pre-existing parse-test failures. Prefer the MCP tools above. If you must use CLI:
slm cache status [--json] [--tenant default] slm cache clear [--json] [--tenant default] slm cache invalidate --tag <tag> [--json] [--tenant default] slm cache ttl --set <seconds> [--semantic <seconds>] [--json] [--tenant default] slm cache semantic on|off [--json] [--tenant default]
These subcommands control daemon-level cache settings. They do not read or write individual cache entries — use the MCP tools for that.
---
Related skills
- `slm-compress` — for large content reduction; cache and compress work together
- `slm-status` — view `cache_kv_hits`/`cache_kv_misses` counters from `slm_optimize_stats`
- `slm-profile` — cache entries are namespaced per profile; switching profiles gives a fresh cache namespace
---
SuperLocalMemory v4.0.0 · Qualixar · AG
World's first local-only AI memory to break 74% retrieval and 60% zero-LLM on LoCoMo. No cloud, no APIs, no data leaves your machine. Additionally, mode C (LLM/Cloud) - 87.7% LoCoMo. Research-backed. arXiv: 2603.14588
Repo: qualixar/superlocalmemory
Other skills on superlocalmemory.
- /slm-compress
Compress large text, tool output, or transcripts to reduce context-window usage while keeping the full 1M window intact — call slm_compress(content, mode, reversible, ttl_seconds) to shrink content; if the result is lossy a ccr_id is returned so you can call slm_retrieve(ccr_id)
Open skill - /slm-governance
Enterprise compliance and governed workspace behavior for SuperLocalMemory. Covers role-based access (admin/member/viewer), retention policies, audit trail, GDPR data export/erase, and how agents must behave when operating under workspace governance. Requires power MCP profile
Open skill - /slm-graph
Index and query a codebase as a structural graph — build the code graph, trace blast radius of a change, find callers/callees/inheritors, semantic code search by meaning, assemble PR review context, and detect what changed since last index. Use when the user asks how code
Open skill - /slm-loop
Run gate-verified bounded loops with SuperLocalMemory as the durable ledger. Use when a task has a checkable acceptance condition (tests, schema, lint, reconciliation) and you must iterate until an INDEPENDENT gate passes — never stopping just because the agent believes it is
Open skill - /slm-mesh
Cross-session peer coordination via the SLM mesh network. Lets multiple AI agent sessions on the same machine discover each other, send messages, share lightweight state, and lock files to avoid conflicts. Requires full, power, or mesh MCP profile. All 8 tools are MCP-only —
Open skill - /slm-profile
Workspace isolation and runtime profile switching for SuperLocalMemory. Each profile is a fully independent memory namespace — separate facts, code graphs, and tool sets. Use switch_profile (MCP, requires code/full/power profile) to change the active workspace without
Open skill

