# pragma: full docs for agents > pragma is a web framework built for coding agents. An app is native HTML, CSS and plain JavaScript (never TypeScript) with a closed set of directives; a Rust CLI compiles, lints and validates it and answers every error with the file, the line, the rule and the fix. Pages ship prebuilt with only the JavaScript they use, and every form is a WebMCP tool by default. This file has everything needed to build a pragma app: install, the loop, the app rules (AGENTS.md) and every doc. Index: https://pragma.leonavas.com/llms.txt. Each part is also a separate file under https://pragma.leonavas.com/docs/. ## Install and create pragma is one Rust binary. Linux x64 binary: https://pragma.leonavas.com/downloads/pragma-linux-x64.tar.gz. Node 22 or newer only runs `.server.js` files. ```sh curl -fsSL https://pragma.leonavas.com/install.sh | sh pragma new my-app cd my-app pragma dev ``` Or build from source with Cargo: ```sh git clone https://github.com/leonavas/pragma && cd pragma && cargo install --path core/cli/crates/pragma-cli ``` ## The loop 1. Read `AGENTS.md` in the app (the rules below), then the doc for the task. 2. Write the code: one `.html` per page or component, plain JS, utility classes. 3. Run `pragma check --strict` and fix every error and warning at its cause, never around the rule. 4. Done when `pragma check --strict` prints no problems. `pragma build` writes `dist/`. ## Contents - [App rules (AGENTS.md)](https://pragma.leonavas.com/docs/rules.md): the rules every pragma app follows; read first - [App structure](https://pragma.leonavas.com/docs/structure.md): where each file goes, pragma.json - [HTML syntax](https://pragma.leonavas.com/docs/syntax.md): HTML directives ({path}, :, ., @, $) and blocks - [Components](https://pragma.leonavas.com/docs/components.md): components, props, slots - [State: script, actions, derived values, stores](https://pragma.leonavas.com/docs/state.md): script: state, actions, derived values, mount, stores - [Routes and router](https://pragma.leonavas.com/docs/routes.md): pages, links, params, query, layout, head tags - [Data: load, server actions, skeleton, SSR](https://pragma.leonavas.com/docs/data.md): load, server actions, skeleton, SSR - [Overlays: modal, alert, dropdown](https://pragma.leonavas.com/docs/overlays.md): modal, alert, dropdown - [CSS](https://pragma.leonavas.com/docs/css.md): styles and theme - [Utility classes](https://pragma.leonavas.com/docs/classes.md): every utility class - [WebMCP: forms are agent tools](https://pragma.leonavas.com/docs/webmcp.md): forms as WebMCP tools, markdown for agents - [npm packages](https://pragma.leonavas.com/docs/packages.md): npm packages: when and which - [Performance](https://pragma.leonavas.com/docs/performance.md): performance defaults and budgets - [Logs](https://pragma.leonavas.com/docs/logs.md): OpenTelemetry logs - [pragma CLI](https://pragma.leonavas.com/docs/cli.md): commands, check rules, deploy --- Source: https://pragma.leonavas.com/docs/rules.md # AGENTS.md pragma app: native HTML, CSS and JS, no framework, usable by AI agents. Docs are in `core/docs/`: read the relevant one before changing code. ## Syntax A page or component is one `.html`: an optional `
The body goes in the default slot.
{$error}
Saved: {$saved}
``` The build accepts any top-level `const` as a handler; if its value is not a function, the event throws in dev (`@input="saveLater" needs a function, but "saveLater" holds …`). A timer just assigns the `let`: ```js let now = Date.now() function mount() { const timer = setInterval(() => { now = Date.now() }, 1000) return () => clearInterval(timer) } ``` `mount(el)` gets the component's root element, for what needs its own DOM (an observer, a measurement, focus): ```js let lines = 0 function mount(el) { const observer = new ResizeObserver(() => { lines = Math.round(el.clientHeight / 24) }) observer.observe(el) return () => observer.disconnect() } ``` `mount` runs only in the browser; read from `el`, never write to it (change state instead). It may be `async`: the function it resolves to is the cleanup. What only `mount` needs (a timer id, an observer, a DOM node) is a `const` inside `mount`, not a top-level `let`: a top-level `let` is state, renders on every change and keeps a DOM node in the instance scope. ## Derived values A value computed from state is a function, called on each render: `$total` in HTML, `total()` in JS. A top-level `let` or `const` computed from state once is stale (`js/stale-derived`), and a function used in JS without `()` is always truthy (`js/derived-call`): ```js let count = 0 let doubled = count * 2 // js/stale-derived: computed once const doubled = () => count * 2 // right: `$doubled` in HTML, `doubled()` in JS function check() { if (empty) return // js/derived-call: always true if (empty()) return // right } ``` `let count = start` (a prop) is fine when an action assigns `count` later: it is state that starts from the prop. A value per item is a field of the rows a derived function returns (`{}` takes paths, not calls): ```js const rows = () => items.map(item => ({ item, label: formatPrice(item.price) })) ``` ```html