affiles CLI reference

Project one directory tree, read-only, to a person who is not at this machine.

affiles is compiled from a closed cli-spec-v1 registry: one source for argv parsing, typed invocation values, which parameter combinations are legal, output contracts, and help. An invocation runs only when it matches exactly one registered combination.

Global arguments

AFDATA registers these itself, so the syntax in Commands leaves them out.

ArgumentWhereWhat it does
--helpevery commandEvery legal shape of that command, complete, plus its subcommands. JSON by default; --output plain for a terminal.
--versionaffiles onlyName, version, and build identity as one protocol result.
--docsaffiles onlyThis document, rendered from the registry.
--output <FORMAT>per output contractRender as json, yaml, plain (default json).
--output-to <DESTINATION>per output contractRoute results and diagnostics to split, stdout, stderr (default split).
--stdout-file <PATH>, --stderr-file <PATH>per output contractAppend that stream to a file instead.

Success output is protocol events, on those terms, unless a command’s own Output line says otherwise.

A shape is one legal set of arguments that may appear together, under a stable id. Where a command has more than one, each id is a heading below. --help returns them all at once, so discovering a command costs one call; there is no recursive mode across commands, and this document is that view.

Commands

affiles api export

Write the generated OpenAPI document.

affiles api export [--directory <PATH>] [--force]
ArgumentMeaning
--directoryDestination directory
--forceReplace an existing generated document

affiles api serve

Serve the bearer-protected projection API.

affiles api serve [--port <PORT>] [--mode <local|lan>] [--access-token-secret <SOURCE>] --root <PATH> [--exclude <GLOB>...] [--max-read-bytes <BYTES>] [--no-symlinks]

Output: protocol events; --output json/yaml/plain (default json), --output-to stdout/stderr (default stdout).

ArgumentMeaning
--portTCP port; use 0 to let the operating system choose
--modeNetwork exposure: local binds 127.0.0.1; lan binds 0.0.0.0 and publishes the LAN address
--access-token-secretBearer credential; falls back to AFFILES_API_ACCESS_TOKEN_SECRET (the value, or where to read it: env:NAME, file[+FORMAT]:PATH#DOT_PATH, literal:VALUE)
--rootThe one directory to project. This is the security boundary: everything under it is reachable by whoever holds the URL. Point it at a directory nobody else writes to — containment is enforced by resolving each path, which a writer inside the root can race
--excludeHide matches entirely, listings included. A pattern without / matches a name at any depth (*.pem); one with / matches the whole relative path (secrets/**), and excluding a directory’s contents excludes the directory
--max-read-bytesCeiling on one read, whatever a request asks for
--no-symlinksFollow no symlink at all. The default follows one whose target is inside the root and refuses one whose target is not

affiles skill install

Install the skill.

skill-install-every-agent — Target every agent that supports the scope

affiles skill install [--agent all] [--scope <personal|workspace>] [--force]

skill-install-one-agent — Target one named agent; only this shape accepts –skills-dir

affiles skill install --agent <codex|claude-code|opencode|hermes> [--scope <personal|workspace>] [--skills-dir <DIR>] [--force]

Arguments across every shape above:

ArgumentMeaning
--agentAgent to manage
--scopeSkill scope
--skills-dirDirectory that contains skill folders
--forceOverwrite or remove an unmanaged Agent-First Files skill at the target path

affiles skill status

Report the installed skill state.

skill-status-every-agent — Target every agent that supports the scope

affiles skill status [--agent all] [--scope <personal|workspace>]

skill-status-one-agent — Target one named agent; only this shape accepts –skills-dir

affiles skill status --agent <codex|claude-code|opencode|hermes> [--scope <personal|workspace>] [--skills-dir <DIR>]

Arguments across every shape above:

ArgumentMeaning
--agentAgent to manage
--scopeSkill scope
--skills-dirDirectory that contains skill folders

affiles skill uninstall

Remove the skill.

skill-uninstall-every-agent — Target every agent that supports the scope

affiles skill uninstall [--agent all] [--scope <personal|workspace>] [--force]

skill-uninstall-one-agent — Target one named agent; only this shape accepts –skills-dir

affiles skill uninstall --agent <codex|claude-code|opencode|hermes> [--scope <personal|workspace>] [--skills-dir <DIR>] [--force]

Arguments across every shape above:

ArgumentMeaning
--agentAgent to manage
--scopeSkill scope
--skills-dirDirectory that contains skill folders
--forceOverwrite or remove an unmanaged Agent-First Files skill at the target path

affiles ui

Open, directly link, or publish one directory tree.

affiles ui --root <PATH> [--exclude <GLOB>...] [--max-read-bytes <BYTES>] [--no-symlinks] [--mode <window|link|session>]

Output: protocol events; --output json/yaml/plain (default json), --output-to stdout/stderr (default stdout).

ArgumentMeaning
--rootThe one directory to project. This is the security boundary: everything under it is reachable by whoever holds the URL. Point it at a directory nobody else writes to — containment is enforced by resolving each path, which a writer inside the root can race
--excludeHide matches entirely, listings included. A pattern without / matches a name at any depth (*.pem); one with / matches the whole relative path (secrets/**), and excluding a directory’s contents excludes the directory
--max-read-bytesCeiling on one read, whatever a request asks for
--no-symlinksFollow no symlink at all. The default follows one whose target is inside the root and refuses one whose target is not
--modeHow this reaches the person: window a browser window is open on this machine; link the page is reachable from this machine’s network at the link URL; session the session is registered only; open it with afui session open or reach it through afui session serve. Falls back to AFUI_DELIVERY, then window

Exit codes

CodeMeaning
0The command ran and succeeded.
1The command ran and failed. The event carries a domain error.code.
2The invocation was rejected before anything ran. error.code is one of the cli_* codes below.

The split is the useful one for a caller: exit 2 means the call was never made, so retrying it unchanged cannot help, while exit 1 means it was.

CLI errors

Every structural failure emits one strict JSON kind:"error" event on stderr, leaves stdout empty, and exits 2. The code names the failure — cli_unknown_argument for an unknown spelling, cli_unregistered_combination for registered arguments in a mixture that is not, and one each for cli_unknown_command, cli_missing_argument_value, cli_invalid_argument_value, cli_duplicate_argument, cli_unexpected_positional, and cli_invalid_utf8. message identifies a safe argument spelling or the failure category and hint gives the command to run next; neither ever quotes a raw value, including secrets. These are decided before any config, secret source, filesystem, network, or domain I/O.

Two exit-1 codes describe the tool itself rather than the call: cli_invocation_invalid means the program misread its own resolved invocation — an unknown action id, or an argument id the selected combination cannot produce — and output_setup_failed means an output sink (--stdout-file, --stderr-file, stream redirection) could not be established. Both are defects to report, not inputs to correct; retrying the same command cannot help.

Domain failures (exit 1) carry their own stable error.code instead, drawn from whatever this tool defines rather than from the cli_* set. Error events are routinely logged, so a message never quotes a value that came from an argument able to carry a credential — a header, a cookie, a token, a password, a proxy URL, an environment value, a form field. Such an error names the argument and the shape that was wrong, and stops there. A value that cannot be a secret — a path, a dot-path, a session name — is quoted, because an error that cannot say which one it means is not worth logging either.