Project context for an AI agent.
Paste this before asking an assistant to implement a feature. It states the framework rules and where code belongs.
This page is written for coding agents. Copy the context blocks into an assistant before asking it to modify an elm-ssr app.
Paste this before asking an assistant to implement a feature. It states the framework rules and where code belongs.
You are editing an elm-ssr app.
Framework facts:
- Routes live in src/<App>/Routes/*.elm.
- Index.elm maps to its folder path.
- A trailing underscore in a file name is a dynamic segment.
- Every route exposes page : Request -> Loader (Document Never).
- Non-GET work belongs in action : Request -> Action (Document Never).
- Pages use ElmSsr.Html / ElmSsr.Svg, not elm/html.
- Islands are normal Browser.element programs and use elm/html.
- Use Island.embed only where client state is needed.
- Do not edit generated/. Run elm-ssr build to regenerate.
Task: <describe the feature>
Route file: src/<App>/Routes/<Route>.elm
Request method: GET | POST | both
Server data:
- Loader.query / queryOne / execute for SQL
- Loader.fetchJson for remote JSON
- Loader.custom only when one typed Worker effect is clearer
Form behavior:
- Validate in action
- Use Action.fromLoader for server effects
- Redirect after success
Client behavior:
- Add an island only if browser state/subscriptions are required
Task: wire runtime support for <feature>
Allowed files:
- app/runtime.ts or Worker entry
- wrangler.jsonc for bindings
- migrations/*.sql for schema
Use:
- cloudflareEffects for KV/D1
- postgresSql for Postgres clients
- withTasks for waitUntil work
- withQueueProducer + createQueueConsumer for queues
- withJobs for startJob/jobStatus
- sessions + csrf for session effects
Bad:
- Import Html from elm/html in SSR page routes.
- Add full-page hydration.
- Put long-running work directly inside a route action.
- Start EventSource from a server-rendered page.
- Store sessions in memory for production.
Good:
- Use ElmSsr.Html in page routes.
- Use a focused Browser.element island.
- Use Loader.startJob or queues for long work.
- Subscribe to SSE from an island.
- Use a durable session store.