Canonical Commands as Application Architecture
Treating typed commands as the single spine shared by navigation, hotkeys, command palettes, and agents.
The Quiet Cost of Scattered Actions
Watch how most web applications grow over their first year. A theme toggle starts as an onClick callback inside the header. Three months later, someone adds a keyboard shortcut in a useEffect listener. Six months later, a command palette re-implements the same toggle against a store method, and a settings panel adds a fourth copy with slightly different side effects.
Every surface works on its own, yet the application no longer has a single definition of what it can actually do.
In Sentinel, where the same household action can be triggered from an iPhone touch control, a keyboard shortcut, a REST API request, a CLI command, an automation rule, or a scoped MCP tool call, duplicating behavior across surfaces was untenable from day one. Every meaningful mutation and read had to pass through one canonical CommandRegistry and CommandBus.
Carrying the Pattern to a Static Studio Site
A public studio website has a much smaller surface area than a home control plane, yet the same architectural hygiene pays immediate dividends. On this site, @studio/commands owns a pure, React-free registry of canonical capabilities:
- Stable namespaced IDs (
navigation.products,theme.toggle,article.bookmark,demo.export,system.copy-page-url). - Typed Zod input schemas where arguments apply.
- Explicit availability predicates (
isAvailable(ctx)) so article or Lab commands only activate where meaningful. - Side-effect classifications (
read,navigate,preference,clipboard,export). - Centralized shortcut metadata bound once through an isolated TanStack Hotkeys adapter.
Buttons in the header, entries in the Mod+K command palette, keyboard shortcuts, and toolbar controls in the Lab all delegate to commandBus.execute(id, ctx, input).
Machine Readability as a Free Byproduct
Because every discoverable action is declared once in @studio/commands, our build-time content pipeline exports /data/capabilities.json directly from the registry. We never hand-maintain a second capabilities list, and we never expose privileged or arbitrary execution surfaces.
This is also what makes a codebase genuinely agent-friendly: an autonomous coding agent does not have to grep through twenty React components to discover how navigation, bookmarks, or theme switching work. There is one typed contract, one execution bus, and one test suite verifying every invariant.