Repository navigation
Configuration
Current as of v1.3.2. Longhand ships with sensible defaults. You can tune hook behavior, relevance thresholds, injection size, and opt-in redaction for your workflow.
longhand configPrints a table of every hook.* key plus redact.enabled and, since 1.3.0, the four backup.* keys, each with its current value and a one-line description, followed by the config file's path:
Key Value Description
hook.min_relevance 2.5 Minimum relevance score to inject context (higher = less noise)
hook.max_inject_chars 2000 Max characters injected per prompt (controls token usage)
hook.max_episodes 2 Max episodes to consider per query
hook.enabled True Whether the prompt hook is active
redact.enabled False Mask secret-shaped strings (API keys, tokens) at ingest
backup.enabled False Git-backed backup of the archive (opt-in)
backup.auto False Hourly pushes from the scheduled reconciler
backup.remote — Where the backup goes (set by backup init)
backup.path — The clone (default <data dir>/backup)
Config file: /Users/you/.longhand/config.json
Edit with: longhand config --set hook.min_relevance=3.0
Edit a key with longhand config --set <key>=<value>, e.g. longhand config --set hook.min_relevance=3.0 or longhand config --set redact.enabled=true. Only hook.*, redact.*, and (since 1.3.0) backup.auto are accepted; backup.enabled, backup.remote, and backup.path are written by backup init. --edit is also a flag on this command, but today it does nothing at all — the table still prints, and there's no interactive editor (#96).
All of these apply to the UserPromptSubmit hook (auto-context injection before Claude sees your next prompt), not to recall itself — a manual longhand recall or MCP recall call always searches, regardless of these thresholds.
Before injecting anything, the hook computes a relevance score for the top-ranked episode against your prompt: 1 point per distinct word of 4+ letters that appears in your prompt and in that episode's problem/diagnosis/fix text, plus confidence × 2. If the score is below hook.min_relevance, nothing is injected — silently, so a low-signal prompt never gets noisy unrelated context glued to it. Only episodes are ever injected this way, not conversation segments. Raise the threshold for less noise; lower it if genuinely relevant context is getting skipped.
Two more gates apply regardless of the threshold: prompts under 12 characters skip recall entirely (not worth the round-trip), and prompts are capped at 8,000 characters before being passed to the recall pipeline.
Upper bound on how much text gets prepended to your prompt as additionalContext. Longer injected text is cut with a trailing [... capped at N chars] marker rather than silently truncated. Lower it to control token usage further; the whole point of this hook is a small, high-signal nudge, not a second copy of the episode.
Set to false to make the UserPromptSubmit hook a no-op without uninstalling it (longhand prompt-hook uninstall removes the hook entry from ~/.claude/settings.json entirely; hook.enabled=false just short-circuits it). Related, but separate: hook.max_episodes (default 2) caps how many candidate episodes the hook considers when scoring relevance.
When true, secret-shaped strings (see Security → Redaction patterns for the full list) are masked at parse time across the main event text fields (content, tool_output, error_snippet, old_content, new_content), the tool-input JSON, and the raw JSON blob — before any of those reach SQLite, Chroma, or a Codex record. One known gap: a git commit message is extracted onto the event as its own field (git_commit_message, separate from tool_output) and isn't in the at-parse-time field list, so it reaches git_operations.commit_message unredacted even with redact.enabled=true — filed as #110. It only affects data ingested after it's turned on; run longhand redact (scan-only) or longhand redact --apply (masks in place and re-embeds affected vectors) to retroactively cover data already in the store — that retroactive pass does cover git_operations.commit_message, so a follow-up redact --apply masks the commit messages already stored — but every later ingest stores new ones unredacted again until #110 is fixed, so re-run it after new ingests.
longhand backup init writes four keys after you have accepted its consent screen: backup.enabled (true), backup.remote (the git remote it validated), backup.path (the clone, default ~/.longhand/backup), and backup.auto (false). config --set accepts only backup.auto in this namespace (longhand config --set backup.auto=true, the same as backup auto on); the other three are owned by backup init and backup disable, so a hand-edited remote can never bypass the private-repository check. With backup.auto on, the scheduled reconcile --fix pushes at most once an hour and only when something changed. See Backup & Restore.
Everything lives under one data directory: SQLite (longhand.db, plus its WAL/SHM files), the ChromaDB vector store (chroma/), config.json, a project-path cache (cache/jsonl_project_map.json), the update-check cache (update-check.json), the ingest lockfile (.ingest.lock, mode 0600), and logs/ (hook-errors-YYYY-MM-DD.log, background-ingest-YYYY-MM-DD.log, background-backfill-YYYY-MM-DD.log, since 1.3.1 live-retry-YYYY-MM-DD.log and session-retry-YYYY-MM-DD.log, then reconcile.log and codex-sync.log — the dated ones start a new file each day, the last two don't). Since 1.3.1, live-retry/ and session-retry/ hold a PID marker (mode 0600) for each busy-lock retry that is still waiting for the ingest lock.
Once backups are on (1.3.0+), four more entries appear: backup/ (the clone, unless backup init --path put it elsewhere), backup-state.json (per-session marks from the last run, mode 0600, never in the repository), backup.lock (held for the duration of a run), and logs/backup.log (auto-mode outcomes and failures). restore creates backup/ and backup-state.json too, even where backups were never turned on, and uses a transient backup-restore/ while it joins split parts.
Resolution order (one rule for most of Longhand, since v0.13.0): an explicit --data-dir flag > the LONGHAND_DATA_DIR environment variable > ~/.longhand. Because child processes inherit the environment variable, setting it relocates the store for the CLI, the hooks, spawned background workers, and the MCP server in one move — and the optional launchd reconciler bakes the resolved path into its plist. longhand doctor prints the resolved directory and which source won.
The exception to that one rule:
-
longhand config --setalways writes~/.longhand/config.json, ignoring both--data-dirandLONGHAND_DATA_DIR— while the hooks and every reader load the config from the resolved data directory. On a relocated store,config --setedits a file nothing actually reads (#96). Edit the config file directly in the relocated directory as a workaround. Sinceconfig --setis the one place that doesn't followLONGHAND_DATA_DIReither, that variable — not--data-dir— is still the one thing that reaches the hooks, the MCP servers, and the launchd reconciler — as long as that process actually sees it. Spawned background workers are the exception: since 1.3.1 they start withLONGHAND_DATA_DIRset to the spawning process's resolved directory, so a--data-dirreaches them too. Claude Desktop is a GUI app that doesn't read your shell profile, andmcp installwrites noenvblock, so addLONGHAND_DATA_DIRto theenvof itslonghandentry by hand.
A narrower related point: ingest's own --data-dir doesn't need to "carry into" registration anywhere, because ingest never registers hooks or an MCP server — only setup does both (ingest and registration) in one command, and setup's own doctor step at the end checks the default/env-resolved store like any other doctor call, not whatever --data-dir setup itself was passed. The other direction matters too: setup --data-dir isn't carried into the hooks or the MCP server it registers — their commands (<path>/longhand ingest-session, ingest-live, __prompt-hook-run, mcp-server) carry no --data-dir — so future sessions land in the default/env store unless LONGHAND_DATA_DIR is set where those processes run.
The data directory is meant to be 0700 (owner-only): LonghandStore's own setup creates it with mkdir(mode=0o700, exist_ok=True). But at least four other code paths can create the same directory first at the process's default umask (commonly 0755, world-readable): the update-check cache writer (writing update-check.json) and config --set (writing config.json) use a bare mkdir(exist_ok=True) with no mode, and schedule install-reconciler and the hook-error logger (when a hook fails before any store exists) create logs/ with parents=True, which applies 0700 to logs/ only — not to a missing ~/.longhand/ above it. Because mkdir(..., exist_ok=True) never changes the mode of a directory that already exists, once one of those two creates it first, LonghandStore's own mode=0o700 on a later call is a no-op — the directory stays at whatever permissions it was first created with, for good (#99).
-
LONGHAND_DATA_DIR— relocate the data directory (see above). -
CODEX_HOME— override where Codex capture looks for rollouts (default~/.codex; scans both itssessionsandarchived_sessionssubdirectories).codex-sync --codex-homeoverrides it per-invocation. -
LONGHAND_NO_UPDATE_CHECK=1— disable the once-daily version check against pypi.org entirely: no cache reads, no hint, no network refresh.
Without that opt-out, the version check is not limited to the interactive CLI the way earlier docs claimed. It's excluded only from the hidden hook/plumbing entry points (ingest-session, ingest-live, __prompt-hook-run, mcp-server, context, backfill-episodes). shared-mcp, mcp serve, and demo are ordinary top-level commands, so a refresh (respecting the 24-hour cache TTL) fires when they exit too — including the scheduled reconciler's reconcile --fix, at most once per 24 hours in practice since it just reuses the cache. So does a background ingest that recall spawns when no project matches — the prompt hook's recall included — since ingest isn't on the excluded list. longhand doctor is the one exception in the other direction: it forces a fresh check on every run, regardless of the cache (#101). The only thing ever transmitted is the HTTPS request to pypi.org itself.
Not configurable. Every Chroma collection (events, sessions, projects, segments, episodes) shares one instance of Chroma's bundled all-MiniLM-L6-v2, run locally through ONNX on CPU — no GPU, no remote inference, no per-collection model loading. Documents are truncated to 2,000 characters before embedding (the full text is always retrievable from SQLite by ID); upserts batch at 500 documents at a time. The ~80MB model download is cached outside the data directory, at ~/.cache/chroma/onnx_models/all-MiniLM-L6-v2, so moving or deleting ~/.longhand doesn't re-trigger the download.
No exceptions since 1.3.2. Before it, longhand analyze --all's episode-collection rebuild and VectorStore.reset() recreated their collections without the CPU-pinned embedder, so they fell back to Chroma's own default embedding function (#98, fixed by #113).
There is no server-side configuration file for either MCP server — no port, no env-based tuning beyond LONGHAND_DATA_DIR. Every knob is a per-call argument:
-
Semantic
longhandserver:max_charson the 5 tools that accept it (see MCP Tools Reference → Token budget),limitup to 1,000, and search queries truncated at 2,000 characters before reaching the embedding model. -
Shared
longhand-sharedserver:limitcapped at 50, search phrases capped at 200 characters, and text/raw-JSON reads served in 8,000-character slices. It also runs every query against a fixed per-query work budget (an internal SQLite instruction-count ceiling), independent of any argument you pass.