Local runtime protection for Claude Code

Claude got stuck in a loop.
ContextGuard stopped it.

Catches loop patterns and bloated output mid-session. Surfaces the root cause and offers safe intervention.

Runs 100% locally. Code and transcripts never leave your machine without action.

Free, no signup required

Claude action → npm test • same failure • attempt 1

LOOP GUARD // EVIDENCE
[Interactive Interceptor Simulator]
Session activeObserving

Analyzing action sequence

$ npm test • same failure • attempt 1
Step:

Monitoring action sequence

Works in under a minute

Immediate value, no setup drama, no guesswork

1

1. Install the CLI

Add ContextGuard to any project in under a minute using curl, PowerShell, or npx.

npx contextguard audit
2

2. Run locally

Everything analyzes on your machine with zero data leakage and no forced signup flow.

100% local-first
3

3. Stop the loop

Prevent repeated reads, detect root cause, and keep the session stable before spending more tokens.

loop guard + cache audit
Why it works

Less waste, less chaos, no privacy tradeoff

-35%

Fewer repeat reads

ContextGuard catches the loop before it burns context, time, and patience.

-60%

Less wasted spend

Token telemetry reveals where inputs, outputs, and cache reads are silently drifting.

0

No external leak

All audits happen locally; only explicit opt-in pushes aggregated stats to the dashboard.

Runtime Protection & Token Control

Precision Control Over Claude Code Loops & Costs

From deep cache and token cost telemetry to live loop interruption and invariant rule retention.

Cost & Prompt Caching Telemetry

Real-time visibility into token input/output, cache write efficiency, and dynamic session cost.

Session Cost Tracking-85.2%
$0.28$1.90

Sub-penny precision accounting calibrated to official Anthropic model pricing.

Input & Output Tokens15.2K TOTAL
Input: 12.4KOutput: 2.8K

Granular accounting of context payload vs generated code stream.

Cache Read vs Write5-MIN WINDOW
94.2K READ / 4.8K WRITE

Continuous tracking of the 5-minute Prompt Caching window saving up to 90% cost.

Cache Hit Efficiency
96.4%HEALTHY REUSE

Maintaining 96%+ cache reuse to maximize 5-hour quota availability.

Prompt Cache Metering EngineSLIDING 5-MIN HIT RATE: 96.4%
[Turn 12] Prompt payload: 98,420 tokens | Cache Read: 94,800 tok ($0.028) | Cache Write: 3,620 tok ($0.013)
✓ Cache hit discount applied: saved $0.264 on single turn (Anthropic Prompt Caching Protocol)
Live Runtime Scenario

Interactive Terminal: Loop Interception & Recovery

Step-by-step reproduction of a real Claude Code session: repeating errors, circuit breaker engagement, evidence telemetry, and stabilization.

LiveStep 1/5
// [14:22:01] User Prompt: "Fix 401 Unauthorized error in auth session endpoint"
claude>I will run the test suite to inspect the failing assertion.
$ claude-tool: bash "npm run test:auth"
FAIL test/auth-session.spec.ts (42ms)
✕ POST /api/v1/auth/session should return 200 with valid bearer (line 42:15)
AssertionError: expected 401 to be 200
Tests: 1 failed, 11 passed, 12 total
[CONTEXTGUARD RUNTIME: OBSERVING BASELINE TELEMETRY]Input Tokens: 12.4K
Speed:
Transcript Inspector // 100% Local-First

Instant .jsonl Session Audit

Drop a Claude Code session file or test the sample transcript to see real costs, loops, and cache efficiency.

Where is my session file located?
~/.claude/projects/your-project/session.jsonl
100% Client-Side Privacy Guarantee

Transcripts are parsed purely in JavaScript inside your browser. Zero server uploads.

Don't have a .jsonl file handy? .
No guessing

You see the problem before it burns your budget and context window.

ContextGuard does more than inspect a transcript. It intercepts repeated failure patterns, reveals the root cause, and helps restore session stability before more tokens are wasted.

Repeats
3x
Cache
96%
Budget
Saved
⚙️Technical Architecture

How ContextGuard Intercepts Loops in Claude Code

Zero cloud code shipping, no network proxying, no binary patching. 100% local client-side Runtime Guard.

Claude Code Hook Protocol Definition
100% CLIENT-SIDE
Configured in ~/.claude/settings.json upon contextguard init:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "contextguard intercept --session-id $SESSION_ID"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Bash|FileEdit|Read",
        "hooks": [
          {
            "type": "command",
            "command": "contextguard record --status $EXIT_CODE"
          }
        ]
      }
    ]
  }
}
✓ Fast & Local:Local hook execution overhead is <2ms without network blocking.
Why not build a custom hook?

