Skip to content

About

Linux PDF/EPUB/web-page reader that sends selected passages or screenshots to Claude chats with the whole book as context

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Study Reader

A Linux PDF/EPUB/web-page reader where any selected passage or screenshot region can be sent to a Claude chat. Each passage you ask about gets its own chat, and every chat shares the whole book as context. Quizzes Claude writes become practice questions that come back right before you'd forget them.

What it does

  • Whole-book context. The book is loaded once into a base Claude session and every chat forks it, so each question already has the whole book behind it and the prompt cache stays warm (see How the shared context works).
  • Ask about anything on the page. Select a passage, or drag a rectangle around a figure or equation, and send it to its own chat.
  • Quizzes that come back. Questions Claude writes go into a spaced-repetition queue (FSRS), with an Android companion app for practice, synced over Syncthing.
  • Web pages too. LessWrong, Alignment Forum and EA Forum posts are fetched through the sites' API.
  • Also: read-aloud, a symbolic calculator and an Anki importer.

About 24,900 lines of Python with 8,800 lines of tests, and in daily use.

Install

Linux only for now. You need pixi and the claude CLI, logged in.

git clone https://github.com/JapanColorado/study-reader.git
cd study-reader
pixi run app

The Android companion is a signed APK on the Releases page.

Run

pixi run app                  # Home
pixi run app path/to/book.pdf # open a book directly
pixi run app https://www.lesswrong.com/posts/…  # open a web page
pixi run install-desktop      # optional: add a launcher entry
pixi run test

Requires the claude CLI to be logged in (claude → /login). The app talks to Claude through the Claude Agent SDK using that login.

Use

The rail down the left switches between Home (today's practice with one Start practice, the books you're reading, your decks, a calendar of recent practice and the questions coming up), Library (every book with its cover, progress and questions; Practice on a book starts on its questions), Practice, Questions (the question browser), Stats and, once one is open, Book: the open book stays open while you visit the other pages (Alt+1–Alt+6; Ctrl+W closes it). Settings is at the bottom of the rail. The Practice entry shows how many questions are waiting.

