Skip to main content
The agentgolf commands that customers use, with their arguments, flags, and exit codes. Add --help to any command for the same detail, for example agentgolf harness setup --help. agentgolf attribution --help also lists diagnostic commands for Agent Golf support, which this page does not describe. Workspace commands use the workspace that you selected when you logged in. harness setup --organization creates a key in the organization of that workspace. logout, otel-headers, and harness managed-settings with --endpoint do not use a workspace. Each command section lists only its own exit codes. For the meaning of each code, and the codes that every command can return, see Exit codes.

agentgolf login

Signs in with device authorization and saves the login for the API address that the CLI uses. It has no arguments or flags. See Log In. Exit codes: 1 when you deny the sign-in or the credential store fails. 4 when the code expires.

agentgolf logout

Removes the saved login for the API address that the CLI uses. It has no arguments or flags. Exit code 0 even when no login was saved. The CLI shows Logged out. in both cases.

agentgolf harness setup

Connects one harness on this machine to an uplink instance. With --all, it connects each harness that it finds on this machine. Give exactly one of <harness> and --all. The command:
  1. Signs you in when you are not logged in.
  2. With --organization, finds the organization of your workspace. It stops when the workspace has no organization, or when you cannot create a publishing key without a workspace.
  3. Without --endpoint, reads the endpoint of your workspace’s Cloud Uplink instance. It stops when Cloud Uplink is not on. With --organization, it also stops when your organization runs no Cloud Uplink instance.
  4. Reads the harness settings file. With --all, it reads the file of each harness that it found before it creates a key. When a setting already has another value, the command stops, names the setting, and creates no key. With --all, it skips only that harness. See All harnesses on the machine. For claude-code, it also opens the system keychain.
  5. Creates a personal publishing key for each harness that it sets up. This needs the Connect Your Harness permission. With --organization, the key has no workspace.
  6. Writes the harness settings: the endpoint, the key in the x-agentgolf-publishing-key header, and every content setting on. The Harness Setup card on Settings > Uplink > Publishing Keys shows the same settings. For claude-code, the command saves the key in the system keychain and writes a helper command in place of the header. See Claude Code and the system keychain.
  • The command keeps the file’s other settings, their order, and the TOML comments. When the file is a symbolic link with an existing target, the command updates the target. When the target does not exist, the command replaces the link with a file. The file gets mode 0600, because it can hold the key.
  • A file that a run of this command wrote already holds a key, so a second run for one harness needs --replace. After --replace, the earlier key stays valid. Revoke it in Settings > Uplink > Publishing Keys. For claude-code, the key in the system keychain counts in the same way. See Claude Code and the system keychain.
  • For copilot, an existing telemetry.headersProvider always counts as another value. The header file also gets mode 0600.
  • Copilot accepts comments and trailing commas in settings.json. The command reads only strict JSON, and refuses such a file. Remove them, or change a setting with copilot config: Copilot then writes the file again without them.
  • A running harness reads its settings only when it starts. Restart the harness after the command.
  • A Self-Hosted Uplink instance needs Uplink 0.1.22 or later to link sessions to the owner of the key.

Claude Code and the system keychain

