Skip to main content
Glama

Vicem — Diet the Context, Pass the Baton

Hit Claude's 5-hour quota limit mid-refactor? Or watching your AI agent lose its mind after 150k tokens of context rot?

Hand off your exact coding session, git diff, and compressed code skeletons to Codex, Gemini, Cursor, Antigravity IDE, or Web AI in 3 seconds — with up to 90% fewer tokens and 0 third-party dependencies.

Vicem 3-Second Context Baton & Diet Demo

$ vicem codex

  ╭─ VICEM CONTEXT BATON & DIET RECEIPT ──────────────────────────────────╮
  │ Source Session : Claude Code (sess-9f3a2c · 42 turns harvested)       │
  │ Context Diet   : 184,200 tok ($2.76) ──► 14,800 tok ($0.22) [-91.9%]  │
  │ Code Skeletons : 18 files compressed (31 bodies indexed in ledger)    │
  │ Security Guard : 2 secrets redacted (OPENAI_KEY, AWS_ACCESS_KEY)      │
  │ Relay Target   : OpenAI Codex CLI (interactive TTY handoff ready)     │
  ╰───────────────────────────────────────────────────────────────────────╯
[OK] [Vicem] Baton written to .vicem/BATON.md (182ms). Launching codex...

Measured Pipeline Contribution (Before vs. After Vicem)

Pipeline Stage

Raw Session State (Before Vicem)

After Vicem Baton & Diet

Measured Contribution

1. Session Continuity Relay

40+ turns of raw JSONL / SQLite history locked inside a single agent

Harvests active Goal, Done, Immediate NEXT & git diff into .vicem/BATON.md

< 3s handoff across 15+ CLI, IDE & Web AI agents

2. Code Skeletonization

Full source files with long implementation bodies (~120,000 tok)

Types & signatures 100% intact; bodies >= 12 lines indexed in .vicem/ledger.json

-80% to -90% code tokens (100% lossless via MCP vicem_rehydrate)

3. Test & Error Log Slimming

Verbose ANSI spinners & node_modules stack frames (~45,000 tok)

Root failure message + top 5 project stack frames (~1,200 tok)

-95% log noise while preserving exact failure root cause

4. Data Sampling & Noise Gate

Lockfiles, build bundles, and multi-megabyte JSON / CSV / SQL dumps

Artifacts filtered; data files reduced to inferred schema + 2 sample rows

-98% data bloat & zero context window overflow

5. Security & Write Integrity

Plaintext credentials in logs & risk of placeholder overwrites

3-Tier local secret redaction + SkeletonWriteGuard & SecretCommitGuard

0 leaked secrets & 0 external packages (dependencies: 0)


Related MCP server: slimctx-token-optimizer

1-Click Setup (macOS, Windows, Linux — Zero Terminal Config Needed)

git clone https://github.com/Rakkunn/vicem.git && cd vicem
  1. macOS / Linux: Double-click setup.command (or run ./vicem.mjs setup).

  2. Windows: Double-click setup.bat.

  3. Browser-Only (Air-Gapped / No Node.js): Open https://rakkunn.github.io/vicem/ or double-click index.html locally in Chrome, Edge, Brave, or Safari (connect-src 'none').

Wait 2 seconds — Vicem automatically registers the global vicem command, configures MCP servers across your installed agents (Claude Code, Codex, Cursor, Windsurf, Antigravity IDE), and installs the .agents/skills/vicem/SKILL.md skill.

Option B: Direct Zero-Install CLI Usage

Vicem consists of standalone files (vicem.mjs, index.html, .agents/skills/vicem/SKILL.md) built entirely on Node.js standard library modules:

# 1. One-click auto-setup (PATH + MCP registration + Git pre-commit guard)
./vicem.mjs setup

# 2. Auto-detect active session and pass baton to recommended target
vicem

# 3. Pass baton to a specific CLI, IDE, or Web AI target
vicem codex
vicem claude
vicem gemini
vicem ide
vicem web

# 4. Compact current bloated session in-place (Context Rot Rescue)
vicem self

# 5. Return baton to previous agent & auto-unmount temporary rules
vicem back

# 6. Restore pre-handoff file snapshot or roll back session
vicem rollback

# 7. Open Hydrated Zero-Network Web Studio (.vicem/studio.live.html)
vicem studio

# 8. Extract & smart-patch code blocks from Web AI clipboard reply
vicem land

# 9. Run <50ms zero-spawn environment & agent storage diagnostics
vicem doctor

