Skip to content

Managing from the CLI

The Alfe CLI connects an agent from a terminal and keeps it running. It installs a small, always-on gateway daemon that keeps the agent connected to Alfe.

  • On a self-hosted agent, you run the CLI on your own machine or server.
  • On a managed agent, Alfe runs the same CLI on the machine it provisions, so you rarely need to touch it.

Install it with:

Terminal window
npm i @alfe.ai/cli -- -g

alfe setup connects an agent on the machine you run it on. It needs that agent’s key, which you generate on the agent’s Overview tab.

Terminal
ALFE_API_KEY=<SETUP_TOKEN> alfe setup

It’s safe to re-run at any time to repair the connection or apply a runtime change.

alfe setup --managed runs the flow without prompts, reading its configuration from environment variables. Alfe uses it to bring a managed machine online, and it also suits your own unattended provisioning.

Terminal
ALFE_API_KEY=<SETUP_TOKEN> alfe setup --managed

Once an agent is connected, a few commands cover most operation:

Command What it does
alfe doctor Check configuration, the API key, the daemon, and the runtime.
alfe whoami Show the connected identity and runtime.
alfe gateway status Show whether the daemon is connected.
alfe gateway restart Restart the daemon.
alfe gateway logs Tail the daemon logs.
alfe runtime switch <runtime> Move the agent to another runtime.
alfe remove Uninstall Alfe’s integrations and revert their config.

Configuration lives at ~/.alfe/config.toml, and setup writes it for you. See the CLI reference for the full command set.

You don’t need the CLI to run a managed agent. Creating one in the dashboard handles all of this, and the agent’s Maintenance controls cover restarts. Agents can also work for themselves over MCP and the Agent API.