For claude-code, the command saves the publishing key in the system keychain: the macOS Keychain, or on Linux the Secret Service, for example GNOME Keyring or KWallet. The entry has the service agentgolf and the user <environment>/claude-code/publishing-key, for example prod/claude-code/publishing-key for https://api.agent.golf. Each environment has one entry, so all Claude Code settings files of one environment use the same key, for example the files of two CLAUDE_CONFIG_DIR profiles. Claude Code then gets the key from agentgolf otel-headers through its otelHeadersHelper setting. agentgolf 0.1.11 added the system keychain. Codex and GitHub Copilot keep the key in their files, and omp gets it from the export lines.
  • The command writes the env block without OTEL_EXPORTER_OTLP_HEADERS, and adds "otelHeadersHelper": "agentgolf otel-headers". For an API other than production, the value is agentgolf otel-headers --environment <env>. The key never goes to settings.json.
  • When settings.json has an OTEL_EXPORTER_OTLP_HEADERS with another header, the command keeps that header and removes only the x-agentgolf-publishing-key entry.
  • Claude Code must find agentgolf on its PATH. The output of the command says this too. If Claude Code does not find it, replace the value with the full path of the binary, for example the output of command -v agentgolf. A value with the full path, for example /opt/homebrew/bin/agentgolf otel-headers, counts as the Agent Golf helper, and the command keeps it.
  • Claude Code runs the helper when it starts and every 29 minutes. When the helper fails, Claude Code exports nothing, and /status shows the error. See Dynamic headers.
  • A key that the system keychain already holds. When a run would replace the stored key, for example the setup of another settings file of the same environment, the command stops and creates no key. The message says that another Claude Code settings file can use the stored key. With --all, the command skips Claude Code and names the --replace command. With --replace, the command creates a new key, and each Claude Code settings file of the environment then uses it. The earlier key stays valid. Revoke it in Settings > Uplink > Publishing Keys.
  • Move from an earlier release. An earlier CLI wrote the key to OTEL_EXPORTER_OTLP_HEADERS in settings.json. Run the command again with the same endpoint, and without --replace, --organization, and --name. The command moves the key to the system keychain, rewrites the file, and creates no key. The output starts with Moved the publishing key from <path> to the system keychain. No key was created. --all moves the key in the same way.
    • When the system keychain already holds another key for the environment, the command stops as above.
    • In the other cases, the earlier header is a setting with another value, so the command needs --replace. With --replace, the command creates a new key, and the earlier key stays valid.
  • A second run. When the file has the helper and the endpoint of the run, and the system keychain has the key, a second run without --replace stops and creates no key. --all shows Already set up. When the file has the helper but the system keychain has no key, the command creates a key without --replace.
  • A device without a system keychain, for example a Linux server without a Secret Service. agentgolf harness setup claude-code stops with exit code 1 before it creates a key. --all skips Claude Code with one line, and sets up the other harnesses. The CLI never saves the key in a plain file by itself. To set up such a device, run agentgolf harness setup claude-code --print, and put the printed settings where you choose. They hold the key in OTEL_EXPORTER_OTLP_HEADERS.

All harnesses on the machine

With --all, the command sets up each Claude Code, Codex, and GitHub Copilot harness that it finds on this machine. It signs you in once, and reads the endpoint once.
  • --all does not include omp, because omp has no settings file. Run agentgolf harness setup omp for it.
  • The command creates one personal publishing key for each harness that it sets up. Each key has the default name, for example Grace's laptop (Codex).
  • When the file of a harness already holds the Agent Golf settings with a publishing key, the command creates no key for it and writes nothing. The output shows Already set up: <Harness> (<path>). No key was created for it. For Claude Code and Codex, this needs the same endpoint as the run. For Claude Code, the system keychain must also hold the key. Copilot settings hold no endpoint, so for Copilot it means only that the publishing-key file and the provider exist. After the line, the command prints the Copilot export lines. They always show the endpoint of the run.
  • With --organization, each Already set up line also names the command agentgolf harness setup <harness> --replace --organization, because the file cannot show the scope of the earlier key. --all never changes the scope of an existing key by itself.
  • When the file of a harness has another value for a setting, the command skips that harness: it creates no key for it and writes nothing. The output names the file, the values, and the command agentgolf harness setup <harness> --replace. That command also has --endpoint, --allow-insecure-endpoint, and --organization when your run had them. The command continues with the other harnesses.
  • So a second run with the same flags changes nothing and exits with 0.
  • The output shows the summary of each harness that the command set up, then one line for each harness that is already set up or that it skipped. For Copilot, the summary also has the export lines.
  • When the setup of a harness fails, the command stops with the error. Before the error, it writes to stderr the summary of each harness that it already set up, and the line of each harness that it skipped. Each harness that it set up keeps its key and settings, and a new run without --replace can show it as already set up. A skipped harness is not set up.
  • When the command finds no harness, it stops with exit code 3 and creates no key. Give the harness name in place of --all.

