# How to Set Up a Development Environment for OpenCodeReview: Complete Guide

> Easily set up your development environment for alibaba/open-code-review. Follow our complete guide for Go and React setup, ensuring a smooth contribution experience.

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

---

**The recommended way to set up a development environment for open-code-review requires installing Go ≥1.25 and Node ≥18, cloning the repository, running `make build` for the Go backend, and `npm install` followed by `npm run dev` in the `pages/` directory for the React UI.**

OpenCodeReview is a mixed-language project maintained by Alibaba that combines a **Go**-based core review engine with a **TypeScript/React** web interface. Setting up a complete development environment involves configuring both toolchains to compile the CLI, run the test suite, and iterate on the frontend components. This guide walks through the exact steps documented in [`CONTRIBUTING.md`](https://github.com/alibaba/open-code-review/blob/main/CONTRIBUTING.md) and the project's `Makefile`.

## Prerequisites

Before cloning the repository, ensure your system meets these requirements:

- **Go ≥1.25** – Required to compile the CLI, agents, diff parsing, and session handling components located in `cmd/opencodereview/` and `internal/`.
- **Git** – Essential for diff generation and repository operations.
- **Make** – Orchestrates build, test, and clean steps via the root `Makefile`.
- **Node ≥18 (LTS)** – Powers the `pages/` UI built with React, Webpack, and Tailwind CSS.
- **npm or pnpm** – Manages frontend dependencies.

## Fork and Clone the Repository

Start by creating your own fork and setting up the local workspace:

```bash

# Fork the repo via GitHub UI first, then:

git clone https://github.com/<your-username>/open-code-review.git
cd open-code-review

# Add upstream remote to stay synchronized

git remote add upstream https://github.com/alibaba/open-code-review.git

```

This workflow follows the official setup instructions in [`CONTRIBUTING.md`](https://github.com/alibaba/open-code-review/blob/main/CONTRIBUTING.md).

## Build the Go Backend

The core review engine resides in `internal/` with its entry point at [`cmd/opencodereview/main.go`](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/main.go). Compile and validate it using the provided Make targets:

```bash

# Compile the CLI binary with version info

make build

# Run the full Go test suite with race detection

make test

```

The `Makefile` defines these targets centrally, ensuring CI and local developers use identical build flags. The binary produces `./dist/opencodereview` (aliased as `ocr` when installed globally).

## Set Up the React Frontend

For full-stack development, initialize the UI located in the `pages/` directory:

```bash
cd pages
npm install    # or pnpm install

npm run dev    # starts dev server on http://localhost:3030

```

To create a production build of the landing page, run `npm run build`. These steps mirror the instructions in [`pages/README.md`](https://github.com/alibaba/open-code-review/blob/main/pages/README.md) and configure the Webpack dev server with hot reloading.

## Configure the LLM Provider

Before running your first review, initialize the AI backend interactively:

```bash
ocr config provider   # Select from built-in providers (OpenAI, etc.)

ocr config model      # Choose the model for the active provider

```

The CLI prompts for API keys and tests connectivity automatically. This configuration is required for the `ocr review` and `ocr scan` commands to function.

## Verify Your Setup

Validate the complete toolchain by running a sample review:

```bash

# Review current git changes (workspace mode)

ocr review

# Or scan specific paths without git diff

ocr scan --path internal/agent

```

To test the built-in web viewer located in `internal/viewer/`, use:

```bash
ocr session list                   # Display saved sessions

ocr session comments <session-id>  # Launch browser UI

```

## Summary

- **Install dual toolchains**: Go ≥1.25 for the backend and Node ≥18 for the React UI in `pages/`.
- **Use Make for Go**: Run `make build` and `make test` from the root to compile `cmd/opencodereview/` and run race-detection tests.
- **Use npm for UI**: Execute `npm install` and `npm run dev` inside `pages/` for frontend development.
- **Configure before running**: Execute `ocr config provider` to set up LLM credentials before testing `ocr review`.
- **No external binaries needed**: The setup is self-contained within the repository structure defined in [`CONTRIBUTING.md`](https://github.com/alibaba/open-code-review/blob/main/CONTRIBUTING.md).

## Frequently Asked Questions

### What Go version is required for open-code-review development?

OpenCodeReview requires **Go 1.25 or higher** according to [`CONTRIBUTING.md`](https://github.com/alibaba/open-code-review/blob/main/CONTRIBUTING.md). This version is necessary to compile the CLI entry point in `cmd/opencodereview/` and the internal packages handling diff parsing and session management.

### Is the frontend setup mandatory for contributing?

No, the React frontend in `pages/` is optional unless you are modifying the landing page or web viewer. You can develop and test the core Go review engine using only `make build` and `make test` without installing Node.js.

### How do I switch between different LLM providers during development?

Run `ocr config provider` to switch providers interactively, then `ocr config model` to select a specific model. The CLI stores these settings locally and validates API connectivity immediately, allowing you to test different backends without rebuilding the binary.

### Can I run the test suite without building the binary first?

Yes, executing `make test` directly runs the Go test suite with race detection enabled. This target is independent of `make build`, so you can verify code changes without waiting for the full compilation of the `opencodereview` binary in `./dist/`.