SiftrCode • Context Optimization for Coding Agents →

The context optimizer for coding agents.

Give your coding agent focused repository context instead of dumping the whole codebase into its prompt.

🎯 Deterministic AST ContextEngine 🧬 6-Tier Variable Resolution 💰 Knapsack Token Budgeting 🔒 100% Local CPU • Zero Code Egress 🔌 Model Context Protocol (MCP)
Illustrative demo • Example task
1. Task Prompt → 2. Candidate Discovery (AST + Git) → 3. Deterministic Ranking → 4. Knapsack Budget Solver → 5. Materialized Bundle
Task Prompt: Candidate Discovery
Budget Cap: 16k tok / $0.05 max
❯
Presets:
cplan_9bf2a481 • ContextPlan
Submodular Synergy Bundle
★ EDIT TARGET (FULL IMPLEMENTATION BODY PROTECTED) RESOLUTION 5 (FULL)
src/webhooks/signature_verifier.ts
Identified via stack trace match & exact prompt symbols. Retained 100% body to allow editing without hallucination.
1,420 tok
100% Retained
⚡ DEPENDENCY INTERFACES (AST SKELETON SYNTHESIS) −92% TOKENS
src/auth/jwt.ts Interface skeleton: 4 types, 2 public methods
480 tok 4,120
src/db/session.ts Interface skeleton: SessionManager, TransactionClient
520 tok 5,800
src/queue/event_bus.ts Interface skeleton: EventPublisher, DeadLetterQueue
610 tok 6,400
✕ SUPPRESSED DEADWEIGHT (ZERO CONTEXT POLLUTION) 14 Files Omitted
tests/e2e/legacy.test.ts, scripts/deploy.sh, docs/arch.md, src/frontend/Header.tsx, src/billing/tax.ts...
Raw Context
94,200 tok
V2 Bundle
3,030 tok
Turn Cost
$0.0091
−96.8% Tokens Save $0.273 / turn

Works with Claude Code & Cursor

Select your coding agent to view instant setup commands.

Connect to Claude Code

• Guide →

Registers SiftrCode's Stdio MCP server to prune code before Claude reads it.

$ claude mcp add siftrcode -- npx -y siftrcode mcp
Or optimize context directly from terminal:
$ siftr context "task description"
Standard Model Context Protocol (MCP) Tools 10 NATIVE TOOLS
siftr_context

Primary context optimizer with 3-stage resolution lineage & budget solver.

siftr_optimize

Alias for siftr_context for outcome-aware context bundle optimization.

siftr_expand

Progressive disclosure expanding discrete methods to BODY with sibling exclusion.

siftr_outcome

Reports tri-state verification (verifiedSuccess: true | false | null) closing the loop.

siftr_session

Initializes sessions with environment discovery and tracks execution lineage.

siftr_rank

Explainable candidate ranker with transparent multi-channel scoring breakdowns.

siftr_skeleton

AST interface extractor for TypeScript, Python, Go, and Rust source files.

siftr_batch_skeleton

High-throughput concurrent AST interface extraction across target files.

siftr_audit

Audits codebase token footprint and calculates potential team ROI savings.

siftr_pack

Generates whole-directory pruned context packs for task-focused areas.

PIPELINE SPECIFICATION

The 6-Stage Optimization Engine

How SiftrCode analyzes task requirements, prioritizes critical edit targets, and compresses supporting context into typed interfaces under strict token budgets.

STAGE 01 Multi-Channel Discovery

Multi-Channel Candidate Recall

Blends Exact symbol matches, BM25 text retrieval, Stack Trace log parsing, Semantic AST Context Graph, and Git Co-Change intelligence to never miss relevant code.

STAGE 02 ContextFeaturesV1

Point-in-Time Versioned Features

Extracts deterministic feature vectors with strict FeatureCutoff timestamps, strictly eliminating data leakage and lookahead contamination.

STAGE 03 ContextRank + Shadow JEV

Deterministic ContextRank • Shadow JEV

Scores candidates deterministically with inspectable component breakdowns. TypeSafe JEV runs concurrently in shadow mode (p95 38ms latency, $r = 0.75-0.78$ oracle alignment) with 100% bit-for-bit plan invariance.

STAGE 04 BundleComposer

Submodular Synergy Bundler

Assembles bundles with diminishing marginal returns. Maximizes task evidence coverage while suppressing same-file symbol redundancy and dead weight.

STAGE 05 3-Stage Resolution Lineage

