Skip to main content

ContextMesh — Intelligent Context Layer for Claude Code

One coding session. Infinite memory. Minimal active context.

ContextMesh sits between Claude Code and the model. It captures every event in your session, builds a structured knowledge graph of your work, and dynamically provides Claude with only the most relevant context for the current task — saving tokens, reducing cost, and preventing context overload.

How it works

Claude Code Hooks → ContextMesh Daemon → Session Graph + Repo Graph
                                               ↓
                              Context Router (multi-signal scoring)
                                               ↓
                              Claude Code ← MCP Server (get_context)
                                               ↓
                              Token Savings Tracker → Report
  • RTK Output Compressor: Automatically intercepts massive terminal outputs (like npm install or massive grep commands) and intelligently compresses them down before sending them to Anthropic, saving you up to 90% on useless token noise.
  • Live Web Dashboard: Monitor your exact token savings and costs averted in real-time by visiting the local God-Mode dashboard at http://127.0.0.1:8765/dashboard.

The key insight: semantic similarity alone fails for long coding sessions because everything related to the same feature looks similar. ContextMesh uses graph proximity + code dependency relationships + causal edges + recency + file overlap — not just vectors.

Installation

The easiest way to install ContextMesh globally is using pipx.

# 1. Install globally
pipx install claude-contextmesh

# 2. Register as a macOS background service (runs silently on boot)
contextmesh install-mac

Setup a new project

When you start working on a new repository, just run:

cd /path/to/your/project
contextmesh init

This instantly connects Claude Code to the MCP server, indexes your codebase for the repo graph, and configures the hooks.

Using ContextMesh

You have two options for running Claude Code with ContextMesh:

Option A: Standard usage

Just run claude normally. Claude will automatically query ContextMesh for relevant memory and codebase context using the MCP server.

Option B: Token Proxy mode (Recommended for Enterprise)

If you want to measure exact token savings and cost reductions on your Anthropic bill, use our wrapper command instead:

claude-mesh

(You can also run contextmesh proxy manually and set export ANTHROPIC_BASE_URL=http://127.0.0.1:8099 if you prefer not to use the wrapper).

View token savings

# Session summary
contextmesh stats --session YOUR_SESSION_ID

# Recent turns with savings breakdown
contextmesh turns --session YOUR_SESSION_ID --limit 20

# Global summary across all sessions
contextmesh stats

# If using proxy mode — actual API token counts
contextmesh stats --proxy

Token savings tracker

Every time Claude calls get_context(), ContextMesh records:

Metric What it is
Accumulated tokens What the full session history would have been
Routed tokens What ContextMesh actually provided
Tokens saved The difference
Compression ratio routed / accumulated
Cost saved Based on your configured per-MTok price

Architecture

Dual Graph

Session Graph — captures every meaningful event:

  • User prompts, tool results, file reads/writes
  • Decisions, bugs, solutions, errors, test results
  • Typed edges: caused_by, solved_by, depends_on, same_task

Repo Graph — deterministic code relationships:

  • Functions, classes, methods, files (Tree-sitter parsed)
  • calls, imports, same_file, tested_by, inherits edges
  • Updated incrementally on every file write

Hot / Warm / Cold Memory

HOT   → Current task context (always injected)
WARM  → Related tasks, decisions, nearby graph nodes (retrieved on demand)
COLD  → Full historical transcripts (never auto-injected)

Context Router

Before every get_context() call:

context_score =
    semantic_relevance   (embedding cosine similarity)
  + graph_proximity      (BFS distance in session graph)
  + file_overlap         (Jaccard similarity with current task files)
  + recency              (exponential decay from now)
  + causal_relevance     (DECISION/BUG/SOLUTION type bonus)
  + unresolved_bonus     (UNRESOLVED_ISSUE always surfaces)

Cache-aware assembly order

STATIC (cacheable)
─────────────────────────────
=== CURRENT TASK ===
[hot nodes — current thread]

=== RELEVANT DECISIONS ===
[top-scored decisions]

DYNAMIC
─────────────────────────────
=== RELATED CODE CONTEXT ===
[repo graph: functions/classes in touched files]

=== RECENT HISTORY ===
[recent warm nodes]

=== UNRESOLVED ISSUES ===
[always surfaced]

Configuration

.contextmesh/config.toml in your project (or ~/.contextmesh/config.toml globally):

[router]
default_budget_tokens = 15000

[tracker]
input_price_per_mtok = 3.0       # Claude Enterprise cached input price
uncached_price_per_mtok = 15.0

[embeddings]
model = "all-MiniLM-L6-v2"       # Local, no API key needed

[tasks]
topic_shift_threshold = 0.35     # Cosine distance to detect task switch

Development

pip install -e ".[dev]"
pytest tests/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_contextmesh-0.6.0.tar.gz (54.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_contextmesh-0.6.0-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file claude_contextmesh-0.6.0.tar.gz.

File metadata

  • Download URL: claude_contextmesh-0.6.0.tar.gz
  • Upload date:
  • Size: 54.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for claude_contextmesh-0.6.0.tar.gz
Algorithm Hash digest
SHA256 dfa45f548f563d11bfbbe29cd0f01fd7b2603389af343184c9a5fd830020e9f5
MD5 aa03c799c76372fe9d76a6ec2fb5cd8b
BLAKE2b-256 5b21bf1b9560df67b2459b2d2d0af1ef2b9c0f54249f6bd853abd2ab1ff6556c

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_contextmesh-0.6.0.tar.gz:

Publisher: publish.yml on gajanansr/ContextMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_contextmesh-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_contextmesh-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48e11c1d9861f59ff6cd08cfeb6606710e71293c2d7a2cb077e9716c67ee6f9e
MD5 2f4daf4f5dd02e8f82e36c130bdf130e
BLAKE2b-256 c323f06a41a8083302eb221caaa9cc938210739423bad11b319f6e759f87c402

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_contextmesh-0.6.0-py3-none-any.whl:

Publisher: publish.yml on gajanansr/ContextMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.9.6

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.7.0

2 files

0.6.1

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.2.0

2 files

0.1.5

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page