Margin is a free mod for Claude Code. Highlight replies in three colours, pin a note to a highlight, drop a "read up to here" marker, sketch an idea, and find it all again in your notebook.
Works in the Claude desktop app (Code tab) and the terminal · Everything stays on your computer · MIT
Try itSelect any words in the reply below, then press a colour.
Short answer: your session cookie and your access token expire at different times, and the page only checks one of them.
Here's what happens. When you sign in, the server sets a cookie that lives for 7 days, but the access token inside it lives for only 15 minutes. The refresh call that should swap in a new token runs only when you navigate, so a tab left open for a while ends up holding a dead token.
The next request fails with a 401, and the error handler treats every 401 as "signed out". That's the logout you're seeing.
Three ways to fix it, from smallest to sturdiest:
I'd go with the third. It's about twenty lines in api.ts and it covers the cases the other two miss, like a laptop waking from sleep.
Claude's answers are good and long. Margin gives you a pen and a bookmark, right in the app.
Yellow, green, pink. Select, press, done. Press it again or use Erase to take it off.
Pin a one-line note to any highlight. It shows under the paragraph and in your notebook.
Drop a marker where you stopped. Resume shows everything after it. Clear it when you're done.
A small sketch pad in the side pane. Strokes are smoothed into clean SVGs with perfect-freehand.
Every highlight, note and sketch lands in Documents/Margin Notebook: a searchable page plus Markdown for Obsidian or Logseq.
No account, no server, no tracking. It's a few files on your computer and you can read every line.
You need Claude Code (the desktop app's Code tab or the terminal). Then:
claude plugin marketplace add basithladdu/margin
claude plugin install margin@margin/plugin install margin --marketplace basithladdu/margin/margin to open your notebook.Documents/Margin Notebook if you care about them.