Clauder — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Clauder (Agent Skill) and scored it 96/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 1 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 1 flagged
The text {match} tells the agent to skip the normal "ask the user first" gate. Used adversarially it removes the human-in-the-loop check before destructive or sensitive actions, turning a normally-gated agent into a fire-and-forget executor.
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
<div align="center"> <img src="assets/logo.svg" alt="ClaudeR Logo" width="180"/> <h1>ClaudeR - The Modern Researcher's Toolkit</h1> <p> <b>Connect a live R or Python session, in RStudio or Positron, to Claude Code, Codex, or any MCP-based LLM agent. For interactive analysis, multi-agent orchestration, and automated manuscript auditing.</b> </p> <p> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a> <a href="https://github.com/IMNMV/ClaudeR/pulls"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome"></a> <a href="https://github.com/IMNMV/ClaudeR/stargazers"><img src="https://img.shields.io/github/stars/IMNMV/ClaudeR?style=social" alt="GitHub stars"></a> <br/> <a href="https://github.com/IMNMV/ClaudeR/actions/workflows/ci.yml"><img src="https://github.com/IMNMV/ClaudeR/actions/workflows/ci.yml/badge.svg" alt="CI status"></a> <a href="https://github.com/IMNMV/ClaudeR/commits/main"><img src="https://img.shields.io/github/last-commit/IMNMV/ClaudeR/main" alt="GitHub last commit"></a> <a href="https://pypi.org/project/clauder-mcp/"><img src="https://img.shields.io/pypi/v/clauder-mcp" alt="PyPI version"></a> <img src="https://img.shields.io/badge/R-%3E%3D4.0-blue?logo=r" alt="R version"> <img src="https://img.shields.io/badge/Python-%3E%3D3.9-blue?logo=python&logoColor=white" alt="Python version"> <a href="https://glama.ai/mcp/servers/IMNMV/ClaudeR"><img src="https://glama.ai/mcp/servers/IMNMV/ClaudeR/badges/score.svg" alt="ClaudeR MCP server"></a> </p> </div>
ClaudeR connects MCP-configured LLM agents, like Claude Code or Codex, to the R session you are already working in. The agent runs code where your cleaned data and fitted models actually are, sees the plots it draws, reads the objects in your environment, and can edit the file open in your editor. A companion Python package does the same for a live Python session, and both work in RStudio and Positron.
Several agents can share one session and divide the work between them, or you can run separate sessions side by side so each agent works on its own dataset without touching the others.
It covers much of what a paid research AI tool does, with the work happening in your own session and a record of every line an agent ran.
# Install
if (!require("devtools")) install.packages("devtools")
devtools::install_github("IMNMV/ClaudeR")
# Set up your AI tool
library(ClaudeR)
install_clauder() # For Claude Desktop / Cursor
install_cli(tools = "claude") # For Claude Code CLI
# Start the server in RStudio
claudeAddin()AI agents: See llms-install.md for automated setup instructions.
| Single agent via Claude Desktop App | Multi-agent: Codex + Claude Code via CLI | GPT 5.4 Codex: Data analysis + Quarto report |
|---|---|---|
![]() | ![]() | ![]() |
<details> <summary><b>Recent Updates</b> (click to expand)</summary>
get_async_result now waits for the job and returns the moment it finishes (up to wait_s seconds, default 300), so a 20-minute model fit takes a handful of calls instead of about 120. When output is too long to send in full, the whole thing is saved to a file and the agent is told where, so it can read the part that was cut instead of running the code again. The addin's Agents panel now hides agents not seen in a day, like cr_roster() already did, so a freshly opened session no longer lists agents from weeks ago.start_console_logging() in the console worked. Cause: globalCallingHandlers() (used to observe warnings and messages) can only be called with an empty handler stack, and inside the Shiny observer that handles the checkbox it errors, which aborted the function before the console callback was registered. The callback is now registered first and unconditionally; the handlers are installed only when logging is started from the console, and otherwise warnings are read from last.warning after each command. Started from the addin, message() output is the one thing not captured, and the addin says so.execute_r_with_plot, saving roughly 4,500 tokens per image when you mostly want text. Your Plots pane is unaffected either way. "Tools available to the agent" hides whole groups you are not using (editor, session, coordination, background jobs, manuscript audit); all 41 tools cost about 8,600 tokens of schema on every request, and a programming-only session needs about 1,200 of that. Both settings are per session and take effect without a restart, though some MCP clients only notice a changed tool list on reconnect. Separately, a bug fix: p <- ggplot(...) returned a full image to the agent even though assignment displays nothing, so the agent was sent plots that never appeared in your Plots pane. Capture now requires the plot to have actually been shown.cat(), progress output, and print() called inside a function. Running f() showed the call but not what f() printed, which is exactly the context an agent needs when you hand it an error you hit yourself. Standard output is now teed to the log and grouped under the command that produced it, alongside the warnings, messages, and errors already captured. Your console still shows everything as normal.tools::pskill(pid, signal = 0). That is the standard idiom on Unix, but on Windows pskill always calls TerminateProcess regardless of signal, so the check killed the session it was asking about, then reported it as alive and left the stale discovery file in place. Starting a server could therefore terminate another RStudio session and leave agents routed to a dead port. Liveness is now probed without signalling. Separately, registering a session whose name is already held by a different live session now warns instead of silently overwriting its discovery file, which had left agents holding the wrong port and token.start_console_logging() / stop_console_logging().modify_code_section and insert_text now save to disk by default and report saved_to_disk, so an agent no longer believes it wrote a file when the change sat unsaved in the buffer. Bounded replacements may change the line count (the old equality constraint is gone). Both tools accept a path to target a specific file, open and focus it, and refuse to edit a different document instead of failing silently. get_active_document now reports the path, the document id, and whether the buffer differs from disk, so buffer state and file state stop being confused for each other. New suggest_edit tool: the agent proposes a change and waits for the user to approve it, using rstudioapi::showEditSuggestion() when the installed rstudioapi provides it, and otherwise staging the edit unsaved so the user accepts by saving or rejects with undo.set_agent_name changes the identity of the whole connection. New as_agent parameter on send_message, check_messages, and wait_for_message acts as a named persona for one call, with a separate read cursor per name. The bridge now enforces the pattern: a second set_agent_name with a different name is refused unless forced, every send confirmation echoes the name it was sent as, and the agent intro states where the current identity came from. (2) Coordination messages bypass R by design, so the console and the Agents panel showed nothing while agents talked. The addin now echoes each new coordination event to the console in full (no truncation), appends it to the session log, and shows a live coordination roster with last-seen ages. (3) A bridge still pointed at a dead R session used to report "success" while writing to a coordination log no live agent reads. Coordination calls now fail loudly when no live session exists, and announce it when the connection re-binds to a different live session. Also from pilot 2: check_cross_references understands S-prefixed supplement numbering, and the audit protocol documents unname() for htest fields and author-plus-year citation matching.set_agent_name tool: an agent sets its working name (for example "Claude-Stasis") once, and execution history, message attribution, presence, and its read cursor all carry that name. This fixes the case where several agents or personas share one MCP connection and collapse into a single random id. get_session_history gains include_past: it parses prior session log files on disk, so the audit of who ran what now survives R restarts. The coordination protocol now makes identity the first step of check-in.screening_report tool computes agreement, Cohen's kappa, PRISMA flow counts, and the conflict set, so the human reads only the disagreements. (2) Grant Panel Mode: grant_panel_prompt(rubric = "nih") convenes a mock study section, one reviewer per criterion, anchored weaknesses, and a ranked list of revisions that would move the score. (3) Response to Reviewers: reviewer_response_prompt() parses a decision letter into a point-by-point registry, reruns analyses so answers carry real computed numbers, gates until every point is answered, and exports the response letter with export_response_letter() plus Word comments in the manuscript.wait_for_message tool that blocks until a partner's event arrives, without touching the busy R session. New consensus gate: after propose_plan(), every execution response carries an agreement banner until all agents run confirm_agreement() with the required sentence verbatim. Only then is the plan marked approved. Plus referee_prompt(stance = "reviewer2"): a hostile-but-fair Reviewer 2 that opens with an unprimed three-sentence read (central claim, and would a strong venue accept it?) and ranks findings fatal / must-fix / minor, each tagged to the study it concerns.referee_prompt() now takes lenses (run any subset), reviewers_per_lens (2 = adversarial prosecutor + verifier pairs, 3 adds a backwards reader), model (a tier for all subagents, e.g. "haiku" for quick passes or "opus" for submission-grade, or a named per-lens vector), and cross_vendor = TRUE to dispatch logic/methods reviewers to a different model vendor via codex/agy/qwen one-shots. Anti-collapse rules are now mandatory in the protocol: reviewer prompts must be written from scratch per lens and stance, the consistency lens reads back-to-front, and every finding carries a corroboration count across independent reviewers.reviewer_zero_prompt(referee = TRUE) (or standalone referee_prompt()) runs five content-only review lenses (argument logic, methods, internal consistency, evidence presentation, framing) as parallel subagents where the CLI supports them. Every finding must anchor to a verbatim quote and survive an independent verification pass before it lands in the document, severities are kept honest, and a clean report on a sound paper is a valid outcome. Alongside it, the new check_cross_references tool deterministically catches dangling references ("see Table 4" when Table 4 no longer exists) and tables or figures the text never mentions.read_file now transparently extracts .docx/.pdf (previously returned raw bytes), and the extractor preserves structure: headings marked, table cells emitted row-wise with separators (they were previously dropped entirely). New reconcile_values tool: enumerates every number in a manuscript and reconciles each against the corpus your code produced, respecting displayed precision (5038.5 matches 5038.46), commas, percents, scientific notation, and < .001 thresholds. The per-value values_registry makes numeric completeness a construction, not a diligence hope. Reviewer Zero now sets audit-clean print options (no more tibble 3-sig-fig false alarms), gates on the value sweep, and takes final verdicts from clean-room runs via probe_scripts(capture_output = TRUE). CrossRef lookups retry with backoff instead of silently truncating the reference check on 429s.reviewer_zero_prompt(writeback = TRUE) turns every flagged claim into a native Word comment in a copy of the manuscript, via the new annotate_manuscript(). (2) Citation upgrades: verify_references now flags retracted/corrected papers using Crossref update notices, resolves arXiv IDs (with a cite-the-published-version check), and bibliographically matches DOI-less references. New search_citations (OpenAlex) and get_bibtex (doi.org) tools mean agents look up citations instead of inventing them. (3) generate_notebook: session logs become narrated Quarto lab notebooks that re-run the analysis when rendered. (4) generate_codebook: one call produces the variable-level codebook plus package/script/output inventory that OSF and journals require. (5) All wired into CI.checkpoint_session snapshots the R global environment to disk, restore_session rolls it back (saving the current state first, so restores are undoable), and list_checkpoints shows what's available. Agents are briefed to checkpoint before risky operations. Users can always recover from the console with ClaudeR::restore_session().reviewer_zero_prompt(prereg_path = ...) appends a Pass 5 that audits the executed analysis against the preregistered plan and produces a complete deviation report. reviewer_zero_prompt(robustness = TRUE) appends a Pass 6 that runs a specification-curve analysis on the primary claims: defensible alternative specs fan out through background jobs and come back as a sensitivity table plus a specification curve.png(); plot(); dev.off() can no longer resend a stale on-screen figure), modify_code_section no longer corrupts replacements containing backslashes, async job results are idempotent and survive bridge timeouts, error responses include everything printed before the error, one agent's long computation no longer tells other agents the addin is down, and Lab Mode's Round-2+ re-verification gate actually fires. Session tokens now come from OS entropy. Logging is on by default. CI (GitHub Actions) now guards every push: R functional checks plus a real MCP stdio handshake against the built bridge.mcp 2.0.0 to PyPI, which removes the server API the bridge is built on. clauder-mcp >= 0.6.1 pins mcp<2. If your bridge broke, run uvx --refresh clauder-mcp. SDK 2.0 migration (and the new Tasks extension for async tools) is planned.load_annotation_data, annotate) let an agent label a CSV dataset row by row without writing any code. Define annotation fields in a _schema column, call data_annotation_prompt() to get the protocol, and the agent handles the rest. The original file is never modified and sessions resume automatically if interrupted.multi_agent_prompt().r_best_practices_prompt() or tell the agent to read it.reviewer_zero_prompt() to get the full protocol.output_path to write to a separate file instead of overwriting the original.claudeAddin() reconnects to the still-running server with the correct port, session name, and execution count. Only clicking "Stop Server" in the UI actually stops the server.clauder_default_8787_20260301_143022.R. A new log file is created each time you click Start Server. All subsequent code execution appends to that file.get_viewer_content reads HTML from interactive widgets (plotly, DT, leaflet) with pagination so agents can inspect htmlwidget output without blowing up context. insert_text inserts text at the cursor position or a specific line/column in the active document. During agent execution, htmlwidgets open in the browser instead of stealing the Shiny addin's viewer pane.connect_session to target a specific session.sessionInfo() output (R version, platform, attached packages). Anyone who receives the log can see exactly what environment the code ran in..R file with just the code. Error blocks are preserved as comments. Also available programmatically via export_log_as_script().uvx clauder-mcp for zero-config setup with no Python path or pip install needed. The installers (install_cli() and install_clauder()) default to uvx, with a use_uvx = FALSE fallback for legacy setups.install_cli(tools = "codex") generates the setup command for OpenAI Codex. Codex joins Claude Code and Gemini as a supported CLI agent.get_session_history to review what other agents have done, or read the shared log file directly. The Shiny viewer tracks connected agents in real-time.~/.claude_r_sessions/ on startup. AI agents find sessions automatically with no hardcoded ports. Name your sessions (e.g. "analysis", "modeling") and run them on different ports. When multiple sessions exist, agents automatically route to the session named "default". Non-default agents should call connect_session to bind to their target session. Single-session setups work with zero config.? button for a built-in guide on multi-session setup and agent identity.execute_r_async now runs long-running code in a separate R process via callr, keeping the main session fully responsive. Other agents can continue working while a job runs. The agent writes self-contained code (explicitly saving/loading data via saveRDS), submits it, and collects the result with get_async_result. No environment copying and no memory doubling, only the data the job needs gets serialized.execute_r call, even when no new plot was created.readOnlyHint, destructiveHint, and idempotentHint annotations per the current MCP spec.escape_r_string now handles backticks, carriage returns, tabs, and null bytes. Applied to task tool inputs to prevent injection.--transport stdio flag and -- separator for current Claude Code CLI. Now removes stale MCP registrations before adding fresh ones, preventing issues when upgrading R versions.</details>
ClaudeR empowers your AI assistant with a suite of tools to interact with your R environment:
wait_s seconds, default 300). wait_s = 0 just checks..docx and .pdf are extracted as structured text with headings marked and table cells kept separated. Supports start_line/end_line pagination for large files..docx as native, anchored Word comments, so authors can accept/dismiss the audit inside Word.< .001 thresholds. Returns a per-value registry so nothing can be silently skipped.path to target a specific file.path to target a specific file.rstudioapi::showEditSuggestion() when available, otherwise stages the change in the editor unsaved so the user accepts by saving or rejects with undo.wait_for_message blocks until a matching event arrives (rendezvous without polling), and everything works even while the R session is busy executing another agent's code.ClaudeR::restore_session()) when you need to recover from an agent mistake yourself.With these tools, you can:
reviewer_zero_prompt() for the full protocol. See the Reviewer Zero section below.ClaudeR includes a built-in protocol for AI-driven technical review of academic manuscripts. The AI acts as "Reviewer Zero": systematically verifying that every p-value, coefficient, and confidence interval in your paper matches the code that produced it.
How it works (core protocol):
read_file (.docx and .pdf are extracted with structure preserved, including table cells), pulling every quantitative and methodological claim into a structured registry (a data.frame visible in your RStudio Environment pane). Audit-clean print options are set first, so console output can never truncate the precision being checked.reconcile_values enumerates every numeric value in the manuscript and supplement and reconciles each against the corpus of numbers your code actually produced, at the document's displayed precision. Every unmatched value must be recomputed or explained before the audit may proceed: completeness by construction, not by diligence. Claim-level recomputation then runs against clean-room script outputs (probe_scripts with output capture), so a stale object in your session can never make a check agree spuriously. Methodological claims (e.g., "zero variance made testing impossible") are tested directly rather than accepted at face value.verify_references checks every DOI against CrossRef and flags metadata mismatches, non-resolving DOIs, and retracted or corrected papers. arXiv preprints are resolved and matched against published versions. DOI-less references get bibliographic matching. In-text citations are cross-checked against the bibliography.Optional extensions, composable via arguments (examples below): a preregistration deviation audit (prereg_path), a specification-curve robustness check (robustness), write-back of every finding as Word comments (writeback), and Referee Mode (referee, or standalone referee_prompt()), a substantive review of the reasoning itself: argument logic, methods, internal consistency, evidence presentation, and framing, run by parallel reviewer subagents with configurable model tiers, adversarial stances, and cross-vendor dispatch, with a deterministic check_cross_references pass and delivery as anchored Word comments.
To get started:
# Print the full protocol prompt to give to your AI agent
reviewer_zero_prompt()
# Optional Pass 5: audit the analysis against your preregistration.
# Produces a deviation report (followed / disclosed deviation /
# undisclosed deviation / not executed) plus a list of exploratory
# analyses that are not labelled as such.
reviewer_zero_prompt(prereg_path = "prereg.docx")
# Optional Pass 6: specification-curve robustness check. The agent
# enumerates defensible alternative analysis choices for the primary
# claims, runs the grid in background jobs, and reports a sensitivity
# table plus a specification curve.
reviewer_zero_prompt(robustness = TRUE)
# Optional write-back: every flagged claim becomes a native Word comment
# in a copy of the manuscript, so you can accept/dismiss findings in Word.
reviewer_zero_prompt(writeback = TRUE)
# All extensions together
reviewer_zero_prompt(prereg_path = "prereg.docx", robustness = TRUE, writeback = TRUE)
# Referee Mode, configured. Quick-and-dirty pass on a fast model tier:
referee_prompt(model = "haiku")
# Submission-grade: strongest tier, adversarial reviewer pairs per lens
# (prosecutor + verifier), and lenses dispatched across model vendors
# (codex/agy/qwen) so same-model blind spots can't hide the same flaw twice:
referee_prompt(model = "opus", reviewers_per_lens = 2, cross_vendor = TRUE)
# Mix tiers per lens: deep model where the reasoning is hard, fast elsewhere
referee_prompt(model = c(logic = "opus", methods = "opus", consistency = "haiku"))The protocol works with .docx, .pdf, .qmd, .Rmd, .tex, or plain text manuscripts and supports multi-script R projects.
ClaudeR comes with a built-in statistical analysis protocol inspired by the modeling workflows I learned from my statistics courses and refined through oof moments from using AI agents in real statistical work. The goal is to steer models with natural language to reproducible, theory-driven analysis which covers EDA, assumption checking, model building, diagnostics, multiple-corrections, and reporting.
# Print the full protocol to give to your AI agent
r_best_practices_prompt()You can also just tell the agent to run ClaudeR::r_best_practices_prompt() and it will read the protocol itself.
When two or more agents share the same RStudio session, they need a way to divide work without stepping on each other. Coordination v2 runs on a typed, append-only event log on disk, shared by the R session and every agent's bridge: typed signals instead of prose conventions, per-agent read cursors (so no agent can clobber another's state), to: addressing with reply threading, lease-based task claims, a latest-wins fact store for shared state, presence stamped by every write, and wait_for_message so an agent can block until its partner's signal arrives instead of polling. The log survives R restarts.
The centerpiece is the consensus gate: when an agent proposes a plan with propose_plan(), every code-execution response in the session carries a banner demanding explicit agreement until every agent has run confirm_agreement() with a required sentence, verbatim. Agents cannot talk past each other into conflicting work: the plan is only marked approved when all parties have confirmed they read each other's position and agree.
# Print the full protocol to give to your AI agents
multi_agent_prompt()You can also just tell the agents to run ClaudeR::multi_agent_prompt() and they will read the protocol themselves.
ClaudeR includes a purpose-built annotation workflow for labelling CSV datasets with an AI agent. The agent works through the dataset row by row using two dedicated MCP tools, with no code required on the agent's end.
CSV format: add a _schema column to your file and define the annotation fields in the first row using a simple type syntax:
text,label,confidence,_schema
"Some text","","","label:choice[positive,negative,neutral];confidence:float[0,1]"
"More text","","",""Supported types: choice[a,b,c], float[min,max], int[min,max], bool, text
Running an annotation session:
# Print the full protocol to give to your agent
data_annotation_prompt()Or tell the agent to run ClaudeR::data_annotation_prompt() and it will read the protocol itself. The agent then calls load_annotation_data to start and annotate to label each row. The original file is never modified, and sessions are automatically resumable if interrupted.
Title and abstract screening is the slowest part of a systematic review. Two humans normally read every record. ClaudeR replaces the bulk reading with two independent AI screeners and leaves the human only the disagreements.
The workflow: export your deduplicated database search to a CSV, add your inclusion and exclusion criteria as a _schema column, and run run_annotation_job twice with two different model families (for example Claude and a free local ollama model). Then:
# Agreement, Cohen's kappa, PRISMA counts, and the conflict set
screening_report("pass_claude_annotating.csv", "pass_qwen_annotating.csv")The report gives you percent agreement, Cohen's kappa between the screeners, the PRISMA flow numbers, and a screening_conflicts data frame holding only the records the two models disagreed on. You adjudicate those, typically a small fraction of the total. Every decision carries a reason, so the audit trail answers "why was this record excluded" with one filter. Print the full protocol with screening_prompt().
A mock study section for your grant before the real one meets. One reviewer subagent per criterion, honest scores, and every weakness anchored to a quote from your proposal.
grant_panel_prompt(rubric = "nih") # Significance, Investigators, Innovation,
# Approach, Environment, scored 1 to 9
grant_panel_prompt(rubric = "nsf") # Intellectual Merit and Broader ImpactsThe chair synthesis ends with the part that matters: a ranked list of concrete revisions that would move your score, each phrased as something you can do this week. Findings can be written into a copy of the proposal as Word comments.
The revise-and-resubmit workflow, compressed. Give the agent the decision letter and your manuscript, and run reviewer_response_prompt(). The agent parses the letter into individual reviewer points, locates each point in your manuscript, and drafts a point-by-point response. Where a reviewer asks a data question, the agent reruns the analysis in your live session, so the answer contains real computed numbers rather than recalled ones. A gate blocks completion until every point has a drafted response.
The deliverables: a formatted response letter via export_response_letter() (markdown, plus .docx when pandoc is installed), and your manuscript annotated with a Word comment at each spot that needs an edit, tagged with the reviewer point it answers.
ClaudeR also connects an agent to a live Python session, and both halves work in Positron as well as RStudio.
import clauder
clauder.start()The agent then executes code in that session, where your loaded dataframes and fitted models already are, and sees the figures it draws. Run it in Positron, Jupyter, VS Code, or a bare REPL. Sessions announce themselves the same way R ones do, so list_sessions shows both and the agent connects to either by name:
Active sessions (2):
analysis [python] — port 8790, pid 8088, started 2026-09-09T10:50:09
modelling [r] — port 8787, pid 84615, started 2026-09-09T09:12:44Start it once per session, the same as claudeAddin() in R. If the port is busy it moves to the next free one and tells you which it took.
If you would rather not type it each time, run it from an IPython startup file:
# ~/.ipython/profile_default/startup/50-clauder.py
import clauder
clauder.start(quiet=True)That opens a server in every Python session you start, including ones you did not intend to expose to an agent, so it is off by default and worth thinking about before enabling.
A Python session gets the live environment. It does not get the editor or the audit tooling, because those drive the IDE through rstudioapi, which has no Python equivalent.
| R | Python | |
|---|---|---|
| Execute code in your live session | yes | yes |
| Plots returned to the agent, and in your plot pane | yes | yes |
| Per-agent log of every line executed | yes | yes |
| Multi-agent coordination and the consensus gate | yes | yes |
| Read and edit your open editor buffer | yes | no |
Approve-before-apply edits (suggest_edit) | yes | no |
| Checkpoint and roll back the environment | yes | no |
| Reviewer Zero and the audit tools | yes | no |
So "load this file, fit the model, plot the residuals" works in Python. "Look at the file I have open and fix that function" is R only. An agent can still read and write those files with its own file tools, it just cannot go through your editor buffer.
R in Positron needs nothing special. Positron ships an rstudioapi compatibility layer, so the editor tools work there, with one difference: suggest_edit stages the change unsaved rather than using showEditSuggestion(), which Positron does not implement. You accept by saving or reject with undo.
ClaudeR uses the Model Context Protocol (MCP) to create a bidirectional connection between an AI assistant and your RStudio environment. MCP is an open protocol from Anthropic that allows the AI to safely interact with local tools and data.
Here's the workflow:
This architecture ensures that the AI can only perform approved operations through well-defined interfaces, keeping you in complete control of your R environment.
ClaudeR supports command-line interface (CLI) agents: the Claude Code CLI, the OpenAI Codex CLI, the Qwen Code CLI, and the Google Antigravity CLI (agy). The Google Gemini CLI shut down on June 18, 2026; agy replaced it, and install_cli(tools = "gemini") still exists for anyone on an old pinned build. This is ideal for developers who prefer a terminal-based workflow, allowing you to interact with your AI assistant directly from the command line while maintaining a live connection to your RStudio session.
ClaudeR is a supervised power tool. The agent executes R code in your live RStudio session, the same session where your data and variables live. You should review what it does, just as you would review a colleague's code before running it.
Binding to 127.0.0.1 is not a security boundary. Any other process on your machine can post code to the port, and so can any webpage you visit, via a cross-origin POST that browsers send without a CORS preflight. Either one is arbitrary code execution in your R session. ClaudeR has two defences:
Origin header is rejected with a 403. Only browsers set Origin, and the MCP bridge never does, so this closes the drive-by-webpage vector with no configuration and no compatibility cost.0600, readable only by you). The bridge reads it and echoes it back as X-Clauder-Token. Tick Require auth token under Advanced to reject every request that lacks it. This closes the local-process vector too.The token is off by default because enforcing it rejects any bridge older than clauder-mcp 0.6.0, which would break existing installs on upgrade. To turn it on:
uvx --refresh clauder-mcp # get a bridge that sends the tokenThen tick Require auth token in the addin's Advanced panel and restart the server. Until you do, the addin prints a one-time console notice when a token-less bridge connects.
validate_code_security() rejects the obvious footguns: system(), system2(), shell(), rstudioapi::terminal, and recursive/wildcard deletes. Treat this as a seatbelt, not a sandbox. It is a regex blocklist and it is trivially bypassable by design (get("system")(...), do.call, eval(parse(...)), and so on). It is there to catch careless generation, not a determined agent. The agent's job is to run arbitrary R, so there is no version of this that is airtight.
The agent can read any file you can read, install packages, overwrite objects in your environment, make network calls, and consume compute. These are necessary for it to be useful. So:
ClaudeR deliberately combines three things: an agent that can execute arbitrary R, tools that pull in untrusted third-party content (read_file, get_viewer_content, verify_references, load_annotation_data), and an R session that can write files and reach the network.
That combination means a manuscript, CSV, or HTML widget authored by someone else is untrusted input on a path to code execution. Reviewer Zero's whole premise (point the agent at a paper you did not write) is exactly the risky shape. A document containing text aimed at the model rather than the reader can redirect what the agent does.
No filter fixes this, because running code is the feature. Mitigate by treating agent sessions over third-party documents as you would running a stranger's script: do it in a project directory, keep logging on, read the log, and don't leave credentials lying around in the working directory or environment.
Restrictions apply only to code executed by the AI. Your manually executed R code is unaffected.
Run this command in your RStudio console:
if (!require("devtools")) install.packages("devtools")
devtools::install_github("IMNMV/ClaudeR")Choose the option that matches your workflow.
#### Option A: For Desktop Apps (Claude Desktop / Cursor)
This function configures the MCP config file automatically for desktop applications. By default it uses uvx to run the clauder-mcp PyPI package, which handles all Python dependencies automatically.
# Load the package
library(ClaudeR)
# Run the installer for Claude Desktop
install_clauder()
# Optional: For Cursor users
# install_clauder(for_cursor = TRUE)For users who cannot use uvx (e.g. restricted environments), fall back to the legacy Python path method:
library(ClaudeR)
install_clauder(use_uvx = FALSE, python_path = "/path/to/your/python")#### Option B: For CLI Tools (Claude Code / Codex / Gemini)
This non-interactive function generates the exact command or JSON configuration needed for your CLI tool.
library(ClaudeR)
# For Claude Code CLI
install_cli(tools = "claude")
# For OpenAI Codex CLI
install_cli(tools = "codex")
# For Qwen Code CLI
install_cli(tools = "qwen")
# For Google Antigravity CLI (agy, Gemini CLI's replacement)
install_cli(tools = "agy")
# For Google Gemini CLI (legacy, shuts down June 18, 2026)
install_cli(tools = "gemini")For users who cannot use uvx, fall back to the legacy Python path method:
install_cli(tools = "claude", use_uvx = FALSE, python_path = "/path/to/my/python")After running the function, you must manually apply the configuration:
~/.gemini/config/mcp_config.json (global) or .agents/mcp_config.json (per-workspace).~/.gemini/settings.json file.After setup, quit and restart any active Desktop Apps or terminal sessions for the new settings to load.
Note: If you upgrade R versions, re-runinstall_cli()orinstall_clauder()to update the MCP server path. The CLI installer automatically removes stale registrations before adding fresh ones.
For all workflows, you must first start the ClaudeR server from RStudio.
library(ClaudeR)
claudeAddin()The ClaudeR add-in will appear in your RStudio Viewer pane. Click "Start Server". Keep this window active while using your preferred tool.
ClaudeR Addin Interface
claude or gemini commands to start interacting with your AI assistant.Note: You can regain console/active document control by clicking the stop button in the RStudio console. This closes the Shiny UI but the MCP server keeps running in the background and your AI agents stay connected. Re-run claudeAddin() to bring the viewer pane back with the same server state (port, session name, execution count). To fully stop the server, click "Stop Server" in the UI before closing.### LLM [agent-id] executing the following code ###.clauder_<session>_<port>_<timestamp>.R (e.g., clauder_default_8787_20260301_143022.R) so you can tell at a glance which session produced which log.sessionInfo() output (R version, platform, attached/loaded packages). This makes logs self-documenting for reproducibility..R file stripped of all timestamps and log headers. Error blocks are kept as comments so you can see what went wrong. Also callable from the console with export_log_as_script().A new log file is created each time you click Start Server. All code executed by agents appends to that file until you stop and start the server again.
data in my environment. Perform exploratory data analysis on it."mtcars dataset and create a scatterplot of mpg vs. hp with a trend line."mpg based on wt and hp."iris dataset and visualize it."If you can do it with R, your AI assistant can too.
8787, but you can change it if needed. On RStudio Server, 8787 is the IDE's own port, so pick a different one (e.g. 8788).config or CLI command.Session -> Restart R) and try again.uvx, ensure uv is installed (curl -LsSf https://astral.sh/uv/install.sh | sh). If using the legacy method, this usually means the wrong Python environment was detected. Re-run the installer with the correct python_path or switch to use_uvx = TRUE.print() (e.g., print(my_plot)).execute_r_with_plot function.execute_r_async for code that takes longer than 25 seconds.get_async_result, which waits until the job is done.callr and do not have access to your main session's environment. The AI must write self-contained code that uses saveRDS() to pass data in and write results out, then loads them back into the main session after the job completes.install_cli() or install_clauder() to update the script path.claudeAddin() to bring the UI back, or click Stop Server in the UI to fully stop it.callr so the main session stays responsive. The background process does not share the main session's environment, so async code must be self-contained.If ClaudeR contributes to published work, a citation is appreciated:
citation("ClaudeR")Vitali, N. (2026). ClaudeR: Connect live RStudio and Python sessions to AI
agents over MCP. R package version 0.15.0.
https://github.com/IMNMV/ClaudeRGitHub's "Cite this repository" button in the sidebar produces the same thing from CITATION.cff.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.