Skip to content

Install the Legion skill

Download the Legion skill, verify it, and install it in Claude Code, Claude, Codex, Cursor, VS Code and other agents that read Agent Skills.

On this page

After this page, your agent has the Legion skill and knows how to rent and manage GPUs on Legion, and when to ask you first.

The skill is a folder named legion with a SKILL.md file and a few reference files. It is plain Markdown. It has no scripts and nothing that runs by itself. An agent loads only the short description at first, and reads the rest when your request is about Legion.

Download it

The skill is one zip file. Its top-level folder is legion, which is what every client expects.

From a terminal:

Shell
curl -sSLO https://legion.ambient.xyz/docs/agents/legion-skill.zip
curl -sSLO https://legion.ambient.xyz/docs/agents/legion-skill.zip.sha256
shasum -a 256 -c legion-skill.zip.sha256

The last command should print legion-skill.zip: OK. The SHA-256 of the current zip is:

Text
064fb6bc090ea0a8069628de55bf1b919b8f7fbba08dee140e75d9a0866de051

The file SKILL.md is also served on its own at /docs/agents/skill/SKILL.md, for agents and tools that read one file.

Install the CLI, if your agent has a shell

Agents that run commands on your computer, such as Claude Code and OpenAI Codex, use the legion command line. It rents and stops GPUs like the MCP tools, and it also connects to a rental over SSH and copies files in and out. Install it in your own terminal:

Shell
curl -fsSL https://raw.githubusercontent.com/AmbientCrypto/legion-cli/main/scripts/install.sh | bash

It checks the release's SHA-256 and installs legion in ~/.local/bin. Then log in:

Shell
legion auth login

Your browser opens Legion. Sign in and approve Legion CLI: the CLI saves an API key named after your computer, with Full access, for 90 days. Revoke it in Settings, API keys, or with legion auth logout. Run the login yourself, not through the agent: it needs a terminal, and the agent never sees the key. On a machine with no browser, use legion auth login --paste with a key you made in the app. In CI, pipe a key to legion auth login --with-token, or set LEGION_API_KEY.

Claude on the web, Claude Desktop and the Claude mobile apps have no shell: there, connect the MCP server instead.

Set your API key, if you use curl

If you connect Claude with sign-in, there is no key for the MCP tools: connect Claude and the skill uses the tools. You need a key only for the skill's curl commands, and for any tool that calls the Legion API from a script. They read your key from the LEGION_API_KEY environment variable. Create a key for the agent in the app first: Settings, then API keys. Give it a name, and an expiry. See Safety.

In the terminal you start your agent from, read the key without showing it or saving it in your shell history:

Shell
read -rs LEGION_API_KEY && export LEGION_API_KEY

Paste the key and press Enter. Then start your agent from that same terminal. Never type the key into the agent's chat. If an agent asks you for it, say no.

If you connect the MCP server with a key, your client reads the key from the same variable, and the agent never needs curl.

Claude Code

Claude Code reads skills from two places:

  • ~/.claude/skills/legion/ for you, in every project;

  • .claude/skills/legion/ for one project, which you can commit so the team shares it. The skill holds no key, so committing it is safe.

For yourself:

Shell
mkdir -p ~/.claude/skills
unzip -o legion-skill.zip -d ~/.claude/skills

For one project, from the project's folder:

Shell
mkdir -p .claude/skills
unzip -o legion-skill.zip -d .claude/skills

Claude Code watches these folders. If it was already running and the skills folder is new, restart it. Then ask a question about Legion, and Claude uses the skill when the question matches its description.

Claude on the web, and Claude Desktop

  1. Make sure code execution is turned on in your Claude settings.

  2. Open Customize, then Skills, press +, then Create skill, then Upload a skill.

  3. Choose legion-skill.zip. Do not unzip it first, and do not zip the files yourself: the zip must have the legion folder as its root, as this one does.

  4. Turn the skill on.

Custom skills belong to your account. Each person on a team uploads their own.

Claude's code execution runs with network access that you or your administrator set, and it can be off. The skill's curl commands need it. If you cannot use the network there, connect the MCP server as a connector, which works without it.

The Claude API

Upload the skill with the Skills API, with the files named legion/SKILL.md and legion/references/<name>.md, then list the skill in the code execution container of your request. See Anthropic's Skills guide (opens in a new tab).

Code execution on the API has no network access, so the skill's curl commands cannot run there. Give your agent the MCP server as well, and it uses the tools instead.

OpenAI Codex, Cursor, VS Code, Gemini CLI and other agents

Agents that follow the open Agent Skills (opens in a new tab) format read a skill folder from a known place. The shared place is .agents/skills/legion/, in the project or in your home folder:

Shell
mkdir -p ~/.agents/skills
unzip -o legion-skill.zip -d ~/.agents/skills

For one project, use .agents/skills in its folder instead. These agents read it:

OpenAI Codex, Cursor, VS Code, Gemini CLI and other agents
AgentPersonal folderProject folder
OpenAI Codex~/.agents/skills/legion/.agents/skills/legion/
Cursor~/.cursor/skills/legion/, and it reads ~/.agents/skills and ~/.claude/skills.cursor/skills/legion/, .agents/skills/legion/
VS Code, GitHub Copilot~/.copilot/skills/legion/, and it reads ~/.claude/skills and ~/.agents/skills.github/skills/legion/, .claude/skills/legion/, .agents/skills/legion/
Gemini CLI~/.gemini/skills/legion/, ~/.agents/skills/legion/.gemini/skills/legion/, .agents/skills/legion/

Other agents that read Agent Skills, such as OpenCode, use .agents/skills/legion/ or their own folder. Check your agent's documentation for the folder, and unzip into it the same way.

Check that it works

Start your agent from the terminal where you set LEGION_API_KEY, and ask:

Text
What can the Legion skill do? Then tell me how much credit my Legion account has.

The agent should describe renting, spend and cleanup, and read your balance. If it does not mention Legion, check that the folder is legion/SKILL.md, not legion/legion/SKILL.md, and restart the agent.

Update it

To update, remove the old folder and install the new zip over it, so no old file is left behind:

Shell
rm -rf ~/.claude/skills/legion
unzip -o legion-skill.zip -d ~/.claude/skills

Use the folder your agent reads. Check the new zip's SHA-256 as above.

Next steps