Agent Skill

Use AFUI for questions with suggested answers and supporting evidence, or for a custom page whose structure helps a person decide or work. AFUI delivers one interface to one person and returns one terminal outcome. It transports typed values without interpreting the Provider’s domain payloads.

Keep ordinary chat questions in chat unless the person requests AFUI, needs to answer from another device, or needs context a separate page presents better. Use afui show ask for questions, including image/table/diff context and several related questions on one page. Use afui show view, or a template of your own, when an interface needs more than a few questions and options. Use a Provider for domain operations, dynamic forms, and sustained interaction.

An unattended question page remains available by default until a person answers, the provider withdraws it, or its owning process exits. Set an idle budget explicitly when the page should expire.

Read only the relevant route

TaskRead
Ask questions, supply context, or collect answersquestions.md
Show a page built from view components (tables, cards, fields), or write a reusable templateshow.md
Write a script-owned surface with a page or view, a declaration and a JSONL providersurfaces.md
Build a Rust Provider page, choose runtime primitives, or test an integrationproviders.md
Find, open, close, or remotely host existing sessions; reopen expired mountssessions.md
Edit, check, preview, or enable a frontend replacementfrontends.md

For exact flags and legal invocation combinations, run the relevant command’s --help, such as afui show --help or afui host serve --help. The installed references work offline. Use afui view catalog to inspect the installed build’s View components, functions, and parameter schemas offline. Full guides and API examples are in the docs/ folder of https://github.com/agentfirstkit/agent-first-ui, and Rust signatures are in the crate’s rustdoc.

Core Rules

  • Parse Agent-First Data events on the resolved output destinations. By default, finite commands send results to stdout and progress and errors to stderr; capture both streams. --output-to can override this routing. Success is a kind:"result" event whose business code sits inside result; failure is kind:"error" with error.code, error.message, and often error.hint. The one exception is afui show --render, which prints the rendered view request itself, ready to pipe into afui show view --data stdin.
  • Exit 2 means the invocation was rejected before anything ran, and error.code is a cli_* code — retrying the same call unchanged cannot help. Exit 1 means the command ran and failed, carrying its own domain error.code.
  • Exit 4 means output could not be written. The action may already have run; inspect its state before retrying, especially when collecting an answer.
  • A session is one person, one interface, and one bounded lifetime with one terminal outcome. provider_id, ui_kind, and session_id route it back to its owner. A Provider may attach the AFUI runtime for retained values, typed requests, progress, ordered messages, and offered bytes while it remains open.
  • AFUI owns the credential, the origin checks, the isolated window, and the cleanup. The Provider owns the Router, the HTML, the typed API, and what completion means. Do not ask AFUI to render or validate domain data — it has no opinion about cases, invoices, or queries.

Terminal outcomes stay separate from runtime traffic

  • Completed(T) — a decision session completed. T is the person’s decision, not a suggestion to weigh against your own plan. afui show reports it as show_completed.
  • Closed — the session ended: a closed window, the host ending a surface, or afui session close. For a decision session this means no decision; for a watched/live surface it is the ordinary terminal outcome. It is not a transient runtime reconnect and does not imply consent. afui show reports it as show_closed.
  • Expired — the credential ran out before they acted. Reopening is legitimate here, but say plainly that the first one timed out. This can only happen to a managed URL; a window never expires, because the window is what bounds it. afui show reports it as show_expired.

Any amount of runtime traffic may precede these, and none of it completes the session. Never read Closed or Expired as consent. If the step needed a human decision before, it still does.

Delivery and waiting

afui show blocks until the page ends. Its readiness is a progress event with progress.phase:"show_ready" and progress.session_id; the terminal result follows on stdout. If your command runner kills long commands, start it with --detach, keep the session_id from the show_started result, and collect the ending with afui session wait <session_id> --timeout-s N, repeating while it returns show_pending. show_started confirms readiness, not an answer. A result is collected once; show_not_found after a successful wait means it was already returned. --detach needs a writable session registry and fails with show_detach_unavailable without one.

show_pending reports waiting_s. AFUI never reminds the person; that is your call, through the conversation or whatever channel already reaches them. A reminder is worth sending when the answer blocks work they expect done, not on every poll.

An explicit --mode overrides delivery derived from the launch file. When AFUI_LAUNCH_FILE supplies a registry, the default is session: the session is registered for a host to present, and afui host list shows what is registered. Otherwise the default is a local window. The launch file’s context is an opaque ownership label; keep secrets out of it.

link binds an AFUI listener on the LAN and advertises an unencrypted HTTP URL (link_url in the readiness event, or in show_started with --detach). The other device must be able to reach that LAN address; it is not a public relay or TLS tunnel. Choose it only when that exposure suits the task, and hand the bearer URL only to the intended person. For an existing protected remote connection, use session with afui host serve; see sessions.md. A Provider that does not offer link omits it from its --mode values.

Recovery

  • cli_unregistered_combination means every flag was spelled correctly but the mixture is not a registered shape. Read the shapes in --help and pick one; adding more flags makes it less likely to match, not more.
  • cli_unknown_argument and cli_unknown_command are spelling errors against a closed registry — the flag does not exist, so no amount of retrying invents it.
  • data_invalid and view_message_invalid name a JSON Pointer path without repeating the value: fix the data at that path before running again.
  • show_window_wait_failed means a window process exited unsuccessfully; show_window_unavailable means it could not launch or exited successfully without reaching its page. Neither is a human close or a decision.
  • A window that never opens is an environment problem (no supported desktop runtime or no display), not an argument problem. Report it rather than falling back to printing a URL the person never asked for.

Setup

Check availability with afui --version. A nonzero exit can also mean an output failure; it is not by itself a reason to reinstall. When setup is requested, the package is agentfirstkit/tap/afui on Homebrew or agent-first-ui on Cargo. afui skill install installs the embedded skill and references into the standard skill folders agents read; for an agent that reads only its own folder, pass it as --skills-dir.

Reporting Problems

If afui itself is wrong — a crash, an internal error, or behavior that contradicts its docs, not a configuration or credential problem — or the person wants a missing feature, offer to open an issue at https://github.com/agentfirstkit/agent-first-ui/issues. Check for duplicates first. Include afui --version, the command, error.code, and expected versus actual, with placeholder data only: never the person’s data, paths, or secrets. File it with gh issue create only after the person approves the draft.