scaffold

Add code to an existing workspace. Primitives + recipes.

sunscreen scaffold <NOUN> <NAME> [FLAGS]

All scaffold operations are idempotent (re-running with the same args is a no-op) and marker-aware (writes happen inside marker regions; hand-edits outside markers survive). See Marker protocol.

Common flags

FlagDefaultDescription
--program <name>required for mostwhich program to scaffold into
--dry-runoffprint planned diffs without writing
--jsonoffmachine-readable summary
--forceoffoverwrite marker content even if a symbol exists

Primitives

instruction <Name>

Add an instruction handler.

sunscreen scaffold instruction CreatePost --program blog

Creates programs/blog/src/instructions/create_post.rs, registers it in lib.rs dispatch, and updates instructions/mod.rs.

account <Name>

Add an account struct.

sunscreen scaffold account Post --program blog \
  --fields "title:string,body:string,author:pubkey"

--fields syntax: name:type[,name:type…]. See CRUD recipe for accepted types.

event <Name>

Add an event.

sunscreen scaffold event PostCreated --program blog \
  --fields "post:pubkey,author:pubkey,timestamp:i64"

error <Name>

Add an error variant.

sunscreen scaffold error PostNotFound --program blog \
  --message "Post not found"

program <Name>

Add a new program to an existing workspace.

sunscreen scaffold program governance

Creates programs/governance/, updates Cargo.toml workspace members, Anchor.toml [programs.localnet], and sunscreen.yml.

Recipes

Composite scaffolds that combine primitives:

NounWhat it scaffolds
crud <Name>account + 4 instructions + 3 events + 2 errors + TS test
spl-token <Name>SPL Token mint/transfer slice
metaplex-nft <Name>Metaplex NFT mint with metadata + master edition

Each recipe runs a dry-run preflight: if any of its constituent primitives would conflict, it bails before writing.

Plugin-provided nouns

When a plugin declares scaffold <noun> commands, sunscreen routes sunscreen scaffold <noun> through that plugin. List available plugin scaffolds:

sunscreen app commands --filter scaffold

Exit codes

CodeWhen
0success
2toolchain missing (rare; only for recipes that compile-check)
3invalid config
4symbol already exists, ambiguous flag, or recipe preflight failure
5not in a workspace
9plugin runtime failure (plugin-routed nouns)