# Using it with AI agents

> Let Claude Code, Codex, Cursor or another coding agent export materials from Blender and wire them into your three.js project.

Blender to TSL docs · https://tools.ashthornton.dev/blender-to-tsl/docs/ai-agents/

An AI coding agent that can reach Blender can do the whole job for you: export a material from the file you have open, export the mesh it belongs to, add both to your three.js project, and tell you what it changed. The add-on gives the agent step-by-step instructions, so it follows the same process every time and stays in step with your version of the add-on.

## What you need

- **Blender to TSL** installed and enabled ([Getting started](https://tools.ashthornton.dev/blender-to-tsl/docs.md)).
- **The [Blender MCP add-on](https://www.blender.org/lab/mcp-server/)**, enabled and connected to your agent. It's the add-on from Blender Lab's extension repository, and needs **Blender 5.1 or newer**. On Blender 5.0, or with no MCP, the agent can [run Blender from the command line](#without-the-blender-mcp) instead.
- **Your .blend open in Blender, in Object Mode.**
- **A three.js project that renders with `WebGPURenderer`** from `three/webgpu`. If your project only uses the classic `WebGLRenderer`, the agent stops and asks before changing that.

## Set up your agent

The quickest way: copy this prompt and paste it into your agent, in your three.js project. It installs the skill in the way that fits it, checks it can reach Blender, and tells you what it did.

**Read the prompt first**

```text
Set up the blender-tsl-export skill from https://github.com/ashthornton/agent-skills so you can export Blender materials into this three.js project as TSL.

1. Install the skill in the way that fits you:
   - Claude Code: run `claude plugin marketplace add ashthornton/agent-skills` then `claude plugin install blender-tsl@ashthornton-tools`. If that CLI isn't available, ask me to type `/plugin marketplace add ashthornton/agent-skills` and `/plugin install blender-tsl@ashthornton-tools` myself.
   - Codex, Cursor, Copilot, Gemini CLI and other agents the skills CLI supports: run `npx skills add ashthornton/agent-skills --skill blender-tsl-export`.
   - Anything else: read https://github.com/ashthornton/agent-skills/blob/main/AGENTS-snippet.md and add those lines to this project's AGENTS.md (or your own instructions file).
2. Check you can reach Blender (5.0 or newer) with the Blender TSL Export add-on enabled: through the Blender MCP if it's connected, otherwise by running Blender headless from the command line.
3. Tell me what you installed, where, and anything I still need to do (such as restarting you so the skill loads).
```

Or set it up yourself. The skill teaches your agent to use the add-on whenever you ask for a Blender material, so your prompts can be short. It's [MIT-0 and on GitHub](https://github.com/ashthornton/agent-skills).

### Claude Code

Install it as a plugin, inside Claude Code:

```text
/plugin marketplace add ashthornton/agent-skills
/plugin install blender-tsl@ashthornton-tools
```

Updates then come through `/plugin`. `/skills` lists **blender-tsl-export** once it's loaded.

**Or install the skill from your purchase zip**

Unzip `blender-tsl-export-skill-<version>.zip` into `~/.claude/skills/` for all your projects, or into a project's `.claude/skills/` for that project only. You should end up with `.claude/skills/blender-tsl-export/SKILL.md`. Start a new session, or run `/reload-skills`.

### Codex, Cursor, Copilot, Gemini CLI and others

The same skill installs with the [`skills` CLI](https://skills.sh):

```bash
npx skills add ashthornton/agent-skills --skill blender-tsl-export
```

Add `-g` to install it for all your projects. `npx skills update` fetches newer versions.

### Agents without skills

Paste [these few lines](https://github.com/ashthornton/agent-skills/blob/main/AGENTS-snippet.md) into your project's `AGENTS.md` (or `CLAUDE.md`, `.cursorrules`, and so on). They tell the agent to use the add-on instead of writing its own converter, and where to find its instructions.

## Ask for a material

Start the agent in your **project's** folder, not Blender's, with Blender open. Then ask in plain words, naming the object or material:

```text
Bring the material on "Wall" from the open Blender file into this project.
```

More things you can ask:

- *Export every material in the open file into src/materials.*
- *Add the coral from Blender to the scene, with its vertex colours.*
- *Swap the placeholder material on the rock for the one in Blender.*

> **Without the skill**
>
> Add a second line so the agent uses the add-on instead of writing its own export: *Use the three.js TSL Material Export add-on's scripting API.*

## What the agent does

1. **Checks your project first:** the three.js version, the renderer, how three is imported, how meshes are loaded, and where static files are served from. It asks before changing anything big, such as your renderer or tone mapping.
2. **Exports the module and its images** with settings that match your project: import paths, texture folder and URL.
3. **Exports the mesh as `.glb`** when the material needs custom attributes, vertex colours or tangents. It works on a temporary copy, so your .blend isn't changed.
4. **Tells you about anything approximated**, by node name, from the export's notes.
5. **Wires the material into your code** and lists what it changed.

Then ask it to run your dev server and check the browser console for errors. It's also worth comparing against Blender from a similar camera angle.

## Without the Blender MCP

Agents can also run Blender from the command line, with no MCP and no Blender window open. The skill knows this route; the agent runs something like:

```bash
blender -b scene.blend --command tsl_export --material BrickWall --out src/materials
```

`--command tsl_export --help` lists every option. The add-on must be enabled in the Blender the agent runs, and Blender has to be on the agent's PATH (or tell it where `blender` is).

> **Git Bash on Windows**
>
> Git Bash rewrites arguments that look like paths, so `--texture-base-url /textures` turns into a Windows path. Put `MSYS_NO_PATHCONV=1` in front of the command. The skill does this for you.

## Tips

- **Save your .blend first** if the agent works from the command line: it reads the file on disk, not what's open in Blender.
- **Label the nodes you want to tweak** (Value and RGB nodes) before exporting. The labels become the uniform names in your code.
- **Name the object, not just the material**, when the mesh matters: the agent then exports the mesh with the right attribute names.
- If the agent says it **can't find the add-on**, check it's enabled in **Preferences ▸ Add-ons** in the Blender it's connected to.
