Agent skill

R Style Guide

by ab604 in ab604/claude-code-r-skills

R style guide covering naming conventions, spacing, layout, and function design best practices.

MITAuto-check passedWriting & Content

Install R Style Guide

skills CLI
$ npx skills add ab604/claude-code-r-skills --skill r-style-guide -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ab604/claude-code-r-skills r-style-guide --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ab604/claude-code-r-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/r-style-guide .claude/skills/r-style-guide && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
r-style-guide
GitHub stars
206
Used in
2 other repos
Token cost
~1.7k tokens
SKILL.md length
156 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
MIT

At a glance

R style guide covering naming conventions, spacing, layout, and function design best practices.

  • Writing & Content work in your project
  • SKILL.md covers Function Writing Best Practices, Style Guide Essentials, Function Design Guidelines and Tidyverse API Conventions, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

R Style Guide is an agent skill from ab604/claude-code-r-skills. R style guide covering naming conventions, spacing, layout, and function design best practices. Use when writing R code.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Writing & Content. The repository describes itself as: Claude Code configurations for R development. The licence is MIT.

When your agent uses it

  • Writing & Content work in your project

Example prompts

  • “/r-style-guide”

What it can do on your machine

Read from SKILL.md and the folder at commit 529de4f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are r).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

R Style Guide loads about 1.7k tokens when it runs. Until then it costs about 34 tokens; SKILL.md has 156 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~34
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ab604/claude-code-r-skills at commit 529de4f, republished under its MIT licence (© ab604). 156 words, ~1,736 tokens.

