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

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 treats code review as a first-class flow that loads its behavior from 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 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 for display in the approval panel.
  3. LLM Evaluation – The diff and system prompts are transmitted via 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 and cached in the session directory (~/.kimi/).

Running Interactive Code Reviews

Start by installing the CLI and launching the interactive shell:


# Requires Python 3.12+

uv pip install kimi-cli

# Launch the TUI

kimi

Inside the shell, trigger the review workflow:

/flow:code-review

This command respects settings in src/kimi_cli/config.py, including the LLM model and max token limits. To export the generated review to a markdown file:

/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:

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:

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 and 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 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. 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 and can be overridden via environment variables. The src/kimi_cli/llm.py module handles all inference, allowing you to specify different models for varying levels of review strictness.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →