Skip to main content

Chat

Chat with AI about your codebase. Ask questions, get explanations, and understand how your code works.

Asking Questions

# Ask about architecture
answer = BrainzLab::Dendrite.ask(
  "How does the authentication system work?"
)
puts answer.text
# => "The authentication system uses Devise with JWT tokens..."

# Ask about specific code
answer = BrainzLab::Dendrite.ask(
  "What does the PaymentService#process method do?"
)

# Ask about patterns
answer = BrainzLab::Dendrite.ask(
  "How are background jobs organized in this codebase?"
)

How It Works

Question


Semantic Search (find relevant code)


Build Context (code chunks + wiki pages)


Claude API (generate answer)


Answer with References
Dendrite uses RAG (Retrieval Augmented Generation) to ground answers in your actual code.

Answer Format

answer = BrainzLab::Dendrite.ask("How do users sign up?")

# The answer text
puts answer.text

# Code references used to generate the answer
answer.references.each do |ref|
  puts "#{ref.file_path}:#{ref.line_start}-#{ref.line_end}"
  puts ref.code_snippet
end

# Confidence score
puts answer.confidence # => 0.95

Chat Sessions

Maintain context across multiple questions:
session = BrainzLab::Dendrite.chat_session

session.ask("What models are in this app?")
# => "There are 15 models including User, Order, Product..."

session.ask("Tell me more about the Order model")
# => "The Order model has the following fields..." (uses context from previous question)

session.ask("How does it relate to User?")
# => "Order belongs_to User through the user_id field..."

Explain Code

Get explanations of specific code:
explanation = BrainzLab::Dendrite.explain(
  file: "app/services/payment_service.rb",
  lines: 15..45
)

puts explanation.summary
puts explanation.step_by_step
puts explanation.edge_cases

Generate Documentation

Ask Dendrite to write documentation:
docs = BrainzLab::Dendrite.generate_docs(
  file: "app/services/notification_service.rb"
)

puts docs.overview
puts docs.methods
puts docs.examples

Best Practices

Be Specific

# Good - specific question
"How does the OrderService calculate shipping costs?"

# Less effective - too broad
"Tell me about orders"

Reference Files

# Good - references specific code
"What does the #process method in PaymentService do?"

# Also good
"Explain app/services/payment_service.rb"

Ask About Patterns

# Good questions about patterns
"How are validations typically handled in this codebase?"
"What's the pattern for background job error handling?"
"How are API responses structured?"

Privacy

  • Code chunks are sent to Claude only when answering questions
  • Embeddings are generated locally
  • Chat history is stored locally
  • You control what code is indexed