English | 简体中文 | 日本語
Instinct
Instinct for your agent or harness: one local memory of what worked, shared by every agent you use.
Install
cargo install --locked instinct-cli
Then, in Claude Code, add the plugin so every prompt and tool call checks your lessons:
/plugin marketplace add koscak-labs/instinct
/plugin install instinct@koscak-labs
Prebuilt binaries and other agents: Install.
- About 76x fewer bytes per prompt than the same lessons in a CLAUDE.md. Memory-file bench
- Killed shells fell from 8.4 a day to 0.3 with tripwires, 57 days on our own machine. Field report
- Hooks answer in about 12 to 15 ms at 2,000 lessons. PR #59
⭐ Star it if your agent should stop repeating your corrections.
You fix your agent's mistake on Monday. On Tuesday a fresh session makes it again, and the other agent you use never heard about it. Every repeat costs tokens, time and another question back to you.
Instinct gives all your agents one memory of what worked. When an agent finds a method that works, or you correct it, it saves the fix as a short lesson in a file on your machine. Before its next decision, any agent that reads that file gets the one lesson that fits, or nothing. Before a command a lesson is about, Claude Code and Codex get it as a warning. Lessons that keep getting marked wrong stop coming back.
It plugs into Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode and more than 70 other agents through a skill, an MCP server, hooks or a few lines in AGENTS.md. It runs offline, needs no API key, and the engine has no third-party dependencies.
Grade your CLAUDE.md in your browser: paste it and see how many tokens it adds to every prompt, next to what Instinct would add. Nothing leaves the page. The same page runs the real engine, compiled to WebAssembly. Save a lesson, mark it wrong twice, and watch it go quiet. You can share what you built as a link.
See it in 30 seconds
Install first with cargo install --locked instinct-cli (or a prebuilt binary, see Install). Then save a lesson and describe a situation where it applies:
export INSTINCT_STORE="$(mktemp -d)/bank.hxdb" # a throwaway bank for this try-out; skip it to use your real one
instinct bank --title 'Run the tests offline' \
--when 'Running the test suite in this repo' \
--found 'Tests fail when cargo tries to reach crates.io from the CI runner' \
--how 'Run cargo test --locked --offline' \
--reconsider 'If you add a dependency, fetch it once with the network on' \
--evidence 'CI failed twice online and passed offline'
instinct recall --q 'the test suite keeps failing on CI' --k 1
[in-ux8hsjq] Run the tests offline (strength 0.50, 0 hit / 0 miss)
WHEN: Running the test suite in this repo
FOUND: Tests fail when cargo tries to reach crates.io from the CI runner
HOW: Run cargo test --locked --offline
EVIDENCE: CI failed twice online and passed offline
RECONSIDER: If you add a dependency, fetch it once with the network on
VALIDITY: source claim not independently verified; candidate, check original evidence
Ask about something unrelated, like instinct recall --q 'write a birthday toast for my sister', and it prints nothing.
Then record how the lesson worked out. A hit raises its strength and a miss lowers it:
instinct hit in-ux8hsjq --note 'offline run passed'
Strength goes from 0.50 to 0.67. Two misses silence a lesson with no hits. This one has a hit, so it takes three, and then recall stops returning it. Its history stays in the file.
When you are done, run unset INSTINCT_STORE so the next commands use your real bank (~/.local/share/instinct/bank.hxdb) instead of the throwaway one.
What it saves your agents
|
What we measured |
Details |
| Tokens |
At 80 lessons, a lookup adds about 301 bytes to the prompt. Pasting the same lessons as one memory file adds 22,957, about 76 times more. |
Memory-file bench |
| Lookup time |
A warm lookup through the MCP server takes 0.22 ms at 10,000 lessons. A cold CLI call takes about 5 ms at 100 lessons. |
Storage measurements |
| Asking you again |
With the lesson available, a fresh Codex printed all four badges. With an empty bank, it stopped and asked for the desk note. |
Handoff test |
| Context per task |
Across six first-use tasks, the lessons handed over came to 4,365 bytes, against 13,776 for always including the whole bank. |
First-use replies |
These are small, scripted tests on one machine, and they measure what reaches the agent more than what it does with it. In one run, framing the lesson for the agent made replies slower end to end (9.7 to 13.9 s against 3.0 to 5.2 s unaided), so measure it on your own work. Transfer experiment
See your own numbers
Every lookup adds one line of counts to a small file next to your bank: how many lessons it handed over, how many bytes, and how long it took. It never stores your questions or lessons. instinct stats adds it up:
Savings, all recorded time:
lookups served 50 (40 found a lesson, 10 found nothing)
kept out of prompts 318,760 bytes versus pasting the whole bank each time, about 79.7k tokens (estimate, about 4 bytes per token)
lookup time 1.0 ms median, 1.1 ms p95
hits / misses 24 / 0 recorded on the bank
lessons proven 8 (2+ hits, strength 0.6 or more)
instinct stats --share turns that into one line you can post. Set INSTINCT_METER=0 to turn the meter off.
Tripwires before risky commands
Instinct can also speak up right before your agent acts. instinct guard runs as a pre-tool hook. When the agent is about to run a command that a saved lesson is about, the lesson reaches the agent as a warning. It never blocks the command, and it stays silent when nothing fits.
instinct bank --title 'pkill -f can kill your own shell' \
--when 'Stopping a process with pkill -f and a pattern' \
--found 'The pattern also matched the shell running the command, so the script died' \
--how 'Find the exact PID with pgrep, then kill that PID' \
--evidence 'Shell exited mid-script twice' \
--tags 'tool_bash pkill;pkill pattern'
Now, before pkill -f server, the agent reads "Instinct tripwire (advisory, nothing is blocked): a saved lesson fits this action", followed by the lesson. Before ls -la or kill 4242, it reads nothing. Tag command lessons with tool_ plus the tool name and the command, like tool_bash pkill, so the guard can match them. The tool name only counts through a tag, so a lesson that merely mentions bash will not fire on every shell command. A check takes about 9 ms. In Claude Code the instinct-autorecall plugin turns tripwires on, and Codex takes the same hook (setup).
An empty bank has nothing to say. instinct starter --apply banks 36 tripwires for classic agent disasters (rm -rf on an empty variable, git push --force, git reset --hard, DROP TABLE, terraform destroy, curl | sh), each with the safe alternative; run it without --apply to read the list first.
Install
1. Install the instinct command
Every route below calls this command, so install it first. With Rust 1.89 or later:
cargo install --locked instinct-cli
instinct demo
instinct demo uses a throwaway bank and shows what a fresh agent gets for a familiar request and for an unrelated one.
Without Rust
Download the script, read it, then run it:
curl -fsSLO https://raw.githubusercontent.com/koscak-labs/instinct/main/install.sh
sh install.sh
On Windows, in PowerShell:
Invoke-WebRequest https://raw.githubusercontent.com/koscak-labs/instinct/main/install.ps1 -OutFile install.ps1; powershell -ExecutionPolicy Bypass -File .\install.ps1
The script downloads the binary for your system from the latest release, checks it against the release's SHA256SUMS and refuses to install on a mismatch. It puts instinct in ~/.local/bin (%LOCALAPPDATA%\instinct\bin on Windows), tells you if that folder is not on your PATH, and changes nothing else. Set INSTINCT_VERSION=v0.3.0 to pick a release and INSTINCT_INSTALL_DIR to pick the folder.
2. Choose where your lessons live
Nothing to set up. With no configuration, Instinct keeps one bank per user at:
| System |
Default bank |
| Linux, macOS |
$XDG_DATA_HOME/instinct/bank.hxdb, else ~/.local/share/instinct/bank.hxdb |
| Windows |
%LOCALAPPDATA%\instinct\bank.hxdb |
Instinct creates the folder readable by you alone (mode 700 on Unix). Every agent on the machine shares the same bank, so they share what each one learns. To keep a bank elsewhere, set INSTINCT_STORE to a file path in the shell profile that starts your agents; it takes priority over the default.
3. Connect your agent
For most agents, one command adds the skill. Run it in your project and pick your agent from the list:
npx skills add koscak-labs/instinct --skill instinct
The skill tells your agent when to look up a lesson and when to save one. For MCP, hooks or an AGENTS.md block instead, see the next section. In Claude Code you can also install everything at once:
/plugin marketplace add koscak-labs/instinct
/plugin install instinct@koscak-labs
Start a fresh session. The next time your agent gets something right that it got wrong before, ask it to save the lesson.
Connect Claude Code, Codex, Cursor or any other agent
Instinct works with anything that can run a command or talk to an MCP server. Pick the first route your agent supports:
| Route |
Works with |
Setup |
| Skill |
79 agents, including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, Roo Code, Kilo Code, Zed, Junie, Kiro, Goose, Amp, OpenCode and Warp |
npx skills add koscak-labs/instinct --skill instinct |
| MCP server |
Claude Code, Codex, OpenCode, Copilot CLI, VS Code, Cursor, Gemini CLI, Qwen Code, Cline, Roo Code, Kilo Code, Continue, Zed, Junie, Kiro, Claude Desktop, Goose, Amp and Droid |
instinct mcp over stdio. Config for each agent |
| Prompt hook |
Claude Code (tested), plus Codex, Gemini CLI and Qwen Code from their docs |
instinct prompt looks up a lesson on every prompt. Setup |
| Tool hook (tripwire) |
Claude Code and Codex (payload-tested) |
instinct guard warns before a command a lesson is about. Setup |
| Instructions file |
Any agent with a shell, including Aider |
Paste a short block into AGENTS.md or your agent's rules file |
| Claude Code plugin |
Claude Code |
/plugin marketplace add koscak-labs/instinct, then /plugin install instinct@koscak-labs |
The skill route needs instinct on the agent's PATH. The MCP server gives the agent four tools: save a lesson, look one up, record a hit or miss, and list proven lessons. Registering it by hand in Claude Code and Codex:
claude mcp add --transport stdio --scope local instinct -- instinct mcp
codex mcp add instinct -- instinct mcp
For automatic lookup in Claude Code, install instinct-autorecall@koscak-labs, or add this hook to .claude/settings.local.json and start Claude (set INSTINCT_STORE only if the bank lives elsewhere):
{"hooks":{"UserPromptSubmit":[{"hooks":[{"type":"command","command":"instinct prompt"}]}]}}
The hook reads your prompt and working folder, finds at most one lesson, and adds it to the session. It never hands over the same lesson twice in one session; the record (<store>.sessions, ids and counts only) is pruned after 35 days. When you write again in the same session and a lesson from earlier still has no verdict, the hook adds one line asking the agent to record instinct hit ID or instinct miss ID if your message shows how it went. Your reply is the best evidence, and the question rides on a turn that is happening anyway, so the agent never takes an extra turn and its last answer stays its last answer. It asks once per session. For harnesses without a prompt hook, instinct settle asks the same question as a Stop hook (--format codex for Codex). The plugins and the CLI use the default bank when INSTINCT_STORE is not set.
Judging lessons from what happened. instinct outcomes joins each delivery in <store>.sessions to the Claude Code or Codex transcript of that session and reads what followed: after a prompt lesson, the next 3 user turns (was there a correction, did the agent act on words the lesson brought); after a tripwire, the next 8 tool calls (did the warned action fail again). Each delivery is labelled helped, misled, unused or unclear, with the evidence line. It is a dry run; --apply records a hit for helped and a miss for misled, once per delivery, and never on top of a hit or miss the agent recorded itself. To measure the effect itself, set INSTINCT_EXPLORE=0.1: the hooks then withhold that share of lessons (picked by a stable hash of session and lesson, so the same session always gets the same answer) and outcomes and instinct eval compare corrections and failures after delivered lessons against withheld ones, with counts and a plain warning while there are fewer than 30 observations per side. It is off by default. A window with no correction is not proof the lesson worked; the labels show what the transcript says, nothing more.