ContextGuard vs Writing Your Own Hooks

Claude Code hooks are powerful, but reliable loop prevention requires deep AST and git delta heuristics. Here is the architectural difference:

Swipe to see the full comparison

CapabilityDIY Custom Bash HookContextGuard Runtime Guard
Loop Detection Logic
✕Primitive exit code check (false-positives during iterative TDD)
✓AST tool signatures + git diff delta inspection (triggers strictly on 0 code progress)
Token Savings Valuation
✕Zero visibility into prompt cache boundaries
✓Full amortized carry-forward valuation across subsequent turns + 5-min cache tracking
Claude Loop Recovery
✕Hard block (Claude often guesses blindly or repeats identical query)
✓Generates structured evidence dossier showing root cause so Claude pivots instantly
Upstream Compatibility
✕Custom scripts break on hook schema updates
✓Maintained, compiled zero-dependency binary tested against every Claude Code release
PRICING & LICENSING // NO HIDDEN FEES

Choose Your Level of Protection

The CLI is free forever for offline inspection. Pro adds active real-time runtime defense with instant automated activation.

100% OFFLINE

Free Community

Local transcript audit, historical loop inspection, and config linting.

$0/ forever
INCLUDED IN CLI:
  • ✓Local CLI audit of .jsonl session files
  • ✓CLAUDE.md & MCP configuration cleanup
  • ✓Cost estimation calibrated to Anthropic rates
  • ✓100% offline processing on your local disk
FREE LIMITS:
  • ✕No active real-time loop interception
  • ✕No Continuity Guard (rules after /compact)
  • ✕No Output Guard (test log distillation)
RUNTIME DEFENSE

Pro Monthly

Active real-time protection for developers building with Claude Code daily.

$9/ month
PRO UNIQUE VALUE:
  • ✓Live Loop Interceptor: stops no-progress loops in runtime
  • ✓Output Guard: compresses verbose test dumps & noise
  • ✓Continuity Guard: preserves active rules across /compact
  • ✓5-Hour Quota Radar & Velocity Alerts
  • ✓Lossless Vault: local offline archive without token burn
  • ✓Instant license key activation & cloud sync
ONE-TIME // EARLY ACCESS★ BEST VALUE

Pro Lifetime

Lifetime access to all Pro capabilities and future updates with zero recurring fees.

$79/ one-time payment
LIFETIME PRIVILEGES:
  • ★All Pro capabilities included forever
  • ★No monthly subscriptions or recurring fees
  • ★Priority access to new modules & beta updates
  • ★Direct founder priority technical support
  • ★Transferable license key
FOR TEAMS

Team & Organization

Centralized quota visibility, team rule synchronization, and organization budget safety.

$29/ user / month
TEAM CONTROL:
  • ✓All Pro features for every team developer
  • ✓Central team dashboard with cache reuse metrics
  • ✓Security rule & policy synchronization
  • ✓Centralized billing and invoice management
  • ✓Dedicated team support

What are you paying for?

Based on typical workloads (10–15 hrs/week with Claude Code), intercepting runaway loops and optimizing prompt cache windows saves an estimated $40–$60/month in avoidable token waste. Explore your exact usage scenario in the interactive calculator below.

Payment Methods

Security Guarantee: Transactions processed via certified gateways (FreeKassa, TryBit). No card numbers stored.

Instant Pro Activation
● Available Online:
  • ✓Credit & Debit Cards (Visa, Mastercard, Mir)
  • ✓Cryptocurrency (USDT TRC20, USDC Polygon, BTC, ETH, TON)
  • ✓Fast Payment System (SBP)
⚡ INSTANT LICENSE DELIVERY

Your ContextGuard Pro license activates automatically upon confirmation. You will instantly receive your activation token for one-line CLI linkage: contextguard login --key <YOUR_KEY>.

Launch-ready

Put the product to work and stop paying for endless repeat loops.

100% LOCAL-FIRST // DATA INTEGRITY

Transparent Privacy Architecture

Your code and prompts never leave your local machine. Cloud telemetry is strictly opt-in and restricted to high-level numeric metrics.

100% ON YOUR DEVICE // ZERO NETWORK REQUESTS

Local Runtime (CLI, Plugin, Web Audit)

