Context Awareness
Mesraiβs context awareness system goes beyond simple pattern matching. It builds a deep understanding of your codebase structure, relationships, and patterns.
How Context Works
Codebase Understanding
When you connect a repository, Mesrai:
- Analyzes your codebase - Understands all source files and their relationships
- Maps dependencies - Tracks how functions and classes interact
- Identifies patterns - Learns your coding conventions and architecture
- Tracks libraries - Understands external library usage
Real-Time Updates
The context is continuously updated:
- New PRs add to the understanding
- Merged changes update the codebase model
- Deleted code is removed from context
Context Types
File Context
Understanding of individual file structure:
- Imports and exports
- Functions and their signatures
- Dependencies and relationships
- How the file is used across the codebase
Project Context
Understanding of overall project architecture:
- Project structure and organization
- Frameworks and libraries in use
- Database and authentication patterns
- Design patterns used in your code
Historical Context
Learning from past reviews:
- Common issues in your codebase
- Patterns that were previously approved
- Rejected patterns and why
Benefits
Smarter Reviews
With full context, Mesrai can:
- Catch breaking changes β Knows when a function signature change affects callers
- Suggest consistent patterns β Recommends code that matches existing style
- Identify dead code β Finds unused functions and variables
- Predict impact β Estimates the risk level of changes
Reduced False Positives
Context awareness dramatically reduces noise:
// Without context: β οΈ Unused variable 'config'
// With context: β
'config' is used in a conditional import elsewhere
const config = require('./config');Configuration
All context settings are configured through the Mesrai Dashboard β no config files needed!
How to Configure
- Go to app.mesrai.com
- Select your Repository
- Navigate to Settings β Context
- Configure your preferences:
- Context depth β How much of your codebase to analyze
- Include/exclude patterns β Specify which files to include
- Privacy settings β Exclude sensitive files from analysis
Context Settings
| Setting | Description |
|---|---|
| Full Context | Analyze entire codebase for maximum accuracy |
| Standard Context | Balance between speed and accuracy |
| Minimal Context | Focus only on changed files |
Privacy Controls
You can exclude sensitive files from context analysis:
- Environment files (
.env,.env.*) - Secret directories (
secrets/,credentials/) - Key files (
*.key,*.pem)
Configure these exclusions in Settings β Privacy on the dashboard.
Context in Action
Example: API Endpoint Review
When reviewing a new API endpoint, Mesrai considers:
- Authentication patterns β How other endpoints handle auth
- Error handling β Standard error response format
- Validation β Input validation patterns used elsewhere
- Database access β How similar queries are structured
// New endpoint being reviewed
app.post('/api/users', async (req, res) => {
const user = await User.create(req.body);
res.json(user);
});
// Mesrai suggests (based on context):
// - Add authentication middleware (used on all other /api routes)
// - Add input validation (pattern from /api/products)
// - Wrap in try-catch (pattern from /api/orders)
// - Sanitize output (remove password field like /api/profile)