Skip to main content

Getting Started

Build your first RAG library in under 60 seconds

Libragen (pronounced “LIB-ruh-jen”) lets you create portable, searchable RAG libraries from any documentation. Libraries are single SQLite files you can share, version control, and query locally—no cloud services required.

Try it now: This documentation is available as a libragen library. Download libragen-docs-0.3.0.libragen and query it locally!

Quick Start

1. Build a Library

Create a library from a directory of markdown, text, or HTML files:

Terminal window
libragen build ./my-docs --name my-library

This will:

  • Process all supported files in ./my-docs
  • Generate embeddings using a local model
  • Build a full-text search index
  • Save everything to my-library-1.0.0.libragen

2. Query Your Library

Search with natural language:

Terminal window
libragen query --library my-library "How do I authenticate?"

Results include relevance scores and source file information.

3. Use with MCP (Optional)

Install the MCP server for your AI tool with one command:

Terminal window
npx -y install-mcp @libragen/mcp

This automatically configures Claude Desktop, Cursor, Windsurf, or other MCP-compatible tools. Your AI assistant can now query your libraries directly.

Installation Options

Use Without Installing

The easiest way to use libragen is with npx:

Terminal window
# Build
libragen build ./docs --name my-docs
# Query
libragen query --library my-docs "your question"

Global Installation

For frequent use, install globally:

Terminal window
npm install -g @libragen/cli
# Now use without npx
libragen build ./docs --name my-docs
libragen query --library my-docs "your question"

Enable shell completions for tab-completion of commands and options:

Terminal window
libragen completions install

As a Project Dependency

For programmatic use in your project:

Terminal window
npm install --save-exact @libragen/core

Library Storage

Libraries are stored and discovered from multiple locations:

Default Installation Location

By default, all installed .libragen files go to the global directory:

PlatformGlobal Path
macOS~/Library/Application Support/libragen/libraries/
Linux~/.local/share/libragen/libraries/
Windows%APPDATA%\libragen\libraries\

You can override the global directory with the LIBRAGEN_HOME environment variable:

Terminal window
export LIBRAGEN_HOME=/custom/path

Library Discovery

When searching for libraries (e.g., libragen list, libragen query), libragen looks in:

  1. Project directory — If .libragen/libraries/ exists in the current directory, it’s searched first
  2. Global directory$LIBRAGEN_HOME/libraries (always included)

Project-Local Libraries

To install a library to a local directory instead of the global directory, use the -p flag (it automatically appends .libragen/libraries):

Terminal window
# Install to ./my-project/.libragen/libraries
libragen install ./my-lib.libragen -p ./my-project

This is useful for:

  • Project-specific documentation
  • Version-controlled library sets
  • CI/CD environments

Environment Variables

Override the global directory with LIBRAGEN_HOME:

Terminal window
export LIBRAGEN_HOME=/custom/path

Run libragen config to see current paths and active environment variables.

Next Steps