Architecture & Core Capabilities

  1. Zero-Config 1-Command Relay (vicem codex, vicem claude, vicem ide, vicem web):

    • Auto-detects the active source session strictly scoped to the current project directory (cwd), preventing cross-project session bleed.

    • Length-adaptive fuzzy target matching (vicem codexx → codex, vicem claud → claude).

    • Interactive CLI handoff preserves full TTY keyboard control (stdio: 'inherit').

  2. 4-Stage Context Diet Engine (-75% to -90% Token Reduction):

    • Stage 1 (Noise Gate): Drops lockfiles, build artifacts, binaries, and minified bundles.

    • Stage 2 (Code Skeletonizer): Preserves interface, type, enum, and class/method signatures 100% intact while replacing function bodies >= 12 lines with /* ... */ or pass (indexing full bodies in .vicem/ledger.json for on-demand MCP rehydration).

    • Stage 3 (Log Slimmer): Strips ANSI codes, carriage-return spinners, and node_modules/site-packages frames while preserving the root error and 5 user stack frames.

    • Stage 4 (Data Sampler): Compresses large JSON/CSV/SQL files into compact schemas + 2 sample rows.

  3. Bookended U-Shaped Attention Baton IA (.vicem/BATON.md):

    • Zone 1 (Top Primacy 15%): # BATON header, ## 1. Goal, and ## 2. Immediate NEXT.

    • Zone 2 (Middle Evidence 75%): ## 3. Done, ## 4. Work Evidence (Git Diff & Slimmed Logs), ## 5. Architectural Context (Code Skeletons), and ## 6. Diet Ledger.

    • Zone 3 (Bottom Recency 10%): EXECUTION ANCHOR preventing placeholder writes and anchoring immediate execution.

  4. 3-Tier Secret Redactor & 3-Pillar Safety Guards:

    • Redacts AWS, GitHub, OpenAI, Anthropic, Google, Slack, Stripe, JWT, PEM private keys, and high-entropy assignments into ‹REDACTED:PROVIDER:HASH4›.

    • Pre-Handoff Lossless Snapshot (.vicem/snapshots/<batonId>/): Protects dirty working-tree files without ever running destructive git checkout --.

    • SkeletonWriteGuard & SecretCommitGuard: Blocks agents from writing { ... }, /* ... */, ‹REDACTED:...›, or <!-- VICEM-BATON-START --> markers into source files.


Manual MCP Server Registration (Optional)

If you prefer manual registration over ./vicem.mjs setup, register vicem.mjs mcp so agents can call vicem_create_baton, vicem_read_baton, vicem_rehydrate, and vicem_check_guard:

# Claude Code
claude mcp add vicem -- node /absolute/path/to/vicem.mjs mcp

# OpenAI Codex CLI
codex mcp add vicem -- node /absolute/path/to/vicem.mjs mcp

Supply-Chain Verification & Minimal TCB

Verify zero third-party dependencies and cryptographic artifact integrity in one command:

# 1. Confirm zero npm dependencies
node -e "console.log(JSON.parse(fs.readFileSync('package.json')).dependencies ?? '0 dependencies')"

# 2. Verify SHA-256 checksums of all core artifacts
shasum -a 256 -c SHA256SUMS

# 3. Run under strict Node.js Permission Model sandbox
node --permission \
  --allow-fs-read=. \
  --allow-fs-write=.vicem \
  --allow-child-process \
  vicem.mjs diet

Automated Test Suite

