# How to Use kimi-cli for Code Review: Complete Workflow Guide

> Learn to use kimi-cli for code review with this complete guide. Trigger automated reviews, preview diffs, and get structured LLM reports to streamline your workflow.

- Repository: [Moonshot AI/kimi-cli](https://github.com/MoonshotAI/kimi-cli)
- Tags: how-to-guide
- Published: 2026-07-19

---

**Use the `/flow:code-review` slash command in the interactive shell to trigger an automated review that collects changed files, renders a diff preview, queries the LLM, and displays a structured report.**

MoonshotAI's `kimi-cli` is a Python-based interactive AI assistant that ships with a built-in **code review flow**. This feature orchestrates multiple sub-agents to analyze repository changes and generate actionable feedback, accessible via both the terminal UI and programmatic Python APIs.

## How the Code Review Flow Works

The architecture defined in [`src/kimi_cli/soul/kimisoul.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/soul/kimisoul.py) treats code review as a first-class **flow** that loads its behavior from [`src/kimi_cli/agents/code-review.yaml`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/agents/code-review.yaml). When you invoke `/flow:code-review`, the system executes four phases:

1. **File Collection** – Utilities in [`src/kimi_cli/utils/file_utils.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/utils/file_utils.py) walk the workspace to identify changed or staged files based on Git status.
2. **Diff Rendering** – The tool generates a compact visual diff using [`src/kimi_cli/utils/rich/diff_render.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/utils/rich/diff_render.py) for display in the approval panel.
3. **LLM Evaluation** – The diff and system prompts are transmitted via [`src/kimi_cli/llm.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/llm.py) to the configured model, which returns a structured critique.
4. **Report Visualization** – Results are rendered in [`src/kimi_cli/ui/shell/visualize/_approval_panel.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/ui/shell/visualize/_approval_panel.py) and cached in the session directory (`~/.kimi/`).

## Running Interactive Code Reviews

Start by installing the CLI and launching the interactive shell:

```bash

# Requires Python 3.12+

uv pip install kimi-cli

# Launch the TUI

kimi

```

Inside the shell, trigger the review workflow:

```bash
/flow:code-review

```

This command respects settings in [`src/kimi_cli/config.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/config.py), including the LLM model and max token limits. To export the generated review to a markdown file:

```bash
/skill:code-review --output review.md

```

## Automating Reviews in Python Scripts

For CI/CD integration or batch processing, use the `KimiCLI` class exposed in [`src/kimi_cli/app.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/app.py):

```python
import asyncio
from kimi_cli.app import KimiCLI

async def main() -> None:
    cli = await KimiCLI.create()
    # Target specific paths or use "." for the entire repo

    await cli.run_flow("code-review", {"path": "."})

if __name__ == "__main__":
    asyncio.run(main())

```

The `run_flow` method accepts a dictionary of parameters that map to the same file-collection logic used in interactive mode, allowing you to script reviews for specific modules or pull requests.

## Core Implementation Files

Understanding these source files enables advanced customization:

- **[`src/kimi_cli/cli/__init__.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/cli/__init__.py)** – Parses command-line arguments and bootstraps the runtime.
- **[`src/kimi_cli/soul/kimisoul.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/soul/kimisoul.py)** – Dispatches the `/flow:code-review` command to the appropriate skill handler.
- **[`src/kimi_cli/agents/code-review.yaml`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/agents/code-review.yaml)** – Defines the sub-agent prompts and review criteria.
- **[`src/kimi_cli/utils/file_utils.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/utils/file_utils.py)** – Handles workspace scanning and Git status detection.
- **[`src/kimi_cli/utils/rich/diff_render.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/utils/rich/diff_render.py)** – Generates the syntax-highlighted diff shown in the approval interface.
- **[`src/kimi_cli/llm.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/llm.py)** – Manages API communication with the underlying language model.
- **[`src/kimi_cli/ui/shell/visualize/_approval_panel.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/ui/shell/visualize/_approval_panel.py)** – Renders the interactive diff preview and final report.
- **[`src/kimi_cli/config.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/config.py)** – Centralizes configuration for models, tokens, and the session directory.

## Summary

- Invoke `/flow:code-review` in the interactive shell to start an automated review of your current workspace.
- The flow leverages [`src/kimi_cli/utils/file_utils.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/utils/file_utils.py) and [`src/kimi_cli/llm.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/llm.py) to collect changes and generate AI feedback.
- Programmatic control is available via `KimiCLI.run_flow()` for automation pipelines.
- Configuration is governed by [`src/kimi_cli/config.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/config.py) and persists sessions to `~/.kimi/`.
- Export results to markdown using `/skill:code-review --output <file>`.

## Frequently Asked Questions

### How do I install kimi-cli?

Install the package using `uv pip install kimi-cli` or `pip install kimi-cli`. The tool requires Python 3.12 or higher and registers the `kimi` entry point for interactive use.

### Can I review specific files instead of the entire repository?

Yes. When using the Python API, pass a specific path to `run_flow`: `await cli.run_flow("code-review", {"path": "src/module.py"})`. In interactive mode, the flow pre-selects changed files but allows you to adjust the selection in the approval panel before sending to the LLM.

### Where are review outputs stored?

Sessions are cached in `~/.kimi/` as managed by [`src/kimi_cli/config.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/config.py). To persist a review to your working directory, use `/skill:code-review --output review.md` after the flow completes.

### Which LLM model does kimi-cli use for code reviews?

The model is defined in [`src/kimi_cli/config.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/config.py) and can be overridden via environment variables. The [`src/kimi_cli/llm.py`](https://github.com/MoonshotAI/kimi-cli/blob/main/src/kimi_cli/llm.py) module handles all inference, allowing you to specify different models for varying levels of review strictness.