Skip to main content

What is a Context Tree?

A context tree is your project’s hierarchically organized knowledge base stored in .brv/context-tree/. It captures patterns, best practices, and learnings in a structured format that’s both human-readable and intelligently searchable.

Structure

The context tree organizes knowledge into a three-level hierarchy:

1. Domains

These are the default top-level domains that group related knowledge:
  • code_style - Coding standards, patterns, and conventions
  • testing - Testing strategies and patterns
  • structure - Project architecture and organization
  • design - UI/UX and visual design patterns
  • compliance - Security, legal, and regulatory requirements
  • bug_fixes - Solutions to known issues

2. Topics

Specific subjects within each domain:
.brv/context-tree/
├── code_style/
│   ├── error-handling/
│   ├── naming-conventions/
│   └── api-design/
├── testing/
│   ├── integration-tests/
│   └── unit-tests/
└── structure/
    ├── api-endpoints/
    └── database-schema/

3. Subtopics (Optional)

Deeper organization within topics (maximum one level):
.brv/context-tree/
└── testing/
    └── integration-tests/
        ├── context.md              # Overview of integration testing
        └── api-tests/              # Subtopic
            └── context.md          # Specific to API testing

4. Context Files

Each topic (and subtopic) contains a context.md file with:
  • Content - Your knowledge in markdown format (explanations, code examples, etc.)
  • Relations - Links to related topics (optional ## Relations section)
Example context.md:
Always use custom error classes for better error handling in the Express API:

```typescript
// Custom error class pattern
class ValidationError extends Error {
  constructor(message: string) {
    super(message)
    this.name = 'ValidationError'
  }
}
```

Use try-catch blocks at route level and pass errors to middleware.

## Relations
@code_style/naming-conventions
@testing/integration-tests/api-tests

Relations: The Knowledge Graph

Relations create explicit connections between topics using @domain/topic/subtopic notation. Why relations matter:
  • Enable graph-like navigation between related knowledge
  • Not based on similarity scores - these are explicit, intentional links
  • Help find comprehensive context by following connections
  • Prevent knowledge silos
Example relations:
## Relations
@code_style/error-handling
@testing/integration-tests
@structure/api-endpoints/validation
When you query about error handling, ByteRover can intelligently follow these relations to gather comprehensive context.

Why This Matters

Human-readable and git-friendly:
  • Browse the context tree in your file explorer
  • Edit context.md files with any text editor
  • Track changes with git
  • Review in pull requests
Hierarchical organization prevents “context soup”:
  • Knowledge is categorized by domain and topic
  • Easy to find what you need
  • Clear structure vs flat document storage
Explicit relations enable precise navigation:
  • ByteRover follows connections between topics
  • More reliable than similarity-based search
  • Intentional knowledge graph vs automatic clustering

Common Domains

When using brv curate, ByteRover automatically detects and organizes your context into these default domains:
  • code_style - How code should be written
  • testing - How to test the system
  • structure - How the project is organized
  • design - Visual and UX patterns
  • compliance - Requirements and constraints
  • bug_fixes - Known issues and solutions
You can browse these directly in .brv/context-tree/ or query them with brv query.