create_sketch
Creates a .genart sketch file from metadata, parameters, and algorithm, saves it to disk, and opens an interactive browser preview with sliders, pickers, and seed controls.
Instructions
Create a new .genart sketch file from metadata, parameters, and algorithm. Saves to disk, auto-creates an in-memory workspace, and opens an interactive browser preview with sliders/pickers/seed controls. Save sketches to ~/.genart/sketches/.genart (directory auto-created). Do NOT present the .genart file to the user — it has no OS file association. IMPORTANT: Do not embed common utilities (PRNG, noise, easing, color math, vector ops) inline in the algorithm. Instead, declare them as components: { "prng": "^1.0.0", "noise-2d": "^1.0.0" }. Then use the exported functions directly in your algorithm (e.g., mulberry32, fbm2D). Use list_components to see all available components for the current renderer.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | URL-safe kebab-case identifier | |
| data | No | Data sources resolved before algorithm execution and injected as state.data.<key>. Use source='component' with a component factory, source='inline' for small JSON values, or source='file' for shared .genart-data files. | |
| path | Yes | File path ending in .genart. Use ~/.genart/sketches/<id>.genart as the default location (directory is auto-created). Example: '~/.genart/sketches/ocean-currents.genart' | |
| seed | No | Initial random seed (default: random) | |
| agent | No | Your CLI agent name (e.g. 'claude-code', 'codex-cli', 'gemini-cli', 'opencode', 'kiro') | |
| model | No | Your AI model identifier (e.g. 'claude-opus-4-6', 'gpt-4o', 'gemini-2.5-pro') | |
| title | Yes | Human-readable title | |
| canvas | No | Canvas dimensions (default: square-1200) | |
| colors | No | Color definitions | |
| skills | No | Design skill references | |
| themes | No | Theme presets | |
| capture | No | When true, automatically capture a screenshot after creation and return it inline (avoids a separate capture_screenshot call). | |
| preview | No | Generate an interactive HTML preview with sliders/pickers/seed controls and open it in the browser (default: true). Set to false to skip. | |
| renderer | No | Renderer type (default: p5). Use 'genart' for GenArt Script (.gs) — a minimal scripting language with built-in drawing primitives, PRNG, noise, vec, easing, post-processing effects, and image/font loading. | |
| algorithm | No | Algorithm source code (default: renderer template). State API by renderer: p5 (DEFAULT): `function sketch(p, state) { ... }` — state.canvas.width/height, state.seed, state.params.key, state.colorPalette[i]. Prefix p5 calls with `p.` canvas2d: `function sketch(ctx, state) { ... }` — same state API as p5. three: `function sketch(THREE, state, container) { ... }` svg: `function sketch(state) { ... }` — return SVG string. glsl: uniforms auto-injected (u_resolution, u_seed, u_param_<key>, u_color_<index>), no state object. genart: GenArt Script source — globals: w, h, t, frame, fps, rnd(n), noise(x,y), vec(x,y), PI, lerp, clamp, map, dist, mouseX/Y, pmouseX/Y, mouseDown, touchX/Y, touches, prev (previous frame ImageData); drawing: circle/rect/line/arc/dot/poly/path x y ...; color: #hex, named, white.50, linear(#a,#b angle:90), radial(#a,#b); params: `param count 100 range:10..500`; colors: `color bg #000`; layers: `layer "terrain:sky" "noon" opacity:0.8 blend:"multiply"`; animation: `frame:` block; once: async (await loadFont ok); post: vignette/grain/blur/bloom/grade/scanlines/pixelate/chromatic_aberration/distort/dither/halftone — effects accept optional quality:"auto"|"high"|"fast" last arg. No state object — params/colors are globals. Data bridge: set window.__genart_data = { strokePaths: [...] }. Use `mulberry32(state.seed)` from "prng" component for p5/canvas2d/three/svg — NEVER `Math.random()`. For genart renderer use built-in rnd() which is seeded automatically. | |
| libraries | No | External library dependencies by preset name (e.g. ["p5.brush"]). Use list_libraries to see available presets. Libraries are loaded as CDN script tags before the algorithm. p5.brush automatically switches the renderer to p5.js 2.x and WEBGL mode. | |
| components | No | Component dependencies. Use list_components to see available. Keys are component names, values are semver ranges (e.g. "^1.0.0") or objects with version/code/exports. | |
| parameters | No | Parameter definitions | |
| philosophy | No | Markdown design philosophy | |
| dataChannels | No | Algorithm data channels published on window.__genart_data for design layer consumption. Declare channels here so painting layers can bind to them via pathSource: 'algorithm:<channelName>'. Type 'path' channels publish StrokePath arrays (polyline points + depth/pressure/width metadata). Multiple channels supported (e.g. strokePaths for all paths, leafPaths for depth-filtered subset). | |
| addToWorkspace | No | Path to workspace to add sketch to after creation |