FeaturesContext Awareness

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:

  1. Analyzes your codebase - Understands all source files and their relationships
  2. Maps dependencies - Tracks how functions and classes interact
  3. Identifies patterns - Learns your coding conventions and architecture
  4. 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

  1. Go to app.mesrai.com
  2. Select your Repository
  3. Navigate to Settings β†’ Context
  4. 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

SettingDescription
Full ContextAnalyze entire codebase for maximum accuracy
Standard ContextBalance between speed and accuracy
Minimal ContextFocus 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:

  1. Authentication patterns β€” How other endpoints handle auth
  2. Error handling β€” Standard error response format
  3. Validation β€” Input validation patterns used elsewhere
  4. 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)

Next Steps