Skip to content

Import a Claude memory export in trail init - #732

Open
anirudhkumar-nanonets wants to merge 5 commits into
mainfrom
claude/init-imports-claude-memory-fad046
Open

anirudhkumar-nanonets wants to merge 5 commits into
mainfrom
claude/init-imports-claude-memory-fad046

Conversation

@anirudhkumar-nanonets

@anirudhkumar-nanonets anirudhkumar-nanonets commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Issue: Claude.ai remembers a lot about how people code, but none of it reaches Claude Code or their team; trail init only read Claude Code's own memory notes on the laptop.
Why: Claude.ai keeps its memory on claude.ai, with no file on the laptop for init to read; the only way out is asking Claude.ai to write its memories out.
Fix: trail init --claude-memory <file> (or - for stdin) reads that pasted export with no model, keeps only the facts about code (never personal ones or secrets), and offers them on init's screen, just for you; r adds one to the repo.

Moves: learnings kept at init (cold_start, new source = claude_ai, PostHog Postgres db 11: 0 today, it's new) and learnings_committed (db 11, the query in daily/project.md): 871 clones / 551 people over the last 7 days, read 2026-10-29.

What I chose

  • Input is a file or stdin, not an interactive paste. Init's screen needs the terminal's raw keys afterwards, so reading a paste from the same TTY until Ctrl-D would end stdin before the screen. Steps: ask Claude.ai "Write out your memories of me verbatim", save the answer, run trail init --claude-memory claude-memory.txt.
  • No model. The export is split into facts (a list item, or one sentence of a paragraph, keeping its heading and any [YYYY-MM-DD] date). A fact is offered only if it names a language, tool, repo, test, deploy, PR, file or the like; never under a "Personal" heading or about family, health, money, life dates or holidays. Secrets are scrubbed and a fact that still looks like one is dropped. Facts the repo already says (alreadySaid) and facts offered before (keyed by their words, so a re-export doesn't repeat them) are left out. At most 8, those naming this repo's code first.
  • Same offer flow, personal by default. The facts are MemoryCandidates with from: "claude.ai" and go through finishMemoryRead, like Claude Code's notes. On the screen they're a new row kind claudeai under "From what Claude.ai knows about you", inside Init's always-follow offer says what the rule does #724's "For your Claude only." section, ticked, "(this repo only)" beside each; r moves one into .trail/learnings ("added to this repo: your team gets it once you commit"), w is off for them, s shows the whole fact.
  • With no screen (an agent ran init, or stdin was the export), they're kept just for the person, never relayed and never in the repo, the same way init already keeps Claude Code's team notes with no screen.

Comparison (in the artifact)

Sample: the author's Claude Code memory for this repo (26 notes: 13 project, 8 feedback, 4 reference, 1 user) vs 22 committed learnings plus 2 personal. Both are short and written for Claude. Claude's memory is mostly about the person and the work around the code; trail's is about the code. Init's existing bar takes 5 of the 26 for the team today.

Checks

  • New tests: test/claude-export.test.ts (parsing, the code-only filter, private and secret facts never offered, offered once, kept just for the person with no screen) and two in test/init-run.test.ts (the screen with r, and an agent run).
  • CI test (ubuntu-latest) first failed on 2 tests of mine in test/skills-words-1b.test.ts: init's copy may not say memory, notes or remember. I missed them locally because my laptop run was under load and I read the failures from a partial log. Fixed in f29ae9a: the screen now says "From what Claude.ai knows about you" and "Claude.ai knows this; Claude Code doesn't.", and the telemetry source no longer spells memory in src/init/run.ts. The words, init, memory and contract test files (270 tests) pass locally. Before the fix CI ran 4141 tests: 4130 passed, these 2 failed, 9 were skipped.
  • Merged main after Init's always-follow offer says what the rule does #724 (438428b): the one conflict was INIT_COPY and KIND_ORDER in src/init/review-screen.ts. The Claude.ai rows now use Init's always-follow offer says what the rule does #724's layout (who gets them said once above the list, where each applies beside its name); the screen test follows it. Init, words, contract and telemetry tests (305) pass locally with a scratch HOME; typecheck is clean.
  • trail check flags src/cli.ts:1675 and :1819. Both are shared-word matches only: neither line reads PR reviews in the _trail-pair child, or runs Claude with the real HOME.

Follow-ups (not in this PR)

  • Facts read in the third person ("The user…", "They…"); a fact moved into the repo with r can carry a name if Claude.ai wrote one. Rewording them needs a model or a person-name check.
  • memoryTitle cuts "Go language support (incl." at the abbreviation's full stop (an existing Claude Code note in the sample).
  • Reading the export from the clipboard (pbpaste) so there's no file to save.

🤖 Generated with Claude Code

trail check flags src/cli.ts:1675 and :1819 on shared words only: neither line reads PR reviews in the pair child or runs Claude with the real HOME.
@trailhq-graft

trailhq-graft Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🌱 graft blast radius

3 areas changed → 1 area can be affected. 3 dependent symbols, depth 2.
Tests: no test reaches Init Command; 2 areas updated their tests.
Tag: @shhdwi — 3 of 4 areas

flowchart TB
  A0(("Look Back Discovery<br/>3 symbols"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0 reached;
Loading
Can be affected Symbols Nearest hop Reached from
Look Back Discovery 3 src/init/look-back-mine.ts:L118-L213 lookBack — calls, depth 1 Look Back Orchestration
Who knows this code — 1 person across 4 areas
Area Who knows it
Look Back Orchestration · changed @shhdwi — 9 commits, last 2d ago
Init Command · changed @shhdwi — 51 commits, last yesterday
Look Back Discovery · affected @shhdwi — 1 commit, last 6d ago
Memory Notes Export · changed only you — nobody else has touched these files

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 3 dependent symbols, grouped by area

Look Back Discovery — 3 symbols in 2 files

  • src/init/look-back-mine.ts:L118-L213 — lookBack (calls, depth 1)
    124: const fail = (what: string, e: unknown) => lb.errors.push(`couldn't read ${what} this time (${e instanceof Error ? e.message.slice(0, 80) : String(e).slice(0, 80)})`);
  • src/init/discover-worker.ts:L1-L109 — discover-worker.ts (calls, depth 2)
    11: import type { LookBack } from "./types.js";
  • src/init/discover-worker.ts:L50-L96 — lookBackOffThread (calls, depth 2)
Test signal per changed area — 2 ✓ · 1 ✗

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • ✓ Look Back Orchestration — 4 of 11 reached · 2 test files changed here: test/claude-export.test.ts, test/init-run.test.ts
    • not reached: countSentence, press, exportRows, memoryItems, isTeam, keepMemory, keepTeam
  • ✓ Memory Notes Export — 2 of 8 reached · 1 test file changed here: test/claude-export.test.ts
    • not reached: flush, push, factKey, factTitle, offerKey, saveMemoryCandidates
  • ✗ Init Command — 0 of 2 reached · no test file reaches it
    • not reached: readClaudeExport, runInitCommand
13 test suites also reference this code

17 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/cli-1b.test.ts
  • test/init-b6-review.test.ts
  • test/init-candidates.test.ts
  • test/init-disk-review.test.ts
  • test/init-fold-lessons.test.ts
  • test/init-keep-cli-review.test.ts
  • test/init-keep-cli.test.ts
  • test/init-lookback.test.ts
  • test/init-screen-review.test.ts
  • test/init-screen.test.ts
  • test/init-team-rows.test.ts
  • test/init-uncompiled-record.test.ts
  • test/trail-memory-notes.test.ts

⚠️ 1 changed file not in the graph (.trail/learnings/2026-10-29-a-claude-ai-memory-export-reaches-anirudhkumar.md) — no parser claims the extension, or the index predates the file.

graft blast · origin/main...HEAD · depth 2 · 12 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Oct 29, 2026
github-actions Bot added a commit that referenced this pull request Oct 29, 2026
github-actions Bot added a commit that referenced this pull request Oct 29, 2026
github-actions Bot added a commit that referenced this pull request Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant