claude-code-r-skills: Skill for Claude Code

.claude/skills/tdd-workflow/SKILL.md

tdd-workflow is a skill for Claude Code from ab604/claude-code-r-skills. It costs 41 tokens per session (5,198 once invoked), scanned A, original, MIT.

A test-driven development workflow for R using testthat, with required tests before code and stated coverage targets. Coverage measures how much of the code or behavior tests exercise.

In plain words
What is it for?
Use it when developing R functions, packages, models, data-processing pipelines, or Shiny components.
Why use it?
It creates a consistent way to test normal inputs, edge cases, errors, and statistical or validation logic.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is ab604/claude-code-r-skills's own configuration. It tells Claude Code how to work on claude-code-r-skills itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-code-r-skills configures →

Part of the r-skills plugin — 8 skills, 4 commands, 3 agents, 4 hooks shipped together

Reuse

Borrowing it

Nothing to install: this file belongs to ab604/claude-code-r-skills. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/ab604/claude-code-r-skills/main/.claude/skills/tdd-workflow/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/ab604/claude-code-r-skills

Made for: Claude Code.

Or install r-skills, the plugin that ships this one along with the rest of its 8 skills, 4 commands, 3 agents, 4 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tdd-workflow

README.md
[![agentmods](https://agentmods.dev/badge/skills/ab604/claude-code-r-skills/tdd-workflow.svg)](https://agentmods.dev/skills/ab604/claude-code-r-skills/tdd-workflow)
Your own site
<a href="https://agentmods.dev/skills/ab604/claude-code-r-skills/tdd-workflow"><img src="https://agentmods.dev/badge/skills/ab604/claude-code-r-skills/tdd-workflow.svg" alt="Measured on agentmods" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,198 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00041 $0.05198
Opus 5 $0.00020 $0.02599
Sonnet 5 $0.00008 $0.01040
Haiku 4.5 $0.00004 $0.00520

Measured 7d ago against content hash 9ce252cbedf6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

tdd-workflow scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/tdd-workflow/SKILL.md · 841 lines

How it starts

The opening of the file, as written. The whole thing — 841 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test-Driven Development Workflow for R

This skill ensures all R code development follows TDD principles with comprehensive test coverage using testthat.

When to Activate

  • Writing new functions or features
  • Fixing bugs or issues
  • Refactoring existing code
  • Adding new model types
  • Creating data processing pipelines
  • Building Shiny components

Getting Started

Initialize testing infrastructure for your package:

# Set up testthat (Edition 3)
usethis::use_testthat(3)

# Create a test file for an existing source file
usethis::use_test("function_name")

# Or create test and source file together
usethis::use_r("function_name")
usethis::use_test("function_name")

Core Principles

1. Tests BEFORE Code

ALWAYS write tests first, then implement code to make tests pass.

2. Coverage Requirements

  • Minimum 80% coverage (unit + integration)
  • 100% coverage for statistical calculations
  • 100% coverage for data validation
  • All edge cases covered
  • Error scenarios tested

3. Test Types

Tests follow a three-level hierarchy: File → Test → Expectation

Unit Tests

Individual functions and utilities:

test_that("rescale01 normalizes to [0, 1] range", {
  expect_equal(rescale01(c(0, 5, 10)), c(0, 0.5, 1))
  expect_equal(rescale01(c(-10, 0, 10)), c(0, 0.5, 1))
})

test_that("rescale01 handles edge cases", {
  expect_equal(rescale01(c(5, 5, 5)), c(NaN, NaN, NaN))
  expect_equal(rescale01(numeric(0)), numeric(0))
  expect_equal(rescale01(c(0, NA, 10)), c(0, NA, 1))
})
Integration Tests

Function interactions and workflows:

test_that("data pipeline produces expected output", {
  raw_data <- read_fixture("sample_input.csv")

  result <- raw_data |>
    clean_data() |>
    transform_features() |>
    summarize_results()

  expect_s3_class(result, "tbl_df")
  expect_named(result, c("group", "mean", "sd", "n"))
  expect_true(all(result$n > 0))
})
Snapshot Tests

For complex outputs that are hard to specify:

test_that("model summary format is stable", {
  model <- fit_model(test_data)
  expect_snapshot(print(summary(model)))
})

test_that("error messages are informative", {
  expect_snapshot(
    validate_input(invalid_data),
    error = TRUE
  )
})

Read the full file on GitHub · 841 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 841 lines · 41 tokens per session scan A 9ce252cbedf6

Subscribe to this mod's changes

tdd-workflow is a skill published in the GitHub repository ab604/claude-code-r-skills (198 stars, last pushed 5mo ago), licensed MIT. It adds 41 tokens to every session and 5,198 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.