# Generative UI rules (A2UI) for business apps

Source: https://tt-tech.io/blog/generative-ui-a2ui-angular
For Angular and React apps that render model-composed screens with A2UI. Add to AGENTS.md or save as a skill. Your project's own rules win where they differ.

## Rules

1. The model only composes screens from a registered catalog. Never render HTML, markup or code that a model produced; do not register the MCP App component unless you need it.
2. Keep the catalog small and read-only for the model: display components only. Anything that moves money, changes data or sends something stays a normal screen with its own checks.
3. Customer values (balances, transactions, names, health data) never go into the prompt. The model passes an identifier; a server-side macro or lookup fills in the values after the model has answered.
4. Treat every macro argument as untrusted model output: validate it with a schema and check that the identifier belongs to the signed-in user before fetching anything.
5. Configure macro expansion to fail loudly (for example `on_error="raise"` in the Python SDK), so a failed or unknown macro renders a visible error, never an empty component.
6. Text the model writes may contain no digits and no currency signs (normalize Unicode first). Every number on screen comes from a macro.
7. Check the model's answer against an allow-list: only the layout components and macros you registered pass, each with a strict schema. Anything else (images, media, links, URLs, function calls, unknown components) is replaced by a visible "blocked" component, never dropped silently. Validate the result as a tree: known ids, each used once, no cycles, a maximum node count.
8. Every action that comes back from the surface is checked on the server, as the signed-in user.
9. The browser only talks to your own backend. Model API keys live on the server, never in client code.
10. The user's own chat message does go to the model. Say on the screen what users should not type (account numbers, diagnoses), and log nothing sensitive from prompts.
11. Treat every model answer as untrusted input, whichever model and however well it behaves. Data the model reads (payment references, documents, emails) can carry instructions from someone else. The gate runs on every answer; a model that refuses an attack is a bonus, not a control.
12. On the client, a render failure shows an error (`role=alert`), never an empty answer. Do not plug a markdown or HTML renderer into model text unless it sanitizes its output; plain escaped text is the safe default.
13. Log what the gate removed and why, including the URL a blocked node wanted, on the server. Sending that log to the browser is for demos only, behind a flag that is off in production.

## Before you say done

- Search the prompt-building code for any field that carries a customer value; there should be none.
- Add a test that a foreign account ID is rejected, and one that the prompt contains no balances.
- List every catalog component in the pull request and confirm none of them triggers a payment or a data change.
- Add a test with a scripted "compromised" model that sends each attack (foreign account, digits in text, an image with a data URL); the gate must block all of them. Do not rely on the real model refusing.
