# Using Axle with AI agents

Let AI coding agents such as Claude Code, Cursor, GitHub Copilot and Gemini CLI ask Axle about your repository and run its tasks.

An AI coding agent that knows Axle doesn't have to read every `package.json` to find out how your repository fits together, or guess which packages to build after a change. Through Axle's [MCP server](https://axlers.dev/docs/reference/mcp.md) it asks Axle directly, and runs builds and tests the way you do, with the cache.

## Set up the agents

Run this at the root of the repository:

```sh
pnpm exec axle setup agents                     # pnpm
npx axle setup agents                           # npm
yarn axle setup agents                          # Yarn
bunx axle setup agents                          # Bun
nubx axle setup agents                          # nub
aube exec axle setup agents                     # aube
```

It writes the configuration for Claude Code, Cursor, GitHub Copilot in VS Code and Gemini CLI, keeping whatever else those files hold. To set up one agent, add `--agent claude`, `cursor`, `vscode` or `gemini`; to see the changes first, add `--dry-run`. Commit the files, so everyone on the team gets the same setup.

The next time the agent opens the repository, it starts `axle mcp` itself. Most agents ask once before they use a new server.

## Telling the agent how to work

The same command writes a few lines of guidance where each agent reads its instructions: a section of `AGENTS.md` at the root for Cursor, GitHub Copilot and Gemini CLI, and a skill in `.claude/skills/axle/SKILL.md` for Claude Code. They tell the agent to run tasks through `axle run` instead of the package manager, to run `axle run build test --affected` before committing, how to see what a change affects and why a task missed the cache, and where the settings are, all with the command that runs Axle in your repository, such as `pnpm exec axle`.

Write your own instructions anywhere else in `AGENTS.md`. Axle only touches the lines between its two markers, and running `axle setup agents` again brings them up to date. [Setting up agents](https://axlers.dev/docs/reference/mcp.md#setting-up-agents) lists each file.

A task's [`description`](https://axlers.dev/docs/reference/configuration.md#tasks) in `axle.toml` helps too: the agent sees it in the task lists the MCP server gives, so it can tell `check` from `lint` without reading the scripts.

## What the agent can do

- **Find its way around:** list the projects, with their folders, scripts and dependencies, or only those a [filter](https://axlers.dev/docs/reference/run.md#choosing-packages) chooses.
- **Read a project's settings:** each task's inputs, outputs and dependencies, and where each setting came from.
- **Plan a change:** which tasks a run would include, and which packages a change affects.
- **Run tasks:** build, test or lint with the cache, and get back each failed task's last 200 lines of output.
- **Understand the cache:** why a task ran instead of coming from the cache.

Ask in plain words, such as "build everything my change affects and fix what fails". The agent picks the tools.

## Safety

Only `run_tasks` changes anything, and it runs your own scripts, as `axle run` would. It never skips the cache with `--force`, and it doesn't start persistent tasks such as dev servers. Everything happens on your machine; the server opens no port and sends nothing anywhere.

## Reading the documentation

An agent that needs to know how Axle works can run [`axle docs`](https://axlers.dev/docs/reference/docs.md) with a few words, such as `axle docs affected --json`, to find the pages about them. Each page of this documentation is also published as Markdown at its address with `.md` in place of the last `/`, such as `https://axlers.dev/docs/reference/run.md`, and [`https://axlers.dev/sitemap.md`](https://axlers.dev/sitemap.md) lists every page. Point an agent there instead of at the HTML: it reads less and the links between pages lead to more Markdown.

## Other agents

An agent that can start an MCP server over standard input and output can use Axle too. Configure it to run `axle mcp` in the repository's root folder, or, when Axle is only installed in the repository, `node node_modules/@axle-rs/axle/bin/axle.js mcp`. Avoid `npx` and `pnpm exec` there: on Windows they're scripts, which many agents can't start without a shell.
