---
title: Getting Started
description: Build your first RAG library in under 60 seconds
section: Getting Started
order: 1
---
import LibraryDownloadLink from '../../components/docs/LibraryDownloadLink.astro';
export const libraryFilename = `libragen-docs-${import.meta.env.PUBLIC_LIBRAGEN_VERSION || '0.1.0'}.libragen`;
export const libraryUrl = `${import.meta.env.SITE}/${libraryFilename}`;
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 <LibraryDownloadLink /> and query it locally!
```bash
curl -L -O https://libragen.dev/libragen-docs-0.4.0.libragen # Download the docs library
libragen install libragen-docs-0.4.0.libragen # Install it
libragen query -l libragen-docs "How do I build a library?" # Query it
```
## Quick Start
### 1. Build a Library
Create a library from a directory of markdown, text, or HTML files:
```bash
libragen build ./my-docs --name my-library
```
Or, build from a git repository:
```bash
libragen build https://github.com/github/docs/tree/main/content
```
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`
> NOTE: Depending on the size of your library, **building may take a few minutes**.
>
> Grab a coffee and come back in a few minutes; it's worth the wait!
### 2. Query Your Library
Search with natural language:
```bash
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:
```bash
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`:
```bash
# Build
libragen build ./docs --name my-docs
# Query
libragen query --library my-docs "your question"
```
### Global Installation
For frequent use, install globally:
```bash
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:
```bash
libragen autocomplete
```
### As a Project Dependency
For programmatic use in your project:
```bash
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:**
| Platform | Global 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:
```bash
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`):
```bash
# 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`:
```bash
export LIBRAGEN_HOME=/custom/path
```
Run `libragen config` to see current paths and active environment variables.
## Next Steps
- [CLI Reference](/docs/cli) - Full command documentation
- [Building Libraries](/docs/building) - Advanced build options
- [CI Integration](/docs/ci-integration) - Automate builds in your pipeline
- [MCP Integration](/docs/mcp) - Connect to AI tools
- [Collections](/docs/collections) - Install curated library bundles
- [Troubleshooting](/docs/troubleshooting) - Solutions to common issues