editor-api

Guides writing ExecuteEditorCode TypeScript against the Lens Studio Editor API.

16|2|Updated Apr 13, 2026
One-click install
npx skills add https://github.com/lens-studio-devs/ls-extensions --skill editor-api-lens-studio-devs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: editor-api
Source: https://github.com/lens-studio-devs/ls-extensions/tree/main/plugins/ls-clad/skills/editor-api
Command: npx skills add https://github.com/lens-studio-devs/ls-extensions --skill editor-api-lens-studio-devs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing code for Lens Studio's ExecuteEditorCode tool is error-prone: the Editor API differs from Lens Scripting, interfaces have strict namespace rules, and common operations have dedicated tools that should be preferred. This Skill provides the contract, access patterns, gotchas, and reference snippets needed to write correct Editor API TypeScript on the first attempt. ## Core Features & Use Cases - Decision rules: Routes tasks to dedicated tools (scene-graphql, asset-graphql) when appropriate and reserves ExecuteEditorCode for bulk operations, custom traversals, and atomic multi-step mutations. - API access patterns: Documents pluginSystem.findInterface(Editor.Model.IModel) entry points and await import("LensStudio:<Name>") module loading, including the hidden-module rule. - Gotcha prevention: Encodes critical rules such as vec3-only transforms, Euler-degree rotations, ComponentNameMap keys, and JSON-serializable return values. - Reference library: Ships working snippets for asset operations, scene object operations, camera/rendering, presets, and project lifecycle (open, save, export, Lens metadata). - Use Case: When asked to create 64 scene objects in a grid or rename assets in bulk, consult this Skill to produce a single correct EEC snippet instead of guessing API signatures from editor.d.ts. ## Quick Start Ask the agent to write an ExecuteEditorCode snippet that creates a grid of scene objects in the current Lens Studio project.

Frequently Asked Questions about editor-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write ExecuteEditorCode snippets for Lens Studio?

Write an ES2021 async function body receiving a pluginSystem parameter, starting from pluginSystem.findInterface(Editor.Model.IModel) for scene or asset access. Return JSON-serializable values and wrap logic in try/catch, returning errors as strings.

When should I use ExecuteEditorCode versus scene-graphql tools?

Prefer dedicated tools like scene-graphql.createSceneObjectFromPreset or asset-graphql.setProperty for single operations. Use ExecuteEditorCode for bulk operations across many objects, custom traversals with filtering, and atomic multi-step mutations in one execution context.

What is the difference between the Editor API and Lens Scripting API?

The Editor API uses editor.d.ts types, pluginSystem.findInterface access, vec3 Euler rotations in degrees, and component names without the Component. prefix. Lens Scripting uses StudioLib.d.ts, script.getSceneObject(), quaternions, and prefixed names; code from one will not run in the other.

Why does addComponent fail with unknown entity type in Lens Studio?

The component string must exactly match a key in ComponentNameMap declared in editor.d.ts, such as LightSource instead of Light or BodyComponent instead of PhysicsBody. Grep interface ComponentNameMap in the project's Support/editor.d.ts for the canonical list.

How do I find Editor API signatures without reading all of editor.d.ts?

Grep the project's Support/editor.d.ts for the specific class with context flags, for example pattern="class SceneObject" with -B 30 -A 60. Interfaces like IModel are declared as class, so grep class IModel rather than interface IModel.

Can ExecuteEditorCode import hidden LensStudio modules?

Only modules declared in Support/editor.d.ts should appear as literal imports like await import("LensStudio:FileSystem"). Hidden modules must be loaded via a dynamic specifier built at runtime with explicit failure handling, and only in workflow-specific code.