← Selected work
Multi-Agent Orchestrator · Project 6

Code Review Agent

Multi-agent code review system — Orchestrator coordinates Security, Performance and Style specialist agents running in parallel via Promise.all(). Each specialist has its own system prompt and LLM call. Scores code 0–100 based on issue severity.

Anthropic Claude · Node.js · React · Promise.all() · Multi-Agent GitHub ↗
New Concepts This Project
Multi-agent orchestrator — one agent coordinates many specialists. Parallel LLM calls — 3 agents run simultaneously via Promise.all(), 3× faster than sequential. Specialist system prompts — each agent has focused expertise and its own LLM call. Score formula — severity-weighted deductions from 100 produce a quality score.

Architecture

User pastes code
        ↓
Orchestrator Agent (claude-sonnet-4-6)
  reads code, detects language
  calls 3 tools IN PARALLEL (one turn):
        ↓
  Promise.all([
    Security Agent,       ← own system prompt + LLM call
    Performance Agent,    ← own system prompt + LLM call
    Style Agent           ← own system prompt + LLM call
  ])
        ↓
  All 3 run simultaneously ← KEY CONCEPT
        ↓
Orchestrator calls combine_feedback
        ↓
Score (0-100) + all issues + final report ✅

What's New vs Projects 1–5

Previous projects:  ONE agent → ONE agentic loop
This project:       ONE orchestrator → MANY specialist agents

Each specialist:
  → Own system prompt
  → Own focused expertise
  → Runs independently via Promise.all()
  → Returns structured JSON

Orchestrator:
  → Coordinates all 3 specialists
  → Combines results
  → Calculates final score

System Prompts

-- ORCHESTRATOR --
You are a senior engineering lead conducting a code review.
1. Analyze the submitted code
2. Identify the programming language
3. Call all three review tools IN PARALLEL:
   - security_review
   - performance_review
   - style_review
4. After receiving all results, call combine_feedback
ALWAYS call all three tools in the same turn (parallel).

-- SECURITY AGENT --
You are a senior security engineer.
Check for: SQL injection, XSS, exposed secrets,
missing input validation, auth issues, CSRF.
Respond ONLY in JSON: { severity, issues[], summary }

-- PERFORMANCE AGENT --
You are a senior performance engineer.
Check for: N+1 queries, memory leaks, blocking async,
unnecessary loops, missing memoization.
Respond ONLY in JSON: { severity, issues[], summary }

-- STYLE AGENT --
You are a senior engineer specializing in code quality.
Check for: poor naming, DRY violations, missing error
handling, hardcoded values, dead code.
Respond ONLY in JSON: { severity, issues[], summary }

Tool Definitions

[
  {
    "name": "security_review",
    "description": "Run security analysis. Checks vulnerabilities, secrets, injection risks.",
    "input_schema": { "properties": { "code": {"type":"string"}, "language": {"type":"string"} } }
  },
  {
    "name": "performance_review",
    "description": "Run performance analysis. Checks N+1, memory leaks, inefficiencies.",
    "input_schema": { "properties": { "code": {"type":"string"}, "language": {"type":"string"} } }
  },
  {
    "name": "style_review",
    "description": "Run style and best practices review. Checks naming, DRY, readability.",
    "input_schema": { "properties": { "code": {"type":"string"}, "language": {"type":"string"} } }
  },
  {
    "name": "combine_feedback",
    "description": "Combine all specialist reviews into final structured report.",
    "input_schema": { "properties": { "security_findings": {"type":"string"}, "performance_findings": {"type":"string"}, "style_findings": {"type":"string"} } }
  }
]

Turn-by-Turn LLM Flow

POST /review { code, language }
        ↓
Turn 1 — Orchestrator LLM Request:
  messages: [{ role: "user", content: "Review this code..." }]

Turn 1 — Orchestrator LLM Response:
  stop_reason: "tool_use"
  content: [
    { type: "tool_use", name: "security_review",    input: {code, language} },
    { type: "tool_use", name: "performance_review", input: {code, language} },
    { type: "tool_use", name: "style_review",       input: {code, language} }
  ]
  ↑ 3 tools called in ONE turn — parallel execution begins ⚡
        ↓
Promise.all([
  Security LLM call  → { severity: "critical", issues: [...] }
  Performance LLM    → { severity: "high",     issues: [...] }
  Style LLM          → { severity: "medium",   issues: [...] }
])  ← all 3 run simultaneously
        ↓
Turn 2 — Send all 3 results back to Orchestrator:
  messages: [..., { role: "user", content: [tool_result × 3] }]

Turn 2 — Orchestrator calls combine_feedback:
  stop_reason: "tool_use"
  ↓ Your code runs buildFinalReview()
        ↓
Turn 3 — Orchestrator final response:
  stop_reason: "end_turn"
  "Code review complete. Score: 17/100..."

Scoring Formula

Start: 100 points

Deductions:
  Critical issue: -25 points each
  High issue:     -15 points each
  Medium issue:   -8  points each
  Low issue:      -3  points each

Example:
  3 critical (-75) + 1 high (-15) + 2 medium (-16)
  = 100 - 106 = max(0, -6) = 17/100

Grades:
  80-100 → Good    (green)
  60-79  → Needs Work (amber)
  0-59   → Poor    (red)

Why Parallel Matters

Without Promise.all (sequential):
  Security Agent  → 15 sec
  Performance     → 15 sec
  Style           → 15 sec
  Total           → 45 sec ❌

With Promise.all (parallel):
  All 3 start at same time
  All finish in ~15 sec
  Total → 15 sec ✅  3× faster!

Token Cost

Agent               Input    Output
────────────────────────────────────
Orchestrator T1     620      180
Security Agent      480      320
Performance Agent   460      180
Style Agent         450      220
Orchestrator T2     1240     140
Orchestrator T3     1580     120
────────────────────────────────────
Total               4,830    1,160    ~$0.000032 per review