AI context.Ready to paste.

This page is written for coding agents. Copy the context blocks into an assistant before asking it to modify an elm-ssr app.

Agent contract
  • Prefer route modules over generated files.
  • Keep Worker wiring in TypeScript.
  • Use Loaders and Actions for server work.
  • Use islands only for browser state.
Copy first

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.

Pasteable context
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.
Feature prompt

Use this when asking for a feature.

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
Runtime prompt

Use this when asking for Worker wiring.

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
Rules

Non-negotiables for AI edits.

Do not invent APIs. Check installed elm-ssr files or upstream docs first.
Do not put database credentials, model keys, or secrets into Elm flags or rendered HTML.
Do not use islands for server data that can be rendered by a Loader.
Do not edit generated Elm output. Edit route/island source and rebuild.
Prefer examples with real module names and exact file paths.
After changing routes, run the elm-ssr CLI build.
Common mistakes
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.