Builds hand-drawn Skia canvases with pure worklet draw(), scene clock, timelines, and pixel goldens. Use when drawing charts, grids, boards, or debugging canvas animation freezes.
Ships in react-native. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Every hand-drawn surface of the app (a progress grid, a chart, an editor, a game board) is one Skia
<Canvas> whose single <Picture> is recorded on the UI thread from the surface's pure draw(),
animated by a timeline that a self-stopping scene clock plays, and proven by unit tests, a draw-call
budget and pixel goldens. This skill ships the canvas kit (src/canvas/), a template surface and two
checkers that prove the result.
<Canvas> per surface with one <Picture> recorded in useDerivedValue from the surface's
draw(), and every computed picture lives in the kit or a surface folder. Why: dynamic pictures
are Skia's immediate-mode case; one picture per frame keeps cost predictable; a computed canvas
elsewhere (a Picture sparkline in components/, animated Skia nodes in a child component) escapes
every rule below. Retained nodes only for static art: a declarative gradient, blur or fixed shape
may live anywhere (sizing it through onSize is layout, not motion), and art recorded once
(createPicture) is listed in the contract's staticCanvases. An atlas only for hundreds of sprites.draw(canvas, frame) is a pure worklet in a 'worklet' file: it reads only frame (view,
fx, highlight, colors, layout, kit), imports Skia types only, allocates no Skia objects,
reads no clock or random source, and imports values only from other 'worklet' modules. Why: the
same function then renders on device, in Jest goldens and in Node with identical pixels, and a plain
function called on the UI thread crashes at runtime only.SurfaceCanvas is opaque by default, so draw()
starts with canvas.drawColor(colors.color.background); a canvas that must show what lies behind it
is declared "opaque": false in the contract and every SurfaceHost/SurfaceCanvas rendering it
passes a literal isOpaque={false}. Why: on Android an opaque canvas is a SurfaceView, neither
clipped by a rounded parent nor blended with what lies behind it, so unpainted pixels show black on
device while iOS and the goldens look right; the declaration alone changes nothing on screen.scene shared value per committed change (makeScene(seq, view, tracks), startAt: NOT_STARTED); the frame runner stamps startAt = info.timestamp on its first frame. Never use
timeSinceFirstFrame. Why: Reanimated resets it to 0 on every re-activation, which froze every
animation after the first (verified on Reanimated 4.5.1).runSceneFrame, which holds the try/catch; never Skia's useClock() or withRepeat(…, -1). Why:
an idle surface must cost nothing (both of those run every frame forever), an uncaught UI-thread
error kills the app, and React Compiler bails out of hooks with value blocks inside try/catch.presentChange cancels old cues, pushes the final view and schedules new cues; the change present
at mount is shown without animation. Why: killing the app mid-animation must lose nothing, the view
is always the final state, and a screen opened again must not replay its last celebration.buildTimeline(events, motion) is pure and honours 'reduced': half durations, no particles or
shake, no overshoot. Why: reduce motion is an accessibility requirement, and as data it is testable.isPlaying: ageMs > 0 && progress < 1). Why: a sample holds a track's
from before it starts, so an unguarded effect shows at full strength at moment 0.highlight (CanvasHighlight,
EMPTY_HIGHLIGHT), and a drag preview sits exactly on the hovered cell. The gesture layer applies
the surface's dragLiftPt once; draw adds no offset. Why: stores, undo and persistence never see a
selection, and the previewed cell must be the cell that receives the drop.isMirroredInRtl) mirrors positions in the layout.
Why: scaleX(-1) mirrors letters and digits.toView() and drawn with drawText (drawFittedText in a small
shape); words and complex scripts use a cached Skia Paragraph; widths come from glyph widths;
fonts come from the bundled TTF through one useFonts provider on both platforms. Why:
drawText does no shaping, measureText is unimplemented in CanvasKit (Jest, Node), and Skia's
Android font manager cannot see fonts embedded with the expo-font plugin.Skia.PathBuilder at unit size and placed with
canvas.translate/scale. Why: the mutable SkPath API is deprecated in Skia 2.6 and allocates.light, dark, plus the opt-in sets
contracts/canvas-surfaces.json lists), beside a canvas-contrast.json saying which colour sits on
which; every declared pair meets WCAG 2.2 AA in every set (text 4.5:1, graphics and shapes 3:1,
distinct kinds apart under colour-blind simulation); meaning is never carried by colour alone.
Why: a missing token is a crash on one theme only, and contrast is provable only when the pairs are
declared and measured; accessibility-as-code's contrast check measures the same file, so its format
is stable and the pairs are never declared a second time in contracts/contrast.json.scene-clock-state. useCanvasLifecycle (app active, screen focused and not covered) stops
the clock, cancels cues and suspends audio; a scene pushed while the surface may not run is held
until it may; every resume records at least one frame; a done message names its run, and JS never
reads the scene shared value back. Why: an overlay or an unfocused screen that stays mounted must
not keep a display link running, no cue or sound may fire once the app leaves the foreground, and a
stale done read through scene.get() froze the picture after an interruption (the case study in
timeline-and-clock.md).CADisableMinimumFrameDurationOnPhone true. Expo's prebuild template sets it, so a
Continuous Native Generation app needs no key; never override it with false in the config or a
plugin, and committed native folders keep it in ios/<App>/Info.plist. Why: without it iOS caps
the app at 60 fps on ProMotion iPhones. Android needs no key.accessible, accessibilityRole="image" (or role="img")
and accessibilityLabel (or aria-label) = t() of surface.describe(view); a purely decorative
canvas opts out explicitly (accessible={false}). Why: Skia content is invisible to VoiceOver and
TalkBack, labels must be translated, and React Native 0.86 defaults accessible to false: iOS
ignores the label and role of a view that is not accessible.useCommittedChange(data, diffEvents) with a pure, tested
diffEvents(previous, next) in the surface folder: the first data and identical refetches animate
nothing; an optimistic update and its rollback are two changes. Why: a query has no reducer to
return events, and a chart that replays on every refetch is noise.realtime-game-loop, palettes and drawing rules
from here). A surface that takes touch also needs canvas-gestures-and-hit-testing in the same
session. A game board: also read references/game-boards.md.templates/contracts/canvas-surfaces.json to contracts/ and fill in the
first surface, then from the repo root run node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-files.mjs .:
it lists every file to copy. Copy each kit-file-missing
file verbatim from templates/ to the path its first line names (templates/src/canvas/** →
src/canvas/, templates/scripts/quality/**, templates/test/goldens/skia-golden.ts), and
templates/src/hooks/use-is-app-active.ts (+ test) → src/hooks/ when the app does not have it
yet. A kit-import-unresolved line names the prerequisite and the skill that creates it (the
table in architecture.md). The iOS 120 Hz key comes from Expo's template (plist-120hz fails only an
override or a committed Info.plist without it); the canonical jest.config.js has the golden
project (jest-golden-project).buildTimeline, the clock and the lifecycle, references/drawing.md for
draw(), the kit, palettes, layout and text, references/api-traps.md for
the worklet rules and API traps. Imitate the template surface and
examples/weekly-chart/.templates/src/features/__FEATURE__/canvas/ to
src/features/<feature>/canvas/, the golden test and its nine baselines from templates/test/goldens/canvas/,
and the contract's schema (templates/contracts/canvas-surfaces.schema.json). Replace __FEATURE__
(tasks), __SURFACE__ (kebab, progress-grid), __SURFACE_PASCAL__ and __SURFACE_CAMEL__ in
file names and contents. The copy compiles and passes as is; then adapt the model, the view, the
events, the layers, the palettes and the contrast pairs.canvas-contrast.json → canvas-model.ts →
to-view.ts → build-timeline.ts with its test (budget, reduced motion, cues) → layout-<id>.ts
with its any-size test → draw-<id>.ts with the budget, moment-0, highlight and label tests →
<id>-surface.ts (isMirroredInRtl, the describe key in every locale catalog, dragLiftPt and
targetsOf when the surface drags or suggests). Run npx jest src/features/<feature>/canvas --ci --selectProjects unit after each step (paths first: --selectProjects would swallow them).CommittedChange (server data:
useCommittedChange(data, diffEvents), the timeline reference's server section), the ViewFormat,
the live motion, useIsFocused(), isInterrupted, the colours, the kit (built once the
useFonts provider exists, drawing.md) and the highlight to SurfaceHost (display-only), or calls
useSurfacePlayer and renders SurfaceCanvas with the gesture layer's input (interactive). The
label is t(surface.describe(view)). A canvas that shows what lies behind it passes
isOpaque={false} (written out on the element, not through a spread) and declares
"opaque": false in the contract.npx eslint --fix src/canvas src/features/<feature>/canvas test/goldens scripts/quality,
npx prettier --write on them (import order and wrapping depend on the names you chose), then
npm run typecheck.npx jest test/goldens/canvas/<id>.golden.test.ts --selectProjects golden -u, open all nine PNGs
and compare them with the intended look (moment 0: old geometry, no effect that starts later,
labels from the view already final; 0.5 mid-flight; 1 the final view), then
CI=1 npx jest --ci --selectProjects golden.node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-code.mjs . and
node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-files.mjs .. Fix every FAIL line (each names the
file, the rule and the fix) and rerun until both print RESULT: PASS.src/canvas/ with its tests, plus test/goldens/skia-golden.ts and the worklet
boundary gate in scripts/quality/; npx jest src/canvas scripts/quality --ci --selectProjects unit passes.canvas-contrast.json,
to-view.ts, build-timeline.ts, layout-<id>.ts, draw-<id>.ts, <id>-surface.ts, and their
tests pass; every pair in canvas-contrast.json meets its ratio in every palette set (the
contrast rules of check-canvas-files.mjs), and no contracts/contrast.json entry names the
surface's palettes (contrast-declared-once).drawColor (or the surface is declared
"opaque": false and every element rendering it passes isOpaque={false}); every computed
canvas lives in the kit or a surface folder, and no surface file sits outside one.diff-events.ts with its test and feeds useCommittedChange;
reopening the screen replays nothing (use-surface-player.test.ts passes).CI=1 npx jest --ci --selectProjects golden passes.npm run typecheck and npx eslint --max-warnings 0 pass; no __PLACEHOLDER__ is left.accessible with an
image role and a translated accessibilityLabel (or opts out as decorative); the surface runs
only while the app is active, the screen focused and nothing covers it (no useClock, no
endless repeat); nothing turns the iOS 120 Hz key off.npx jest src/canvas/scene-clock --ci --selectProjects unit passes (push while paused, resume
after done, stale done, and both recorded traces).node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-code.mjs . prints RESULT: PASS.node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-files.mjs . prints RESULT: PASS.Neither checker prints SKIP lines. Both print NOT APPLICABLE only when no package.json declares
@shopify/react-native-skia, and both stop with exit 2 when a configured canvasSurfaceDirs glob
matches no surface folder or contracts/canvas-surfaces.json is malformed.
timeSinceFirstFrame or a t0 stored on JS. The second change freezes. Stamp
startAt from info.timestamp in the frame runner.Skia.Paint(), Skia.Color() or paths inside draw() or at module import. Native
allocations every frame, and module scope breaks tests. Build once in the kit (makeDrawKit,
buildPaths); one recorder per canvas via useState.draw(). The view is the final
state; anything that vanishes carries its own position in a track.onDone(run, seq) through finishRun and through useCanvasLifecycle.onDone with scene.get().seq on the JS thread. Until the UI applies a push, the JS
read returns the old scene, so the done of the scene before an interruption stops the next scene on
its first frame. Compare runs in scene-clock-state.pushScene holds it until the surface may run.useReducedMotion() in canvas code. It reads the setting once at app
start, so a later change is missed; pass the live setting as motion.scaleX: -1 for RTL. Mirror positions in the layout instead.drawColor, or pass isOpaque={false} and declare it.expo-font plugin and resolving them with matchFont or
Skia.FontMgr.System() for the canvas. Works on iOS only; Android falls back to a system font.
Load the TTF with useFonts and pass the provider everywhere.seqs.structuralSharing: false, or putting Date, Map, Set or class instances into the
query data or select result a surface reads. Only plain JSON keeps its identity across
refetches, so each refetch becomes a change and the chart replays.<Canvas> (a <Picture>, shared values, draw calls) in src/ui/ or components/,
or a surface's files in a folder no surface glob matches. Make it a surface folder and render it
with SurfaceHost; a static declarative canvas is fine anywhere.useClock() or withRepeat(…, -1). The frame loop runs for as
long as the canvas is mounted (idle, unfocused, covered); play a timeline through the scene clock.accessible. TalkBack may read it, VoiceOver never
focuses it; write all three (SurfaceCanvas does).contracts/contrast.json. Two tables drift. The pairs
live once, in the surface's canvas-contrast.json, which this skill and accessibility-as-code both
measure. If that skill reports canvas-palettes.json as an undeclared colour table, update it (drawing.md).isRtl && TextDirection.RTL. RTL is 0; choose explicitly.-u without opening the PNGs. Fix the code, or
accept a deliberate change and say why.draw() or layout(). It throws on the UI thread at runtime
only; move the helper into a 'worklet' module (the template's canvas-ids.ts).isPlaying.draw() (row - 1). The item lands elsewhere and an edge row
becomes unreachable; set dragLiftPt on the surface and let the gesture layer lift the pointer.highlight.measureText, or drawing golden text without a loaded typeface. CanvasKit
returns undefined for the first and draws nothing for the second.| File | What it is | Read/run when |
|---|---|---|
| references/architecture.md | When to use Skia, data flow, file map, the kit's public API, the CanvasSurface contract, surface kinds, prerequisites and owners, the contract file and config keys, When multi-package | Workflow step 1, before any canvas work |
| references/timeline-and-clock.md | Tracks, sampling, buildTimeline, the startAt fix, scene-clock-state, the frozen-surface case study with its traces, presenter, cues, lifecycle on iOS and Android, the clock trace and canvas-frame probe, 120 Hz | Step 3, before writing a timeline or touching the clock |
| references/drawing.md | draw() rules, highlights and effects, kit and palettes, contrast pairs and the colour-blind profile, paths, layout, RTL, text and fonts, particles, atlas, performance, accessibility, the template and the example | Step 3, before writing draw, layout, view or palettes |
| references/testing-and-goldens.md | Test levels, the draw-call budget, golden set-up and acceptance, failures, the device-only marker, headless previews, simulators, emulators and the E2E probe | Step 8, and whenever a golden fails |
| references/api-traps.md | Worklet rules, the SDK 57 API churn table, the re-verify list | Step 3, and when something works in Jest but not on a device |
| references/game-boards.md | Games appendix: board folders, kinds, Lights Out from the template, selection, hints and drag, recurring needs | Step 1, when the surface is a game board |
templates/src/canvas/ | The kit: layout, types, timeline, draw kit, scene, clock decisions (+ the recorded-trace test), frame runner, clock hook, recorder, text, canvas (isOpaque), presenter, cues, lifecycle, player, host, server-data change hook, E2E probe, PNG painter, with tests (layout, types, track and sample are canonical synced copies, identical in every skill that carries them) | Step 2 (copy verbatim) |
templates/src/hooks/ | use-is-app-active.ts (+ test): the shared foreground hook the lifecycle reads, a synced copy of the canonical file react-components-and-hooks owns; keep the app's copy if it already has one | Step 2 (copy verbatim, unless the app has it) |
templates/src/features/__FEATURE__/canvas/ | The template surface (the Tasks progress grid): palettes, contrast pairs (canvas-contrast.json, format 1 in drawing.md), model, ids, view, timeline, layout, draw, surface object, tests | Step 4 |
templates/test/goldens/ | skia-golden.ts (synced canonical matcher), the __SURFACE__.golden.test.ts golden and its nine reviewed baselines | Steps 2, 4 and 8 |
templates/scripts/quality/ | check-worklet-boundary.ts (+ test) and worklet-transform.test.ts: the npm test gate for 'worklet' modules | Step 2 (copy verbatim) |
templates/contracts/ | canvas-surfaces.json (the app's surfaces, kinds, opacity, palette sets, staticCanvases) and its JSON schema | Steps 2 and 4 |
| examples/weekly-chart/ | A second, complete surface folder to imitate: a server-fed bar chart with diff-events.ts, tweens, a guarded flash, RTL mirroring, two regions, fitted digits, its tests and a golden test that loads the bundled TTF (no baselines: you accept them in step 8) | Steps 3 and 6 |
scripts/check-canvas-code.mjs | Checks worklets, the frame clock and idle clocks, the worklets API, pure and opaque draw, the opacity contract, per-frame allocation, the Skia API, where computed canvases and surface files live, accessibility, lifecycle, the clock decisions and the reduce-motion source | Step 9 and at the end |
scripts/check-canvas-files.mjs | Checks kit files and their imports, the layout probe's containment, surface files, palettes, the contrast pairs (measured in every set, never declared again in contracts/contrast.json), timeline and draw tests, goldens and baselines, the iOS 120 Hz key (no override, committed Info.plist), the Jest golden project | Steps 2 and 9 and at the end |
scripts/selftest.mjs | Proves both checkers pass the templates and catch each planted bug | After changing a checker or a template |
scripts/lib/ | canvas-scope.mjs (kit and surface folders, the contract, declared packages), canvas-contrast.mjs (the contrast file's keys, WCAG and colour-blind maths), source-scan.mjs (synced: worklet, JSX and import helpers) and plist.mjs (synced: reads Info.plist) | When changing a checker |
scripts/check-lib.mjs | The shared script library (synced; never edit here) | Never by hand |
assets/shared.json | The shared files this skill copies in | When adding a shared file |
assets/template-placeholders.json | The placeholder values the template checks fill in (tasks, progress-grid) | When renaming the template surface |
tests/bases/app/ | Fixture base beside the templates: stand-ins for files other skills own (AppText, renderWithProviders, app.config.ts, jest.config.js), package.json, a live surface and the contract | When changing a fixture |
tests/fixtures/ | One overlay suite per checker: good/ plus one planted bug per case (mutation.json + EXPECT.txt) | When adding a rule to a checker |
canvas-gestures-and-hit-testing - touch on the canvas: gestures, hit-testing, drag, the pointer sample (load with this skill for any interactive surface).networking-and-server-state - the queries, keys and optimistic updates a server-fed surface reads.realtime-game-loop - fixed-step loops, simulate-then-replay and live surfaces.game-rules-engine - rules, events and seeded randomness for game boards.audio-and-haptics-feedback - the audio and haptics ports the cue scheduler calls.accessibility-as-code - contrast and colour-blind checks of the palettes, the live reduce-motion value, per-cell actions.golden-and-snapshot-tests - the golden policy and accepting baselines.performance-budgets - frame-time recording and on-device budgets.i18n-strings-and-catalogs and rtl-and-direction - the describe keys, digits and direction.unit-and-component-tests - the Jest projects, the Skia unit mock and the device-only marker.design-system-structure - the tokens the palettes take their values from, and AppText.e2e-maestro and debug-menu-and-test-hooks - flows that read the canvas probe, and the switch that shows it.motion-and-animation - Reanimated animations of ordinary views.icons-app-icon-and-splash - code-drawn icons and store art from the same Skia code.expo-sdk-upgrade - moving Skia, Reanimated and Worklets to the next SDK.assets/shared.json (opens in a new tab)assets/template-placeholders.json (opens in a new tab)examples/weekly-chart/build-timeline.test.ts (opens in a new tab)examples/weekly-chart/build-timeline.ts (opens in a new tab)examples/weekly-chart/canvas-contrast.json (opens in a new tab)examples/weekly-chart/canvas-model.ts (opens in a new tab)examples/weekly-chart/canvas-palettes.json (opens in a new tab)examples/weekly-chart/canvas-palettes.ts (opens in a new tab)examples/weekly-chart/diff-events.test.ts (opens in a new tab)examples/weekly-chart/diff-events.ts (opens in a new tab)examples/weekly-chart/draw-chart.test.ts (opens in a new tab)examples/weekly-chart/draw-chart.ts (opens in a new tab)examples/weekly-chart/layout-chart.test.ts (opens in a new tab)examples/weekly-chart/layout-chart.ts (opens in a new tab)examples/weekly-chart/to-view.ts (opens in a new tab)examples/weekly-chart/weekly-chart-surface.ts (opens in a new tab)examples/weekly-chart/weekly-chart.golden.test.ts (opens in a new tab)references/api-traps.md (opens in a new tab)references/architecture.md (opens in a new tab)references/drawing.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/react-native:skia-canvas-renderingfrom react-native
npx claudepluginhub zakariaf/reactnative-skills --plugin react-native73 skills in this plugin
/accessibility-as-codeEnforces a11y labels, 44pt targets, 200% text, VoiceOver, TalkBack. Use when adding a pressable, swipe or a11y label, text clips when large, contrast fails or Reduce Motion is missed. Not for RTL (rtl-and-direction)./adaptive-layoutLays screens out by window, not device: breakpoints, master-detail panes, readable widths, grids. Use when making screens responsive or for tablets, iPad, foldables, rotation, split screen, orientation lock. Not for tab bars (navigation-and-routing)./admob-ads-and-consentBuilds AdMob ads behind a port - banners, interstitials, rewarded, UMP consent then ATT, pacing, ADS_MODE test IDs. Use when touching ads, consent, ATT, ad IDs or rewarded perks. Not for purchases (in-app-purchases)./analytics-and-consentGates analytics on opt-in consent: no SDK before a yes, typed events without personal data, ATT. Use when adding analytics, events, screen views or a usage-data toggle. Not for crashes (crash-reporting-and-observability)./android-emulator-buildAssembles Release APKs with Gradle on an AVD started by name (pinned JDK and SDK) and inspects them. Use when trying the app on the Android emulator, or Gradle, adb, an AVD or the SDK fails. Not for Play uploads (android-release-play)./android-release-playShips Android App Bundles to Google Play: upload key, Play App Signing, AAB gate, versionCode, tracks, rollout. Use when releasing or signing for Play, or an upload, rollout or version code fails. Not for eas.json (eas-build-and-submit).Other plugins' skills for the same job