Installing AI Coding Agents
Coder workspaces provide a relatively safe way to experiment with AI coding agents, like Claude Code, Gemini CLI, or Open AI’s Codex. These tools, which generate and also execute code, can be useful but they are also inherently dangerous. Simon Willison has identified dozens of examples of “prompt injection” attacks, which can trick AI tools into running nefarious code. Because Coder workspaces are isolated virtual machines, the potential damage a rogue AI agent running in a workspace can cause is reduced (but not eliminated).
To use an AI coding agent, you will most likely need an API key from an LLM provider. We are not able to provide API keys.
Most AI coding agents are distributed as NodeJS packages, so we need to install nodejs and a package manager (we’ll use pnpm).
# use pixi to install nodejs and pnpm
$ pixi global install nodejs pnpmThe package manager, pnpm, has a setup script that we need to run so that the tools we install are available in the $PATH.
# setup pnpm
$ pnpm setup
# update our current $PATH variable
$ source /home/coder/.bashrcYou should now be able to install and run your coding agent. For example, to install the Gemini CLI:
# install gemini
$ pnpm install -g @google/gemini-cli
# create a new workspace to run the agent in
$ mkdir workspace
$ cd workspace
# set any credentials as environment variables
export GOOGLE_CLOUD_PROJECT=...
export GEMINI_API_KEY=...
# run gemini
$ gemini