Getting Started with nanoRag
nanoRag is a Salesforce CLI plugin that builds BM25 document libraries and attaches them to your Agentforce agent. The library and index live in your org as ContentDocument and StaticResource records — no embeddings, no vector database, no Data Cloud.
Want to try it without installing anything? Try in your org →
1. Install the Salesforce CLI
Verify the installation:
Run this command:
sf --version
Expected output: @salesforce/cli/
2. Install the nanoRag plugin
Requires Python 3.10+.
git clone https://github.com/ankita13makker/nanoRAG.git
cd nanoRAG
sf plugins link plugins/sf-nanorag
The plugin creates its own virtual environment and installs Python dependencies on link.
Verify the installation:
Run this command:
sf nanorag --help
Expected output: A list of nanorag subcommands (install, build, attach, …)
3. Authenticate Your Org
The org needs Agentforce enabled and a NextGen (AgentScript) agent.
sf org login web --alias myOrg
Verify your org connection:
Run this command:
sf org display user
Expected output: Your org username and alias
4. Deploy the Apex Runtime
One-time per org. Installs the Apex classes that score queries at runtime.
sf nanorag install --target-org myOrg
5. Build a Library
sf nanorag build --target-org myOrg \
--library-name product_docs \
--files ./docs/guide.pdf ./docs/faq.docx
Supported formats: PDF, DOCX, PPTX, XLSX, MD, TXT, and 30+ others.
6. Attach to Your Agent
sf nanorag attach --target-org myOrg \
--library-name product_docs \
--agent-developer-name My_Service_Agent
Your agent can now retrieve from the library. Test a query:
sf nanorag search --target-org myOrg \
--library-name product_docs \
--query "how do I cancel"
When to Use BM25 vs. Embeddings
nanoRag uses BM25 — fast, deterministic keyword search. Use it when:
- Users search with the same words that appear in your documents
- Your corpus is product docs, policy manuals, runbooks, or API references
- You have under ~10k documents
Reach for an embedding-based RAG instead when:
- You need synonym matching (user says "cancel," doc says "terminate")
- Your corpus is multilingual and users mix languages
- You need long-form generative answers, not retrieved passages
The agent action signature is the same either way — start with BM25 and swap backends later if recall feels shallow.
Reference
| Command | Purpose |
|---|---|
sf nanorag search | Test search against a library |
sf nanorag detach | Remove a library from an agent |
sf nanorag library list | List libraries in the org |
sf nanorag library delete | Delete a library |
sf nanorag file add | Add files, rebuild the index |
sf nanorag file delete | Remove files, rebuild the index |
sf nanorag skill install | Install the matching Claude Code skill |
All commands accept --json for structured output. Source: github.com/ankita13makker/nanoRAG.