Skip to main content
Glama
docshelf

docshelf

by bahler01
README.md
# docshelf

**Local search over large document collections for Claude Code.** Point it at folders of PDFs, Word files,
Markdown and text files. Claude then finds the passages that answer a question by meaning (ranked, each with
its file and page) and can turn the whole collection into a skill.

## Why: what it adds to plain folder search

Claude Code can already search a folder: it finds files by name and lines by exact words, then reads the
files. For a few documents, or when you know the exact wording, that is all you need.

On a large collection that breaks in three places:

1. **The words don't match.** You ask how to keep an audience curious; the book calls it a "curiosity gap".
   Exact-word search finds nothing, or hundreds of unranked hits. On a test library of nine books (about
   2,000 pages), one common English word matched 217 times across the books, while the same idea typed in
   another language matched nothing.
2. **Reading everything does not scale.** A handful of books is hundreds of thousands of words: more than
   fits in Claude's working context, slow and expensive to read again for every question, and lost anyway
   when a long session gets summarised.
3. **Answers need a source.** For a script, a design rule or a client brief you want "page 64 of X", not
   "somewhere in the folder".

docshelf builds an index of the collection once, on your computer, and connects it to Claude Code as a tool,
`search_docs`. After that a question returns the 5-8 passages closest in meaning, ranked, each with its file,
chapter and page, in about half a second on an NVIDIA GPU, even when the wording or the language differs.
Claude reads only those passages, cites the page, and opens the full document when it needs more.

| | Plain folder search | docshelf |
| --- | --- | --- |
| Finds | exact words, file names | meaning: synonyms, paraphrases, other languages |
| Returns | every match, unranked | the best 5-8 passages, ranked |
| Source | file and line | file, chapter and page |
| What Claude reads | whole files, again for every question | a few passages |
| Best for | a few documents, code, exact names and IDs | hundreds to thousands of pages |

**When you don't need it.** Under about 500 pages, give Claude the documents directly (a Claude Project or a
folder works). For code and exact identifiers, plain search is better.

**From documents to a skill.** Optionally, docshelf turns the collection into a Claude Code skill: agents
read each document and write digests with page references, a separate auditor checks every reference, and
the finished skill keeps the key rules always at hand while calling `search_docs` for details and citations.

Under the hood: structure-aware chunks (pages, chapters, headings), BM25 for exact terms plus multilingual
embeddings for meaning, merged and then reordered by a cross-encoder reranker. Details: `docs/DESIGN.md`.

## Requirements

- Windows 11 (tested); Windows 10 should work but is untested.
- An NVIDIA GPU with about 4 GB of free video memory and a current driver (tested on an RTX 50-series card).
  Without one it runs on the CPU, slowly.
- About 11 GB of free disk space: Python environment 3.3 GB, models 3.5 GB, a temporary download cache up to
  3.3 GB, plus the index (small).
- Claude Code, and internet access for the one-time downloads.
- [uv](https://docs.astral.sh/uv/) (Claude offers to install it if it is missing) and git to clone this
  repository.

## Install: give it to Claude

Clone or copy this repository somewhere permanent, then tell Claude Code:

> Read `<path to this repository>/CLAUDE.md` and set up docshelf for me.

Claude follows `.claude/skills/docshelf-setup/SKILL.md`. It will ask you:

- which folders to index, and what each holds;
- a name for the library and a line on what it is about;
- where to put the Python environment and the models (outside the repository);
- whether the search should be available in all your projects or in one;
- before each download (with size and source), before registering the search server with Claude Code, and
  before any optional scheduled task.

It then checks your GPU driver, picks the matching PyTorch build, installs everything, downloads the models,
builds the index, runs a test search, registers the server, proves that the server answers over stdio
(`doctor --mcp-check`) and installs a small skill that tells Claude when to search.

**The one step left to you:** restart Claude Code, approve the new server if asked and allow the
`search_docs` tool the first time it is used. Then check it: `/mcp` lists the server, and "use search_docs
to find what the documents say about ..." returns passages with pages.

To install by hand instead, follow [docs/INSTALL.md](docs/INSTALL.md).

## What runs where

- Everything runs locally: indexing, embeddings, reranking, search. There is no cloud service and no LLM in
  the search itself.
- Claude Code starts the search server itself, as a child process talking over stdio. It opens no network
  port.
- docshelf is installed into its environment as a normal package: nothing is written into this repository,
  so it can be read-only. After updating the repository, re-run the install line (`docs/INSTALL.md`, step 5).
- Network is used only to download PyTorch, the Python packages and the two models (Qwen3-Embedding-0.6B and
  bge-reranker-v2-m3) once.
- Claude sees only the passages a search returns, as part of your conversation, not your folders as a whole.
- A rebuilt index is picked up by the running server on its next search, without restarting Claude.

## Quality and speed (measured, stated honestly)

- The pipeline and its ranking constants were measured on one library of about 3,000 chunks, using 89
  questions with known answer pages. Your documents are different; no accuracy figure is claimed for them.
- Speed: about 0.4-0.7 s per query on an NVIDIA GPU once the models are loaded. The first search in a session
  loads the models (10-20 s). On a CPU a query takes about 15-30 s.
- Memory: about 3.3 GB of video memory and 3 GB of RAM while the server is in use (about 6 GB of RAM on CPU).
- Indexing: about 50 s for a first build of 2,600 chunks on a GPU; later builds only process new or changed
  files.
- Queries in a different language from the documents work through the multilingual models. An extra
  cross-language step (the "bridge") runs by default only for queries that contain letters outside the
  Latin script, whatever that script is; see `docs/DESIGN.md` for what it can and cannot do.

## Limits

- No OCR: scanned PDFs without a text layer give no text. Run OCR first and index the result. PDFs whose
  text layer is broken (one character per line, spaced-out letters) are indexed as extracted and searched
  poorly; the build and `doctor` name the file and pages so you can re-export or OCR them.
- Formats in this version: PDF, DOCX, Markdown, plain text. No spreadsheets, slides, HTML, e-books or images.
- Tested on Windows with an NVIDIA GPU (CUDA 13 build of PyTorch). Other PyTorch builds and the CPU-only
  install are documented but untested.
- For live team tools (Slack, Jira, Confluence) use Claude's official connectors rather than indexing them:
  they stay current and respect each person's permissions.

## Optional

- A daily re-index as a Windows scheduled task (opt-in): `scripts/register-reindex-task.ps1`.
- A skill for your field built from your documents: `.claude/skills/docshelf-build-skill/SKILL.md`.

## Uninstall

Remove the MCP server (`claude mcp remove <name> --scope <scope>`, with the scope it was registered in;
for `local` or `project` scope run it in that project's folder), the `<name>-search` skill folder, the
scheduled task if you made one (`scripts/unregister-reindex-task.ps1`), the Python environment and the
library folder with its index. Deleting the model cache (about 3.5 GB) is optional. Step by step: the "Uninstall" section of
[docs/INSTALL.md](docs/INSTALL.md).

## License

MIT, see [LICENSE](LICENSE). Third-party components and their licences: [docs/LICENSES.md](docs/LICENSES.md).