agentafk

Install afk on your computer

Install, update, and remove afk on macOS, Linux, or Windows.

Install the agent-afk npm package to get the afk command. It runs on macOS, Linux, and native Windows. WSL2 is an alternative if you prefer a Linux environment on Windows.

Requirements

  • Node.js matching ^22.22.2 || ^24.15.0 || >=26.0.0. In plain terms: Node 22.22.2 or newer within 22.x, Node 24.15.0 or newer within 24.x, or Node 26 and later.
  • npm, available with a standard Node.js installation. You do not need pnpm to install the published CLI.
  • A terminal and access to a configured model provider, or a local model server.
  • Git if you want to use repository and worktree workflows.

Install for your platform

Check Node.js

Use a supported Node.js installation, then verify it in your terminal:

node --version
npm --version

Install the CLI

npm install -g agent-afk
afk --version

If the executable is not found, check that your Node installation's global npm binary directory is on PATH.

Authenticate and check the installation

On an unconfigured install using Claude, start with:

afk login
afk doctor

afk login reuses an existing Anthropic credential when one is available, or prompts for a key or OAuth token and saves it. It is not a browser sign-in command. See API keys and authentication for other providers and credential sources, then follow the Quickstart for your first model request.

Bring an existing setup

If you have Claude Code or Codex plugins, skills, or MCP configuration, preview an import:

afk migrate --dry-run

Run afk migrate to review and confirm the detected sources. It records a trust grant and live-reads the source directories on later sessions rather than copying the files. MCP servers are excluded unless you pass --mcp, because they can run commands at startup. -y skips the confirmation for a deliberately unattended import. See Migrate an existing setup before granting that trust.

Shell completion

afk completion requires a shell name and prints a completion script. Supported shells are zsh, bash, and fish, not PowerShell. Add the appropriate line to your shell startup configuration to load it in future terminals:

Enable zsh's completion system before loading the script:

autoload -Uz compinit
compinit
eval "$(afk completion zsh)"

Optional worktree shell integration

The optional shell-init wrapper lets afk change your parent shell's directory into a preserved worktree after a session exits. Without it, afk can print the directory but cannot change your shell's working directory.

For bash or zsh, add this line to your shell startup configuration:

eval "$(afk shell-init)"

For fish:

afk shell-init fish | source

This defines an afk shell function and replaces any existing alias or function with that name. It is separate from completion, and is not required to run afk. It does not provide a PowerShell wrapper.

Update afk

afk update --check
afk update

--check reports whether a newer version exists without installing it. afk update installs the latest published version through npm using the running Node installation. afk upgrade is an alias. Use --pin with a specific published version if you need to install that version instead of the latest.

Automatic update behavior is controlled by updatePolicy:

ValueBehavior
notifyDefault. Check for updates and show a notice.
autoAlso trigger a background update when a newer version is detected.
offDisable the automatic update check. Explicit afk update still works.

To disable automatic checks:

afk config set updatePolicy off

Use Editing configuration for other values and configuration scope. For service behavior and all update options, see Run as a service and the CLI reference.

Uninstall

If you installed background services, remove them through afk service uninstall before removing the CLI. See Run as a service for service names and removal steps.

Remove the npm package:

npm uninstall -g agent-afk

This does not erase your saved configuration, credentials, or sessions under ~/.afk/. Remove any completion and shell-init lines you added to your shell startup files. Keep or back up the state directory unless you deliberately want to remove that data too.

On this page