Download SKILL.mdSave it as .claude/skills/r-style-guide/SKILL.md (or your agent's skills folder).
name
r-style-guide
description
R style guide covering naming conventions, spacing, layout, and function design best practices. Use when writing R code.

R Style Guide & Function Writing Best Practices

Consistent naming, spacing, structure, and function design for R code

Function Writing Best Practices

Structure and Style
r
# Good function structure
rescale01 <- function(x) {
  rng <- range(x, na.rm = TRUE, finite = TRUE)
  (x - rng[1]) / (rng[2] - rng[1])
}

# Use type-stable outputs
map_dbl()   # returns numeric vector
map_chr()   # returns character vector
map_lgl()   # returns logical vector
Naming and Arguments
r
# Good naming: snake_case for variables/functions
calculate_mean_score <- function(data, score_col) {
  # Function body
}

# Prefix non-standard arguments with .
my_function <- function(.data, ...) {
  # Reduces argument conflicts
}

Style Guide Essentials

Object Names
  • Use snake_case for all names
  • Variable names = nouns, function names = verbs
  • Avoid dots except for S3 methods
r
# Good
day_one
calculate_mean
user_data

# Avoid
DayOne
calculate.mean
userData
Spacing and Layout
r
# Good spacing
x[, 1]
mean(x, na.rm = TRUE)
if (condition) {
  action()
}

# Pipe formatting
data |>
  filter(year >= 2020) |>
  group_by(category) |>
  summarise(
    mean_value = mean(value),
    count = n()
  )
Assignment
r
# Good - Use <- for assignment
x <- 5

# Avoid - = for assignment (use only for function arguments)
x = 5  # Less clear intent
Indentation and Line Length
  • Use 2 spaces for indentation (never tabs)
  • Keep lines under 80 characters when possible
  • For long function calls, put each argument on its own line
r
# Good - Long function call
do_something_complicated(
  data = my_data,
  arg_one = value_one,
  arg_two = value_two,
  arg_three = value_three
)

# Good - Long pipe chain
result <- data |>
  filter(year >= 2020) |>
  mutate(
    new_var = old_var * 2,
    another_var = str_to_lower(text_var)
  ) |>
  summarise(
    mean_value = mean(value),
    .by = category
  )
Comments
r
# Good - Comments explain WHY, not WHAT
# Calculate running average to smooth noise in sensor data
running_avg <- zoo::rollmean(values, k = 5)

# Avoid - Comments that just repeat the code
# Add 1 to x
x <- x + 1
File Organization
r
# 1. Load packages at the top
library(dplyr)
library(ggplot2)

# 2. Source any helper files
source("R/helpers.R")

# 3. Define constants
MAX_ITERATIONS <- 1000
DEFAULT_THRESHOLD <- 0.05

# 4. Define functions
process_data <- function(data) {
  # ...
}

# 5. Main script logic (if not a package)
main <- function() {
  data <- read_csv("data/input.csv")
  result <- process_data(data)
  write_csv(result, "data/output.csv")
}

Function Design Guidelines

Single Responsibility
r
# Good - Each function does one thing
read_and_validate <- function(path) {
  data <- read_csv(path)
  validate_columns(data)
  data
}

validate_columns <- function(data) {
  required <- c("id", "value", "date")
  missing <- setdiff(required, names(data))
  if (length(missing) > 0) {
    stop("Missing columns: ", paste(missing, collapse = ", "))
  }
}

# Avoid - Function does too many things
do_everything <- function(path, output_path, ...) {
  # Reads, validates, transforms, models, plots, writes...
}
Return Values
r
# Good - Explicit return for complex functions
calculate_metrics <- function(data) {
  metrics <- list(
    mean = mean(data$value),
    sd = sd(data$value),
    n = nrow(data)
  )
  return(metrics)
}

# Good - Implicit return for simple functions
square <- function(x) {
  x^2
}

# Avoid - Return in the middle without good reason
process <- function(x) {
  if (is.null(x)) return(NULL)  # OK - early exit
  # ... more code
  result  # Implicit return at end
}
Error Handling

Prefer cli::cli_abort() over stop() for user-facing errors. Structure messages as a problem statement followed by context bullets.

r
# Good - cli::cli_abort() with structured bullets
# Bullet types: x = error detail, i = info/hint, ! = warning
validate_input <- function(x, threshold = 0) {
  if (!is.numeric(x)) {
    cli::cli_abort(c(
      "{.arg x} must be numeric.",
      x = "You supplied {.cls {class(x)}}.",
      i = "Convert with {.fn as.numeric} first."
    ))
  }
  if (any(x < threshold)) {
    cli::cli_abort(c(
      "{.arg x} must be >= {threshold}.",
      x = "{sum(x < threshold)} value{?s} below threshold.",
      i = "Set {.arg threshold} to adjust the lower bound."
    ))
  }
}

# Good - reference argument names, functions, and classes with inline markup
cli::cli_abort(c(
  "{.fn my_func} requires a data frame.",
  x = "{.arg data} is {.cls {class(data)}}, not {.cls data.frame}.",
  i = "Did you mean to call {.fn as.data.frame}?"
))

# Avoid - stop() with string concatenation
stop("`x` must be numeric, not ", typeof(x), call. = FALSE)

Inline markup tokens:

  • {.arg x} — argument name (backtick-formatted)
  • {.fn foo} — function name
  • {.cls {class(x)}} — class name
  • {.val {value}} — literal value
  • {?s} — pluralisation (value{?s} → "value" or "values")
Default Arguments
r
# Good - Sensible defaults
summarise_data <- function(data, na.rm = TRUE, digits = 2) {
  # ...
}

# Good - NULL default for optional arguments
filter_data <- function(data, min_value = NULL, max_value = NULL) {
  if (!is.null(min_value)) {
    data <- filter(data, value >= min_value)
  }
  if (!is.null(max_value)) {
    data <- filter(data, value <= max_value)
  }
  data
}

Tidyverse API Conventions

Data-First Argument
r
# Good - Data as first argument for piping
my_transform <- function(data, var, threshold = 0.5) {
  data |>
    filter({{ var }} > threshold)
}

# Usage
data |> my_transform(value, threshold = 0.8)
Prefixed Non-Standard Arguments
r
# Good - Prefix with . to avoid conflicts
group_summary <- function(.data, ..., .by = NULL) {
  .data |>
    summarise(..., .by = {{ .by }})
}
Consistent Return Types
r
# Good - Always return tibble
my_function <- function(data) {
  result <- data |>
    # processing...
    filter(!is.na(value))

  tibble::as_tibble(result)
}

Common Style Mistakes

Avoid These Patterns
r
# Avoid - Inconsistent spacing
x<-1+2  # No spaces
x <- 1 + 2  # Correct

# Avoid - Unnecessary parentheses
if ((x > 0)) {}  # Extra parens
if (x > 0) {}    # Correct

# Avoid - Using T/F instead of TRUE/FALSE
if (x == T) {}     # T can be overwritten
if (x == TRUE) {}  # Correct

# Avoid - Semicolons to separate statements
x <- 1; y <- 2  # Hard to read
x <- 1          # Correct
y <- 2

# Avoid - attach() - creates ambiguity
attach(mtcars)
mean(mpg)  # Which mpg?
detach(mtcars)

# Correct - Be explicit
mean(mtcars$mpg)
# or
with(mtcars, mean(mpg))
# or
mtcars |> pull(mpg) |> mean()

© ab604, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/r-style-guide of ab604/claude-code-r-skills.

Open the folder on GitHubat commit 529de4f

Used in 2 other repositories

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in ab604/claude-code-r-skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

R Style Guide next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

R Style Guide compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
R Style Guide this skillab604/claude-code-r-skills2062 repos~1.7kAutomated safety check: PassMIT
Socialcoreyhaines31/marketingskills54k4 repos~4.5kAutomated safety check: PassMIT
HumanizerAzure-Samples/interview-coach-agent-framework17237 repos~5.8kAutomated safety check: PassMIT
Avoid AI Writingconorbronsdon/avoid-ai-writing4.9k3 repos~8.1kAutomated safety check: PassMIT
JavaScript Concept Fact Checkerleonardomso/33-js-concepts67k1 repos~5kAutomated safety check: PassMIT
User-Facing Text Cleanupguillaumemeyer/watermarks-remover24k—~3.5kAutomated safety check: PassMIT

Similar skills

  • Social

    coreyhaines31/marketingskills

    When the user wants help creating, scheduling, or optimizing social media content for LinkedIn, Twitter/X, Instagram, TikTok, or Facebook, or wants to do social listening and engagement triage.

    54k GitHub starsUsed in 4 repos~4.5k tokens
    Writing & ContentAuto-check passed
  • Humanizer

    Azure-Samples/interview-coach-agent-framework

    Official

    Remove signs of AI-generated writing from text. An agent skill from Azure-Samples/interview-coach-agent-framework.

    172 GitHub starsUsed in 37 repos~5.8k tokens
    Writing & ContentAuto-check passed
  • Avoid AI Writing

    conorbronsdon/avoid-ai-writing

    Audit and rewrite content to remove AI writing patterns ("AI-isms").

    4.9k GitHub starsUsed in 3 repos~8.1k tokens
    Writing & ContentAuto-check passed
  • JavaScript Concept Fact Checker

    leonardomso/33-js-concepts

    Verifies the technical accuracy of JavaScript concept pages by checking code examples, MDN and ECMAScript claims and external links through a five-phase method.

    67k GitHub starsUsed in 1 repo~5k tokens
    Writing & ContentAuto-check passed
  • User-Facing Text Cleanup

    guillaumemeyer/watermarks-remover

    Audits prose for invisible Unicode characters and rewrites it while keeping facts, citations, code and required disclosures unchanged and the writer's voice intact.

    24k GitHub stars~3.5k tokensUpdated today
    Writing & ContentAuto-check passed
  • Install Anti Slop

    trycompai/crm

    Install and configure the anti-slop Oxlint plugin in a local TypeScript or JavaScript repository.

    11k GitHub starsUsed in 1 repo~881 tokens
    Writing & ContentAuto-check passed

More from ab604/claude-code-r-skills

All 8 skills in this repo
  • R Bayes

    ab604/claude-code-r-skills

    Patterns for Bayesian inference in R using brms, including multilevel models, DAG validation, and marginal effects.

    206 GitHub starsUsed in 2 repos~2.5k tokens
    Auto-check passed
  • R Oop

    ab604/claude-code-r-skills

    R object-oriented programming guide for S7, S3, S4, and vctrs.

    206 GitHub starsUsed in 2 repos~1.9k tokens
    Auto-check passed
  • R Package Development

    ab604/claude-code-r-skills

    R package development guide covering dependencies, API design, testing, and documentation.

    206 GitHub starsUsed in 2 repos~2.4k tokens
    Auto-check passed
  • R Performance

    ab604/claude-code-r-skills

    R performance best practices including profiling, benchmarking, vctrs, and optimization strategies.

    206 GitHub starsUsed in 2 repos~2.4k tokens
    Auto-check passed
  • Rlang Patterns

    ab604/claude-code-r-skills

    rlang metaprogramming patterns for data-masking, injection operators, and dynamic dots.

    206 GitHub starsUsed in 2 repos~2.1k tokens
    Auto-check: notes
  • TDD Workflow

    ab604/claude-code-r-skills

    Test-driven development workflow for R using testthat. An agent skill from ab604/claude-code-r-skills.

    206 GitHub starsUsed in 2 repos~4.8k tokens
    Auto-check passed

Questions about R Style Guide

What does R Style Guide do?

R style guide covering naming conventions, spacing, layout, and function design best practices. R Style Guide is an agent skill from ab604/claude-code-r-skills. R style guide covering naming conventions, spacing, layout, and function design best practices.

When should I use R Style Guide?

R Style Guide fits situations like: writing & Content work in your project.

How do I install R Style Guide in Claude Code?

Run `npx skills add ab604/claude-code-r-skills --skill r-style-guide -a claude-code`. Or copy the skill folder (.claude/skills/r-style-guide in ab604/claude-code-r-skills) into .claude/skills/r-style-guide in your project. Claude Code loads it when a task matches its description.

How do I install R Style Guide in Codex?

Run `npx skills add ab604/claude-code-r-skills --skill r-style-guide -a codex`. Or copy the skill folder (.claude/skills/r-style-guide in ab604/claude-code-r-skills) into .agents/skills/r-style-guide in your project. Codex loads it when a task matches its description.

Can I use R Style Guide in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ab604/claude-code-r-skills --skill r-style-guide -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/r-style-guide, .gemini/skills/r-style-guide, .github/skills/r-style-guide and .opencode/skills/r-style-guide in your project.

What does R Style Guide need to run?

SKILL.md names no scripts, command-line tools or credentials: R Style Guide is instructions for the agent only.

Does R Style Guide access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is R Style Guide safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does R Style Guide use?

R Style Guide is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does R Style Guide use?

About 1.7k tokens (SKILL.md is roughly 6.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to R Style Guide?

Skills that share tags, products or a category with R Style Guide: Social (coreyhaines31/marketingskills, 54k stars), Humanizer (Azure-Samples/interview-coach-agent-framework, 172 stars), Avoid AI Writing (conorbronsdon/avoid-ai-writing, 4.9k stars) and JavaScript Concept Fact Checker (leonardomso/33-js-concepts, 67k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains R Style Guide?

ab604 (a GitHub user) maintains it in ab604/claude-code-r-skills, which has 206 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on September 17, 2026.

Source: ab604/claude-code-r-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.