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

Top-level folders that group related knowledge areas. ByteRover automatically detects and creates domains on-demand as you curate, letting your context tree structure emerge naturally from your project.
.brv/context-tree/
├── authentication/
├── api-design/
└── database/

2. Topics

Specific subjects within each domain:
.brv/context-tree/
├── authentication/
│   ├── jwt-implementation/
│   ├── oauth-flow/
│   └── session-management/
├── api-design/
│   ├── rest-endpoints/
│   └── graphql-schema/
└── database/
    ├── user-models/
    └── migration-strategy/

3. Subtopics (Optional)

Deeper organization within topics (maximum one level):
.brv/context-tree/
└── authentication/
    └── jwt-implementation/
        ├── jwt_token_generation.md
        └── refresh-tokens/              # Subtopic
            └── refresh_token_rotation.md

4. Context Files

Each topic (and subtopic) contains markdown files with descriptive names:
  • Content - Your knowledge in markdown format (explanations, code examples, etc.)
  • Relations - Links to related topics (optional ## Relations section)
Example markdown file:
JWT tokens expire after 24 hours and require refresh token rotation for security:

```typescript
// Token generation pattern
function generateTokens(userId: string) {
  const accessToken = jwt.sign(
    { userId, type: 'access' },
    process.env.JWT_SECRET,
    { expiresIn: '24h' }
  );

  const refreshToken = jwt.sign(
    { userId, type: 'refresh' },
    process.env.REFRESH_SECRET,
    { expiresIn: '7d' }
  );

  return { accessToken, refreshToken };
}
```

Store refresh tokens in the database with rotation tracking.

## Relations
@authentication/session-management
@api-design/rest-endpoints
@database/user-models

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
@authentication/session-management
@api-design/rest-endpoints
@database/user-models/token-storage
When you query about authentication, 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 markdown 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