Skip to contents

Launches an interactive Shiny app where an LLM reviews your R code and suggests improvements for reproducibility, readability, and resilience. The app displays your code with proposed edits highlighted inline. You can accept or reject each suggestion, and accepted edits are applied to the file immediately.

Usage

review(file_path, client = NULL, max_pending = NULL)

Arguments

file_path

Path to the R file to review.

client

The model to use for the review, either as an ellmer::Chat object or a "provider/model" string in the same format accepted by ellmer::chat(). If not provided, the reviewer.client option will be consulted. See reviewer_options for details. If neither are present, the user will be shown an interactive dialog to select a client.

max_pending

Maximum number of pending edits allowed at once before the model waits for user responses. Higher values reduce wait time but may feel more overwhelming. If not provided, the reviewer.pending_edits option is used. Defaults to 2.

Value

The function's main purpose is its side-effect, a Docs-style interface opened in the browser. On app close, the ellmer::Chat object used for the review session is returned invisibly. The underlying chat object is stored as .last_review on the search path for easy access after review.

Examples

if (FALSE) { # \dontrun{
# Set the client option (possibly in your .Rprofile)
options(reviewer.client = ellmer::chat_openai(model = "gpt-5.2"))
review("analysis.R")

# Or pass the client directly
review("script.R", client = "openai/gpt-5.2")
review("script.R", client = ellmer::chat_openai(model = "gpt-5.2"))
} # }