Authoring in Code (SDKs + CLI)
Studio is the fastest way to build a study visually, but some research workflows are better served by code: when you want a study under version control, generated programmatically from a stimulus set, reproducible from a script, or reviewed in a pull request. PsyCloud offers two first-class authoring SDKs plus a CLI for exactly that workflow.
A fluent, chainable builder for Python.
A pipe-friendly (|>) builder for R.
Validate, inspect, compile, import, and export bundles.
One model, one bundle
The SDKs express the same model and compile to the same bundle format the CLI validates,
inspects, and publishes — the same artifacts Studio produces (designProgram.json,
screenProgram.json, bindings.json, and friends). That means:
- A study authored in code runs on the same runtime as one built in Studio.
- You can import a code-authored bundle into Studio to keep editing visually, and export Studio or imported studies back to Python/R/TypeScript code. See Interoperability.
The authoring shape is identical across SDKs — you describe an experiment, add phases that generate trials from factors, define a screen for each trial, and bundle it. The CLI then verifies and compiles that bundle:
library(psycloudr)
bundle <- experiment(id = "hello.stroop", name = "Hello Stroop") |>
phase("main") |>
factors(word = c("red", "blue"), ink = c("red", "blue")) |>
cross() |>
shuffle() |>
screen("trial") |>
ask(text(trial$word, fill = trial$ink), keypress(keys = c("r", "b"))) |>
record(word, ink) |>
bundle(with_auto_ids = TRUE)Install
# install.packages("remotes")
remotes::install_github("bbuchsbaum/psycloud", subdir = "packages/psycloudr")Pick the language you already analyze your data in, then use the CLI for the repeatable checks around it. The two SDKs are intentionally feature-matched, and many example studies ship in both — so your choice is about ergonomics, not capability.
Verified examples
The canonical example catalog treats each converted CoffeeScript study as a regression target for the SDKs and runtime. Use these checks before editing the authoring surface:
npm run examples:coffee:inventory
npm run test:coffee-conversionsEvery converted example should have matching CoffeeScript, Python, R, and checked bundle artifacts.