Action How
Ask about a passage Drag over text → Ask in new chat (Ctrl+Return)
Add a passage to the open chat Add to current chat (Ctrl+Shift+Return)
Ask about a figure or equation Screenshot region (Ctrl+Shift+S), drag a rectangle
Send Enter (Shift+Enter for a new line). Sending with no text asks "Explain this."
Read a footnote or cross-reference Footnote markers are marked with a violet pill, linked references with a fainter one. Hover one to preview the target; click to jump there. ← Back (bottom left), Alt+Left or the mouse's back button returns. Works with the PDF's own links and with plain superscript footnote numbers
Jump back to a snippet's source Click the quote or thumbnail in the chat
Zoom Ctrl+= / Ctrl+- or Ctrl+wheel
Crop the page margins so the text fills the view Crop margins (Ctrl+Shift+0), remembered per book
Library / open file / new chat / close the book Ctrl+L / Ctrl+O / Ctrl+N / Ctrl+W
Mark a book finished Finished in the toolbar, or right-click it in the library. Finished books move to a collapsible Finished section; toggle it off or choose Move back to reading to undo
Open a web page Open web page… (Ctrl+Shift+O; a copied link is filled in). Opening the same address again opens the saved copy; right-click it in the library → Fetch a fresh copy to update it in place, keeping its chats and notes
Find in the book Ctrl+F (or the magnifier in the toolbar; a selection becomes the query). Every match is highlighted, the current one in orange; Enter / Shift+Enter (or F3 / Shift+F3) step through them, and the sidebar lists them all with their page, section and surrounding text; click one to jump there. Case, accents, ligatures and words hyphenated across lines don't matter. The book is searched from the page you're on, a few pages at a time, so matches near you come first; Escape closes it
Show or hide contents / chats F9 / F10
Ask about a question while practicing On the Practice page, F10 (or the Chat button, lit while it's open) shows a chat panel beside the questions, in the calculator's place. It follows the questions: each question brings up your last chat about it, else the quiz chat it came from (a question's Open chat opens that one here too), else a new chat, among the chats of the question's book (questions with no book have chats of their own, without a book in them). A Question chip in the box means the question goes with your message: until you've answered it Claude is asked to help without giving the answer away, and once it's shown Claude sees the answer and what you answered. Remove the chip to leave the question out until the next one. Chats started here are marked with a question icon and also appear in the book's chat list
Throwaway chats The ghost button in a chat panel's header: from then on new chats aren't saved. A throwaway chat never shows in the chat list, its quizzes don't go into practice, and it is deleted (with its Claude session) as soon as you leave it: another chat, a new chat, another book or question, turning the button off, or quitting. Save chat on its banner keeps it as an ordinary chat after all
Stop a reply While Claude is replying, the send button becomes a stop button (or press Esc in the box). What arrived so far stays as the reply, marked Stopped; Regenerate asks again, and your next message tells Claude where it was cut off
Calculator (takes the chat panel's place) F11, in a book or on the Practice page (beside the questions there, also the Calculator button at its top, lit while it's open). Desmos-style math input: / makes a stacked fraction, ^ an exponent, sqrt a root, and → steps out of them. Type e.g. v = 3.2, 12v / ans, sin(30) in DEG. Arithmetic is exact, and the button beside a result switches between decimal and fraction (0.1 + 0.2 = 3/10). Define your own functions with f(x) = x^3 + 2x (or g(x, y) = …) and use them: f(2), f'(2), f''(x) (type ' for a prime). Each definition shows its derivative's formula and a plot of the function and its derivative (drag to pan, Ctrl+scroll to zoom, double-click to reset); a function sees variables as they are when it's used. Derivatives are worked out exactly: ddx types d/dx, so d/dx (x² sin x) with x unset gives the formula, and with x stored, its value; partial types ∂ for ∂g/∂x and ∂²g/∂x∂y. int types ∫ (limits, then the formula, then dx; infinite limits too), sum and prod type Σ and Π (n=1 below, 10 above), and solve(x^2 = 2, x) lists every solution (solve(…, x, 1) the one near 1, solve(…, x, 0, 5) those between 0 and 5); click a solution to use it. ↑ recalls earlier input; history is kept per book, functions included. On the Practice page it shows the history of the book of the question you're practicing, and calculations go there; questions with no book share one history. There, a question's formula like $f(x) = 3x^2 - 2x$ or a given like $k = 4.5$ N/m has a small calculator button beside it that opens the calculator with it defined
Quiz yourself Quiz me (Ctrl+Shift+Q, or in the selection popup): on the selection, else on the section you're reading. The arrow beside it lists the chapter, section and subsection around the page (and the page alone); picking one quizzes on it and makes that depth the button's default for the book. Documents of 50 pages or fewer also offer the whole document. Or Quiz me under any of Claude's replies. The request is drafted in the composer of a new quiz chat (or, for a reply, the same chat) with a Quiz chip, so you can add instructions ("…, harder, only derivations") before pressing Enter; removing the chip, Esc or leaving the chat drops it. Claude writes a quiz sized to the material (a few questions for a short passage, more for a long section or chapter) with multiple-choice, true/false, calculation (typed like the calculator), self-check (recall the answer, Show answer, then rate yourself) and, where nothing else fits, short-answer questions. Answers are checked as you go, short answers are graded by Claude, and the score and answers are kept; Retake starts over (your first answers still count for practice). Asking "quiz me on…" or "flashcards on…" in any chat works too, and follow-up messages see your answers. Revise… on a quiz (or asking in the chat) has Claude rewrite it as a new reply: questions it keeps are updated in place, attempts and all, new ones go into practice as new questions, and dropped ones are removed if never attempted; the old quiz is faded with a link to the revision
Practice Every quiz question goes into practice, where it comes back right before you'd forget it (scheduled with FSRS), in a deck named after the book, tagged with the book's section (Book::Chapter::Section, from its contents) and 1–3 concept tags Claude picks, reusing yours; your first answer in the chat counts as its first attempt. The Practice page (the rail, or Start practice on Home) starts with the counts and the buttons that start a session, then one question at a time: answer it (checked as in the quiz; for self-checks, fill-in-the-blanks and short answers, recall it or write it out, then Show answer to see the answer, and for a short answer its key points), then rate it Missed / Shaky / Got it / Easy (1–4, Space for the suggested rating). Questions link back to their page and chat; Edit opens a question in the browser, Suspend leaves one out, and a quiz's In practice toggle leaves out all its questions. Under the counts it lists your decks and your books (one tab each), each book with its chapters and sections in reading order, with due and new questions: pick a deck (with its subdecks), a book, a section, or all, or several at once (Ctrl+click adds or removes one, Shift+click picks a range; a long press on the phone), practiced together as one session; a book or section has only its due and new questions. In a book, Practice (F8; the toolbar button shows the book's count) starts on that book's questions, as does Practice on a book in the Library; Alt+6 (or Book in the rail) goes back to reading. A deck's ▶ on Home starts it straight away. At most 20 new questions a day are introduced across all decks (Settings → Practice settings). A multiple-choice question's choices are drawn in a new order every time it comes up, and after each attempt Claude writes it a new set (the right answer reworded, new wrong ones; the question stays as written), as it writes calculation and short-answer problems a fresh version with new numbers; Settings → Practice settings → New numbers and new choices after each attempt turns the rewriting off, and a question's own checkbox in the browser turns it off for that question
Browse and edit questions Questions in the rail (Ctrl+Shift+B) is the question browser: a sidebar of decks, tags (with a filter box; section tags in book order), books, flags, question types and saved searches (click to search; Ctrl+click narrows, Shift+click widens), a sortable table (right-click the header for columns: created, due, interval, stability, difficulty, retrievability, attempts, lapses, last attempt…), and an editor with a live preview for the current question. Search like Anki: words, "a phrase", deck:Physics (with subdecks), tag:exam, is:due / new / learn / learned / suspended, flag:1, type:fill_in (a question type: self_check, both_ways, fill_in, image_labels, choice, truefalse, calculation, short_answer; self-check and fill-in work too, and so do the older names flashcard, reversed, cloze, occlusion, numeric, written, as does is:review), book:Perloff, added:7, rated:1:1, prop:ivl>30, prop:r<0.8, re:…, - to negate, OR and parentheses. On a selection: change deck (Ctrl+D), add or remove tags, suspend (Ctrl+J), flag (Ctrl+1–7), forget, set due date, find and replace, question info with every attempt (Ctrl+Shift+I), delete. Right-click a deck to practice it, rename or move it (Parent::Child), or delete it
Make questions Add in the browser (Ctrl+E), picking a type: Self-check, Self-check (both ways: a second question asks the back for the front), Fill-in-the-blank (select text and press Ctrl+Shift+C for {{c1::…}}; a hint goes after ::; one question per number), Multiple choice, True/false, Calculation or Short answer. The editor's type box switches a question between self-checks and the answered types, carrying its text over; editing a fill-in-the-blank or a both-ways self-check changes its sibling questions too, and tags apply to them all. Fields take Markdown with $math$ and inline HTML; paste or drop images into them
Make a deck with Claude Make a deck with Claude… on Home, beside the Practice page's deck list (or on the empty Practice page), in the browser's Claude menu (Ctrl+Shift+M), or Make questions here with Claude… on a deck in the browser's sidebar (the new deck goes under it). Describe what you want to learn, optionally paste notes or attach files (PDF, EPUB, text or images) for Claude to draw from, and pick a model (Sonnet by default). Claude decides how many questions the subject needs, picks the type that fits each idea (self-check, both-ways self-check, fill-in-the-blank, multiple choice, true/false, calculation, short answer) and names the deck. Its draft opens in a window of its own: untick the questions you don't want, rename the deck, and ask for changes in plain words ("more on X", "make #4 harder", "fewer fill-in-the-blanks"); Claude answers with just the changes. Add puts the ticked questions in the deck as new questions. The draft keeps working if you close the window, and survives closing the app until you add or discard it
Improve questions with Claude Select questions in the browser → Claude → Improve with Claude… (Ctrl+Shift+K), or right-click a deck → Improve this deck's questions with Claude…. Claude proposes a better type for each question where one fits (a recall question as multiple choice or a calculation, a sharper self-check), splits a question that asks several things into a few short ones (the first keeps the question's history, the others start as new questions), or keeps it. The same draft window shows each proposal beside the question as it is: tick the ones you want, ask for changes (or for new questions on top), then Apply. Claude sees the questions a few at a time, one request per group; a change that names questions ("make #4 and #12-15 harder") goes only to their groups, and one that names none goes to every group, after asking when that's more than five requests. A rewritten question keeps its deck, tags, schedule and history, and Claude → Undo Claude's rewrite of this question brings the old version back
Migrate from Anki Settings → Migrate from Anki… (or the browser's File menu): pick a profile and tick the decks to bring over. Anki's notes and cards become questions: self-checks (one-way or both ways), fill-in-the-blanks or image labels, with their tags, images, schedule (FSRS memory state and due date), suspended state, flags and full review history (as attempts), plus Anki's FSRS parameters and desired retention. Anki is only read, from a copy, so it can stay open; running it again skips what was already brought over
Statistics and FSRS settings Stats in the rail (or from the browser): today's attempts, question counts, a practice calendar, attempts and forecast charts, true retention, and interval, stability, difficulty and retrievability distributions, for all decks, one deck or one book. Settings → Practice settings: new questions per day, desired retention, Optimize FSRS parameters (fits them to your attempts; needs a few hundred), or back to the defaults, plus rewards and streaks and the daily goal
Practice on your phone The Android companion app, Study Practice (android/, see its README), practices the same questions: due and new questions, every question type (calculations with a math keyboard), FSRS, decks, books and sections, flags, bury, suspend, XP and streaks, and a daily reminder. The two sync through a folder Syncthing shares between them: Settings → Phone sync… picks it here, and the app's Settings picks the same folder on the phone. This computer writes your questions into it (at startup, every two minutes and on quitting) and applies what you practiced on the phone, in the order it happened, so practicing on both between syncs is fine. Update both together: the app needs a snapshot from this version of Study Reader
Listen while you read Read aloud (toolbar) or F5 reads from the top of the visible page on through the book, lighting up the sentence being read and the word being spoken and turning pages to keep up (scroll away and it waits a few seconds before following again). F5 pauses and resumes, F4 / F6 go back or forward a sentence (back replays the sentence if it is under way), Shift+F5 stops, and clicking a sentence while reading jumps there. In the selection popup, Read aloud reads just the selection and Read from here reads on from it. The bar under the page sets the speed (0.5–3×) and voice, and Skip silence shortens the quiet before, inside and after each sentence (about a tenth less listening; Kokoro only, rendered or not). Running headers, footers, page numbers, footnotes and figure captions are skipped, and math is spoken ("x squared", "a over b"; web pages' formulas from their TeX). Listen under a Claude reply reads it aloud, highlighting each paragraph. The default voice is Kokoro, a natural-sounding neural voice that runs on your computer (it loads in the background when you open a book, and voices other than Heart download once on first use; it needs a CPU about twice as fast as speech, so a battery power profile can make it pause); Settings → Read-aloud voice switches to the system's speech-dispatcher voice, which starts instantly but sounds robotic, and is also the fallback if Kokoro can't start
Narration by Claude Before a page is read aloud, Claude Haiku goes through it (a picture of the page plus its extracted text) and writes what should be said: the text in reading order (columns, boxes), word for word, with equations said in words as printed, figure captions read after the paragraph beside them, and the labels inside figures, tables, code listings, footnotes, running headers and page numbers left out. The page still lights up sentence by sentence and, wherever the words are the page's own, word by word. Each page is sent once (about 5–10 seconds, through your Claude login) and kept: F5 waits for the page in view (Preparing the narration…), then stays a couple of pages ahead; Settings → Read-aloud voice → Narrate the whole book now… does every page up front, three at a time, while the book is open. A page Claude fails on is read as extracted. Narrate on the read-aloud bar (or Settings → Read-aloud voice → Narrate with Claude) turns it off and on; reading a selection alone never waits for it. With narration on, Render on Colab narrates the rest of the book first and renders the narrated sentences, so audio rendered before narration (or with it off) plays only while it is off
Render a book's audio on Colab So reading aloud never waits on your computer: the ☁ button on the read-aloud bar (or Settings → Read-aloud voice → Render audio on Colab…) → Render on Colab rents a Colab GPU through the colab CLI (uv tool install google-colab-cli, then run colab sessions once in a terminal to sign in; a T4 by default, or pick another GPU) and renders the book's sentences in your voice and at your speed (made at no more than 1.3×, where Kokoro is clean, and sped up from there). A 600-page textbook is about 25 hours of speech. Each finished part is copied into the app as it goes, and the GPU is released when every book is done. Books sent while one renders wait their turn on the same GPU. It keeps going after you quit, as long as the computer is on, and picks up at the next launch; Stop rendering releases the GPU. Reading aloud plays the audio at any speed (other speeds are time-stretched), falling back to Kokoro on your computer for anything not rendered, such as text you changed voice for. Audio the old Drive notebook made in ~/Google-Drive/study-reader-tts is still copied in when you open the book
Revisit a passage you asked about Click its highlight → pick one of its chats, or start a new one
Annotate a passage Drag over text → Note (Ctrl+Shift+N). The passage is highlighted in blue and the Notes panel (F12, in the chat panel's place) opens on its note. Notes take Markdown and $math$; Ctrl+Enter saves. Hover a blue highlight to read its note, or click it to open the note, ask about it, or delete it. The panel lists the book's notes in page order, with a search box, and Export (↓) saves them as a Markdown file
Redo a reply Regenerate under the chat's last reply (Retry after an error)
Edit a message Hover it → Edit: it loads into the box below, where you can change the text or its passages; sending replaces it and every reply after it. Esc cancels
Rename a chat Double-click it (or F2, or right-click → Rename…)
Model The chat header's dropdown sets the open chat's model. Settings (bottom of the rail) → Default model for new chats sets what new chats start with
Theme Settings → Theme: match the system, light, or dark. Dark pages recolors the book itself in dark mode

Claude can answer with interactive visualizations (plots, diagrams, simulations with sliders). They render inline in the chat. Each one is fitted to the panel's width and height. Open ↗ on a visualization's header shows it in a larger window, fitted to the window: Ctrl+scroll (or Ctrl+=/−, the toolbar) zooms at the pointer, Ctrl+0 fits it again, dragging empty space pans, F11 goes full screen, and its sliders and buttons stay docked in view while zoomed. Asking for one ("visualize this", "plot it so I can vary k") helps.

Every passage and screenshot region you ask about stays highlighted in the book. Right-click a chat or a library entry to delete it; deleting a chat removes its highlights.

Web pages

A web page is saved as a PDF snapshot (in web/ under the data directory) and then reads like any book, so its highlights and page numbers stay put. Images are fetched once, when the snapshot is made.

  • LessWrong, the Alignment Forum and the EA Forum (and GreaterWrong links) are read through the sites' API:
    • a post comes with its 30 best comments, threaded, each with the comments it replies to;
    • a sequence (/s/…) becomes one book with a chapter per post;
    • a wiki page (/w/…, /tag/…) includes every tab, each starting a new page.
  • Other sites go through readability-style article extraction, which drops menus and sidebars. A link straight to a PDF or EPUB opens that file.
  • Math is re-typeset with MathJax, and each formula's TeX source is kept in the page's text, so selections and Claude see $\frac{a}{b}$ rather than scattered glyphs.

How the shared context works

The first message about a book sends its full text to Claude once, in a "base" session. Every new chat forks that session, so all chats start from the same prefix (which the prompt cache serves cheaply) and stay independent of each other. Follow-ups resume the chat's own session. Regenerating or editing forks the chat's session at the reply just before the changed message, so Claude doesn't see the replaced turns.

  • Books too large for the context window fall back to sending the pages around the snippet. The status line under the transcript says which mode a book is in.
  • If Claude Code has pruned a session, the app re-shares the book or replays the saved transcript automatically.
  • Context is extracted text, so figures and scanned pages only reach Claude through screenshots.

Notes

  • Data lives in ~/.local/share/study-reader/ (database, screenshots, question images in media/, session working directories). Set STUDY_READER_DATA to move it. The first run after the terminology rename keeps a copy of the old database beside it as study-reader.before-rename.db.
  • An exported ANTHROPIC_API_KEY is ignored so requests use the Claude login rather than per-token API billing. Set STUDY_READER_USE_API_KEY=1 to use the key instead.
  • Chats run with no tools and no MCP servers, including claude.ai connectors.
  • Visualizations run in a sandboxed frame with no network access. Bundled d3 v7 and Chart.js v4 (in assets/viz/) are inlined when a visualization uses them.
  • The chat view uses software rendering because GPU compositing in QtWebEngine leaves it blank on some Wayland compositors (seen on COSMIC). Set STUDY_READER_WEB_GPU=1 to re-enable GPU rendering.
  • EPUBs are rendered by MuPDF as fixed pages, with limited CSS support.

How this was built

Built with Claude Code, and most commits say so. I decide what to make, write the specification, review the changes and use the result every day.

License

MIT

About

Linux PDF/EPUB/web-page reader that sends selected passages or screenshots to Claude chats with the whole book as context

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages