- 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
1
Add the server
2
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.3
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.
1
Build the binary
Build
3ngram-hook from source (Go 1.24+; prebuilt release binaries follow
post-launch) and place it on your PATH:2
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.3
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.4
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. The precheck emits a structured
hookSpecificOutput.additionalContext JSON payload, which Claude Code surfaces
to the model next to the tool result — after the edit executes — so the
memories inform the model’s next actions rather than the edit being made (plain
PreToolUse stdout, by contrast, only reaches the hook transcript — view with
Ctrl-R). This differs from the SessionStart briefing, which lands in context
before your first prompt. It stays fire-and-forget: any failure exits silently
and never blocks the edit.THREENGRAM_BRIEFING_KIND=scope
and THREENGRAM_SCOPE=work. Setting THREENGRAM_SCOPE alone has no effect
unless the kind is scope.5
Verify the pipeline
0 means configured and reachable. 1 means no key was found; 2
means the key was rejected or the service was unreachable.The binary’s usage line also lists a
sync subcommand. It is a deferred
placeholder — currently a no-op that prints “not yet supported” and exits
0; the sync API routes do not exist yet. Do not wire it to a hook event.Confirm capture and recall across sessions
1
Capture in one session
Ask Claude Code to remember a decision (Layer 1). Confirm it landed:
search returns the memory you just saved.2
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.