---
name: inferenceos-token-saver
description: Systematic token-saving strategies using InferenceOS local context, caching, and session persistence to reduce Claude Code subscription usage.
user-invocable: true
---

# InferenceOS Token Saver

## Objective
Reduce token consumption in Claude Code by leveraging InferenceOS's local-first capabilities: context compression, result caching, session persistence, and adaptive routing.

## Execution Workflow

### 1. Start with a Route, Not Raw Reads
Before reading files or searching, call the InferenceOS MCP tool `inferenceos_route_task` with your task. It returns:
- Pre-searched context (saves grep/read tokens)
- Cached results from prior identical tasks (free reuse)
- A compressed workspace brief (replaces 20+ file reads)
- Matched skills and workflows (pre-built execution plans)

### 2. Use Cached Routes
If the route returns `route_mode: "distilled"`, a prior successful execution exists. Use its plan and context directly — zero exploration tokens needed.

### 3. Persist Everything
After completing work:
- `inferenceos_persist_result`: Caches the task/plan/summary for future reuse
- `inferenceos_auto_store_turn`: Saves the conversation turn locally

### 4. Use Session Notes Instead of Replay
For follow-up work, call `inferenceos_refresh_session_note` with `compact: true` instead of re-reading the full conversation history. This gives a ~500-token summary of the entire prior session.

### 5. Token Audit
Call `inferenceos_token_audit` to compare what the local-first approach saved vs. a naive approach. This helps quantify savings.

## Concrete Token Savings

| Action | Naive Cost | With InferenceOS | Savings |
|--------|-----------|-------------------|---------|
| Session start orientation | ~20K tokens (read 15 files) | ~500 tokens (briefing) | 97% |
| Repeated task | ~8K tokens (re-search) | ~200 tokens (cache hit) | 97% |
| Follow-up session | ~15K tokens (replay history) | ~500 tokens (session note) | 96% |
| Debug investigation | ~12K tokens (grep + read) | ~3K tokens (pre-searched context) | 75% |

## Red Flags & Constraints
- Do not skip the route step for non-trivial tasks — it's the single biggest token saver.
- Do not re-read files that are already in the context bundle from the route.
- Always persist after completing work — unpersisted work means the next session pays full price again.
- Use `compact: true` on session notes to get the lean version.
