Skip to main content

pi-music-agent: Claude Code for sheet music

pi-music-agent lets you work with sheet music by talking to the Pi coding agent in plain English. You can say “write me a minuet in the style of these
pieces”, “fill in the gap in this score” or “rewrite this in F major”. Pi calls a fixed, tested music tool for each request. Pi never edits the tool’s
source code. The music is kept in ABC notation, a plain-text format that is easy for language models to read and write.

Composing a piece runs a loop:

  1. A composer LLM writes ABC.
  2. A validator checks it, and any errors go back to the composer for up to 5 retries.
  3. A critic LLM scores the result and triggers revisions.
  4. The piece is rendered to an HTML sheet-music viewer.

Tasks that can be exact are done without an LLM. Transposition, bar and gap analysis, and validation are all deterministic, so a transposed piece is
always correct. When filling a gap, a guard checks every bar outside the gap and rejects any edit that touches it.

The viewer shows the notation and has Play, Download MIDI, Print/Save PDF and Download .abc buttons.

n8n is the primary backend for validation, scan-to-notation conversion, an inbox workflow (drop a file in .input/ and it is converted, gap-filled and
rendered) and a compose webhook. If n8n can’t be reached, the agent falls back to local abcjs for validation and to local Audiveris and music21 for scans.
The LLM is swappable between OpenRouter (default Kimi K2.6) and a local Ollama model.

Offline smoke tests cover the music logic, the loop, the n8n client and the HTTP API, all with fake LLMs and no API key. The repo also has a live scenario
test for a gap fill and a composition, which I haven’t run because no API key was set.

Licensed GPL-3.0-or-later.

Technologies used

Languages and runtime

  • TypeScript 5 (strict, ESM)
  • Node.js 18+ (built and tested on Node 22)
  • JavaScript (n8n Code nodes and check scripts)

Built with

javascripthtmltypescript

Prize Categories Entered

  • DigitalOcean

    Best Open-Source AI Project

    Submitted
  • Event prize

    Best Use of n8n

    Submitted