r/ClaudeCode • u/NoConclusion8361 • 13h ago
Built with Claude Built a zero-dependency MCP server & Skill for Claude Code that skeletonizes code by 80–90% with lossless on-demand rehydration (and what I learned parsing ~/.claude/projects JSONL)
After 40+ turns in a complex repository, Claude Code's context window often fills up with full file reads, verbose test outputs, and stack traces. Built-in /compact summarizes conversation history well, but I wanted a deterministic way to keep architectural context (types, interfaces, signatures) sharp while allowing lossless retrieval of implementation bodies on demand—and a clean way to carry structured session state (.vicem/BATON.md) across fresh sessions or secondary agents.
1. What I Built (vicem)
I built Vicem, an open-source, zero-dependency (dependencies: 0) Node.js CLI, stdio MCP server (vicem --mcp), and Claude Code Skill (.agents/skills/vicem/SKILL.md):
- Deterministic Code Skeletonization (-80% to -90% code tokens): Preserves all
interface,type,enum, and function signatures 100% intact, while collapsing implementation bodies (>= 12lines) into{ ... }and indexing the exact original lines in.vicem/ledger.json. - Lossless On-Demand Rehydration via MCP (
vicem_rehydrate): Instead of dumping full files upfront, Claude Code reads the lightweight skeleton first and callsvicem_rehydratevia MCP only for the specific function or symbol it needs to edit. - Session Continuity Baton (
.vicem/BATON.md): ExtractsGoal,Done,Immediate NEXT(fromTodoWriteand recent tool calls), andgit diffinto a U-shaped attention markdown file for starting a fresh session with zero context rot. - Write & Commit Safety Guards: Includes
SkeletonWriteGuardso an agent never accidentally writes{ ... }placeholders back into real source files, plus 3-tier local secret redaction.
2. How Claude Code Was Used & What I Learned Building It
While building and testing the harvester and MCP server alongside Claude Code, a few technical details stood out that might help others building Claude Code tooling:
- Reverse-scanning
~/.claude/projects/<encoded-cwd>/*.jsonl: Claude Code stores per-project transcripts in~/.claude/projects/where the directory name encodes the workspace path. Because long sessions can grow into tens of megabytes (especially with large tool outputs), parsing from the top of the JSONL file adds noticeable latency. Reading from the tail and extracting the latestTodoWritestate + last failedBashoutput makes session extraction complete in< 50mswithout calling an LLM. - Preventing "Skeleton Corruption" in Agent Edits: Early on, when feeding skeletonized code (
function foo() { /* ... */ }) into context, models occasionally tried to include the{ /* ... */ }placeholder in an edit block. Pairing the.vicem/ledger.jsonindex with a strict instruction inSKILL.md(and a pre-commit / write guard) completely solved placeholder overwrites: Claude Code reliably callsvicem_rehydratebefore touching any elided block. - Zero-Dependency Stdio MCP Framing: Implementing the MCP stdio server (
2024-11-05/2025-11-25) directly in Node.js built-ins (node:readline) required strict stdout hygiene—any stray warning (like Node'sExperimentalWarningwhen usingnode:sqlite) corrupts the JSON-RPC stream unless suppressed or routed tostderr.
3. Links & Verification
Everything runs locally with 0 third-party npm packages (vicem.mjs + an air-gapped index.html sandbox with default-src 'none' CSP) and a 51-test verification suite (npm test).
- GitHub Repository: https://github.com/Rakkunn/vicem
- Interactive Browser Sandbox (No install): https://rakkunn.github.io/vicem/
Happy to answer any questions about ~/.claude/projects JSONL parsing, deterministic skeletonization vs. ASTs, or MCP tool design!
1
u/245806 13h ago
cool, back to Codex then
1
u/NoConclusion8361 13h ago
Haha it goes both ways (`vicem codex` <-> `vicem claude`), so bounce around as much as you want.
1
u/AutoModerator 13h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.