Enterprise-grade autonomous code review powered by AI and MCP tools
Named after the Hindu deity of justice and death, Yama judges code quality and ensures only the worthy changes pass through.
| Aspect | Legacy | Current |
|---|---|---|
| Architecture | Coded orchestration | AI autonomous orchestration |
| Bitbucket Integration | Direct handler imports | External MCP server |
| Context Strategy | Pre-fetch everything | Lazy load on-demand |
| AI Role | Static analyzer | Autonomous agent with tools |
| Decision Making | TypeScript code | AI decides |
| Tool Access | None | All operations via MCP |
| File Analysis | All at once in prompt | File-by-file AI loop |
| Jira Integration | None | MCP tools for requirements |
| Comment Posting | Batch after analysis | Real-time as found |
| PR Blocking | Manual logic | AI decision based on criteria |
YamaOrchestrator
β
MemoryManager (per-repo condensed memory)
β
NeuroLink AI Agent (Autonomous)
β
MCP Tools (Bitbucket + Jira)
β
Pull Request Operations
-
Context Gathering (AI-driven)
- Reads per-repo memory (past review learnings)
- Reads PR details
- Finds and reads Jira ticket
- Loads project standards from memory-bank
- Reads .clinerules for review guidelines
-
File-by-File Analysis (AI-driven)
- Reads each file diff individually
- Searches code for context when needed
- Reads reference files to understand patterns
- Comments on issues immediately
-
PR Description Enhancement (AI-driven)
- Analyzes changes and requirements
- Generates comprehensive description
- Updates PR with enhanced content
-
Final Decision (AI-driven)
- Evaluates all findings
- Applies blocking criteria
- Approves or blocks PR
# Node.js 20.18.1+ required
node --version
# Install Yama
npm install @juspay/yamaCreate a .env file:
# Bitbucket
BITBUCKET_USERNAME=your.email@company.com
BITBUCKET_TOKEN=your-http-access-token
BITBUCKET_BASE_URL=https://bitbucket.yourcompany.com
# Jira (optional)
JIRA_EMAIL=your-email@company.com
JIRA_API_TOKEN=your-jira-api-token
JIRA_BASE_URL=https://yourcompany.atlassian.net
# AI Provider (optional - defaults to auto)
AI_PROVIDER=google-ai
AI_MODEL=gemini-2.5-pro
# Langfuse Observability (optional)
LANGFUSE_PUBLIC_KEY=your-public-key
LANGFUSE_SECRET_KEY=your-secret-key
LANGFUSE_BASE_URL=https://cloud.langfuse.com# Create default config
npx yama init
# Or copy example
cp yama.config.example.yaml yama.config.yaml
# Edit configuration
vim yama.config.yaml# Test initialization
npx yama review --help# Review by PR ID
npx yama review \
--workspace YOUR_WORKSPACE \
--repository my-repo \
--pr 123
# Review by branch
npx yama review \
--workspace YOUR_WORKSPACE \
--repository my-repo \
--branch feature/new-feature# Test without posting comments
npx yama review \
--workspace YOUR_WORKSPACE \
--repository my-repo \
--pr 123 \
--dry-runnpx yama enhance \
--workspace YOUR_WORKSPACE \
--repository my-repo \
--pr 123import { createYama } from "@juspay/yama";
const yama = createYama();
await yama.initialize();
const result = await yama.startReview({
workspace: "YOUR_WORKSPACE",
repository: "my-repo",
pullRequestId: 123,
dryRun: false,
});
console.log("Decision:", result.decision);
console.log("Issues:", result.statistics.issuesFound);Note: Local mode initializes Git MCP internally via the package script
mcp:git:server (uvx mcp-server-git with npx @modelcontextprotocol/server-git fallback).
import { createYama } from "@juspay/yama";
const yama = createYama();
const result = await yama.reviewLocalDiff({
mode: "local",
repoPath: process.cwd(),
diffSource: "staged", // staged | uncommitted | range
focus: ["Security Analysis", "Code Quality"],
prompt: "Prioritize correctness and edge cases",
outputSchemaVersion: "1.0",
});
console.log(result.decision);
console.log(result.issues);SDK override example (no config file edit needed):
const yama = createYama({
configOverrides: {
ai: {
provider: "anthropic",
model: "claude-3-7-sonnet-latest",
},
},
});Precedence in SDK mode:
configOverrides > config file > environment variables > defaults
CLI local mode:
npx yama review --mode local --repo-path . --diff-source stagedversion: 2
configType: "yama"
ai:
provider: "auto"
model: "gemini-2.5-pro"
temperature: 0.2
mcpServers:
jira:
enabled: true
review:
enabled: true
focusAreas:
- name: "Security Analysis"
priority: "CRITICAL"
- name: "Performance Review"
priority: "MAJOR"See yama.config.example.yaml for complete configuration options.
Create custom review standards for your repository:
mkdir -p memory-bankCreate memory-bank/coding-standards.md:
# Project-Specific Review Standards
## Critical Security Rules
1. ALL payment data MUST be encrypted
2. NO credit card numbers in logs
3. ALL database queries MUST use parameterized statements
## Performance Requirements
- API response time: < 200ms p95
- Database queries: < 50ms p95Yama AI will automatically read and apply these standards.
AI reads only what it needs:
- Sees unfamiliar function? β
search_code("functionName") - Needs to understand import? β
get_file_content("path/to/file.ts") - Confused about structure? β
list_directory_content("src/")
AI comments as it finds issues:
- No batching - immediate feedback
- Severity-based emojis (π CRITICAL,
β οΈ MAJOR, π‘ MINOR, π¬ SUGGESTION) - Actionable suggestions with code examples
AI reads Jira tickets:
- Extracts acceptance criteria
- Verifies implementation matches requirements
- Calculates requirement coverage
- Blocks PR if coverage < 70%
AI uses tools to understand code:
search_code()- Find function definitionsget_file_content()- Read related fileslist_directory_content()- Explore structure
AI learns from past reviews and remembers across PRs:
- Reads condensed memory before each review for context
- Writes learnings after PR merge (false positives, missed issues, team conventions)
- LLM-powered condensation keeps memory within a configurable word limit
- Per-repo isolation β each repository gets independent memory keyed by
workspace-repository - Storage as
.mdfiles at configurable path (e.g.,memory-bank/yama/memory/) - Environment variable overrides for all settings (
YAMA_MEMORY_ENABLED,YAMA_MEMORY_MAX_WORDS, etc.)
AI applies these criteria automatically:
-
ANY CRITICAL issue β BLOCKS PR
- Security vulnerabilities
- Data loss risks
- Authentication bypasses
-
3+ MAJOR issues β BLOCKS PR
- Significant bugs
- Performance problems
- Logic errors
-
Requirement coverage < 70% β BLOCKS PR (when Jira enabled)
- Incomplete Jira implementation
- Missing acceptance criteria
Yama uses MCP (Model Context Protocol) servers for tool access:
- Package:
@nexus2520/bitbucket-mcp-server - Tools: get_pull_request, add_comment, search_code, get_file_blame, etc.
- Status: Production ready
- Package:
@nexus2520/jira-mcp-server - Tools: get_issue, search_issues, get_issue_comments
- Status: Optional integration
Track review performance with Langfuse integration:
# Set Langfuse environment variables
export LANGFUSE_PUBLIC_KEY=your-public-key
export LANGFUSE_SECRET_KEY=your-secret-keyAnalytics include:
- Tool calls made
- Token usage
- Cost estimate
- Duration
- Decision rationale
# Verify environment variables
echo $BITBUCKET_USERNAME
echo $BITBUCKET_TOKEN
echo $BITBUCKET_BASE_URL- Check
focusAreasin config - Verify
blockingCriteriaare clear - Ensure
temperatureis low (0.2-0.3) - Review project-specific standards in memory-bank
- Enable
lazyLoading: truein config - Reduce
maxFilesPerReview - Set
maxToolCallsPerFilelimit - Use
excludePatternsto skip generated files
| Metric | Target |
|---|---|
| Review time | < 10 min for 20 files |
| Token usage | < 500K per review |
| Cost per review | < $2 USD |
| Accuracy | > 95% of V1 findings |
- Use lazy loading - Don't pre-fetch everything
- Cache tool results - Reuse MCP responses
- Exclude generated files - Skip lock files, minified code
- Limit file count - Split large PRs
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
MIT License - see LICENSE for details.
βοΈ Built with β€οΈ by Juspay β’ Powered by AI & MCP β’ Autonomous Code Quality Justice