Learn R Programming

btw

A complete toolkit for connecting R and LLMs

Overview

btw helps R users work with Large Language Models, whether you’re pasting context into ChatGPT, chatting with an AI assistant in your IDE, or building LLM-powered applications.

The challenge: LLMs need context about your R environment to be helpful—your data structures, the packages you’re using, relevant documentation.

btw provides a flexible toolkit that works across different workflows:

  • Copy-paste to external LLMs: Quickly gather context from your R session and copy it to your clipboard for pasting into ChatGPT, Claude, or any other chat interface.
  • Interactive chat in R: Launch a full-featured AI assistant directly in your IDE that can explore your environment, read documentation, and help you write code.
  • Build LLM-powered tools: Integrate btw’s capabilities into your own applications, whether you’re creating custom chat interfaces or connecting R to coding agents.

Quick Start

Copy-paste workflow

Use btw() to gather context from your R session and copy it to your clipboard:

library(btw)

# Describe a data frame
btw(mtcars)

# Include package or function documentation
btw("{dplyr}", ?dplyr::across)

# Combine multiple pieces of context
btw(mtcars, "{dplyr}", "How do I calculate the mean mpg by cylinder?")

The context is copied to your clipboard, ready to paste into ChatGPT, Claude, or any LLM chat interface.

Interactive chat in your IDE

Launch a chat interface with btw_app():

btw_app()

For persistent project context, create a btw.md file with use_btw_md(). This creates a project-specific configuration file where you can define your preferred LLM provider, model, and custom instructions that apply to all conversations in your project.

Building with btw

btw supercharges ellmer! Use btw_client() for a pre-configured chat client, the same client used by btw_app().

# Uses provider, model, tools and instructions from btw.md
chat <- btw_client()
chat$chat("Help me write documentation for...")

Or use btw_tools() to get a list of tools you can register with any ellmer chat client.

library(ellmer)

chat <- chat_anthropic()  # or chat_openai(), chat_ollama(), etc.
chat$register_tools(btw_tools())

chat$chat("What data frames are in my environment?")

Pick and choose which tools you use with friendly group names

# Only provide documentation and file tools
chat$register_tools(btw_tools(c("docs", "files")))

or expose btw tools to external coding agents via the Model Context Protocol using mcptools.

# Run as a background process or in a separate R session
btw_mcp_server()

You can configure the MCP server in Claude Desktop, Continue, or other MCP-compatible tools to give them access to your R environment.

Installation

You can install btw from CRAN:

install.packages("btw")

To install the latest development version, you can install from posit-dev.r-universe.dev:

# install.packages("pak")

pak::repo_add("https://posit-dev.r-universe.dev")
pak::pak("btw")

Or you can install the development version from GitHub:

# install.packages("pak")
pak::pak("posit-dev/btw")

Learn More

Copy Link

Version

Install

install.packages('btw')

Monthly Downloads

884

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Garrick Aden-Buie

Last Published

December 23rd, 2025

Functions in btw (1.0.0)

btw_tool_env_describe_data_frame

Tool: Describe data frame
btw_tool_git_branch_checkout

Tool: Git Branch Checkout
btw_tool_env_describe_environment

Tool: Describe an environment
btw

Plain-text descriptions of R objects
btw_tool_git_branch_create

Tool: Git Branch Create
btw_this.data.frame

Describe a data frame in plain text
btw_tool_files_read_text_file

Tool: Read a file
btw_tool_files_write_text_file

Tool: Write a text file
btw_tool_git_status

Tool: Git Status
btw_tool_git_branch_list

Tool: Git Branch List
btw_tool_git_commit

Tool: Git Commit
btw_tool_github

Tool: GitHub
btw_tool_search_package_info

Tool: Describe a CRAN package
btw_tool_git_diff

Tool: Git Diff
btw_tool_git_log

Tool: Git Log
btw_tool_session_package_info

Tool: Gather information about a package or currently loaded packages
btw_tool_session_check_package_installed

Tool: Check if a package is installed
btw_tool_web_read_url

Tool: Read a Web Page as Markdown
btw_tool_session_platform_info

Tool: Describe user's platform
use_btw_md

Create or edit a btw.md context file
btw_tool_search_packages

Tool: Search for an R package on CRAN
btw_tool_package_docs

Tool: Describe R package documentation
btw_tool_files_code_search

Tool: Code Search in Project
btw_tool_files_list_files

Tool: List files
btw_tool_ide_read_current_editor

Tool: Read current file
btw_tools

Tools: Register tools from btw
mcp

Start a Model Context Protocol server with btw tools
btw_task_create_readme

Task: Create a Polished README
btw-package

btw: A Toolkit for Connecting R and Large Language Models
btw_this.character

Describe objects
btw_task_create_btw_md

Task: Initialize Project Context File
btw_this

Describe something for use by an LLM
btw_client

Create a btw-enhanced ellmer chat client
btw_this.environment

Describe the contents of an environment
btw_tool_docs_package_news

Tool: Package Release Notes