CLI overview

sunscreen [GLOBAL_FLAGS] <COMMAND> [ARGS] [FLAGS]

Top-level commands

CommandWhat it does
chain newCreate a new workspace (Anchor or Pinocchio)
chain buildRun anchor build + Codama regeneration
chain serveSupervised dev loop with local validator
chain doctorDiagnose toolchain + workspace markers
scaffoldAdd instruction, account, event, error, program, or recipe
generateGenerate IDL, Codama clients, frontend hooks
appManage plugins (install, list, run, hook, marketplace)
doctorDetect installed toolchain versions
initInteractive wizard for new users
examplesBrowse embedded example projects
quickstartComposite recipe shortcuts (token, nft, dao, blog)
walletWallet helpers (new, airdrop)
deployDeploy programs to a network
learnOpen a topic in the embedded learn index

Global flags

FlagWhat it does
--jsonmachine-readable output on stdout; human messages on stderr
-v / -vv / -vvvverbosity (warn / info / debug)
--workdir <DIR>override working directory
--config <FILE>path to an alternative sunscreen.yml
--helpper-command help
--versionprint sunscreen version

Exit codes

CodeMeaning
0success
1unexpected error (bug) — please report
2toolchain missing (anchor, solana, cargo, pnpm, …)
3invalid config (sunscreen.yml schema violation)
4user input conflict (resource exists, ambiguous flag, …)
5missing workspace (no sunscreen.yml upward from cwd)
9plugin runtime failure

Full list with next_step strings in Errors & exit codes.

Environment variables

Sunscreen prefers explicit flags over magic environment variables. Pass --config <FILE> and --workdir <DIR> as needed. Standard Rust env vars (RUST_LOG, RUST_BACKTRACE) apply to the binary as usual.

--json contract

When you pass --json, sunscreen guarantees:

  • One JSON object per command on stdout, or NDJSON (one object per line) for streaming commands (chain build --headless, chain serve --headless).
  • Human-readable status messages, errors, hints, and progress go to stderr — never mixed into stdout.
  • Top-level shape: { "status": "ok"|"error", "code": "<machine-readable>", "data": {…}, "next_step": "<optional hint>" }.
  • Error objects include error.code, error.message, and error.next_step.

Machine integrations should always pass --json and parse stdout only.