jac-fullstack-patterns

Wire main.jac entry modules, endpoints, and client-server imports for fullstack Jac applications.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-fullstack-patterns-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-fullstack-patterns
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-fullstack-patterns
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-fullstack-patterns-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Fullstack Jac apps fail in non-obvious ways at the client-server seam: endpoints return 405 because a name is missing from the entry import, client calls silently assign Promises instead of values, and sv import placement breaks Vite builds. This Skill encodes the wiring rules that prevent those failures. ## Core Features & Use Cases - Entry module wiring: Register def:pub functions and walkers via plain imports in main.jac, mount the client with def:pub app, and configure [serve] base_route_app. - Client-server call patterns: Choose between function RPC and walker spawn, use sv import correctly in client modules, and pass typed objects across the boundary with hydration. - Caching and mutation discipline: Apply the 60-second reader cache behavior and the write-then-refetch pattern for state updates. - Use Case: When adding a new server endpoint that returns 405 Method Not Allowed, check that its exact name appears in the entry module's import list, then run jac check to catch contract drift at stale client call sites. ## Quick Start Ask the AI to wire a new fullstack Jac feature with a server endpoint in a feature module and a client component that calls it, following the import and registration rules.

Frequently Asked Questions about jac-fullstack-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I register a new server endpoint in a Jac fullstack app?

Add the endpoint's exact name to the entry module's import list in main.jac using a plain import from the feature module. A def:pub function not named in that import returns 405 Method Not Allowed even if the module is already imported.

What is the difference between def:pub function RPC and walker spawn in Jac?

Function RPC accepts positional and keyword arguments resolved against the server signature and returns a typed value. Walker spawn takes kwargs only, mapping them to the walker's has fields, and returns results in result.reports as a list.

Why does my Jac client call return a Promise instead of data?

sv import stubs are async, so calling them without await assigns a Promise and causes a silent runtime crash. Always write items = await fetch_items() when calling server functions from client modules.

When should I use sv import versus plain import in Jac?

Use plain import in main.jac for in-process server imports that register endpoints. Use sv import only inside client modules to generate RPC stubs; using it in server code declares a microservice boundary where session cookies do not cross.

Why does my Jac app show stale data after an external change?

The client runtime caches reader endpoint responses for 60 seconds with an LRU cache. Out-of-band changes like another tab or server-side mutation are invisible until a writer call invalidates the cache or the TTL expires.

How do I detect contract drift between Jac client and server code?

Run jac check across the project after editing a server endpoint's signature or types. Warnings like W1101 Cannot import name appear at the exact stale client sv import or spawn line, flagging the cross-boundary mismatch.