tidy-evaluation
Use when programming with tidyverse data-masked functions (dplyr, ggplot2, tidyr) and need to pass column references through functions. Covers: forwarding patterns with {{ and ..., names patterns with .data/.env pronouns, bridge patterns with across()/all_of(), double evaluation and ambiguity pitfalls. Does NOT cover: expression mechanics (r-metaprogramming), error handling (rlang-conditions), function design (designing-tidy-r-functions).
What this skill does
# Tidy Evaluation Programming Patterns
Data masking lets you refer to data frame columns as if they were regular objects. Programming with data-masked functions requires special patterns to pass column references through your functions.
## Quick Reference
| Goal | Pattern |
|------|---------|
| Forward single argument | `{{ var }}` |
| Forward `...` to data-mask | `...` directly |
| Forward `...` to tidy-select (single arg) | `c(...)` |
| Use column name from string | `.data[[var]]` |
| Use column names from vector | `across(all_of(vars))` |
| Disambiguate env-variable | `.env$x` |
| Disambiguate data-variable | `.data$x` |
| Bridge selection to data-mask | `across({{ var }})` |
| Bridge names to data-mask | `across(all_of(vars))` |
| Bridge data-mask to selection | `transmute()` then `all_of()` |
| Prevent double evaluation | Assign to column first |
## What is Data Masking?
Data masking inserts a data frame at the bottom of the environment chain, giving columns precedence over user-defined variables:
```r
# Without masking: must use $ notation
mean(mtcars$cyl + mtcars$am)
# With masking: columns are directly accessible
with(mtcars, mean(cyl + am))
dplyr::summarise(mtcars, mean(cyl + am))
```
### Why Injection is Needed
Data-masking functions defuse their arguments. When you wrap them, you must inject the user's expression:
```r
# Without injection: summarise sees literal "var1 + var2"
my_mean <- function(data, var1, var2) {
dplyr::summarise(data, mean(var1 + var2)) # Error!
}
# With injection: summarise sees "cyl + am"
my_mean <- function(data, var1, var2) {
dplyr::summarise(data, mean({{ var1 }} + {{ var2 }}))
}
```
## Argument Behaviors
| Behavior | Example Functions | Key Features |
|----------|-------------------|--------------|
| Data-masked | `mutate()`, `summarise()`, `filter()` | Column refs, `.data`/`.env`, `{{`, `!!` |
| Tidy-select | `select()`, `pivot_longer(cols=)` | Helpers (`starts_with`), `c()`, `:`, `{{` |
| Dynamic dots | `list2()`, `tibble()` | `!!!` splice, `{name}` interpolation |
### Documenting Argument Behaviors
```r
#' @param var <[`data-masked`][dplyr::dplyr_data_masking]> Column to summarize.
#' @param cols <[`tidy-select`][dplyr::dplyr_tidy_select]> Columns to pivot.
#' @param ... <[`dynamic-dots`][rlang::dyn-dots]> Name-value pairs.
```
## Forwarding Patterns
### Single Argument with `{{}}`
The embrace operator forwards an argument, inheriting behavior from the wrapped function:
```r
# Forwarding to data-masked context
my_summarise <- function(data, var) {
data |> dplyr::summarise({{ var }})
}
mtcars |> my_summarise(mean(cyl))
# Forwarding to tidy-select context
my_pivot <- function(data, cols) {
data |> tidyr::pivot_longer(cols = {{ cols }})
}
mtcars |> my_pivot(starts_with("c"))
```
### Multiple Arguments with `...`
Pass `...` directly to data-masked functions:
```r
my_group_by <- function(.data, ...) {
.data |> dplyr::group_by(...)
}
mtcars |> my_group_by(cyl, am)
```
For tidy-select functions taking a single argument, wrap in `c()`:
```r
my_pivot <- function(.data, ...) {
.data |> tidyr::pivot_longer(c(...))
}
mtcars |> my_pivot(cyl, am, vs)
```
## Names Patterns
Use strings or character vectors instead of expressions. Your function becomes "regular" with no data-masking complications.
### `.data[[var]]` for Single Column
```r
my_mean <- function(data, var) {
data |> dplyr::summarise(mean = mean(.data[[var]]))
}
my_mean(mtcars, "cyl")
# No masking surprises
am <- "cyl"
my_mean(mtcars, am) # Uses "cyl", not masked
```
### `all_of()` for Character Vectors
```r
vars <- c("cyl", "am")
mtcars |> tidyr::pivot_longer(all_of(vars))
mtcars |> dplyr::select(all_of(vars))
```
### Loop Pattern
```r
vars <- c("cyl", "am", "vs")
for (var in vars) {
result <- mtcars |>
dplyr::summarise(mean = mean(.data[[var]]))
print(result)
}
# Or with purrr
purrr::map(vars, ~ dplyr::summarise(mtcars, mean = mean(.data[[.x]])))
```
## Bridge Patterns
Convert between argument behaviors when the wrapped function doesn't match your desired interface.
### Selection to Data-Mask: `across()`
Give your function tidy-select behavior when wrapping a data-masked function:
```r
my_group_by <- function(data, var) {
data |> dplyr::group_by(across({{ var }}))
}
# Now supports selection helpers:
mtcars |> my_group_by(starts_with("c"))
```
For `...`, wrap in `c()`:
```r
my_group_by <- function(.data, ...) {
.data |> dplyr::group_by(across(c(...)))
}
```
### Names to Data-Mask: `across(all_of())`
Accept character vectors for data-masked operations:
```r
my_group_by <- function(data, vars) {
data |> dplyr::group_by(across(all_of(vars)))
}
my_group_by(mtcars, c("cyl", "am"))
```
### Data-Mask to Selection: `transmute()` Bridge
Three-step pattern for data-masked input to tidy-select functions:
```r
my_pivot_longer <- function(data, ...) {
# 1. Capture inputs in data-masked context, get names
inputs <- dplyr::transmute(data, ...)
names <- names(inputs)
# 2. Update data with the expressions
data <- dplyr::mutate(data, !!!inputs)
# 3. Pass names to tidy-select
tidyr::pivot_longer(data, cols = all_of(names))
}
mtcars |> my_pivot_longer(cyl, am_scaled = am * 100)
```
## Transformation Patterns
### Named Arguments: Code Around `{{}}`
Add code around embraced arguments:
```r
my_mean <- function(data, var) {
data |> dplyr::summarise(mean = mean({{ var }}, na.rm = TRUE))
}
```
### `...` Arguments: Use `across()`
Map an expression across multiple columns:
```r
my_mean <- function(data, ...) {
data |> dplyr::summarise(
across(c(...), ~ mean(.x, na.rm = TRUE))
)
}
mtcars |> my_mean(cyl, disp, hp)
```
### Filter with `if_all()` / `if_any()`
Combine logical conditions across columns:
```r
filter_non_min <- function(.data, ...) {
.data |> dplyr::filter(
if_all(c(...), ~ .x != min(.x, na.rm = TRUE))
)
}
filter_any_max <- function(.data, ...) {
.data |> dplyr::filter(
if_any(c(...), ~ .x == max(.x, na.rm = TRUE))
)
}
```
## Disambiguation: .data and .env Pronouns
Data masking can cause collisions when variable names exist in both the data and environment.
### Column Collisions
```r
x <- 100
df <- data.frame(x = 1:3, y = 4:6)
# Ambiguous: which x?
df |> dplyr::mutate(z = y / x)
#> Uses column x (data takes precedence)
# Explicit: use environment x
df |> dplyr::mutate(z = y / .env$x)
```
### In Functions (Critical)
Always use `.env` for function parameters that might collide:
```r
my_rescale <- function(data, var, factor = 10) {
# Safe even if data has a 'factor' column
data |> dplyr::mutate(
"{{ var }}" := {{ var }} / .env$factor
)
}
```
### Full Disambiguation
```r
df |> dplyr::mutate(
result = .data$y / .env$x
)
```
## Pitfalls
### Double Evaluation
Expressions injected multiple times execute multiple times:
```r
# BAD: times100() runs twice
summarise_stats <- function(data, var) {
data |> dplyr::summarise(
mean = mean({{ var }}),
sd = sd({{ var }})
)
}
# If var = times100(cyl), function executes twice
# GOOD: Evaluate once, reference result
summarise_stats <- function(data, var) {
data |>
dplyr::transmute(var = {{ var }}) |>
dplyr::summarise(mean = mean(var), sd = sd(var))
}
```
Exception: Glue strings (`"{{ var }}"`) don't suffer from double evaluation.
### `{{` Out of Context
Outside data-masking, `{{` becomes literal double-braces and silently returns the value:
```r
# In non-tidy-eval function:
f <- function(x) {{ x }}
f(1 + 1)
#> [1] 2 # No error, but not defuse-and-inject
```
### `!!` and `!!!` Out of Context
Outside injection context, these become logical negation:
```r
x <- TRUE
!!x # Double negation: TRUE
!!!x # Triple negation: FALSE
```
No error, just wrong semantics.
### `{{` on Non-Arguments
`{{` should only wrap function arguments:
```r
# Correct
my_fn <- function(arg) {
summarise(data, {{ arg }})
}
# Problematic: x is not a defused argument
x <- expr(cyl)
summarise(Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.