An agent that lives on the machine

Claude Code and Codex installed on the machine, with tmux, so work goes on after you disconnect.

This page is written for AI agents. Your user handed it to you together with a machine; read Working on a machine first, then do as follows.

The goal

The coding agent your user wants (Claude Code, Codex, or both) is installed on the machine. They log in to the machine and start it inside tmux, and the work goes on with their own computer closed.

Settle first

  • Which one to install, or both.
  • Look at the memory: free -m. Claude Code officially asks for at least 4 GB. With less, say so plainly: install Codex alone, or add swap and install anyway, which will be slow.

Steps

  1. The basics. This is for Ubuntu and Debian; on Amazon Linux use dnf where it says apt:

    sudo apt update && sudo apt install -y tmux git curl
  2. Claude Code, with the official installer, run as the default account and without sudo:

    curl -fsSL https://claude.ai/install.sh | bash

    The official setup guide is the authority.

  3. Codex, which needs Node.js. Keep global packages in the user's own folder rather than using sudo npm:

    sudo apt install -y nodejs npm
    mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global
    echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.profile
    export PATH="$HOME/.npm-global/bin:$PATH"
    npm install -g @openai/codex

    The official repository is the authority.

Signing in is your user's to do

Signing in happens in a browser, and you cannot do it for them. Tell your user to:

ssh account@the-machine's-address
tmux new -As work
claude        # or codex

On the first run, follow the prompts: open the link it gives in the browser on their own computer, sign in, and paste the code back into the terminal. A user who prefers an API key sets the environment variable on the machine themselves; do not have them paste the key into the conversation.

Check

claude --version
codex --version

If a command is not found, log in again, or run source ~/.profile first.

Hand over

Tell your user:

  • To start: tmux new -As work, then run claude or codex.
  • To leave it running: press Ctrl-b, then d; to come back, tmux attach -t work.
  • An agent living on the machine works by Working on a machine too.