DEV Community

Cover image for I got tired of my coding agent re-reading the same command output, so I built Dejavu
Salnik a
Salnik a

Posted on

I got tired of my coding agent re-reading the same command output, so I built Dejavu

If you drive a terminal coding agent (Claude Code, Codex, Cursor's agent, Aider, opencode, Gemini CLI), you've probably watched it do this:

  1. Run pnpm test. 40 lines of output. One test fails.
  2. Change something unrelated.
  3. Run pnpm test again. The same 40 lines. The same failure.
  4. Repeat five more times.

Every one of those reruns dumps the full output back into the agent's context. But the information the agent actually needs is the delta: did the failure change? The rest is noise it has already seen.

I kept hitting the same thing with git diff, rg, build logs, and typechecks too. And prompting the agent to "not reread unchanged output" doesn't reliably work. So I built Dejavu, a command-output memory layer for coding agents.

The idea: run the real command, print only what's new

Dejavu is a PATH shim. You launch your agent through it:

dejavu start claude
Enter fullscreen mode Exit fullscreen mode

That prepends a shim directory to PATH. Now when the agent runs pnpm test:

agent runs:      pnpm test
PATH resolves:   <dejavu-cache>/shims/bin/pnpm
shim runs:       dejavu run --shim-name pnpm -- test
Dejavu runs:     the real pnpm found later in PATH
Dejavu stores:   redacted stdout, stderr, metadata, exit code
agent receives:  first output, "unchanged" notice, or a compact delta
Enter fullscreen mode Exit fullscreen mode

The agent doesn't know Dejavu exists. It keeps running ordinary commands. Dejavu just remembers what each command printed last time.

What the agent sees

Identical rerun:

dejavu: output unchanged since run 8c51f73.
Command: pnpm test
Exit code: 1
Suppressed ~4,820 estimated tokens.
Full output: dejavu show b92d1aa --stdout
Enter fullscreen mode Exit fullscreen mode

Small change:

dejavu: output changed since run b92d1aa.
Changed lines:
- expected 403, received 200
+ expected 403, received 500
Enter fullscreen mode Exit fullscreen mode

The command ran all three times. Only the display changed.

The part I care most about: it never skips execution

The fear with anything in your PATH is that it silently caches and hands your agent stale results. Dejavu doesn't. The invariant:

  • It always runs the real underlying command.
  • It always preserves the real exit code.
  • Full output is stored locally and always recoverable: dejavu show latest --stdout.
  • It only optimizes command shapes it recognizes as safe: test runners, tsc/eslint, read-only git (status/diff/log/show), rg/grep, find, docker logs. Anything it can't confidently classify passes through untouched.
  • Mutating commands (git commit, git push, installs, docker build, watch modes) pass through.
  • DEJAVU=off pnpm test bypasses it for one command.
  • Nothing is sent to a server. The cache is local.

It's not a cache in the "skip work" sense. It's a memory layer for what got printed.

Does it actually help? Early numbers

I want to be precise, because it's easy to overclaim. The built-in suite (dejavu bench) runs the real classify + reduce pipeline over deterministic scenarios:

Scenario Agent reads without with Dejavu
js validation loop (5x test) 5,561 2,443 (-56%)
git workflow (diff, 40 files) 10,329 954 (-91%)
search loop (rg, 180 matches) 9,346 644 (-93%)
large build log (40k lines x2) 1,057,554 241
machine-readable git equal by design equal

And in ~12 real Codex sessions: 52-55% less intercepted output, and ~87% in repeated local rerun loops.

Important caveat: that's reduction on the outputs Dejavu touches, not a claim about your total token spend. The strongest effect is in rerun loops. The benchmark is reproducible on your machine, and CI fails if the numbers regress (dejavu bench --check).

Try it

# no install
npx @salnika/dejavu start codex

# or
brew tap Salnika/dejavu && brew install dejavu
cargo install dejavu-cli
Enter fullscreen mode Exit fullscreen mode

Then:

cd my-project
dejavu start claude
Enter fullscreen mode Exit fullscreen mode

Rust, MIT, macOS/Linux/WSL (no native Windows yet). Everything is on GitHub: https://github.com/Salnika/dejavu

If you try it, the feedback I'm most after: command shapes where the delta hides something you actually needed, and any case where the classifier reduced something it shouldn't have. Those reports are the most valuable thing right now.

Top comments (0)