dslc-io/tidytuesdayr/tdd-workflow
Claude Code and agent skill by dslc-io/tidytuesdayr
- community
Checking that the SKILL.md file is still in the repository.
Test-driven development workflow. Use when writing any R code (writing new features, fixing bugs, refactoring, or reviewing tests).
Install
npx vskill@latest install dslc-io/tidytuesdayr/tdd-workflowSKILL.md
TDD workflow
Core principle
Write a failing test first, then implement the minimal code to make it pass, then refactor. Never write implementation code without a failing test driving it.
File naming
Tests for R/{name}.R go in tests/testthat/test-{name}.R. Place new tests next to similar existing ones.
Running tests
Testing functions load code automatically. You do not need to call library() or devtools::load_all() separately.
Coverage
Goal: 100% for every edited file. After editing R/file_name.R, verify:
Files excluded from the coverage requirement:
R/*-package.RR/aaa-shared_params.R- Files matching
R/import-standalone-*.R
Test types
Unit tests
Test individual functions in isolation:
Integration tests
Test end-to-end pipelines through multiple functions:
Snapshot tests
For complex outputs that are hard to specify with equality assertions:
When snapshots change intentionally, check the content of the file corresponding to the edited test file, then accept:
Snapshots are stored in tests/testthat/_snaps/. The filename corresponds to the R file being tested, ending with .md.
Test design principles
- Self-sufficient: each test contains its own setup, execution, and assertion. Tests must be runnable in isolation.
- Duplication over factoring: repeat setup code rather than extracting it. Clarity beats DRY in tests.
- One concept per test: a failing test should tell you exactly what broke.
- Minimal with few comments: keep tests lean. Avoid over-commenting.
- Issue reference in description: the
descof every newtest_that()call should end with one or more parenthetical issue references for the issue(s) verified by those tests — typically the issue currently being solved. Never guess or invent issue numbers. Determine the number from the user's prompt, the branch name (git branch --show-current), orgh issue list. Before writing a number, verify you can trace it to one of these sources. If no tracked issue applies, use#noissue. The numbers in the examples below are illustrative placeholders — do not copy them:
``r test_that("fetch_records() returns correct columns (#1)", { ... }) test_that("build_summary() returns correct columns (#2, #3)", { ... }) test_that(".check_record() errors on empty input (#noissue)", { ... }) ``
testthat Edition 3 — deprecated patterns
Essential expectations
Equality & identity
Conditions
Errors thrown by this package (via .pkg_abort()) should always be tested with stbl::expect_pkg_error_snapshot(), which captures both the error class hierarchy and the user-facing message in one snapshot:
Pass transform = stbl::.transform_path(path) to scrub volatile values (e.g. temp paths) from the snapshot before comparison.
Errors thrown by `stbl` (via stbl::to_*() / stbl::stabilize_*()) should be tested with stbl::expect_pkg_error_classes(). Since the message text is controlled by stbl, only the class hierarchy needs to be asserted:
For composite stbl error classes (where the class name contains dashes, e.g. stbl-error-coerce-character), pass each dash-separated component as a separate argument. Underscores within a component are kept as-is:
Errors from other packages can be tested with expect_error(), optionally wrapped in expect_snapshot() to lock down the message text:
Collections
Type & structure
Logical
These expectations are a last resort when more-specific checks aren't available.
withr patterns for temporary state
Fixtures
Store static test data in tests/testthat/fixtures/ and access via:
Mocking
Mock functions that might have unstable output, hit external servers, etc.
Common mistakes
- Do not modify tests to make them pass. Fix the implementation.
- Do not write tests that depend on other tests' state. Each test must be independently runnable.
- Ask for help if test is bad. If you think a test might be invalid, do not loop through trying to make impossible tests pass. Ask for help if possible.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/tdd-workflow/SKILL.md
Popularity
- Repository stars
- 80
- Repository forks
- 19
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dslc-io/tidytuesdayr/tdd-workflow)