r-mirai
Help users write correct R code for async, parallel, and distributed computing using mirai.
Skill by Charlie Gao (@shikokuchuo)
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/posit-dev-r-mirai
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: writing, code-generation
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/r-mirai
What's inside
- Skill name
r-mirai- Description
- Help users write correct R code for async, parallel, and distributed computing using mirai. Use when users need to run R code asynchronously or in parallel, write mirai code with correct dependency passing, set up parallel workers, convert from future or parallel, use mirai_map, integrate with Shiny or promises, or configure cluster/HPC computing.
- License
- MIT
- Metadata
- author: Charlie Gao (@shikokuchuo) · version: 1.2
- Instructions
- 422 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
mirai is a minimalist R framework for async, parallel, and distributed evaluation, built on nanonext.
## Core Principle: Explicit Dependency Passing
mirai evaluates expressions in a **clean environment** on a daemon process. Nothing from the calling environment is available unless passed explicitly — this is the #1 source of mistakes.
```r
# WRONG: my_data and my_func are not available on the daemon
m <- mirai(my_func(my_data))
```
There are two ways to pass objects, and the names used **must match** the names referenced in the expression.
### `.args` (recommended)
Objects in `.args` populate the expression's **local evaluation environment** — available directly by name inside the expression.
```r
m <- mirai(my_func(my_data), .args = list(my_func = my_func, my_data = my_data))
```
### `...` (dot-dot-dot)
Objects passed via `...` are assigned to the **daemon's global environment**. Use this when objects need to be found by R's standard scoping rules (e.g., helper functions called by other functions).
```r
m <- mirai(my_func(my_data), my_func = my_func, my_data = my_data)
```
### Shortcut: pass the whole calling environment
```r
# .args form — populates local eval env
process <- function(x, y) mirai(x + y, .args = environment())
# ... form — single unnamed environment, populates daemon global env
df_matrix <- function(x, y) mirai(as.matrix(rbind(x, y)), environment())
```
### When to use which
| Scenario | Use |
|----------|-----|
| Data and simple functions | `.args` |
| Helper functions called by other functions that need lexical scoping | `...` |
| Pass entire local scope to local eval env | `.args = environment()` |
| Pass entire local scope to daemon global env | `mirai(expr, environment())` |
| Large objects shared across many tasks | `everywhere()` first, then reference by name |
## Common Mistakes
### Unqualified package functions
Daemons start with no user packages loaded. Same applies inside `mirai_map()` callbacks.
```r
# WRONG: dplyr is not loaded on the daemon
m <- mirai(filter(df, x > 5), .args = list(df = my_df))
# CORRECT: namespace-qualify
m <- mirai(dplyr::filter(df, x > 5), .args = list(df = my_df))
# CORRECT: load inside the expression
m <- mirai({
library(dplyr)
filter(df, x > 5)
}, .args = list(df = my_df))
# CORRECT: pre-load on all daemons
everywhere(library(dplyr))
m <- mirai(filter(df, x > 5), .args = list(df = my_df))
```
### Expecting results immediately
`m$data` accesses the value but may still be unresolved. Use `m[]` (or `collect_mirai(m)`) to block until done; use `unresolved(m)` for a non-blocking check.
```r
m <- mirai(slow_computation())
result <- m[] # blocks until resolved
if (!unresolved(m)) result <- m$data # non-blocking
```
## Setting Up Daemons
### No daemons required
`mirai()` works without calling `daemons()` first — it launches a transient background process per call. Setting up daemons is only needed for persistent pools of workers.
### Local daemons
```r
# Start 4 local daemon processes (with dispatcher, the default)
daemons(4)
# Direct connection (no dispatcher) — lower overhead, round-robin scheduling
daemons(4, dispatcher = FALSE)
# Concise programmatic statistics (vs. the richer status())
info()
# Reset (daemons otherwise persist for the session)
daemons(0)
```
### Scoped daemons (auto-cleanup)
`with(daemons(...), {...})` **creates** daemons and automatically cleans them up when the block exits.
```r
with(daemons(4), {
m <- mirai(expensive_task())
m[]
})
```
### Scoped compute profile switching
`local_daemons()` and `with_daemons()` **switch** the active compute profile to one that already exists — they do not create daemons.From posit-dev/skills, MIT.
More from posit-dev/skills
- 0.815score
r-cli
Garrick Aden-Buie (@gadenbuie)
Comprehensive R package for command-line interface styling, semantic messaging, and user communication.
SkillAFreshness: A★ 547Claude Code +9 - 0.815score
shiny-py-optimize
Garrick Aden-Buie (@gadenbuie)
Diagnose and fix performance problems in Shiny for Python apps — slow startup, sluggish interactions, blocking operations, and apps that struggle beyond a…
SkillAFreshness: A★ 547Claude Code +9 - 0.815score
r-lifecycle
Garrick Aden-Buie (@gadenbuie)
Guidance for managing R package lifecycle according to tidyverse principles using the lifecycle package.
SkillAFreshness: A★ 547Claude Code +9 - 0.815score
pr-create
Garrick Aden-Buie (@gadenbuie)
Creates a pull request from current changes, monitors GitHub CI, and debugs any failures until CI passes.
SkillAFreshness: A★ 547Claude Code +9 - 0.815score
shiny-r-optimize
Garrick Aden-Buie (@gadenbuie)
Diagnose and fix performance problems in Shiny for R apps — slow startup, sluggish interactions, long-running blocking operations, and apps that struggle…
SkillAFreshness: A★ 547Claude Code +9 - 0.815score
r-testthat
Garrick Aden-Buie (@gadenbuie)
Best practices for writing R package tests with testthat version 3+.
SkillAFreshness: A★ 547Claude Code +9 - 0.809score
r-cran-extrachecks
Garrick Aden-Buie (@gadenbuie)
Prepare R packages for CRAN submission by checking for common ad-hoc requirements not caught by devtools::check().
SkillAFreshness: A★ 547Claude Code +9 - 0.809score
critical-code-reviewer
Garrick Aden-Buie (@gadenbuie)
Rigorously review code or pull requests for correctness, security, accessibility, maintainability, tests, and edge cases.
SkillAFreshness: A★ 547Claude Code +9 - 0.809score
review-testing
Garrick Aden-Buie (@gadenbuie)
Review test code for quality, design, and completeness after implementing a feature or fixing a bug.
SkillAFreshness: A★ 547Claude Code +9 - 0.809score
r-cran-status
Garrick Aden-Buie (@gadenbuie)
Look up an R package's live status on cran.r-project.org - submission/review state (queue, human review, waiting, archived, past version's fate) or R CMD…
SkillAFreshness: A★ 547Claude Code +9 - 0.809score
describe-design
Garrick Aden-Buie (@gadenbuie)
Research a codebase and create architectural documentation describing how features or systems work.
SkillAFreshness: A★ 547Claude Code +9 - 0.806score
pr-threads-resolve
Barret Schloerke (@schloerke)
Bulk resolve unresolved PR review threads on the current branch’s PR — typically after threads have been addressed manually or via /pr-threads-address
SkillAFreshness: A★ 547Claude Code +9
Signals
- Stars
- 547
- Forks
- 57
- Open issues
- 6
- Last commit (this folder)
- Oct 6, 2026 (21 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.2
- License
- MIT
- Repository
- github.com/posit-dev/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Cite this page
r-mirai skill. Agent Mart. https://agentmart.dev/skills/posit-dev-r-mirai (last updated 2026-10-24)