resolve-codemode
by tsanirudh
README.md
# Resolve Code Mode
[Cloudflare's Code Mode](https://blog.cloudflare.com/code-mode/) applied to DaVinci Resolve:
instead of dozens of single-purpose MCP tools, Claude gets **four tools** and writes **one Lua
program** that does the whole job inside Resolve. Works on **Resolve Free 21.2** (macOS).
| Tool | What it does |
|---|---|
| `search_api` | Finds Resolve API methods. All 443 entries were **verified to exist on the running Resolve**, with measured notes (signatures, gotchas). |
| `execute` | Runs a Lua program. **Dry run by default**: reads hit the real project, changes are only recorded. `apply` snapshots the timeline first and **rolls back automatically** if the program errors. |
| `look` | Returns frames of the timeline as Resolve renders them, so Claude can check its own edit. |
| `rollback` | Undoes the last apply. |

## Benchmark
5 editing tasks on a copy of a real 11-minute, 4K timeline (64 clips), Claude Sonnet, headless,
graded by a checker inside Resolve. Tool calling = [davinci-resolve-mcp-free](https://github.com/emircbngl/davinci-resolve-mcp-free) (52 tools).
| | Tool calling | Code Mode |
|---|---|---|
| Tasks passed | 5/5 | 5/5 |
| Input tokens | 683,077 | **146,075** (4.7× fewer) |
| Cost | $0.48 | **$0.26** (47% less) |
| Wall time | 72 s | 62 s |
| Tool calls | 13 | 11 |

Per-task numbers: [bench/results.md](bench/results.md). One run per task, so treat it as an
indication, not a law. Most of the token difference is context: 52 tool definitions are sent
on every turn, 4 tools plus on-demand API search are not. In 3 of 5 tasks the tool-calling run
reached for its own `run_lua` escape hatch, i.e. it wrote code anyway.
## How it works
- **Transport**: Resolve Free 21.1.2+ has no external scripting and its Lua can't touch files,
so programs are typed into Resolve's Console window via macOS Accessibility (reusing
davinci-resolve-mcp-free's console channel) and the answer is read back.
- **Dry run**: [`runtime.lua`](resolve_codemode/runtime.lua) wraps the `resolve` object in a
proxy. `Get*`/`Is*`/`Has*`/`ExportFrame` pass through; every other call is recorded and, in
dry run, replaced by a stand-in.
- **API index**: the `.pyi` method reference is missing from the install, so candidate names
from Blackmagic's README/CHANGELOG are probed on live objects (`type(obj.Name) == "function"`).
## Setup
Needs macOS, DaVinci Resolve (Free or Studio, tested on 21.2 Free), Python 3.11+ and Claude Code.
```bash
git clone https://github.com/tsanirudh/resolve-codemode.git && cd resolve-codemode
python3 -m venv .venv && .venv/bin/pip install -e .
claude mcp add --scope user resolve-codemode -- "$PWD/.venv/bin/resolve-codemode"
```
This pulls in [davinci-resolve-mcp-free](https://github.com/emircbngl/davinci-resolve-mcp-free) from
GitHub for the Console channel. Then allow Claude Code in **System Settings → Privacy & Security →
Accessibility** (the entry is a lowercase `claude`) and restart it. Open Resolve with a project and ask
Claude to do something to your timeline.
- Rebuild the API index for your own Resolve version: `.venv/bin/python scripts/build_index.py`
- Tests: `.venv/bin/pip install pytest && .venv/bin/python -m pytest` (needs `luajit`)
- Benchmark: `.venv/bin/python bench/run.py` (needs `claude auth login`; edit `SOURCE` in
`bench/run.py` to a timeline in your project)
## Credits
The Console channel comes from [davinci-resolve-mcp-free](https://github.com/emircbngl/davinci-resolve-mcp-free).
The idea is Cloudflare's [Code Mode](https://blog.cloudflare.com/code-mode/). MIT licensed.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues