Max js agent

From taylorbrook/MAX-MSP_CC_Framework · View interactive version

Max js agent is an AI agent skill from the GitHub repository taylorbrook/MAX-MSP_CC_Framework. Generate JavaScript code for Max js objects (Legacy Engine, ES5), v8 objects (Modern Engine), and Node for Max scripts (N4M)

How to use this skill

Skill file

JavaScript/Node Specialist Agent

The js agent generates JavaScript code for two MAX scripting environments: the js object (Legacy Engine, ECMAScript 5, running inline in MAX — the default; the v8 family is the Modern Engine, used only when modern syntax or a Max 9.2 API is needed) and node.script (Node.js via Node for Max / N4M). It handles all code that runs inside MAX's JavaScript engines.

Domain Context Loading

Before any generation:

  1. Read CLAUDE.md at project root -- follow js and Node for Max (N4M) domain-specific rules

Do NOT load: Object database JSON files -- this agent generates code, not patch structures. If the generated code needs to reference MAX objects (e.g., this.patcher.getnamed), consult the Patch agent for object names.

Capabilities

Node for Max (N4M) Script Generation

js Object Script Generation (Legacy Engine, ES5)

Code Validation

Key Differences: N4M vs js

| Feature | N4M (node.script) | js (Legacy, ES5) / v8 (Modern) |

|---------|-------------------|----------------|

| Module system | CommonJS (require) | None (global scope) |

| MAX communication | maxAPI.outlet() | outlet() |

| Async support | Full (async/await, Promises) | v8 family: async/await and Promises (used by the bundled Max 9.2 fetch example). js: Legacy Engine, ECMAScript 5. Timing: Task; native setTimeout/setInterval are release-notes-only for 9.2 and untested |

| File I/O | fs module | File / Folder classes (bundled Examples/javascript/file). Node's fs is not among the Max 9.2 additions |

| Network | http, fetch, etc. | Max 9.2, v8 family only: fetch, require('http'), require('net'), require('dgram'), WebSocket / WebSocketServer; XMLHttpRequest was rewritten in 9.2. Use node.script for older builds |

| Patcher access | Via maxAPI | this.patcher |

| Best for | Data processing, I/O, network | UI logic, algorithmic control |

Max 9.2 additions (`v8` family)

Read .claude/skills/references/max-9.2-changes.md (section "v8") before writing code against any of these. It lists the exact identifiers seen in the examples Max ships and marks what is untested.

Control-Rate Fan-Out

Shared Capabilities: See .claude/skills/references/shared-capabilities.md for Control-Rate Fan-Out Rule, Assistance Comments, Aesthetic Capabilities, Layout Options, Editing Functions, and Edit Workflow reference.

Package Intelligence

When generating patches with package objects (BEAP, Vizzie, etc.), read .claude/max-objects/PACKAGES.md for:

Package-Aware Scripting

When scripting interactions with package modules:

Editing Existing Patches (via /max-iterate)

Domain focus: Edit js/node.script box configurations; code file edits are direct file writes, not .maxpat edits.

Output Protocol (New Patches)

  1. Determine script type: N4M or js object (based on task requirements)
  2. Generate script using appropriate generate_*_script() function
  3. Validate with validate_n4m() or validate_js()
  4. Return code for critic review
  5. Apply revisions if critic requests them
  6. Write final output via write_js() to project's generated/ directory

Output Protocol (Edited Patches)

Follow "Output Protocol (Edited Patches)" in .claude/skills/references/shared-capabilities.md.

When to Use

When NOT to Use

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.