| name | r-btw |
| description | Use when code loads or uses btw (library(btw), btw::), providing R session context to LLMs, registering tools for ellmer chat, or copying R object descriptions to clipboard |
btw: Context Tools for R and LLMs
Overview
btw connects R's context to LLMs. Provides tools that describe R objects, fetch documentation, and expose R information to chat sessions.
btw vs mcptools: btw gives tools TO ellmer (R → LLM). mcptools lets agents INTO R (LLM → R).
Install: install.packages("btw")
References
Read references/API.md before writing code.
references/API.md - Complete function reference
references/package-docs.md - Tool registration and usage patterns
When to Use
- Copy R object descriptions to clipboard for LLMs
- Register R documentation tools with ellmer
- Give chat sessions access to R help, data frames, packages
- Create project context files (btw.md)
When NOT to Use
- Want agents to run R code (use r-mcptools)
- Just need to print object (use
print() or str())
- One-off manual description (just copy/paste)
Quick Reference
library(btw)
btw(mtcars)
btw("ggplot2")
btw_this(model)
library(ellmer)
chat <- chat_openai()
chat$set_tools(btw_tools())
chat$chat("What functions does dplyr have?")
use_btw_md()
edit_btw_md()
Common Mistakes
| Issue | Solution |
|---|
| btw vs mcptools confusion | btw = tools TO chat; mcptools = agent INTO R |
| Tools not registered | Must call chat$set_tools(btw_tools()) |
| Using in scripts vs console | btw() for clipboard works in console |
| Expecting code execution | btw describes, doesn't execute (use mcptools) |
Core Functions
Description:
btw(): Generate plain-text descriptions (copies to clipboard)
btw_this(): Create LLM-optimized descriptions
Integration:
btw_tools(): Register with ellmer
btw_client(): btw-enhanced ellmer chat
btw_app(): btw-enhanced ellmer app
Project Context:
use_btw_md(): Create project context file
edit_btw_md(): Modify context file
Skills:
btw_agent_tool(): Create agent tool from markdown file
btw_task_create_skill(): Create a new skill via task
btw_skill_install_github(): Install skill from GitHub
btw_skill_install_package(): Install skill from R package
Advanced
See references/ for:
- API.md: Complete function reference
- Package docs: Full package documentation
Integration
With ellmer: chat$set_tools(btw_tools())
Cross-package patterns: See r-ai meta-skill