Skip to content

Managing from the CLI

The Alfe CLI is how you connect an agent from a terminal and keep it running. A small, always-on gateway daemon maintains the connection between the agent and Alfe: it stays online, relays messages, and lets the platform manage the agent’s lifecycle.

  • 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 host it provisions for you — so you rarely need to touch it, though you can connect to inspect the agent.

Install it with:

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

alfe setup is the interactive wizard that connects an agent on the machine you run it on. It authenticates you, installs and configures the agent runtime, initializes the workspace, and installs the gateway daemon as a system service so the agent stays online across reboots.

Terminal window
alfe setup

When it finishes, the agent is connected. It’s safe to re-run at any time to repair the connection or pick up new configuration.

Provision non-interactively: alfe setup --managed

Section titled “Provision non-interactively: alfe setup --managed”

alfe setup --managed runs the same connection flow without prompts, reading its configuration from environment variables. This is what Alfe uses to bring a managed host online automatically, and it’s also useful for your own unattended server provisioning.

Terminal
ALFE_API_KEY=<your-api-key> alfe setup --managed

It resolves the API key, writes the local configuration, installs and configures the runtime, initializes the workspace, and installs and starts the gateway daemon — all in one non-interactive pass. The result is an agent that comes back online automatically after a reboot.

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

Command What it does
alfe doctor Check configuration, authentication, and daemon health.
alfe whoami Show the connected identity.
alfe gateway status Show whether the daemon is connected.
alfe gateway restart Restart the daemon (reconnect to Alfe).
alfe gateway logs Tail the daemon logs.
alfe remove Uninstall Alfe’s integrations and revert their config.

alfe remove only removes Alfe’s own artifacts — it does not touch your agent runtime, its workspace, or anything else on the machine.

Configuration lives at ~/.alfe/config.toml and is written for you by setup — you don’t normally edit it by hand. See the CLI reference for the full command set.

You don’t have to use the CLI to run a managed agent — creating one from the dashboard handles all of this for you. The CLI is there when you want direct, scriptable control or need to connect a self-hosted agent. You can also manage agents programmatically over MCP and the Agent API.