Provides a gesture module and hit-testing system for Skia canvases. Use when canvas taps, swipes, drags, or aim need typed intents and accurate hit detection against the drawn layout.
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 touch on a hand-drawn canvas (a progress grid, a planner, a chart, a game board) goes through one
gesture module, useCanvasGestures, which hit-tests against the same CanvasLayout the renderer draws
with and emits at most one typed CanvasIntent per gesture; the surface's pure intentToAction(state, intent) alone decides whether it becomes a domain action. This skill ships that input kit
(src/canvas/gestures/), the shape of each surface's intent function and hit-targets test, and a
checker that proves both.
src/canvas/gestures/use-canvas-gestures.ts
(Gesture.* builders on Gesture Handler 2.x, hooks on 3.x). No builder or gesture hook in the canvas
kit, a surface folder, a file that renders a canvas or feeds one (a hook named in a canvas
GestureDetector or SurfaceCanvas input), or the feature folder of a canvas that takes touch. A
self-contained control there (a sheet's own GestureDetector) is ordinary UI; a gesture hook that is
ordinary UI is listed in contracts/canvas-input.json gestureExempt. Why: a Gesture Handler major then rewrites one file, and no second gesture can
double-fire on a canvas.onEnd (onStart for long press), never in
onUpdate/onChange; every pan has an onFinalize that resets the pointer (or the stick command).
Why: a drag that emitted per update would apply many actions, and a cancelled drag (a call, the
system back gesture) must not leave its preview behind.hitTest(layout.get(), point, HIT_SLOP) on the derived layout the picture draws with (useSurfacePlayer().layout). Why: draw and
touch cannot drift at any canvas size, and taps on the outer edge still land.intentToAction(state, intent) in the surface folder beside to-view.ts (a game surface: intent-to-move.ts,
intentToMove). It builds a candidate and returns it only when the domain's one source of truth
accepts it (listActions(state) lists it, or validate(state, action) passes), and imports no
React, React Native, Expo, Skia, store, service, API or UI value. Why: tests, undo, hints, bots and
replays share one definition of allowed, and a finished or locked state gives null.tap, long-press, swipe,
drag-end, aim), returning null for the kinds the surface ignores. Why: an exhaustive switch
turns a new kind into a compile error instead of a silent no-op.highlight.selected; the gesture layer always sends selected: null and
the model hook fills it in; a tap inside a select region only selects; a miss or an applied action
clears it. Why: the store, undo, persistence, analytics and automated players never see a selection.surface.dragLiftPt, default 0), to the
hover, the drawn preview and the drop target; the intent function and draw() add none, and a
surface with a lift keeps that much canvas below its last row (unreachableByDrag proves it). Why:
the preview cell is then always the drop cell, and no edge row becomes unreachable.event.x/y do not mirror under RTL (verified on iOS), so
flipping again sends touches to the wrong cell.pointer shared value feeds the picture
(frame.fx.pointer); only hover changes cross to JS, behind isSameTarget. Why: a React render
per finger move cannot fit a 120 Hz frame (8.3 ms).MIN_TOUCH_PT on the smallest supported canvas, proven by
a hit-targets test with smallestTargetPt; MIN_TOUCH_PT follows quality-gates.json
a11y.minTouchPt (44 pt; 48 for Material-sized Android designs). Fix the layout, never the test,
never hitSlop. Why: accessibility-as-code's target minimum applies to canvas cells too.GestureHandlerRootView. No
Pressable, Touchable or button inside a canvas GestureDetector or around a <Canvas>/<SurfaceCanvas>,
and no onPress*/onLongPress/onTouch*/onResponder* on the canvas or on the element that directly
wraps it; a whole-card press around a display-only canvas is an ordinary control, listed in
gestureExempt. Why: React Native's touch system hit-tests on its own (no shared layout, no slop, no
single intent) and competes with Gesture Handler; without the root view no gesture fires on a device.'worklet' module (classify-swipe.ts,
stick-command.ts, pan-intent.ts, the kit's canvas-layout.ts) importing values only from other
'worklet' modules; JS is reached with scheduleOnRN (never runOnJS), shared values with
.get()/.set() (never .value). Why: a plain function throws on the UI thread on a device while
every Jest test passes, and React Compiler needs the accessors.npx expo install; ~2.32.0 on SDK 57): the builder
API on 2.x, the hook API on 3.x, never mixed, the gesture module migrated whole. Why: the 3.x
composition hooks accept only 3.x gestures.Math.sqrt only) inside the intent function. Why: saves stay
compact and replays exact on every device.(tick, command) logs.fullScreenGestureEnabled: false (iOS 26 turns full-screen back on
by default) and the canvas keeps off the side edges (iOS edge swipe, Android gesture navigation).
Why: the system claims those swipes first, so the move goes back instead.none, swipe, drag, aim; a simulation uses the stick,
references/stick-input.md). Input needs the canvas kit's
src/canvas/canvas-layout.ts and canvas-types.ts: when they are missing, set the kit up with
skia-canvas-rendering first (this skill's templates/src/canvas/ holds identical synced copies).templates/src/canvas/gestures/ to src/canvas/gestures/ verbatim,
and templates/contracts/canvas-input.json with its schema to contracts/ (replace __FEATURE__
and __SURFACE__, list buttonComponents). Make GestureHandlerRootView the app's outermost view
(input-pipeline.md, "The root view"). Run node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-input.mjs .:
it names every missing piece.intent-to-move.ts in its canvas folder (game rules
cannot import the canvas kit); games may import src/canvas/** by default
(architecture-and-boundaries' gameFacing defaults), so no contract entry is needed.hit-targets.test.ts like the examples: the largest
view laid out on the smallest supported canvas, smallestTargetPt(layout) >= MIN_TOUCH_PT, and with
a lift unreachableByDrag(layout, edgeRowTargets(...), DRAG_LIFT_PT) empty on portrait and wide
canvases. A region below the minimum changes the layout, not the test.useCanvasGestures(player.layout, { panMode, dragLiftPt: surface.dragLiftPt ?? 0, onIntent, onHover, onMiss }), keeps the selection, dispatches
non-null actions and hands input and highlight to <SurfaceCanvas>
(examples/progress-grid/use-progress-grid-input.ts).
Set the stack screen's gesture options (rule 16) in the route's layout.npx jest src/canvas/gestures src/features/<feature> --ci --selectProjects unit
(paths first: --selectProjects takes several values and would swallow them). Gesture tests follow
references/testing-gestures.md.npx eslint --fix and npx prettier --write on the new files, then
npm run typecheck.node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-input.mjs . (or --surface <id>
to limit the surface side), fix every FAIL line (each names the file, the rule and the fix) and
rerun until it prints RESULT: PASS.src/canvas/gestures/ holds the kit and npx jest src/canvas/gestures --ci --selectProjects unit
passes: tap → cell with selected: null, a miss → onMiss, drag → one drag-end, a cancelled
drag → nothing, swipe → one direction, hover on change only, a lifted drag's hover and drop on
one cell, long press → cell, stick → integer commands, touch-target helpers.hit-targets.test.ts proves MIN_TOUCH_PT on the smallest supported
canvas, and a surface with a drag lift proves every edge row reachable on portrait and wide canvases.GestureDetector, no React Native touch on a canvas, GestureHandlerRootView outermost, and the canvas screen's stack options keep
the system back gestures off horizontal pans (checked on both platforms).npm run typecheck, npx eslint --max-warnings 0 and npx prettier --check pass; no
__PLACEHOLDER__ is left.node ${CLAUDE_SKILL_DIR}/scripts/check-canvas-input.mjs . prints RESULT: PASSThe checker prints one SKIP only while the root layout does not exist yet
(SKIP src/app/_layout.tsx [gesture-root] not yet created (app-startup-and-bootstrap creates it)),
and NOT APPLICABLE when no canvas takes touch (no input kit, no contract surface, no surface with an
intent file or a useCanvasGestures caller, no SurfaceCanvas input, no gesture and no React Native
touch in the canvas scope); a contract holding only gestureExempt or buttonComponents asks for nothing.
Gesture.Tap() in a feature component or screen around the canvas. It skips hit-testing and the
one-intent rule; add a mode to use-canvas-gestures.ts and consume its intents.select-* action or a selected field in the store for tap-then-tap. Undo, persistence and bots
see it; keep it in the model hook, list the region in SELECT_REGIONS, read intent.selected.draw() (row - 1). The preview and the drop drift
apart and an edge row becomes unreachable; set dragLiftPt on the surface.onUpdate "for responsiveness". One drag becomes many actions; show
responsiveness through the pointer preview and emit on release.event.x for right-to-left. The layout already mirrors surfaces that opt in.hitSlop or shrinking the test's grid to reach 44 pt. Fix the layout; the
slop is the fixed 8 pt HIT_SLOP of hit-testing, not a substitute for size.jest.spyOn(sv, 'set')): the mock's members are read-only;
pass a recording stand-in.'worklet' module.Pressable around the canvas, or onTouchStart on it, "just for one tap". It hit-tests beside
the layout and double-fires with the gesture module; add the mode to use-canvas-gestures.ts.style={{ flex: 1 }} on GestureHandlerRootView. The canonical lint bans inline
styles; use a StyleSheet style.| File | What it is | Read/run when |
|---|---|---|
| references/input-pipeline.md | The pipeline, CanvasIntent, hit-testing, composition and thresholds, pan modes, pointer and drag lift, RTL, touch targets, the root view, the detector and React Native touch on a canvas, system back gestures on iOS and Android, accessibility and E2E taps, the contract and config keys, When multi-package | Workflow step 1, before any input work |
| references/intent-to-action.md | Rules for the intent function, the two legality forms, patterns (tap, drag with a lift, tap-then-tap, swipe, aim, long press), wiring the screen, games, tests | Steps 3 and 5 |
| references/testing-gestures.md | Jest set-up, what each test proves, driving gestures, mock traps, checks on named iOS simulators and Android emulators | Step 6, step 9, and when a gesture test misbehaves |
| references/stick-input.md | Integer stick commands for simulations and their tests | Step 1 for real-time games |
| references/gesture-handler-versions.md | Gesture Handler 2.32 today, the 3.x hook mapping (verified on 3.2.1) and the one-file migration | When the Expo SDK moves Gesture Handler, or when reading 3.x examples |
templates/src/canvas/gestures/ | The input kit: canvas-intent.ts, classify-swipe.ts, pan-intent.ts, stick-command.ts, touch-targets.ts, use-canvas-gestures.ts, the two test probes, and a test for each module | Step 2 (copy verbatim) |
templates/src/canvas/ (other files) | canvas-layout.ts (+ test), canvas-types.ts, timeline/ (+ test): synced canonical copies of the canvas kit's contract files (skia-canvas-rendering owns them) | Step 1, only when the app has no canvas kit yet |
templates/contracts/ | canvas-input.json (the surfaces that take touch, button components, exemptions) and its JSON schema | Step 2 |
| examples/progress-grid/ | Tasks progress grid: tap to toggle a day; intent-to-action.ts (+ test), progress-grid-rules.ts (the legality list), hit-targets.test.ts, use-progress-grid-input.ts (the screen wiring) | Steps 3 to 5 |
| examples/inbox-planner/ | Drag an inbox task onto a day, or tap-then-tap; a drag lift with edge-row proofs on portrait and wide canvases | Steps 3 and 4, for drag and selection |
| examples/sliding-puzzle/ | Games: swipe to slide (the 15-puzzle), rules in rules/, intentToMove in the surface folder | Step 3, for swipe surfaces |
| examples/arena-aim/ | Games: pull back and release, aim quantised to integers, with a property test | Step 3, for aim surfaces |
scripts/check-canvas-input.mjs | Checks the kit, its worklets, the one gesture module, test ids, single intents, hover on change, pan finalize, slop, physical coordinates, detector children, React Native touch on a canvas (canvas-rn-touch), the root view, the intent function (present, tested, pure, exhaustive), touch-target tests and gate, the API version and the Worklets API | Steps 2 and 8, and at the end |
scripts/lib/input-scope.mjs | Where the checker looks: layout, config keys, the contract, surfaces and which take touch | When changing the checker |
scripts/lib/source-scan.mjs | Synced source helpers (masking, JSX tags, imports, worklet directive) | When changing the checker |
scripts/check-lib.mjs | The shared script library (synced; never edit here) | Never by hand |
scripts/selftest.mjs | Proves the checker passes the templates and examples and catches each planted bug | After changing the checker, a template or an example |
tests/bases/app/ | Fixture base: stand-ins for files other skills own (the root layout, SurfaceCanvas, the progress-grid model, view, layout and surface, the screen and model hook), package.json, quality-gates.json | When changing a fixture |
tests/fixtures/ | One overlay suite: good/ plus one planted bug per case (mutation.json or DELETE.txt, EXPECT.txt) | When adding a rule to the checker |
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 |
skia-canvas-rendering - the picture, CanvasLayout, PointerSample, SurfaceCanvas and the drag preview this skill feeds (load both for an interactive canvas).accessibility-as-code - the touch-target minimum, hold alternatives and the canvas's spoken summary.unit-and-component-tests - the Jest projects, jest.setup.ts and test forms the gesture tests follow.naming-conventions - testID grammar and kebab-case kinds.state-management-zustand - the store whose dispatch receives the actions.react-components-and-hooks - model hooks and React Compiler rules for the wiring.app-startup-and-bootstrap - the root layout that holds GestureHandlerRootView.navigation-and-routing - stack screen options for back gestures.rtl-and-direction - which surfaces mirror and how direction switches.e2e-maestro - tapping canvas cells from the published layout on both platforms.realtime-game-loop - the fixed-step loop that consumes stick commands.game-rules-engine and game-session-host - listMoves, hints and the game screen.expo-sdk-upgrade - the SDK move that brings Gesture Handler 3.assets/shared.json (opens in a new tab)assets/template-placeholders.json (opens in a new tab)examples/arena-aim/intent-to-move.test.ts (opens in a new tab)examples/arena-aim/intent-to-move.ts (opens in a new tab)examples/inbox-planner/hit-targets.test.ts (opens in a new tab)examples/inbox-planner/intent-to-action.test.ts (opens in a new tab)examples/inbox-planner/intent-to-action.ts (opens in a new tab)examples/inbox-planner/layout-planner.ts (opens in a new tab)examples/inbox-planner/planner-rules.ts (opens in a new tab)examples/progress-grid/hit-targets.test.ts (opens in a new tab)examples/progress-grid/intent-to-action.test.ts (opens in a new tab)examples/progress-grid/intent-to-action.ts (opens in a new tab)examples/progress-grid/progress-grid-rules.ts (opens in a new tab)examples/progress-grid/use-progress-grid-input.ts (opens in a new tab)examples/sliding-puzzle/intent-to-move.test.ts (opens in a new tab)examples/sliding-puzzle/intent-to-move.ts (opens in a new tab)examples/sliding-puzzle/sliding-puzzle-rules.ts (opens in a new tab)references/gesture-handler-versions.md (opens in a new tab)references/input-pipeline.md (opens in a new tab)references/intent-to-action.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
canvas-gestures, hit-testing, skia, touch-input, gesture-handler
73 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)./react-native:canvas-gestures-and-hit-testingfrom react-native
npx claudepluginhub zakariaf/reactnative-skills --plugin react-nativeOther plugins' skills for the same job