Docs

CLI reference

View as Markdown

Every afile command in one place. Run afile <command> --help for a command's options.

npm i -g @afile/cli

It needs Node.js 24 or later, and installs two commands: afile, and afile-mcp for MCP.

Commands

CommandWhat it does
save <file | ->Save a file, or standard input, encrypted
itemsList this agent's items, newest first
show <item>Read one item: its name, size, version and links
get <item | link>Decrypt an item or a shared link to a file or standard output
update <item> [file | -]Save a new version, or rename or retag an item
delete <item>Delete an item and close every link to it
search <words>Find items by name, tag or note
secret <name>Save a secret from standard input
secretsList secret names, never their values
run --secret <name> -- <cmd>Run a command with secrets in its environment
share <item>Get a link that lets someone download one item
receiveGet a link where someone can send files to this agent
linksList this agent's open links and how often each was used
close <link>Close a link at once
connectConnect this agent to aFile and create its key
meShow this agent, its storage and whether a person is linked
keyShow this agent's key, or export it with --export
logoutForget the token and key on this machine
addAdd the aFile skill to your agents
removeRemove the aFile skill from your agents
mcpPrint MCP settings for Claude Code, Gemini CLI or OpenCode
instructionsPrint text your person can paste into any chat

The commands for your person, link, unlink, ask, asks, check, cancel and recipients, need a self-hosted aFile server.

Options for every command

OptionWhat it does
--jsonPrint the API's JSON, for scripts and agents
-y, --yesAnswer yes to every prompt
--api <url>Use another aFile API (https://api.afile.sh unless you say otherwise)
-h, --helpShow help
-v, --versionShow the version

Environment

VariableWhat it does
AFILE_TOKENUse an existing token
AFILE_CONFIG_DIRKeep a separate agent on the same machine
AFILE_API_URLUse another aFile provider

The token and key live in ~/.config/afile/credentials.json, readable only by you. afile logout forgets them on this machine, and doesn't delete anything at aFile.

Exit codes

0 means it worked, 1 means the request failed, and 2 means the command itself was wrong, such as an unknown command or a missing argument. With run, the exit code is the command's own.