Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

datapages-architecture

БесплатноБез исполняемых скриптовНе проверен

Plan a Datapages app or feature: choose where to store values, how to update the browser, where to define handlers, how to scope event subjects and how many…

romsharkот romshark★ 122 звезды на GitHub

Об этом скилле

Architecture

Read datapages first for the build loop, hard rules and naming conventions.

Use this skill to choose the Datapages constructs a feature needs. Ask the operator when a missing requirement would change that choice. Then read the referenced skill before implementing the selected construct.

Keep authoritative state on the server, separate reads from commands and send complete page updates instead of small DOM patches.

New app

datapages init  # go.mod, app/app.go, cmd/server/main.go, compose.yaml, Makefile, CI
make up         # start the broker
make dev        # datapages watch

init creates PageIndex, PageError404, PageError500, Head and RecoverError. It writes only missing files and deletes nothing. You can run it again without overwriting existing files.

init asks which Web Component setup to scaffold with the app package: Datastar Rocket, TypeScript bundled by esbuild, JavaScript modules or none. --web-components rocket|typescript|javascript|none answers without the prompt, and -n alone picks none. Pick one only when the app needs JavaScript that would be impractical in Datastar attributes; see datapages-templates.

Before the first page, decide:

question decides
Are users authenticated? Session data type and the Session alias shared by all handlers. See datapages-sessions.
What does a handler need besides the request? App fields. A page has no named dependency fields, only App *App.
Can data change without the reader acting? Whether events are needed. See datapages-events.
Will 1 or multiple server processes run? Broker, session store and data placement. See Server topology.

Add sessions, state and events when a feature needs them, not upfront.

Before implementation

Do not guess requirements that change the application model. Ask the operator when they are unclear.

unknown determines
Authentication or per-user data Whether data belongs in a session. See datapages-sessions.
Persistence What must survive a process restart and where it is stored.
External changes Whether data can change without the current tab acting and needs events. See datapages-events.
Per-tab server state Whether a handler without a request needs tab-local values.
URL state Whether a value must be shareable or survive reload.
Server topology Whether 1 or multiple server processes will run. See Server topology.
Shared routes Whether a handler belongs to a page, *App or an embedded shared type.

Do not ask when the requirement is already explicit in the task or existing code.

Use the smallest model that satisfies the requirements. Add sessions, events, State[T], persistence or shared handlers only when a current requirement needs them.

Default architecture

For server-backed interactive or real-time data, prefer Datastar's CQRS model:

  • the server stores authoritative state;
  • separate reads from commands;
  • long-lived SSE handlers provide reads;
  • short-lived actions are commands;
  • commands mutate authoritative state and notify subscribers;
  • On handlers react to events and render from authoritative state;
  • prefer complete page updates over small DOM patches;
  • keep plain GET rendering correct.

A command should normally mutate state and dispatch an event. The event says that something changed; it is not the authoritative state. Subscribers read the current state, render the page and send the result over SSE.

Render 1 template for each page and let Datastar update the changed DOM. Split templates into smaller components when useful. Do not add small patches only to reduce transferred HTML. SSE uses a 1 MiB window for zstd and brotli, and 32 KiB for gzip. A larger fragment cannot reuse its previous render; patch a smaller element or use datapages.SSECompressionLargeFragments(). datapages.WithSSECompression configures the server. A page's StreamConfig overrides it for the page's streams, and StreamConfigPOSTSave for the response of POSTSave.

Each stream update must contain enough current state to restore the UI after a missed event or interrupted connection. Send complete current state when a missed incremental update would make the client incorrect.

Handle local interactions on the client. Examples include opening a menu, changing a class and validating a local field.

Where to store a value

Give each value 1 owner:

value owner constraint
Shared by all users and outlives a request App field behind a repository 1 App serves all requests in 1 process. Guard its fields. For multiple servers, see Server topology.
1 user across tabs and restarts Session data and its store Every handler uses the same data type.
1 browser tab datapages.State[T] Reconnect starts zeroed. StreamOpen rebuilds it.
Shareable URL state that survives reload Query field with `reflectsigna
Полный SKILL.md на GitHub

Установить datapages-architecture в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл datapages-architecture?

Plan a Datapages app or feature: choose where to store values, how to update the browser, where to define handlers, how to scope event subjects and how many server processes to run. Use before other Datapages skills when these choices are not set.

Как установить скилл datapages-architecture?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл datapages-architecture запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить datapages-architecture с