Keys without a workspace

With --organization, the command creates a personal publishing key without a workspace in the organization of your workspace. One such key works for all workspaces of the organization. Its sessions belong to the organization, and each workspace sees them through the organization session permissions.
  • The key works only on the uplink instances of the organization: the Cloud Uplink instance of the organization, and the Self-Hosted Uplink instances of the organization (Organization Settings > Uplink > Self-Hosted). It does not work on an uplink instance of a workspace.
  • Without --endpoint, your organization must run its Cloud Uplink instance. With --endpoint, give the endpoint of a Self-Hosted Uplink instance of the organization. The command cannot check that the instance belongs to the organization.
  • You need the Connect Your Harness permission in a workspace of the organization.
  • Without --name, the name of the key ends with organization, for example Grace's laptop (Claude Code, organization).
  • Revoke the key in Organization Settings > Uplink > Publishing Keys.
Examples:
Exit codes:
  • 1: a setting already has another value and you did not give --replace, or the settings file cannot be read, parsed, or written. For claude-code, also when the system keychain cannot be opened, or already holds a key that the run would replace without --replace. With --all, a settings conflict or one of these Claude Code keychain cases skips that harness. A file read or parse error stops the run before it creates a key. A write error stops further setup.
  • 2: you give both or none of <harness> and --all, or you give --all with --name or --print. Also when the --endpoint URL is not valid, or it is an http URL on a host that is not loopback without --allow-insecure-endpoint.
  • 3: your Agent Golf deployment does not offer Cloud Uplink. With --organization, also when your workspace has no organization. With --all, also when the command finds no harness.
  • 5: Cloud Uplink is off for your workspace, or you do not have Connect Your Harness. With --organization, also when your organization runs no Cloud Uplink instance, or your Agent Golf deployment does not offer keys without a workspace.

agentgolf harness managed-settings

Prints the managed settings document of one harness, for an admin who rolls out the settings to a team. agentgolf 0.1.10 added this command. The document holds the endpoint and the content settings. It holds no publishing key, and the command creates no key. Each developer then runs agentgolf harness setup --all to add their personal publishing key. When you gave --endpoint, each developer gives the same URL: agentgolf harness setup --all --endpoint <url>. See Roll out to a team.
  • The command writes only the document to stdout, so you can redirect it to a file. It writes one note to stderr that names where to install the file.
  • Without --endpoint, the command signs you in when you are not logged in, and reads the endpoint of your workspace’s Cloud Uplink instance. Cloud Uplink must be on.
  • With --endpoint, the command does not sign in and does not call the API. It checks the URL with the same rules as agentgolf harness setup.
  • The command does not accept omp, because omp has no settings file.
  • With --otel-headers-helper, the Claude Code document also names the helper agentgolf otel-headers, with --environment <env> for an API other than production. When you merge the env block into managed-settings.json, merge otelHeadersHelper too. A managed otelHeadersHelper wins over the value of each user. See Settings precedence. Each developer still runs agentgolf harness setup claude-code, which saves their personal publishing key in the system keychain, and needs agentgolf on the PATH of Claude Code. The command does not accept the flag for codex or copilot.
  • Install the managed helper only after each developer ran agentgolf harness setup claude-code with a release that saves the key in the system keychain, 0.1.11 or later. A helper that fails stops all exports of the device, also on a device that still has the static header of an earlier release.
Exit codes: 2 when the harness is not claude-code, codex, or copilot, you give --otel-headers-helper with codex or copilot, the --endpoint URL is not valid, or it is an http URL on a host that is not loopback without --allow-insecure-endpoint. Without --endpoint, also 3 when your Agent Golf deployment does not offer Cloud Uplink, and 5 when Cloud Uplink is off for your workspace.

agentgolf otel-headers

