companion-variable-definition

Declare and register Companion module variables using setVariableDefinitions and CompanionVariableDefinition.

Updated May 19, 2026
One-click install
npx skills add https://github.com/digitaldrummerj/bitfocus-companion-skills --skill companion-variable-definition-digitaldrummerj
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: companion-variable-definition
Source: https://github.com/digitaldrummerj/bitfocus-companion-skills/tree/main/plugins/companion-variable-definition
Command: npx skills add https://github.com/digitaldrummerj/bitfocus-companion-skills --skill companion-variable-definition-digitaldrummerj

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @companion-module/base.

What problem does it solve? Bitfocus Companion modules must declare variables before users can reference them in button text or the variable picker, and mistakes like invalid variableId characters or missing re-registration cause variables to silently not appear. This Skill provides the exact patterns for registering variable definitions correctly. ## Core Features & Use Cases - Static Variable Registration: Build and register CompanionVariableDefinition arrays via setVariableDefinitions() inside init(). - Dynamic Variable Sets: Generate per-channel variable definitions programmatically based on device capabilities like channel count. - Naming Validation: Enforce variableId rules allowing only alphanumeric characters and underscores. - Use Case: A module for an audio mixer needs variables for each of its 16 channels. Use this Skill to generate channel_1_level through channel_16_level definitions dynamically and re-register them whenever the device reports a new channel count. ## Quick Start Ask the agent to declare new Companion variables for your module and register them with setVariableDefinitions in init().

Frequently Asked Questions about companion-variable-definition

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

FAQPage Schema
How do I declare variables in a Bitfocus Companion module?▼

Build an array of CompanionVariableDefinition objects with variableId and name fields, then pass it to self.setVariableDefinitions(). Call this inside init() so the variables appear in Companion's variable picker as soon as the module loads.

How to create dynamic Companion variables based on channel count?▼

Build the definitions array programmatically by looping from 1 to the device-reported channel count and pushing entries like channel_1_level. Call setVariableDefinitions() again whenever the device reports a new capability set, since it replaces the entire registered set.

What characters are allowed in a Companion variableId?▼

A variableId may contain only alphanumeric characters and underscores. Hyphens, spaces, dots, and parentheses are invalid, so use my_variable instead of my-variable or my variable.

Why is my Companion variable not showing in the variable picker?▼

The variable was likely never registered with setVariableDefinitions(), or it was registered before init() completed. Define variables inside init() after this.config is set, and re-call the registration function whenever the variable set changes.

Does setVariableDefinitions also set variable values?▼

No, setVariableDefinitions only declares that variables exist so they appear in the picker. Values are set separately with setVariableValues(), which is covered by the companion-variable-set-value skill.