node --test test/*.test.mjs

Available Tools

4 tools
vicem_check_guardC

Verifies code or git diff against SkeletonWriteGuard, SecretCommitGuard, and StalenessDriftGuard.

NameRequiredDescriptionDefault
diff_textNoOptional diff or code text to inspect

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, yet it never says whether this is a non-mutating inspection, what happens when a guard trips (blocking error vs. findings list), or whether omitting diff_text falls back to the working tree or staged changes. Only the set of checks is disclosed, not the behavior around them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One front-loaded sentence with no filler. It is efficient, though the terseness borders on under-specification rather than tightness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema and no annotations, so the description should explain the result shape (pass/fail, findings per guard) and default input behavior; it does neither. For a verification tool whose whole value is its verdict, that leaves the agent unable to predict what it gets back.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the single optional parameter is documented in the schema, so the baseline applies. The description does not clarify the important implied semantics of omitting diff_text (what gets inspected by default) even though zero parameters are required.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

A concrete verb ("Verifies") plus resource ("code or git diff") that clearly separates it from the baton read/write/rehydrate siblings. The three guard names are internal jargon that the description never explains, so the agent knows it checks something but not what each guard enforces.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No statement of when to call this, no preconditions (e.g., before committing or writing skeleton files), and no reference to alternatives or when not to use it. The agent must infer the trigger point from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

vicem_create_batonB

Creates a compressed U-Shaped Context Baton (.vicem/BATON.md) from the current project and git/session state.

NameRequiredDescriptionDefault
goalNoPrimary engineering goal
targetAgentNoTarget agent identifier (e.g., codex, claude, ide)
budgetTokensNoToken budget (default: 4000)

TDQS

B3.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and it does disclose two useful behavioral facts the schema does not: the tool writes a file to a fixed path (.vicem/BATON.md) and derives content from current project plus git/session state. It omits critical mutation behavior — whether an existing BATON.md is overwritten, whether a backup exists, and what 'compressed' means operationally.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no filler; the artifact path and derivation source come early. It is efficient, though the brevity contributes to the guidance gaps noted elsewhere rather than being a fault of structure.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-required-parameter file-writing tool with no output schema and no annotations, the description covers what is produced but not what the baton is for downstream (vicem_rehydrate) or what happens on a repeat call. Adequate minimum, with a real gap around idempotency and lifecycle.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, including the 4000-token default for budgetTokens, so the schema already documents all three parameters. The description adds no further semantics about how goal or targetAgent influence the emitted baton, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and artifact: creates a compressed U-Shaped Context Baton written to .vicem/BATON.md from the current project and git/session state. An agent can tell this is the write-side counterpart to vicem_read_baton from the name alone, but the description never explicitly contrasts itself with the read/rehydrate/guard siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no when-to-use guidance, no precondition (e.g., run at end of session, before handing off), and no mention of the alternatives vicem_rehydrate or vicem_read_baton. The agent must infer the handoff workflow entirely from the sibling names.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

vicem_read_batonB

Reads the current .vicem/BATON.md and checks for git HEAD drift.

NameRequiredDescriptionDefault

No parameters

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. 'Reads' correctly signals a non-mutating operation and the drift check is a disclosed behavior beyond the name, but there is no explanation of what drift detection returns, whether drift makes the call fail or merely reports a flag, or what the agent should do with that result.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single tight sentence with the resource first and the drift check second. No filler, nothing redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-param read with no output schema, the definition should say roughly what comes back (baton contents, drift status, or an error on drift) and how it relates to vicem_rehydrate. It says what it touches but not what the caller receives or should do with a drift result.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, so there is nothing for the description to clarify; the baseline for a parameterless tool applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Reads the current .vicem/BATON.md') plus a secondary behavior ('checks for git HEAD drift'), which clearly separates it from vicem_create_baton. It does not distinguish itself from vicem_check_guard or vicem_rehydrate, which sound adjacent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no statement of when to call this versus vicem_rehydrate or vicem_check_guard, and no prerequisites or sequencing hints. The agent must infer that this is the cheap way to inspect current state before deciding on other actions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

vicem_rehydrateA

Restores the exact, secret-redacted source code of a skeletonized function/class from .vicem/ledger.json so you never write { ... } placeholders.

NameRequiredDescriptionDefault
file_pathYesRelative file path (e.g. src/auth.ts)
symbol_nameYesFunction, method, or class name (e.g. verifyJwt)

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden; it does disclose two meaningful traits: the data source (ledger.json) and that secrets are redacted in the returned code. It does not state what happens when a symbol is missing/not skeletonized, nor any permission or error behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with zero waste; the core action and its justification are stated immediately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter read tool with no output schema and no annotations, the description conveys what comes back (exact redacted source) and where it comes from. Only failure/edge-case behavior is unstated, which is a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both parameters are already documented with examples. The description adds nothing beyond the schema, so the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (restores) and resource (secret-redacted source code of a skeletonized function/class) with its source (.vicem/ledger.json). The operation is clearly distinct from the baton/guard siblings, though it does not explicitly name or contrast them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'so you never write { ... } placeholders' implies the context of use (when a function body has been skeletonized), but there is no explicit when-to-use/when-not guidance or reference to alternatives such as vicem_read_baton.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv1.0.0
    • First observedvicem_check_guard
    • First observedvicem_create_baton
    • First observedvicem_read_baton
    • First observedvicem_rehydrate

TDQS

A3.5/5.0

Scored across 4 tools

Disambiguation4/5

The four tools have mostly distinct purposes: creating/reading the baton, rehydrating source, and running guard checks. There is minor overlap because vicem_read_baton checks git HEAD drift while vicem_check_guard also verifies staleness drift, but the descriptions clarify the different scopes.

Naming Consistency4/5

All tools use a consistent vicem_ prefix and mostly follow a verb_noun pattern: create_baton, read_baton, check_guard. vicem_rehydrate is verb-only, which is a minor deviation but still clear and readable.

Tool Count5/5

Four tools are well-scoped for the server's purpose of managing compressed context batons and code skeletons. Each tool earns its place without feeling thin or bloated.

Completeness4/5

The surface covers the core lifecycle: creating and reading the baton, restoring skeletonized source, and checking guards. Minor gaps exist, such as no explicit delete/clear baton or list ledger entries operation, but agents can likely work around these.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Local-first MCP server that watches your coding sessions and injects a compact summary at the start of each new session. 85.6% token reduction, SQLite storage, no cloud. Works with Claude Code, Cursor, Cline, and Windsurf.
    15
    643 npm
    9
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Provides reversible context compression for AI agents, reducing token usage while preserving the ability to retrieve original content, and serves as an MCP server for integration with tools like GitHub Copilot and Claude Code.
    3
    1
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    A task-aware context compression layer for Agent workflows, RAG pipelines, and AI Coding assistants, reducing noisy logs, retrieval chunks, and code context into high-signal LLM inputs via CLI, Python SDK, and MCP.
    329
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents and MCP-compliant clients to dynamically shrink long-horizon context windows, pruning verbose tool outputs, HTML boilerplate, and semantic redundancy by roughly 40-70% without frontier LLM round-trips. Runs deterministically as a zero-dependency Python stdio server, accepting a payload plus optional compression and risk-bound options.
    7
    -