ts-core
БесплатноБез исполняемых скриптовНе проверенAuthoring guide for the primary Native SDK app-logic path: TypeScript app cores - Model, Msg, update, and the pure functions they call, written in the closed…
от vercel-labs★ 7 869 звёзд на GitHubОб этом скилле
Author app cores in the TypeScript subset
TypeScript is the primary app-authoring language. An app core is a Native SDK app's deterministic logic: Model (the app state), Msg (a discriminated union of everything that can happen), update(model, msg) (the one pure transition function), and the pure helpers they call. You write it as a TypeScript module rooted at src/core.ts - splitting into more modules under src/ when it grows (see "Splitting a core into modules") - and the build checks the whole import graph with the @native-sdk/core frontend and compiles it to native code with the external core compiler. No JS engine ships in the binary — the program either passes the subset checker and compiles to native, or you get a teaching error naming the rule, the fix, and the reason. The same file is executable TypeScript: it typechecks with stock tsc and runs unmodified under node, so you can poke behavior with plain node scripts before the native build.
A whole TS app starts as three files of truth and zero Zig: src/core.ts (this guide; plus core-class modules it imports under src/), src/app.native (the markup view over the core's model), and app.json (windows, identity, permissions). Existing app.zon manifests remain supported. Optional ordinary-TypeScript service modules live under src/services/ and are never imported by the core; load native skills get ts-services for that boundary. native init scaffolds the three-file base; the build detects src/core.ts in the tree (never a flag or config — a tree with both src/core.ts and src/main.zig is a teaching error) and generates the wiring outside the app. The loop:
native dev --core # the fastest loop: run the core under node's virtual host —
# dispatch Msgs as JSON lines ({"kind":"add"}, {"$bytes":"…"}
# for bytes payloads, {"advance":1000} to run virtual timers),
# watch the model + effect transcript. Logic only, no renderer.
native dev # build and run the real app (markup hot reload)
native check # subset-check core.ts + validate markup + app.json/app.zon
native build # ReleaseFast binary; native test runs the app's tests
The complete reference app in this idiom is examples/soundboard in the SDK repo: the soundboard music library as three files and zero Zig — const catalog tables, REAL audio through the Cmd.audioPlay stream, scrub-to-seek on a markup slider, a motion-gated Sub.timer playback clock, the full text-edit engine on a search field, controlled scroll, registered cover assets, the width-adaptive grid through the frame channel, clipboard, and context menus, with an end-to-end suite driving the shipping markup.
The contract
export interface Model { /* readonly data fields only */ }
export type Msg =
| { readonly kind: "add" }
| { readonly kind: "toggle"; readonly id: number };
// ...one arm per thing that can happen; at least two arms
export function initialModel(): Model { /* pure */ }
export function update(model: Model, msg: Msg): Model {
switch (msg.kind) {
// one case per arm; the switch must be exhaustive (no default needed
// once every arm is present — a missing arm is a build error)
}
}
updateis pure and synchronous: next model out, plus optionally command data describing effects. When a dispatch needs an effect, declare the return typeModel | [Model, Cmd<Msg>]and return[nextModel, cmd]— the runtime interprets the command after the model commits and dispatches any result back to you as aMsg.initialModelmay return the same pair ([Model, Cmd<Msg>]) to run a boot effect once at install, and an app that needs recurring timers exportssubscriptions(model): Sub<Msg>. See "Effects are Cmd data" below.- Exported helper functions (
export function doneCount(model: Model): number) compile to public native functions — and every exported helper taking exactly ONE Model parameter also becomes a Model declaration markup binds by the helper's own name ({doneCount}), so derived values need no model field. One binding name per member: a helper that collides with a field (or another helper) is a taught NS1031. - Update-only state (fields, helpers, or Msg kinds nothing in markup binds or dispatches — host-fired timer arms, persistence bookkeeping) is declared once:
export const viewUnbound = ["nextId", "tick"] as const;. It emits as theview_unboundopt-outnative check's unbound-state lint reads; a name outside the model surface is a taught NS1032. Entries are the TypeScript names exactly as declared ("nextId") and Msg kinds as theirkindtags — the same names markup binds, because there are no other names. - Names: your names are your names — fields, helpers, and locals emit into Zig with their TS spellings (
doneTodaystaysdoneToday), and markup binds them verbatim. String-literal unions emit as native enums.
Tests against the compiled app
Put
Установить ts-core в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ts-core?
Authoring guide for the primary Native SDK app-logic path: TypeScript app cores - Model, Msg, update, and the pure functions they call, written in the closed app-core subset, checked by the @native-sdk/core frontend, and compiled ahead-of-time to native code by the external core compiler. Use for new apps unless the user explicitly chose Zig, when writing or modifying a src/core.ts app core, fixing subset checker errors (NS1001-NS1069), or deciding how to express state, messages, text (bytes and the byte-text string methods), text input, continuous controls (sliders, scroll), effects (Cmd), subscriptions (Sub), the host-event wiring channels (frameMsg, keyMsg, pinchMsg, dropMsg, appearanceMsg, chromeMsg, envMsgs, app manifest assets), derived values, the view_unbound lint opt-out, local mutation of owned arrays, or how to split a core into modules under src/ (relative imports, namespace imports, @native-sdk/core/text, @native-sdk/core/events). Use ts-services alongside this guide for src/services work.
Как установить скилл ts-core?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ts-core запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic