/learn Command
The /learn command indexes local files so you can ask questions about them. It creates a searchable knowledge base from your code, documentation, and data files.
Basic Usage
In the chat interface:
/learn ./srcThis indexes all supported files in the ./src directory.
Syntax
/learn [options] <path>Options
| Option | Description |
|---|---|
-a | Include all files (not just code files) |
-c <size> | Chunk size for splitting documents |
-o <overlap> | Overlap between chunks |
-d | Delete the current index |
Examples
Index a Directory
/learn ./my_projectInclude All Files
By default, only code and documentation files are indexed. Use -a to include everything:
/learn -a ./dataCustom Chunk Size
For large documents, adjust how content is split:
/learn -c 1000 -o 200 ./docsThis uses 1000-character chunks with 200-character overlap.
Delete Index
Remove the current index to start fresh:
/learn -dSupported File Types
The learn command indexes these file types by default:
Code Files
- Python (
.py) - JavaScript (
.js,.jsx) - TypeScript (
.ts,.tsx) - Java (
.java) - C/C++ (
.c,.cpp,.h) - Go (
.go) - Rust (
.rs) - Ruby (
.rb) - PHP (
.php)
Documentation
- Markdown (
.md) - Text (
.txt) - reStructuredText (
.rst)
Notebooks
- Jupyter notebooks (
.ipynb)
Documents (with -a flag)
- PDF (
.pdf) - HTML (
.html)
Querying Learned Content
After learning, use /ask to query:
/learn ./srcThen:
/ask How does the authentication module work?Or just ask directly in chat—the AI will search your indexed content automatically.
arXiv Papers
You can learn from arXiv papers by providing an arXiv ID:
/learn arxiv:2301.00001This downloads and indexes the paper for Q&A.
How It Works
- Scanning: The command scans the specified path for supported files
- Chunking: Large files are split into searchable chunks
- Embedding: Each chunk is converted to a vector embedding
- Indexing: Embeddings are stored in a local vector database
- Retrieval: When you ask questions, relevant chunks are retrieved and provided as context
Best Practices
Focus on Relevant Content
Index specific directories rather than entire projects:
# Good - focused
/learn ./src/authentication
/learn ./Re-learn After Changes
If you update files, re-run learn to update the index:
/learn ./srcCombine with Documentation
For better results, include README files and documentation:
/learn ./src ./docsUse Clear Questions
When querying, be specific:
# Good
/ask What parameters does the create_user function accept?
/ask How does the code work?Troubleshooting
“No results found”
- Verify the files were indexed: check the learn output for file count
- Try a more specific or different query
- Ensure the content you’re asking about exists in indexed files
Slow indexing
- Large directories take time to process
- Consider indexing subdirectories separately
- PDF files take longer due to text extraction
Outdated results
- Re-run
/learnafter making changes to source files - Use
/learn -dto clear and rebuild the index