🛡️ ClaudeGuard — VS Code Extension
Fix the most painful Claude Code problems directly in your editor.
Built in response to the March 2026 wave of bugs: prompt cache drain, unauthorized file deletion, context quality degradation, and CLAUDE.md bloat.
Problems This Solves
| Problem |
How ClaudeGuard Fixes It |
| 🔴 Unauthorized file deletion (confirmed data loss bugs) |
Auto-checkpoint before every Claude session + one-click restore |
| 🟡 Silent 5-20 min hangs |
Detects missing CLAUDE_ENABLE_STREAM_WATCHDOG and guides you to fix it |
| 🟡 Context quality degradation after ~150K tokens |
Live token usage estimate + warning when you should run /compact |
| 🟡 Bloated CLAUDE.md wasting tokens on every message |
Token counter + section analyzer + optimization report |
| 🟡 No visibility into session state |
Real-time dashboard with session duration, files changed, checkpoint age |
Features
💾 Auto-Checkpoint (Safety Net)
- Detects when Claude Code starts running and automatically commits your current state to git
- Shows checkpoint age in the status bar — warns when it's time to checkpoint again
- One-click restore from checkpoint history if Claude deletes something it shouldn't
- Works with any git repo; offers to initialize git if not set up
📊 Session Health Dashboard
- Live Claude Code process detection
- Estimated token usage with progress bar
- "Run /compact now" warnings before quality degrades
- Known issue tracker showing your current mitigation status
- Recent checkpoint history
📝 CLAUDE.md Optimizer
- Live token counter in the status bar when editing CLAUDE.md
- Warns when you save if you're over the 2,000 token target
- Analyzes sections as
critical / useful / bloat
- Detects duplicate content, filler phrases, and over-verbose sections
- Generates an optimization report with specific fixes
- Includes a best-practice template when creating CLAUDE.md from scratch
⚡ Watchdog Setup
- Checks if
CLAUDE_ENABLE_STREAM_WATCHDOG=1 is set (the community-discovered fix for hangs)
- Shows shell-specific instructions to set it permanently
Installation
From source (until published to marketplace)
git clone https://github.com/your-org/claude-guard
cd claude-guard
npm install
npm run compile
Then in VS Code: Ctrl+Shift+P → "Extensions: Install from VSIX" — or press F5 to run in Extension Development Host.
Build the VSIX
npm install -g @vscode/vsce
vsce package
# Produces claude-guard-1.0.0.vsix
code --install-extension claude-guard-1.0.0.vsix
Commands
| Command |
Description |
ClaudeGuard: Create Safety Checkpoint |
Commit everything to git right now |
ClaudeGuard: Restore Last Checkpoint |
Pick from checkpoint history and hard-reset |
ClaudeGuard: Open Session Dashboard |
Full health dashboard in side panel |
ClaudeGuard: Edit CLAUDE.md |
Open or create CLAUDE.md with template |
ClaudeGuard: Analyze & Optimize CLAUDE.md |
Full token analysis report |
ClaudeGuard: Toggle Auto-Checkpoint |
Enable/disable auto-checkpoint on Claude detection |
Settings
| Setting |
Default |
Description |
claudeGuard.autoCheckpoint |
true |
Auto-checkpoint when Claude Code is detected |
claudeGuard.checkpointOnSave |
false |
Checkpoint on every file save (aggressive) |
claudeGuard.tokenWarningThreshold |
150000 |
Warn when estimated tokens exceed this |
claudeGuard.claudeMdMaxTokens |
2000 |
Target token budget for CLAUDE.md |
claudeGuard.watchdogEnabled |
true |
Check for the streaming watchdog env var |
The Problems in Detail
Why checkpoints matter
GitHub issue #29023: Claude Code v2.1.58 deleted an entire C:\Users\msafa directory.
Issue #24196: Claude combined a copy with an unauthorized recursive delete.
Issue #27507: Deleted 30 minutes of backtest results with no confirmation.
The fix: A git commit before Claude starts = full recovery in 10 seconds.
Why the watchdog matters
The streaming idle watchdog is disabled by default. Without it, Claude hangs for 5-20 minutes with no recovery — the abort function targets undefined variables. One power user logged 576 failures in 3,539 requests (16.3%) over 6 days.
The fix: export CLAUDE_ENABLE_STREAM_WATCHDOG=1 in your shell profile.
Why CLAUDE.md token count matters
Every message Claude processes reads your CLAUDE.md first. At 5,000 tokens, that's 5,000 tokens burned on every single interaction. With the cache bugs active since March 23, those aren't cached — they're full-price every time.
The fix: Keep CLAUDE.md under 2,000 tokens. Move details to .claude/rules/ files.
Contributing
PRs welcome. Key areas for improvement:
- Actual token counting via the Anthropic API (vs. current estimation)
- MCP server manager (toggle servers per session)
- Integration with
git worktree for parallel Claude sessions
- Windows process detection improvement
License
MIT