3-Stage Lineage & Discrete Method BODY

Preserves canonical lineage (ranker → budgeted → final). Isolates method bodies at discrete BODY resolution while strictly excluding sibling methods.

STAGE 06 BudgetSolver

Constrained Cost Optimization

Strictly enforces token caps (e.g. 16,000 max) and economic cost ceilings (e.g. $0.05/turn) with precise pricing models for Sonnet 3.7 and GPT-4o.

EMPIRICAL PILOT STUDY • SIFTRBENCH 25-TASK REAL VALIDATION

SiftrBench: Shadow JEV Real-World Pilot

Audited empirical evaluation across 25 real-world engineering tasks on Express, FastAPI, and SiftrCode. ContextRank remains the active deterministic decision-maker while TypeSafe JEV runs asynchronously in shadow mode, establishing genuine continuous distributions across 500 bounded calls with 100% bit-for-bit plan invariance and zero synthetic substitutions.

Sample Scale
25 Real Tasks
500 bounded evaluations across Express (10), FastAPI (10), and SiftrCode (5).
Latency (P50 / P95)
4ms / 6ms
Strictly bounded calls (mean 20/task, max 20) with peak concurrency 4.
Continuous Distributions
Genuine JEV
Relevance 0.3445, Edit 0.2159, Root Cause 0.2042. Zero synthetic 0.0s.
Plan Invariance
100%
Bit-for-bit plan identity in shadow mode. Zero production plan divergence.
Stratified SiftrBench Pilot Matrix (N=25 Audited Real Tasks)
Real Codebase Evaluation • Bounded Shadow Invariants
Target Codebase Tasks Task Types Shadow Calls Latency (P50/P95) Plan Invariance
benchmarks/express-repo 10 tasks Bug Fix, Test Failure, Features, Refactor 200 calls 4ms / 6ms 100% Identical
benchmarks/fastapi-repo 10 tasks Async Generators, Security Scopes, Routing 200 calls 4ms / 6ms 100% Identical
src/ (SiftrCode) 5 tasks AST Skeleton, BudgetSolver, Candidate Retrieval 100 calls 4ms / 6ms 100% Identical
Semantic Relevance
0.3445 mean
[0.2106 – 0.6951]
Implementation Needed
0.2983 mean
[0.1605 – 0.6630]
Likely Edit Target
0.2159 mean
[0.0601 – 0.6225]
Likely Root Cause
0.2042 mean
[0.0609 – 0.5737]
Controlled Live Remote JEV Smoke Study • Operational Telemetry
SDK: @typesafe-ai/[email protected] • Model: jev-latest • Commit: ef61f2f
PASSED • 0 LINEAGE DEFECTS CLEAN BUILD VERIFIED
Live Remote Calls
25 / 25

100% success • 0 failed • 0 retries

Remote Latency
179ms P50

P95 446ms • Non-blocking shadow

Plan Invariance
100% SHA-256

Normalized plan bit-level equivalence

Concurrency
4 / 4 max

Honest measured peak concurrency

Lineage Discrepancy
0 Mismatches

0 orphans • 0 snapshot mismatches

Egress Protection
Zero Raw Source

Metadata-only • secrets stripped

Ground Truth Oracle Correlation Empirical Pilot
ROOT CAUSE
r = 0.5743
RELEVANCE
r = 0.5115
EDIT TARGET
r = 0.2868
Ranking Impact (Baseline vs JEV) +0.0166 NDCG@5
NDCG@5
0.4725 → 0.4891
NDCG@10
0.4235 → 0.4342
› Audited Wire Payload Shape (Metadata-Only Egress • Call 1) Sample Req ID: req_01a0c49368217c7487475df9316a7709

Every remote candidate evaluation passes through EnforcedEgressGateway. Raw source bodies and secrets are excluded; only string lengths, symbol paths, and scalar features are transmitted over the wire:

