tdd-workflow

Enforce a test-driven development workflow for R code using testthat.

1|Updated May 13, 2026
One-click install
npx skills add https://github.com/impact-initiatives/ana_app --skill tdd-workflow-impact-initiatives
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-workflow
Source: https://github.com/impact-initiatives/ana_app/tree/main/.claude/.claude/skills/tdd-workflow
Command: npx skills add https://github.com/impact-initiatives/ana_app --skill tdd-workflow-impact-initiatives

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents regressions and fragile refactors in R code by enforcing a test-first (TDD) workflow with consistently high test coverage using testthat.

Core Features & Use Cases

  • Test-first development: write failing testthat tests before implementing the corresponding R code.
  • Coverage guardrails: target 80%+ coverage overall, including strict expectations for statistical calculations and data validation logic.
  • Multiple test types: unit, integration, and snapshot tests to keep behavior correct and stable as the codebase evolves.
  • Package-native organization: organize tests into tests/testthat with fixtures, helpers, and setup files to support reproducible checks.
  • Common R development scenarios: apply when adding new functions, fixing bugs, refactoring, extending models, building data pipelines, or developing Shiny components.

Quick Start

Tell your AI to set up testthat for your R package, then generate a failing unit test for the function you plan to write and help you implement the minimum code to make it pass while tracking coverage toward 80%+.

Frequently Asked Questions about tdd-workflow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I start test-driven development in R to prevent regressions?

Test-driven development in R uses testthat to write failing tests before implementing code. You set up testthat in your package, generate a failing unit test, and implement the minimum code required to pass it.

What is the recommended code coverage target when writing R unit tests?

The recommended code coverage target for R unit tests is 80% or higher overall. You must enforce strict coverage expectations specifically for statistical calculations and data validation logic to ensure reliable refactoring.

How do I organize testthat tests for an R package to support reproducible checks?

You organize testthat tests under the tests/testthat directory using fixtures, helpers, and setup files. This package-native test organization supports reproducible checks for unit, integration, and snapshot tests.

Can I use snapshot testing to keep R code behavior stable during refactoring?

Snapshot testing validates R code behavior by capturing expected outputs and comparing them against future runs. You can use snapshot tests alongside unit and integration tests to keep behavior correct and stable as your codebase evolves.

When should I apply a test-first workflow for R data processing pipelines?

You should apply a test-first workflow when building data processing pipelines, adding new functions, fixing bugs, refactoring packages, extending models, or developing Shiny components to reduce regressions and ensure output validation.

Does test-driven development work for fixing bugs in existing R packages?

Test-driven development works for fixing bugs in R packages by requiring you to write a failing testthat test that reproduces the bug first. You then implement the fix to make the test pass while tracking coverage toward 80%.