Skip to content

targetfy v1

Choose a tag to compare

@Athospd Athospd released this 22 Nov 04:08
· 13 commits to main since this release

The first release of targetfy, a Claude Code skill that turns existing R scripts into an equivalent {targets} pipeline, checks that it really is equivalent, then offers optional Enhancements.

Install

git clone https://github.com/Athospd/targetfy.git ~/.claude/skills/targetfy

Then, in Claude Code: /targetfy my_script.R, or ask it to convert your R script(s) to targets.

Requires R >= 4.1 with targets (>= 1.12), tarchetypes, callr and jsonlite. targetfy never installs packages.

What's in v1

Conversion

  • One or more .R scripts, in the order you list them, become _targets.R plus one functions file per script (R/<script>_functions.R). Each meaningful object becomes a Target.
  • library() calls go into tar_option_set(packages = ...). Input files are tracked, output files become file Targets, and saveRDS → readRDS handoffs between scripts become direct dependencies.
  • Bare plots become plot Targets. Console-only lines (View, help, print, setwd, install.packages…) are dropped and listed in the report.
  • It never modifies an existing file. When _targets.R already exists, it writes targets_<name>.R with its own store.
  • A script sitting loose in Downloads or Desktop gets its own Working Folder, holding a copy of it and only the files it reads.

Verification (scripts/check.R)

  • You choose between Run and compare (the Equivalence Check) and Only validate the files (the Static Check). The Equivalence Check runs your scripts and the Pipeline in throwaway copies and compares every mapped Target with all.equal(), and every written file by content.
  • Stochastic Targets (random numbers, model seeds) are detected and compared by structure.
  • Up to 3 fix-and-recheck rounds.
  • It keeps going. Scripts that fail on their own fall back to the Static Check, with the failing line reported. A missing package is reported as not_checked, never as a bug in the Conversion.

Choosing R (scripts/find-r.R)

  • Finds every R installation, loads targetfy's and your scripts' packages in each (including set_engine("<pkg>") engines), and picks the one where everything loads. This catches version conflicts like an outdated yardstick in the Rscript on your PATH.

Report and graph

  • targetfy-report.md records every Target's check result, every dropped or changed line, and what couldn't be verified and why.
  • tar_glimpse() opens the Pipeline's graph in your browser.

Enhancement wizard

  • After a passing check, it offers storage formats, dynamic branching and {crew} parallel workers, one at a time. Each one is re-checked and undone if it breaks Equivalence.

Not yet supported

.Rmd, .qmd and .ipynb notebooks, a Targets granularity setting, and stricter comparison with {waldo}. See docs/design-v1.md.

House style: a pinned copy of targets-r-skill by Ulrich Atz (CC-BY-4.0).