/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 ./src

This indexes all supported files in the ./src directory.

Syntax

/learn [options] <path>

Options

OptionDescription
-aInclude all files (not just code files)
-c <size>Chunk size for splitting documents
-o <overlap>Overlap between chunks
-dDelete the current index

Examples

Index a Directory

/learn ./my_project

Include All Files

By default, only code and documentation files are indexed. Use -a to include everything:

/learn -a ./data

Custom Chunk Size

For large documents, adjust how content is split:

/learn -c 1000 -o 200 ./docs

This uses 1000-character chunks with 200-character overlap.

Delete Index

Remove the current index to start fresh:

/learn -d

Supported 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 ./src

Then:

/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.00001

This downloads and indexes the paper for Q&A.

How It Works

  1. Scanning: The command scans the specified path for supported files
  2. Chunking: Large files are split into searchable chunks
  3. Embedding: Each chunk is converted to a vector embedding
  4. Indexing: Embeddings are stored in a local vector database
  5. 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 ./src

Combine with Documentation

For better results, include README files and documentation:

/learn ./src ./docs

Use 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 /learn after making changes to source files
  • Use /learn -d to clear and rebuild the index