# Core Technology Stack of Open-Code-Review: A Deep Dive into Alibaba's AI-Powered CLI

> Explore the core technology stack of Open-Code-Review, Alibaba's AI-powered CLI. Discover how pure Go, LLM agents, and Node.js deliver augmented code reviews.

- Repository: [Alibaba/open-code-review](https://github.com/alibaba/open-code-review)
- Tags: deep-dive
- Published: 2026-08-04

---

**Open-Code-Review is a pure-Go command-line application that combines deterministic engineering with LLM agents, wrapped in a Node.js npm distribution layer to deliver AI-augmented code reviews.**

Open-Code-Review (OCR) from Alibaba is architected as a high-performance CLI tool that bridges deterministic code analysis with dynamic AI reasoning. The core technology stack centers on Go 1.25 for the runtime engine, leveraging modern libraries for terminal interfaces and LLM orchestration. This architecture ensures reliable diff extraction, precise comment positioning, and extensible tool-use capabilities while maintaining a lightweight distribution footprint through npm.

## Language Runtime and Module Structure

The foundation of the core technology stack of open-code-review is **Go 1.25**, declared in [`go.mod`](https://github.com/alibaba/open-code-review/blob/main/go.mod). This choice provides the concurrency primitives and performance characteristics necessary for processing large codebases and managing multiple LLM API connections simultaneously.

The module path `github.com/alibaba/open-code-review` organizes the codebase into logical packages. The `cmd/` directory contains CLI entry points, `internal/agent/` houses the orchestration logic, and `internal/tool/` manages the extensible tool registry.

## CLI Framework and Terminal Interface

For command-line interaction, the project uses **Cobra** (`github.com/spf13/cobra`) to define the declarative command hierarchy. In [[`cmd/opencodereview/main.go`](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/main.go)](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/main.go), Cobra registers subcommands like `ocr review`, `ocr scan`, and their respective flags.

The interactive terminal UI relies on the **Bubble Tea** framework (`github.com/charmbracelet/bubbletea`) paired with **Lipgloss** for styling. Implementation details in [[`cmd/opencodereview/provider_tui.go`](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/provider_tui.go)](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/provider_tui.go) handle real-time progress indicators, prompt rendering, and viewer navigation without leaving the terminal.

## LLM Integration and SDK Architecture

The stack integrates multiple LLM providers through dedicated SDKs. The [[`internal/llm/resolver.go`](https://github.com/alibaba/open-code-review/blob/main/internal/llm/resolver.go)](https://github.com/alibaba/open-code-review/blob/main/internal/llm/resolver.go) file orchestrates connections to:

- **OpenAI Go SDK** (`github.com/openai/openai-go/v3`)
- **Anthropic SDK** (`github.com/anthropics/anthropic-sdk-go`)
- **ModelContextProtocol SDK** (`github.com/modelcontextprotocol/go-sdk`)

These SDKs handle prompt transmission, tool-call serialization, and response streaming, enabling the agent to perform dynamic reasoning across different model providers.

## Core Components of the Technology Stack

### Diff Extraction and Git Integration

Deterministic change detection happens in [[`internal/diff/git.go`](https://github.com/alibaba/open-code-review/blob/main/internal/diff/git.go)](https://github.com/alibaba/open-code-review/blob/main/internal/diff/git.go). This package generates `model.Diff` objects supporting three modes: workspace changes (staged/unstaged), specific commits, and range comparisons between refs.

```bash

# Review staged, unstaged and untracked changes

ocr review

# Review a specific commit

ocr review --commit abc123def

# Review a range between two refs

ocr review --from main --to feature-branch

```

These commands invoke the Go package defined in [[`cmd/opencodereview/review_cmd.go`](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/review_cmd.go)](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/review_cmd.go).

### Agent Orchestration and Tool-Use Engine

The heart of the system resides in [[`internal/agent/agent.go`](https://github.com/alibaba/open-code-review/blob/main/internal/agent/agent.go)](https://github.com/alibaba/open-code-review/blob/main/internal/agent/agent.go). The `Agent.Run` method drives the high-level pipeline: bootstrap → diff → filter → sub-task dispatch → output.

The tool-use engine, registered in [[`internal/tool/tool_registry.go`](https://github.com/alibaba/open-code-review/blob/main/internal/tool/tool_registry.go)](https://github.com/alibaba/open-code-review/blob/main/internal/tool/tool_registry.go), implements six built-in tools including `code_search`, `file_read`, and `code_comment`. Developers can extend functionality by registering custom tools:

```go
// internal/tool/custom_tool.go
package tool

func init() {
    Register("my_custom_tool", func(args map[string]any) (any, error) {
        // Custom analysis logic
        return map[string]string{"result": "analysis_complete"}, nil
    })
}

```

### Memory Compression and Session Persistence

To manage context window limitations, [[`internal/agent/compression.go`](https://github.com/alibaba/open-code-review/blob/main/internal/agent/compression.go)](https://github.com/alibaba/open-code-review/blob/main/internal/agent/compression.go) implements memory compression strategies. Session data persists as append-only JSONL files in `~/.opencodereview/sessions/`, managed by [[`internal/session/persist.go`](https://github.com/alibaba/open-code-review/blob/main/internal/session/persist.go)](https://github.com/alibaba/open-code-review/blob/main/internal/session/persist.go), enabling replay in the web viewer.

Programmatic usage of the Go library follows this pattern:

```go
package main

import (
    "context"
    "github.com/alibaba/open-code-review/internal/agent"
    "github.com/alibaba/open-code-review/internal/config"
)

func main() {
    // Load configuration (provider, model, rules, etc.)
    cfg, _ := config.LoadConfig()

    // Create the review agent
    a := agent.NewAgent(cfg)

    // Run the agent on the current workspace diff
    _ = a.Run(context.Background())
}

```

## Observability and Telemetry

The stack includes **OpenTelemetry** (`go.opentelemetry.io/otel`) instrumentation via [[`internal/telemetry/trace.go`](https://github.com/alibaba/open-code-review/blob/main/internal/telemetry/trace.go)](https://github.com/alibaba/open-code-review/blob/main/internal/telemetry/trace.go). This emits spans for review runs, diff parsing operations, and per-file sub-tasks, allowing operators to trace performance bottlenecks and monitor production deployments.

## Distribution and Packaging Layer

While the engine is pure Go, distribution leverages a thin **Node.js** wrapper published as `@alibaba-group/open-code-review` on npm. The [[`package.json`](https://github.com/alibaba/open-code-review/blob/main/package.json)](https://github.com/alibaba/open-code-review/blob/main/package.json) defines the `ocr` binary entry point ([`bin/ocr.js`](https://github.com/alibaba/open-code-review/blob/main/bin/ocr.js)), enabling installation via `npm install -g ocr` and automatic platform-specific binary management.

Agent behavior is controlled through JSON prompt templates stored in [[`internal/config/template/task_template.json`](https://github.com/alibaba/open-code-review/blob/main/internal/config/template/task_template.json)](https://github.com/alibaba/open-code-review/blob/main/internal/config/template/task_template.json). These templates define planning phases, main loop instructions, and compression triggers. Architecture documentation in [[`pages/src/content/docs/en/architecture.md`](https://github.com/alibaba/open-code-review/blob/main/pages/src/content/docs/en/architecture.md)](https://github.com/alibaba/open-code-review/blob/main/pages/src/content/docs/en/architecture.md) provides the conceptual map for these components.

## Summary

- **Go 1.25** forms the performance-critical foundation, handling concurrency and deterministic operations in the core engine.
- **Cobra** and **Bubble Tea** deliver the CLI structure and interactive terminal experience.
- **OpenAI, Anthropic, and MCP SDKs** provide multi-provider LLM connectivity for the agent.
- The **tool registry** architecture in `internal/tool/` enables extensible agent capabilities with six built-in tools.
- **OpenTelemetry** integration in [`internal/telemetry/trace.go`](https://github.com/alibaba/open-code-review/blob/main/internal/telemetry/trace.go) ensures production observability.
- **Node.js/npm** wrapping allows convenient cross-platform distribution while the runtime remains pure Go.

## Frequently Asked Questions

### Is Open-Code-Review written entirely in Go?

The core engine is pure Go, but the distribution mechanism uses a Node.js wrapper. The Go binary handles all diff extraction, agent orchestration, and LLM communication, while the npm package (`@alibaba-group/open-code-review`) merely provides a convenient installation and update mechanism for the pre-built executables.

### How does the tool-use mechanism work in Open-Code-Review?

The tool-use engine operates through a central registry defined in [`internal/tool/tool_registry.go`](https://github.com/alibaba/open-code-review/blob/main/internal/tool/tool_registry.go). Six built-in tools (`code_search`, `file_read`, `code_comment`, etc.) are registered at startup. The LLM agent can invoke these tools during its reasoning loop, receiving structured results that inform subsequent analysis steps or final review comments.

### What LLM providers does Open-Code-Review support?

According to the source code in [`internal/llm/resolver.go`](https://github.com/alibaba/open-code-review/blob/main/internal/llm/resolver.go), the system supports OpenAI models (via `openai-go/v3`), Anthropic's Claude series (via `anthropic-sdk-go`), and any ModelContextProtocol-compatible provider (via `go-sdk`). The resolver pattern allows runtime selection between these providers based on configuration.

### How are review sessions stored and replayed?

Sessions persist as append-only JSONL files in the user's home directory under `~/.opencodereview/sessions/`. The [`internal/session/persist.go`](https://github.com/alibaba/open-code-review/blob/main/internal/session/persist.go) package handles serialization, storing each review run's metadata, diff context, and agent outputs. These files can be loaded later by the TUI viewer for retrospective analysis or audit trails.