All parsing, transcript analysis, CLAUDE.md linting, and loop interception happen strictly on your computer.

  • ✓Source code, git diffs, and repository files
  • ✓User prompts and Claude model output text
  • ✓CLAUDE.md contents, .env files, and secret tokens
  • ✓Raw session transcripts (~/.claude/projects/)
  • ✓Local hook telemetry vault (~/.contextguard/vault/)
● LOCAL IN-MEMORY PROCESSING
STRICTLY USER-INITIATED (--push)

Cloud Dashboard (Team Analytics)

Sent only when explicitly running npx contextguard audit --push or signing into the dashboard.

  • ✓Aggregated token counts (Input / Output / Cache)
  • ✓Estimated session cost in USD and cache hit rate
  • ✓Anonymous hostname label for team aggregation
  • ✓Account email and Pro license status
● EXPLICIT OPT-IN METRICS
STRICT CODE-LEVEL GUARANTEE

What ContextGuard Never Does

Architecturally isolated perimeter with zero telemetry leak, no proxying, and zero access to proprietary code.

  • ✕Never reads or uploads source code to the cloud
  • ✕Never intercepts your Anthropic or OpenAI API keys
  • ✕Never transmits telemetry without an explicit --push flag
  • ✕Never sells or shares user data with third parties
● AIR-GAPPED LOCAL PERIMETER

Data Processing & Isolation Diagram

Clear visual separation of the local perimeter and optional cloud layer

Full Privacy Policy→
● CODE-LEVEL PRIVACY ENFORCEDZERO BACKGROUND EGRESS BY DEFAULT

ContextGuard hooks connect locally via Node.js middleware. Token analysis and loop detection run instantly in-process with zero external network sockets.

FAQ // FREQUENTLY ASKED QUESTIONS

Frequently Asked Questions

Everything you need to know about privacy, pricing, compatibility, and real-time runtime defense in ContextGuard.

01Where are my prompts, source code, and repository files sent?↓

Nowhere, ever. ContextGuard operates under a strict Local-First architecture. All parsing, .jsonl transcript auditing, loop interception, and config linting run entirely in your local environment. Not a single line of code or prompt is transmitted. Optional cloud dashboard and team analytics activate strictly via opt-in (--push) and transmit only anonymous aggregated token counts.

02Do I need a separate Claude paid subscription or an Anthropic API key?↓

ContextGuard works alongside the official Claude Code CLI under any authentication mode: whether you use a Claude Pro / Max web subscription or a direct Anthropic API key. ContextGuard does not require its own API key and does not alter your billing relationship with Anthropic.

03How does ContextGuard calculate dollar cost estimations?↓

Costs are calculated directly from the token usage fields in official Claude Code session logs and official Anthropic API pricing rates across Sonnet, Opus, and Haiku models, including Prompt Caching write and 90% read discount tiers.

04Does runtime inspection slow down Claude Code command execution?↓

No. ContextGuard hooks execute locally with negligible overhead (< 2ms median, p95 < 4ms). In fact, by compressing massive test failure dumps via Output Guard, ContextGuard actively speeds up Claude's generation latency.

05Which operating systems and terminal environments are supported?↓

ContextGuard is cross-platform and natively supports macOS (Apple Silicon M-series & Intel), Linux (Ubuntu, Debian, Fedora, Arch), and Windows (PowerShell, WSL2, CMD). It only requires Node.js 18+.

06How accurate are the token metrics and loop detection algorithms?↓

Token accounting is exact relative to official Claude Code session logs generated by Anthropic's backend. The loop detector inspects tool call parameters, exit-code sequences, and git diff deltas to prevent false positives.

07How does subscription cancellation work and is there a refund guarantee?↓

You can cancel your monthly subscription with a single click from the dashboard at any time with no questions asked. We offer a full 14-day money-back guarantee on all initial purchases. For any billing questions or refund requests, our team is available 24/7 at support@contextguard.tech.

08What is included with the Pro Lifetime license?↓

Pro Lifetime is a one-time $79 investment instead of recurring fees. You receive permanent Pro access to all current and future ContextGuard CLI modules, a personal license key, beta channel access, and direct technical support from the founders (team seat licenses and centralized organization cloud compute billed separately).

09Why use ContextGuard instead of writing a custom Claude Code hook script?↓

A simple custom hook can intercept basic exit codes, but cannot safely distinguish genuine iterative work from token-burning loops. ContextGuard performs real-time git working-tree delta analysis, amortized token savings valuation across subsequent session turns, automated prompt-cache boundary tracking, and generates structured recovery evidence that forces Claude to break out of failure loops without losing session context.