Fast Jev Compaction
Audited from github.com/tamaratran/fast-jev-compaction
Fast Jev Compaction is a Claude Code plugin and npm library that compacts long agent sessions by asking TypeSafe's Jev which tool calls and results to keep, drop or truncate, instead of summarizing them with an LLM.
- Language
- TypeScript
- License
- MIT
- Running for
- 1 month
- Team
- Solo
Why this architecture
Two Jev Noul questions per tool call, gated by a threshold in code, prune a transcript without rewriting it, and a thin hook adapter falls back to Claude Code's built-in summary whenever Jev fails or saves too little.
Tech stack by layer
5 technologies · audited Oct 2, 2026- TypeScriptnpm library in src/ (ESM, Node 18+) with no runtime dependencies; compiled with tsc.
- Native fetchCalls the System One endpoint directly through an injectable fetch, with request building and response validation in src/request.ts.
- VitestUnit tests for the library and the hook adapter.
- JevAnswers two Noul questions per tool call: keep the call, and keep the result verbatim.
- Claude CodeFunction-hook plugin (hooks/fast-jev.ts) that replaces the built-in compaction summary, falling back to it on errors.
Fast Jev Compaction architecture diagram
Open SVGDiagram as text
- Claude Code session (/compact · auto-compact) → Function hook (hooks/fast-jev.ts): transcript
- Function hook (hooks/fast-jev.ts) → Compaction library (TypeScript · src/)
- Compaction library (TypeScript · src/) → Jev (TypeSafe System One): keep? nouls
- Compaction library (TypeScript · src/) → Function hook (hooks/fast-jev.ts): pruned history
- Function hook (hooks/fast-jev.ts) → Claude Code session (/compact · auto-compact): or fallback
Key architectural decisions
4 decisions- 01
Delete instead of summarize
The README explains that LLM summaries are lossy, so the library never rewrites anything: it only removes tool calls and tool results that Jev judges no longer needed, and user and assistant text stays verbatim and in order.
- 02
Two Noul questions per tool call
For every non-pinned call, Jev answers whether the call itself still matters and whether its result must stay verbatim. Against keepThreshold (0.5 by default) code keeps both, keeps the call with a truncated result, or removes the pair, so the decision logic is ordinary code around two probabilities.
- 03
Fit the state in code, in stages
State is the whole conversation with tool results replaced by short notes. It is fitted under maxStateTokens (25k by default) by successively truncating tool inputs, abridging long texts and collapsing old messages, and questions are batched so each request stays under maxRequestTokens (30k), below Jev's 32k limit.
- 04
Library first, plugin as a thin adapter
src/ is an npm package with a pluggable JevAsker transport and exported building blocks (collectToolCalls, fitState, batchCalls, decideCall, applyDecisions); hooks/fast-jev.ts is a thin Claude Code function hook that uses it and falls back to the built-in summary when reduction is too small or Jev fails.
How Fast Jev Compaction is built
How Fast Jev Compaction is structured
The repository is both an npm package and a Claude Code plugin:
| Path | Role |
|---|---|
src/compact.ts, src/state.ts, src/messages.ts |
Pairing calls with results, fitting the state, applying decisions |
src/request.ts, src/client.ts |
Building System One requests, validating responses, the default fetch client |
src/types.ts, src/index.ts |
Public types and exports |
hooks/fast-jev.ts, hooks/hooks.json |
The Claude Code function hook adapter |
.claude-plugin/ |
Plugin and marketplace manifests |
types/claude-code.d.ts |
Type reference for Claude Code's hook API |
tests/ |
Vitest tests for the library and the hook |
package.json declares no runtime dependencies. TypeScript, tsx, vitest and @types/node are development-only.
Backend & APIs
The core API is compactMessages(transcript, options), which returns the pruned messages, per-call decisions and stats. Message is a subset of Claude Code's SessionMessage, so a session transcript can be passed in directly. Transport is pluggable: implement JevAsker (one ask(state, questions) method), or inject fetch for tests. Options cover the Jev model (jev-latest by default), the endpoint, keepThreshold, preserveRecentMessages, maxStateTokens, maxRequestTokens and truncateHeadChars.
The decision logic is plain code around two Noul probabilities per call:
- A keep-result probability at or above the threshold keeps the call and its result.
- Otherwise, a keep-call probability at or above the threshold keeps the call and truncates the result to its head plus a note.
- Otherwise the pair is removed.
The first message and the newest messages are pinned and never touched.
Data & persistence
There is no storage. The state Jev sees is built per compaction from the transcript, oldest first, with tool results replaced by notes such as ok, 4213 chars (omitted). Tokens are estimated from character counts, which the README notes are calibrated to land a little above Jev's reported counts. When questions do not fit in one request, the same state is resent with each batch, the batches run concurrently, and their answers are merged.
Build, test & deploy
- Scripts:
build(tsc),typecheck(library plustsconfig.hooks.json),test(vitest run),demo(tsx examples/demo.ts) andvalidate:plugin(claude plugin validate). - Installing in Claude Code requires function hooks (Claude Code 2.1.274+,
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1) and a marketplace install from the repository. - There are no CI workflows in the repository.
What to copy (and what not to)
Copy:
- Prune, don't paraphrase. Typed keep/drop decisions keep exact paths, errors and commands that a summary would lose.
- Fit state in code before asking the model, in explicit stages, and stay under the documented request limit.
- A library with a thin adapter, so the same logic can run outside Claude Code and be tested with an injected
fetch. - Always have a fallback to the built-in behaviour.
Don't copy blindly:
- The README is explicit that a probability is not a proof that a result is safe to delete. It accepts that because the assistant can re-run the tool. Decisions that are not cheap to undo need higher thresholds or review.
- Token counts are estimates, not tokenizer output.
Rules for building on Jev: Next.js + AI SDK + Jev and Jev browser agent. Data on 648 open-source Jev repos: Jev for developers.
Sources & repo audit
- README (how it works, options, plugin install)
- package.json
- src/compact.ts
- hooks/fast-jev.ts (Claude Code adapter)
Independent analysis of repository at github.com/tamaratran/fast-jev-compaction. Spotted an inaccuracy? Use the claim form to request a correction.
Maintainer? Add the architecture badge to your README
[](https://stackitfast.com/project/fast-jev-compaction) Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Fast Jev Compaction's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "Fast Jev Compaction" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Fast Jev Compaction**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Fast Jev Compaction
- **What It Does**: Fast Jev Compaction is a Claude Code plugin and npm library that compacts long agent sessions by asking TypeSafe's Jev which tool calls and results to keep, drop or truncate, instead of summarizing them with an LLM.
- **Domain & Category**: Claude Code Plugin
- **Production Scale**: Solo
- **Development Mode**: CLASSIC
- **Architectural Rationale**: Two Jev Noul questions per tool call, gated by a threshold in code, prune a transcript without rewriting it, and a thin hook adapter falls back to Claude Code's built-in summary whenever Jev fails or saves too little.
- **Live Website Reference**: https://github.com/tamaratran/fast-jev-compaction
- **Source Repository**: https://github.com/tamaratran/fast-jev-compaction
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, Node.js, Jev, Claude Code, Vitest
- **Primary Language(s)**: TypeScript
- **License of the reference repo**: MIT
- **Backend & APIs**: TypeScript — npm library in src/ (ESM, Node 18+) with no runtime dependencies; compiled with tsc.; Native fetch — Calls the System One endpoint directly through an injectable fetch, with request building and response validation in src/request.ts.
- **Infrastructure & deploy**: Vitest — Unit tests for the library and the hook adapter.
- **Tooling, testing & ops**: Jev — Answers two Noul questions per tool call: keep the call, and keep the result verbatim.; Claude Code — Function-hook plugin (hooks/fast-jev.ts) that replaces the built-in compaction summary, falling back to it on errors.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/tamaratran/fast-jev-compaction @ e3f262a)
1. **Delete instead of summarize**: The README explains that LLM summaries are lossy, so the library never rewrites anything: it only removes tool calls and tool results that Jev judges no longer needed, and user and assistant text stays verbatim and in order.
2. **Two Noul questions per tool call**: For every non-pinned call, Jev answers whether the call itself still matters and whether its result must stay verbatim. Against keepThreshold (0.5 by default) code keeps both, keeps the call with a truncated result, or removes the pair, so the decision logic is ordinary code around two probabilities.
3. **Fit the state in code, in stages**: State is the whole conversation with tool results replaced by short notes. It is fitted under maxStateTokens (25k by default) by successively truncating tool inputs, abridging long texts and collapsing old messages, and questions are batched so each request stays under maxRequestTokens (30k), below Jev's 32k limit.
4. **Library first, plugin as a thin adapter**: src/ is an npm package with a pluggable JevAsker transport and exported building blocks (collectToolCalls, fitState, batchCalls, decideCall, applyDecisions); hooks/fast-jev.ts is a thin Claude Code function hook that uses it and falls back to the built-in summary when reduction is too small or Jev fails.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
- Structure as a Turborepo monorepo with strict package boundaries:
- `apps/web`: Application UI, routing, layouts, and server endpoints.
- `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
- `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
- `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
- Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
- Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
- Utilize Vite 6 with TanStack Router for fully type-safe routing. Manage server state and caching via TanStack Query v5 with optimistic UI updates.
4. **Design System & Aesthetics**:
- Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
- Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
- Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
- Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer: client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.Frequently asked about Fast Jev Compaction
What does Fast Jev Compaction do?
It replaces Claude Code's compaction summary with pruning: TypeSafe's Jev decides, for every old tool call and result, whether to keep it, truncate the result or drop the pair. Everything that is kept stays verbatim, and user and assistant text is never rewritten.
How do I install Fast Jev Compaction in Claude Code?
Function hooks need Claude Code 2.1.274 or newer with CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 and TYPESAFE_API_KEY set. Then run claude plugin marketplace add tamaratran/fast-jev-compaction and claude plugin install fast-jev-compaction@fast-jev-compaction, and restart or run /reload-plugins.
Does it use the TypeSafe SDK?
No. The library has no runtime dependencies and calls https://api.typesafe.ai/v1/systemone through an injectable fetch, with its own request builder and response validation; a custom JevAsker transport can be plugged in.
What happens if Jev fails or removes too little?
The library throws on Jev failures, malformed answers, a missing key or a history that cannot be fitted, and the Claude Code hook then falls back to the built-in summary. The hook also falls back when the reduction is too small to be worth it.
One email a month: new deep dives and stack trends
New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.
Similar architectures
- BrowserlessClassicHeadless Browser Automation Infrastructure · 2-5 PeopleShares TypeScript · Node.js
- Tailwind CSSClassicUtility-First CSS Engine & Framework · 1M+ MAUShares TypeScript · Node.js
- AstroHybridIsland Architecture Web Framework · 1M+ MAUShares TypeScript · Node.js · Vitest
- tRPCHybridEnd-to-End Typesafe API Framework · 1M+ MAUShares TypeScript · Node.js
- Next.jsHybridFullstack React Framework · 1M+ MAUShares TypeScript · Node.js
- Open Code ReviewHybridHybrid Deterministic + LLM Agent Code Review Tool · 20+ peopleShares Node.js · TypeScript