Skip to content

Getting Started

nathan nelson edited this page Nov 23, 2026 · 9 revisions

Getting Started

Five minutes from clone to your first longhand recall returning a real answer from your past sessions.

Requirements

  • Python 3.10–3.14 — check with python3 --version. 3.15 can't install Longhand yet: onnxruntime, which chromadb requires, has no 3.15 build, so pip finds nothing to install (see the README).
  • Claude Code installed and used at least once (Longhand reads from ~/.claude/projects/)
  • macOS or Linux — Windows is not supported; use WSL2. A non-blocking windows-latest × py3.12 CI leg exists (continue-on-error, so it never blocks a merge), but it currently fails in core tests, not just native-dependency edge cases (18 core-test failures per run as of 1.3.2 — the 12 seen since at least v1.2.1, plus 6 backup tests added in 1.3.0 — #112). The workflow's own written policy is explicit: "red in core → keep the job, claim nothing" — hence no support claim. The launchd background reconciler is macOS-only regardless.
  • Disk: typical users need 200–400MB; heavy daily use can reach several GB (the author's own store: 8.0 GB SQLite + 2.9 GB Chroma = ~10.8GB for 1,045 sessions, roughly 10.6MB per session, measured 2026-11-22 — SQLite + Chroma together). The ~80MB embedding model download is cached separately, outside the data directory.

If you've never run Claude Code, there's nothing for Longhand to ingest. Come back after you've had a few sessions.


Install

pip install longhand

Confirm the CLI is on your PATH:

longhand --version

To upgrade later, run pip install -U longhand.

Developer install (from source)

If you want to hack on Longhand itself, clone the repo and use editable mode:

git clone https://github.com/Wynelson94/longhand.git
cd longhand
pip install -e .

pip install -e . installs in editable mode so you can pull updates with git pull without reinstalling.


Setup

One command wires up everything:

longhand setup

This does five steps in order (printed 1/5 through 5/5), each of which you could also run on its own:

  1. Ingest — discovers every JSONL file in ~/.claude/projects/ and parses every event (user messages, assistant text, tool calls, tool results, thinking blocks) into SQLite and ChromaDB. Analysis (project inference, episode extraction, segment clustering, outcome classification) runs inline as part of this step, not separately.
  2. Install SessionEnd + Stop hooks — adds both to ~/.claude/settings.json: SessionEnd runs the full ingest when a session closes; Stop runs a cheap live-tail on every assistant turn so an in-progress session is queryable before it ends.
  3. Install UserPromptSubmit hook — auto-injects relevant past context before Claude sees your next prompt. Skip with --skip-prompt-hook.
  4. Install MCP server for Claude Desktop — writes Claude Desktop's config directly. For Claude Code, setup prints the one-line claude mcp add longhand -s user -- longhand mcp-server command (or install the Longhand plugin, which wires this automatically). Skip with --skip-mcp.
  5. Doctor — verifies all components wired correctly.

Other flags: --skip-ingest skips the backfill entirely; --skip-analysis stores and embeds events but defers episode/segment extraction to a later longhand analyze --all (useful for a huge ~/.claude/projects); --data-dir points setup at a non-default store.

Setup takes about two minutes on a laptop with a year of sessions, and is safe to re-run — but re-running re-ingests every session rather than skipping what's already indexed (that incremental skip is longhand ingest's behavior, not setup's).

Want to see the shape of the output before pointing Longhand at your real history? longhand demo seeds a sandboxed store under $TMPDIR/longhand-demo-<timestamp>/ (that's /var/folders/.../T/... on macOS, typically /tmp/... on Linux) with 3 fictional sessions and walks through recall and recall_project_status — the demo corpus and store never touch your real ~/.longhand or ~/.claude. One caveat: demo isn't excluded from the once-daily update check, so it can still read or write ~/.longhand/update-check.json on exit (see Configuration).

First-time ingest on a large history (100+ sessions) can take a few minutes because ChromaDB has to generate embeddings for every event. Subsequent longhand ingest runs are incremental — unchanged files are skipped by size — but re-running longhand setup always re-ingests everything.


Your first recall

Ask it something in plain English:

longhand recall "that time we fixed the auth middleware"

You'll get back matched projects, relevant problem→fix episodes with diffs, conversation segments, and a prebuilt markdown narrative you can read top-to-bottom.

Try a fuzzy time reference:

longhand recall "the bug I was stuck on a couple weeks ago"

The time parser recognizes exactly these phrases — no exact dates required, and nothing else: right now / currently, earlier today / this morning, today, yesterday, this week, last week, (a) couple weeks ago, this month, last month, (a) couple months ago, (a) few months ago, last year, this year, recently / lately, and "N day(s)/week(s)/month(s)/year(s) ago". It does not parse calendar month names ("in March") or absolute dates; a query without one of the phrases above searches your whole history instead of a time window.


Use it from inside Claude Code

Once the MCP server is registered — via the Longhand plugin, or claude mcp add longhand -s user -- longhand mcp-server — Claude can call recall tools during a live session. Try asking:

"Do you remember the stripe webhook bug I fixed? Show me the diff."

Claude will call recall with your question, pull the episode, show you the fix, and continue the conversation with full context. No more re-explaining.

See the MCP Tools Reference for every tool Claude has access to.


What if something didn't work

Run the built-in diagnostic:

longhand doctor

It reports the status of the database, the hooks, the MCP registration, and the index. Most first-run issues show up there with a clear fix.

If doctor looks clean but something still isn't working, see the Troubleshooting page.


Common first-run gotchas

  • "No sessions found" on first ingest — confirm Claude Code has actually written to ~/.claude/projects/. If you're a brand-new Claude Code user with zero completed sessions, Longhand has nothing to read.
  • MCP tools not showing up in Claude Desktop — restart Claude Desktop after longhand setup (or longhand mcp install) so it picks up the new config.
  • MCP tools not showing up in Claude Code — setup/mcp install only write Claude Desktop's config. Run the command setup printed (claude mcp add longhand -s user -- longhand mcp-server), or install the Longhand plugin, which registers the server automatically via its bundled .mcp.json.
  • Slow first recall — ChromaDB lazy-loads its embedding model on first query. First call in a fresh process takes about 0.6s; warm calls after that run at a ~128ms median (measured 2026-09-27, 792 sessions, Apple M4 — your numbers will vary with corpus size and hardware).
  • Hook didn't fire — longhand doctor will tell you if the hooks are installed. Check that ~/.claude/settings.json contains SessionEnd and Stop entries.

Next steps

  • MCP Tools Reference — learn what Claude can call
  • CLI Reference — browse the 24 commands
  • Codex — using Codex too? Capture its threads into the same archive and search both from either client
  • Backup & Restore — opt-in push of the archive to a private git repo you own (needs git on PATH), and restore on a new machine
  • Configuration — tune hook behavior and relevance thresholds

Clone this wiki locally

⌂ 换网址