- MCP connection (OAuth) — the
remember,search, andbriefingtools, available inside a session. - Hooks (API key) — a read-side context feed. The
SessionStartbriefing injects your open work into the model’s context at the start of every session; an optionalPreToolUseprecheck runs before edits. Both are fire-and-forget so they never block you.
Prerequisites
- A 3ngram account — the email and password you use for the dashboard at
https://app.3ngram.ai. - Claude Code installed and signed in.
Layer 1 — Connect over MCP
Authenticate
Run
/mcp inside a session and pick 3ngram. A browser opens the 3ngram
consent page; sign in, check the redirect host, and approve the two scopes
(memory:read, memory:write). The client registers itself and stores a
rotating refresh token — you will not sign in again until the grant is revoked.
See the Quickstart for the full OAuth walkthrough.Save your first memory
In a session, ask Claude Code:It calls
remember, appending a typed decision to your default scope. Writes
never overwrite — see Memory model.Layer 2 — Add the hooks
The hooks are a small static binary,3ngram-hook, that reads from the REST API so each Claude Code session starts with context. They are read-only: high-value write capture stays with the remember tool and the /debrief skill, never a mechanical hook.
Install the binary
Download the prebuilt
3ngram-hook for your platform from
GitHub Releases, verify its
sha256 against checksums.txt, and place it on your PATH.Create an API key
In the dashboard, open Settings → API keys and create a key. The full key is
shown once, in the form
3ng_<prefix>_<secret>. Copy it immediately.Give the hook the key
Either export it in your shell profile or the or write it to
env block of
~/.claude/settings.json:~/.config/3ngram/api-key (one line, no quotes). The hook talks
to the REST API at https://api.3ngram.ai by default, so no host configuration
is needed.Wire the hook events
Add the By default the briefing orients by the current project when you are in a git
checkout, and falls back to your whole account otherwise. To orient from a
specific scope instead, set both env vars:
SessionStart briefing to ~/.claude/settings.json. Its output is
injected into the model’s context at the start of every session:You can also wire
3ngram-hook precheck to PreToolUse (matcher Write|Edit)
to look up related memories before edits. In current Claude Code its output
appears in the hook transcript (view with Ctrl-R) rather than being injected
into the model’s context automatically — PreToolUse plain stdout is not added
as context the way SessionStart is. Treat precheck as a diagnostic aid, not a
guaranteed model-visible feed.THREENGRAM_BRIEFING_KIND=scope
and THREENGRAM_SCOPE=work. Setting THREENGRAM_SCOPE alone has no effect
unless the kind is scope.Confirm capture and recall across sessions
Capture in one session
Ask Claude Code to remember a decision (Layer 1). Confirm it landed:
search returns the memory you just saved.Recall in a new session
Quit and start a fresh Claude Code session, then ask the same
search question.
The memory is still there — that is the cross-session proof, and search finds
it regardless of scope or project.The SessionStart briefing also runs automatically, but it is scoped: inside a
git checkout it orients by the current project, so it surfaces this memory only
if you saved it with that project. To see unscoped memories in the briefing,
capture them with a project, or set THREENGRAM_BRIEFING_KIND=all (or scope)
as covered above.