Skip to main content

Query context from the context tree

This guide walks you through querying context from your context tree using agentic search. The typical flow for querying context in ByteRover starts with the /query (/q) command (executed by you) or brv query command (executed by your coding agent via your prompts). To query your context tree, copy this prompt and paste it into your coding agent’s chat (e.g., Cursor, Claude Code, etc.):
> query the context tree about Express health check implementation
Your coding agent will then execute the command:
brv query "Express health check endpoint implementation"
When the command runs, ByteRover intelligently searches your context tree using multi-step reasoning—not similarity scores. Example:
$ brv query "What is the context tree structure?"
Querying context tree...
🔧 find_knowledge_topics Querying knowledge base...
 find_knowledge_topics Complete (2 topics retrieved)

Query Results:
The context tree is a hierarchical file-based structure used to store and organize knowledge. Here's an overview of its structure:

**Location:** The context tree is stored in the `.brv/context-tree/` directory.

**Domains:**
The top level of the tree consists of a predefined set of domain folders. These domains include categories like `architecture`, `components`, and `apis`.

**Topics:**
Within each domain folder, there are topic subfolders. Each topic folder represents a specific area of knowledge within that domain.

**Content:**
The actual knowledge is stored in `context.md` files within each topic folder. These files contain the context information and are timestamped.

What Makes This Intelligent?

Not Similarity but Agentic Search: ByteRover doesn’t just find similar documents. It reasons about what you’re asking for and strategically searches the context tree. Follows explicit relations: ByteRover follows the @domain/topic relations between topics to gather comprehensive, connected context. Synthesizes information: Instead of returning ranked documents, ByteRover reads relevant context files and synthesizes a coherent answer with citations. Context-aware answers: You get understanding, not just matches. ByteRover comprehends your query semantically and provides relevant, actionable information.

Multi-Step Queries

For complex tasks requiring different types of context, you can run multiple queries: Copy this prompt and paste it into your coding agent’s chat:
> first query the context tree about Express setup, then query about TypeScript testing patterns
Your coding agent will then execute:
brv query "Express server setup with TypeScript"
brv query "TypeScript testing patterns and best practices"

Crafting Effective Queries

The quality of your results depends on your query. Here are some tips: Specific queries work better:
brv query "Express health check endpoint with TypeScript and tests"
vs. vague queries:
brv query "server stuff"
Include technical details:
brv query "JWT authentication middleware implementation with refresh tokens"
Reference specific patterns or technologies:
brv query "React hooks for form validation with Zod schema"
Note: While ByteRover understands semantic meaning, specific and detailed queries still produce better results because they help focus the search.

You’re in Control of Your Queries

The brv query command is flexible and adapts to how you want to work:

Broad Exploration

Want to see everything related to a topic? Use a general query: Copy this prompt and paste it into your coding agent’s chat:
> query all context about authentication
Your coding agent will execute:
brv query "authentication"
ByteRover explores relations across topics to give you a comprehensive view of all authentication-related knowledge.

Focused Retrieval

Need specific implementation details? Be more precise: Copy this prompt and paste it into your coding agent’s chat:
> query context about OAuth PKCE flow implementation
Your coding agent will execute:
brv query "OAuth PKCE authorization code flow implementation"
ByteRover searches specific domains and topics for targeted information.