DEV Community

Fillip Kosorukov
Fillip Kosorukov

Posted on

Keeping Claude Code Context Alive Across a Desktop, a Laptop, and a VPS

I work from two computers — a desktop during the day, a laptop at night. Both run Claude Code. Both need to know what the other one did. For months the answer was "tell the second machine what you did on the first," which is exactly the kind of chore that eventually kills a workflow.

This is the setup that finally replaced all the manual context-passing. It's not clever, but it works, and I haven't lost a thread in about six weeks.

My name is Fillip Kosorukov. I'm a solo founder building a couple of SaaS products, none of which would ship without AI-assisted coding. Everything here runs on Ubuntu, Python 3, and a small pile of shell scripts.

The problem, stated precisely

Claude Code has session memory inside a given conversation, and per-project CLAUDE.md files that travel with the repo. What it doesn't have, out of the box, is a durable cross-machine working memory — the sort of thing where you can tell it "we decided X yesterday on the other computer" and it already knows.

My fix has three parts:

  1. A knowledge directory on the VPS that every machine syncs to (~/knowledge/)
  2. A session-end hook that auto-commits and pushes that directory
  3. A startup ritual that pulls the latest state and reads the recent CHANGELOG

The ritual takes less than a minute on either machine and gives the assistant a useful cold-start state.

The directory layout

~/knowledge/
├── INDEX.md
├── CHANGELOG.md           # append-only, every agent writes when finishing meaningful work
├── scratch.md             # Karpathy append-and-review note
├── meta/
│   └── sources-of-truth.md  # which file owns which category of information
├── <project>/
│   ├── rules.md           # durable behavior rules
│   ├── hypotheses.md      # unconfirmed patterns
│   ├── knowledge.md       # confirmed facts
│   ├── decisions/YYYY-MM-DD-topic.md
│   └── raw/               # ingested source material
Enter fullscreen mode Exit fullscreen mode

Nothing special. Markdown I can grep. That's the point. When I want to know whether a fact exists, I can ripgrep the tree from any machine in any shell.

The sync mechanism

The VPS is the source of truth. Desktop and laptop are clones. Git does the heavy lifting.

On each machine there's a hook that fires when a Claude Code session ends. It runs:

cd ~/knowledge
git add -A
git diff --cached --quiet || git commit -m "auto-commit: session end $(date -I)"
git push origin main 2>/dev/null
Enter fullscreen mode Exit fullscreen mode

A 2-hour cron catches anything the hook missed (sessions that crash, SSH disconnects, etc.):

0 */2 * * * bash ~/scripts/push_knowledge.sh
Enter fullscreen mode Exit fullscreen mode

And before I start meaningful work on either machine, I run git pull on the knowledge directory. The assistant reads the CHANGELOG first when it boots into a project, so the last thing either machine did is always in context.

The two rules that keep the base clean

Sync alone doesn't save you. The knowledge base has to not rot, or all you're syncing is garbage. Two rules have been load-bearing for me:

One home per fact. Every category of information lives in exactly one file. If a fact belongs in localmention/rules.md, it does not also live in a global memory, a skill definition, or a note somewhere. The meta/sources-of-truth.md index tells agents (and me) where each category of knowledge lives. Without this, you'll end up with three slightly divergent copies of the same fact and no way to tell which is current.

Two outputs per task. Every substantial piece of work produces both the code change AND a knowledge update. Together. In the same session. Not deferred. This is the single rule that separates knowledge bases that grow from knowledge bases that stagnate after the first three weeks.

The bit most people miss: the scratch note

One file in the knowledge tree does disproportionate work: scratch.md. It's an append-and-review note in Andrej Karpathy's original style, adapted for AI-assisted coding.

Rules:

  • Drop any uncategorized thought there. Ideas. Links to read. Half-formed observations. "Should I try X."
  • New entries go on top, timestamped.
  • No tags. No folders. No categorization at capture time.
  • Weekly, I say "review scratch" and the assistant walks me through entries. For each, I decide: keep, promote (to a proper home — rule, hypothesis, decision), or delete (explicit only).

Capture is fast because no classification decision is required. Classification happens later, during review, with more information. Most entries end up being deleted as noise. The real patterns resurface across multiple reviews and earn promotion.

Starting this file was the single highest-return change I made to the whole setup.

What it cost to get here

A few things I got wrong along the way so you don't have to:

  • Don't put secrets in the knowledge base. Ever. It's in git, it's backed up, it's synced to multiple machines, and eventually it'll end up somewhere public. Separate secrets store, referenced by filename only.
  • Verify runtime paths before editing files that run under cron, systemd, or hooks. I've been bitten three times editing the wrong version of a file. Global git hooks live at ~/.git-hooks on my box; per-repo .git/hooks/ are inert. Systemd services with ProtectHome can't write outside their ReadWritePaths. Check git config --get core.hooksPath and systemctl cat <service> before editing.
  • Stagger platforms when cross-posting. I publish to Substack first (with canonical URL), then Dev.to and Hashnode a day or two later with canonical_url pointing back. Google ranks the original correctly and the secondaries pull traffic to it.
  • The hook enforcement is the whole game. Without the auto-commit hook, I forgot to push. Without the cron catch-all, the hook missed crashes. Without the scratch review, the file filled with noise. Discipline fails; automation doesn't.

What it looks like day-to-day

I close my laptop at 11 PM. The knowledge directory auto-commits and pushes. Next morning I sit down at the desktop, git pull, start a Claude Code session, and the assistant boots with a CHANGELOG that already tells it what I decided last night. Six weeks in, I haven't lost a thread.

If you're running AI-assisted coding across multiple machines, I'd skip every proprietary memory feature and start with a git-synced Markdown tree. It's boring. That's the point.


Fillip Kosorukov is a solo founder in Indianapolis. More at fillipkosorukov.net.

Top comments (0)