deja-vu · hashgraph-online — Claude Code hook: match prompts against session history
deja-vu pulls earlier coding sessions from disk into context at session start and before each terminal command.
MIT ★ 1,596 updated 2026-10-29
.claude/settings.jsonWhat deja-vu does
The deja-vu hooks bundle looks through coding sessions already stored on disk, pulling from Codex, Claude Code, Cursor, opencode, and nineteen other tools, including records written before the plugin was added. The lookup runs locally; no model is called during the search.
Five events trigger it. SessionStart loads relevant context from earlier sessions, UserPromptSubmit checks the new request against that history, PreToolUse runs a check before Bash and apply_patch calls, PreCompact writes the current session to memory before context gets compacted, and SessionEnd marks a session as closed. Each one calls ${PLUGIN_ROOT}/hooks/deja.sh with its own timeout, between 10 and 30 seconds.
The hooks are wired through a project's .claude/settings.json file. Without an entry there, Claude Code never fires these events and the history lookup stays off.
What it helps with
- load prior work on a codebase back into context at session start
- match a new prompt against earlier coding sessions
- check history before running a shell command
- write the current session to memory before compaction
- mark a session as finished on exit
Example prompts for the agent
- Check if we already touched this module in an earlier session
- Look through past sessions before running this command
- Save this session to memory before the context gets compacted
How to install deja-vu
Manually: put the files in place
.claude/settings.jsonThe hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json
Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command
Questions about deja-vu
How do I install deja-vu in Claude Code?
Add the hook entries to a project's .claude/settings.json file, wiring handlers for the SessionStart, UserPromptSubmit, PreToolUse, PreCompact, and SessionEnd events.
What does deja-vu do?
It searches coding sessions already sitting on disk, including ones from Codex, Cursor, and opencode, and surfaces matches before commands run and when a session starts.
Does the search need a model call?
No, lookups run against a local index with no model involved.
Source text
hooks.json · MIT
Hooks bundle shipped with the deja-vu plugin for Claude Code.
Search the coding sessions already on your disk — Codex, Claude Code, Cursor, opencode and nineteen more — including work from before it was installed, indexed locally with no model in the loop.
Triggers on: PreToolUse, UserPromptSubmit, SessionStart, SessionEnd, PreCompact.
```json
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "${PLUGIN_ROOT}/hooks/deja.sh hook-context",
"timeout": 10,
"statusMessage": "Recalling past sessions…"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "${PLUGIN_ROOT}/hooks/deja.sh hook-prompt",
"timeout": 10,
"statusMessage": "Searching past sessions…"
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash|apply_patch",
"hooks": [
{
"type": "command",
"command": "${PLUGIN_ROOT}/hooks/deja.sh hook-tool",
"timeout": 10,
"statusMessage": "Checking relevant history…"
}
]
}
],
"PreCompact": [
{
"matcher": "manual|auto",
"hooks": [
{
"type": "command",
"command": "${PLUGIN_ROOT}/hooks/deja.sh hook-precompact",
"timeout": 30,
"statusMessage": "Saving this session to memory…"
}
]
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "${PLUGIN_ROOT}/hooks/deja.sh hook-session-end",
"timeout": 10,
"statusMessage": "Marking this session as ended…"
}
]
}
]
}
}
```
© vshulcz · MIT · hashgraph-online/awesome-codex-plugins
Similar hooks
All hooks for Agent setup: memory, context, orchestration →deja-vu by other authors comes first.