Repository navigation
targetfy v1
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/targetfyThen, 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
.Rscripts, in the order you list them, become_targets.Rplus one functions file per script (R/<script>_functions.R). Each meaningful object becomes a Target. library()calls go intotar_option_set(packages = ...). Input files are tracked, output files become file Targets, andsaveRDS→readRDShandoffs 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.Ralready exists, it writestargets_<name>.Rwith 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 outdatedyardstickin theRscripton your PATH.
Report and graph
targetfy-report.mdrecords 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).