Prints the OTLP header with your Claude Code publishing key, for the Claude Code otelHeadersHelper setting. agentgolf harness setup claude-code writes this setting, and saves the key in the system keychain. Claude Code runs the command when it starts and every 29 minutes. agentgolf 0.1.11 added this command. See Claude Code and the system keychain.
  • The command reads only the system keychain. It does not read AGENTGOLF_API_BASE_URL, does not sign in, and does not call the network.
  • On success, stdout has one line: {"x-agentgolf-publishing-key":"<key>"}.
  • No message on stderr holds the key.
Exit codes: 3 when the system keychain has no key for the environment. Stdout is then empty, and stderr names agentgolf harness setup claude-code. For an environment other than prod, the message adds that AGENTGOLF_API_BASE_URL must name the API of that environment. 1 when the system keychain cannot be read.

agentgolf attribute

Links one of your own sessions to one GitHub pull request, when automatic attribution did not find the link. It has the same result as a manual link in the dashboard. You need the Attribute Own Sessions permission. For when to use a manual link, see Link a session by hand. On success, the command shows Associated <conversation-id> with <owner>/<repository>#<number>. When the link exists already, Agent Golf keeps it and the command succeeds. Exit codes: 2 when the URL is not a GitHub pull-request URL. 3 when you have no session with this ID, or your workspace has no such pull request. 5 when you do not have Attribute Own Sessions.

agentgolf attribution

agentgolf attribution audit reads the pull requests of your workspace and their linked sessions.

agentgolf attribution audit

Compares the automatic links of each pull request with its manual links and with the author of the pull request. The command reads each pull request that changed from --since up to, but not including, --before. You need the View Pull Requests and Repositories permission. For example, the pull requests that changed in October 2026:
Exit codes: 1 when the --before value is not valid, or it is not later than --since. 2 when a flag is missing, or the --since value is not valid. 5 when you do not have View Pull Requests and Repositories.

agentgolf mcp

Runs a read-only Model Context Protocol (MCP) server over standard input and output, for an AI tool on this machine. The AI tool starts the command. The server reads the workspace of your CLI login, with your permissions. It has no arguments or flags, and it needs CLI 0.1.5 or later. The command serves the AI tools on this machine. It has the tools of the remote Agent Golf MCP server, and also read_local_session, which reads local Claude Code, Codex, and GitHub Copilot CLI transcripts. For each tool and the permission that it needs, see MCP Tools. To connect an AI tool without the CLI, for example claude.ai or ChatGPT, use the remote server. See Connect an AI Tool with MCP. To add the server to an AI tool:
  1. Log in with agentgolf login.
  2. Add the server to the MCP settings of the AI tool. For example, Claude Desktop and Cursor use this form:
  3. Restart the AI tool. It lists the tools of the server.
  • A desktop app may not have the PATH of your shell. When the AI tool cannot start agentgolf, give the full path of the binary, for example the output of command -v agentgolf.
  • The server starts without a login. A tool that reads Agent Golf then returns an error that names agentgolf login. After you log in, the next call works without a restart.
  • The token of your login never appears in a tool result.
  • read_local_session reads only files on this machine. It needs no login and sends nothing to Agent Golf. Its excerpts enter the context of your AI tool. See read_local_session.
  • Some tools and transcript formats need a later CLI release. See Local transcripts for the versions. Run agentgolf --version to see your version.
Exit codes: 0 when the AI tool closes the connection. 1 when the MCP connection does not start, or fails.

Environment variables

harness setup also reads CLAUDE_CONFIG_DIR, CODEX_HOME, COPILOT_HOME, and HOME to find the settings file. With --all, it also reads PATH to find each harness. The login uses XDG_CONFIG_HOME on Linux. See Where the CLI keeps the login.

Output

  • The CLI writes the result to stdout. It writes the sign-in instructions, notes, and errors to stderr. agentgolf mcp writes only MCP messages to stdout, and agentgolf otel-headers writes only the header JSON.
  • Each error has the form error: <message>.
  • Each request to the API stops after 10 seconds.

Exit codes

Each command can also stop with 1 when your login is not valid or the CLI cannot reach the API, and with 4 when the API answers that it is not available for a short time.