Skip to main content

Local rule memory for Claude Code and Cursor—corrections distilled into lasting guidance, recalled in context, one deliberate gate when stakes are high. 经验留下的痕迹,比记忆更深。

Project description

Nokori 残り

Nokori

A behavioral memory layer forged for Claude Code and Cursor.

PyPI Python License Stars

Languages: English | 简体中文 | 繁體中文 | 日本語

Quick Install · How It Works · Architecture · Configuration · CLI Reference · Web UI


What experience leaves behind runs deeper than memory.

Nokori (残り) means what remains: the thing still standing in place after the noise dies down.

Every session ends, and every correction you made evaporates with it. In the next session the agent wakes a stranger again, the same stranger who force-pushes, forgets to run the migration, types a dangerous command straight at the production database.

Nokori refuses to let it forget. It settles every "don't do that" you ever said into recallable behavioral rules: when your words drift back toward that scene, the rule surfaces on its own inside the agent's context. New rules first live as candidates underwater, collecting evidence in the background. Only after the cold path and posthoc evidence trust them can the sharpest ones become Gate-eligible and block the first risky tool call before the agent touches your files.

Your data stays on your machine, in SQLite, the whole way through. Retrieval during a chat never touches a model. Only the post-session extract calls an LLM, and even then it is fed nothing but compressed session fragments. Want it fully offline? Point the endpoint at a local Ollama.


Who is it for

  • People who keep correcting the same class of problem: force pushes, forgotten migrations, commands fired at the wrong database
  • People who want cross-project "don't do that" knowledge they build once and carry across repos, instead of re-teaching every repo from scratch
  • People who trust local: rules sit in SQLite on your own machine, exportable anytime, whole chats never sent out

One minute overview

You correct Claude / Cursor
    └─▶ Nokori carves a rule (what scene + what to do)
            └─▶ Next time your words drift near that scene
                    └─▶ The rule auto-writes into the agent's context (reminder)
                            └─▶ If it later becomes trusted + gate_eligible:
                                 block once before the first matching tool call (Gate)

During a chat Nokori only does retrieval and small file I/O, never making you wait on a model. The LLM is only called after the session closes, when it extracts new rules from the transcript at its own pace.


Quick install

Prerequisites: Python >= 3.11, Claude Code or Cursor already installed

# Recommended: pipx with local semantic retrieval
brew install pipx && pipx ensurepath
pipx install "nokori[local-embed]"

# Register hooks
nokori install --all        # or --cursor / default is Claude Code only

# Verify
nokori health
Other install methods
# Minimal install (BM25 only, no local model)
pipx install nokori

# Dedicated venv
python3 -m venv ~/.local/venvs/nokori
~/.local/venvs/nokori/bin/pip install "nokori[local-embed]"
echo 'export PATH="$HOME/.local/venvs/nokori/bin:$PATH"' >> ~/.zshrc

# From source
git clone https://github.com/KorenKrita/nokori.git && cd nokori
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[local-embed,dev]"

Full installation guide (Cursor config, updating, uninstalling) in Installation


Quick start

# 1. Add a candidate rule
nokori add \
  --trigger "Force pushing to a shared branch" \
  --action "Use --force-with-lease, or push to a new branch" \
  --severity high_risk

# 2. Verify the shadow match
nokori test "I'll just git push --force this branch"

# 3. Run maintenance (let evidence move rules forward)
nokori maintain

# 4. Rule out of date? Dismiss it
nokori dismiss <short_id>

Just open Claude Code or Cursor and work as usual. When a rule matches, the agent sees the injected reminder before it replies. For trusted + gate_eligible rules, the first sensitive tool call is blocked once.


Core features

Feature Description
Autonomous quality flywheel candidate -> active -> trusted; rules must earn evidence before gaining authority
Zero model calls on hot path Hooks do deterministic retrieval/matching/scoring only; no LLM wait between prompt and reply
Hybrid retrieval BM25 out of the box + optional local/remote semantic vectors, RRF fusion
Conservative Gate Only trusted + gate_eligible rules can block tools, and only once per turn
Shadow evidence Candidates accumulate counterfactual evidence in the background without disturbing the current chat
Local-first SQLite + filesystem, data never leaves your machine, optional offline LLM
Cross-tool support Native support for both Claude Code and Cursor
Web UI nokori web for a visual dashboard to manage all state

Documentation

Document Content
Architecture Flywheel mechanism, hook timing, injection vs Gate, Shadow Pool
Installation Platform install, Cursor config, updating & uninstalling
Configuration config.toml, environment variables, full reference
Retrieval Engine BM25, embedding, injection tiers
Rule Lifecycle State machine, promotion conditions, maintenance tasks
Automatic Extraction Cold-path pipeline, merge strategy, async mode
Gate Mechanism Two-layer matching, configuration, prompt-hash safety
CLI Reference All commands and options
Web UI Visual dashboard features and development

Relationship with existing systems

System Relationship
CLAUDE.md Complementary. Nokori doesn't touch your CLAUDE.md; it handles the dynamic "when X, do Y"
Claude Code auto-memory No conflict. Memory leans factual, Nokori leans behavioral rules
Other memory plugins Hooks can coexist, but avoid stacking many context-injection plugins

Data storage

All data lives in one local directory, ~/.nokori/. There is no network sync. Rules store behavioral descriptions, not your source code. Only the cold-path extract calls an LLM; point the endpoint at a local Ollama for fully offline operation.


Development

python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[local-embed,dev]"
python -m pytest tests/

Project constraints: hot-path hooks use only stdlib + urllib (no LLM calls between prompt and reply), all hooks wrapped in top-level try/except fail-open. Base install includes fastapi + uvicorn for the web dashboard.


License

MIT

Project details


Release history Release notifications | RSS feed

This version

0.5.8

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nokori-0.5.8.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nokori-0.5.8-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file nokori-0.5.8.tar.gz.

File metadata

  • Download URL: nokori-0.5.8.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nokori-0.5.8.tar.gz
Algorithm Hash digest
SHA256 50a30645f8d8e6aa96a13da915d39359b6082d911e356424b8cd8f5eb7c805db
MD5 360c24a8b5b128eee96b04c8a6662abf
BLAKE2b-256 19b3022efc59182a3fca273d429826472c77b132fe435b06851f109dd48386dc

See more details on using hashes here.

File details

Details for the file nokori-0.5.8-py3-none-any.whl.

File metadata

  • Download URL: nokori-0.5.8-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nokori-0.5.8-py3-none-any.whl
Algorithm Hash digest
SHA256 61f434381713081b6f2866aa9ff57100826cc10c4185b6c853f447ef0efb42c0
MD5 04852788a49ebfcaf54f41c93b0a2d4a
BLAKE2b-256 33d7d1522db6b6f3bda96c44a389a510bee09c9e3f7dee0527886822c83db4e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page