{
  "schemaVersion": "string (12 chars)",
  "task": {
    "prompt": "string (73 chars)",
    "evidenceSummary": "string (13 chars)",
    "taskType": "string (11 chars)"
  },
  "candidate": {
    "contextUnitId": "string (21 chars)",
    "kind": "string (11 chars)",
    "title": "string (11 chars)",
    "path": "string (30 chars)"
  },
  "relationships": {},
  "history": {
    "coChange": "number (0.0000)",
    "recentChange": "number (1.0000)"
  }
}
Rights Profile: ALLOW (TASK_PROMPT, SYMBOL_NAME, SYMBOL_METADATA, PATH, NUMERIC_FEATURE) • DENY (RAW_SOURCE, SOURCE_SNIPPET, TRAINING) SIFTR_JEV_REMOTE_PROCESSING=true Application Verified
Shadow Safety, Canonical AgentEnvironment Lineage & Migration 13
JEV runs in non-blocking SHADOW mode. Production ContextPlans remain 100% deterministic ContextRank outputs. AgentEnvironment.systemConfigurationHash is the authoritative single identity binding sessions, plans, decision observations, JEV signals, and SQLite durability.
Architecture Deep Dive →
Outcome-Aware Context Economics

Token Economics & ROI

Smarter context allocation, not naive stripping. SiftrCode V2 maximizes marginal agent utility per token—cutting typical context payloads by 60%–88% while guaranteeing 100% full implementation fidelity on direct edit targets.

Budget Profile: Balanced (Default) • Optimal Quality & Cost
Variable-Resolution Allocation (85,000 Raw Tokens) Stage 05 • ResolutionRank
100% BODY RESOLUTION 16.5% of raw
Edit & Failure Targets
14,000 tokens • 0% fidelity loss

Full function bodies preserved for files the agent modifies or inspects. Zero missing lines, zero hallucinated edits, zero re-try loops.

88% AST COMPRESSION 4.9% of raw
Structural Dependencies
4,200 tokens • Signatures & Types

Distant callers and imports synthesized into typed AST interface skeletons. Retains all interfaces, types, and docs while collapsing bodies.

100% PRUNED BLOAT 78.6% dropped
Transitive Distractors
66,800 tokens • 0 ingested

Unrelated services, test fixtures, and noise files omitted safely before prompt ingestion, shielding the LLM from distraction and context drift.

Context Window

Payload per Turn

−78.6% Tokens
85k
42k
85,000
raw tokens (100%)
Raw
−78.6%
18,200
optimized
V2
Without Siftr
SiftrCode V2

100% full bodies on edit targets • 88% AST skeletons on dependencies.

Claude Spend

Monthly Cost / Dev

Save $280 / mo
$357
$178
$357.00/mo
$4,284 / yr
$0.255/turn
Save $280
$76.44/mo
$917 / yr
$0.055/turn
Without Siftr
SiftrCode V2

Saves $0.20/turn • $3,367 net annual savings per engineer.

Multi-Model Impact per Turn (85k Raw → V2 Optimized) Current Frontier Pricing
Claude 3.7 Sonnet $3.00 / MTok
$0.255 $0.055 / turn
−78.6%
OpenAI GPT-4o $2.50 / MTok
$0.213 $0.046 / turn
−78.6%
Claude 3 Opus / o1 $15.00 / MTok
$1.275 $0.273 / turn
Save $1.00/t
Net ROI
+$3,367/ dev
Prompt Speed
4.7xfaster
10-Dev Team
+$33.7k/ yr
$ npx siftrcode optimize --profile balanced
Truthful Token Accounting • TokenizerRegistry Calibrated
Tracks estimatedRenderedTokens calibrated against Claude BPE (~3.7 chars/tok) and GPT cl100k/o200k (~3.6 chars/tok) with measured actualProviderInputTokens reconciliation. Zero hidden context overflow.
Audit telemetry →

* Modeled on typical 85k-token repository payload at 50 turns/day, 28 work days/mo (1,400 turns/mo per dev). Claude 3.7 Sonnet ($3.00/MTok in), GPT-4o ($2.50/MTok in), Claude 3 Opus ($15.00/MTok in).

Simple Licensing

Free open-source CLI for individuals. Paid caching for teams.

OPEN SOURCE
INDIVIDUAL DEVELOPERS

Community CLI

$0 Free forever (MIT)
  • ✔ Context Engine (siftr context)
  • ✔ Multi-Channel Candidate Discovery & Recall
  • ✔ Safe Variable Degradation & Edit Target Protection
  • ✔ AST Interface Skeletons (TS, Py, Go, Rust)
  • ✔ Stdio & HTTP/SSE Model Context Protocol (MCP)
TEAM PRO
FOR STARTUPS & TEAMS

SiftrCode Pro

$19 / seat / mo
  • ✔ Everything in Community CLI
  • ✔ Team Cross-Repo Semantic Context Cache
  • ✔ Exposure-Aware Outcome Telemetry & Analytics
  • ✔ CI/CD PR Context Gates & Custom Budget Ceilings