⌘

Context Lens

v1.0.8🛡️Tier 1 Security AuditedCLI v2.1.287+ Verified

Interactive token distribution breakdown by system instructions, MCP tools, and codebase buffers.

@prompt-metrics•★1,240 stars•↓5,600 active installs•MIT License
View Source ↗
⚡Installation Specifier
$/plugin install context-lens@marketplace

Problem Solved & Architectural Motivation

Renders an interactive terminal breakdown showing exact token percentages consumed by system prompts, MCP tool schemas, conversation history, and project files. Alerts when prompt caching expires.

Before Execution

Zero-Time AST Interception

Evaluates tool payloads prior to kernel fork.

Scoring Model

0-100 Impact Index

Weighted heuristic scoring: files touched, git dirty state, env scope.

Non-Intrusive

Native CLI Hook

Zero proxy daemon required; hooks straight into Claude tool calls.

Lifecycle Architecture & Hook Flow

POSIX Event Engine
Step 01
Claude Plan
Prompt Inference
→
Step 02
Tool Call
tool.call Payload
→
HOOK INTERCEPT
context-lens
<18ms Heuristic
→
Step 04
OS Execution
Kernel Fork

Manifest Schema (plugin.json)

{
  "name": "context-lens",
  "version": "1.0.8"
}

Hook Implementation (register.js)

TypeScript SDK
export default function setup(lens) {
  lens.on('turn.before', (metrics) => {
    lens.ui.printContextBar({
      system: metrics.systemTokens,
      tools: metrics.mcpTokens,
      user: metrics.conversationTokens
    });
  });
}
Security Audit95/100
Network EgressNone (Zero Socket Egress)
Filesystem ScopeBounded to Workspace
Credential Exposure0 Leaks Detected
Sandbox IsolationHost User Privilege

Technical Specifications

Min CLI Versionv2.1.287+
Categorycontext-usage
Runtime Overhead< 18ms AST
LicenseMIT
Mod Publisher