Hans-Vader/squadjs-plugin-creator-skill
creating-squadjs-plugins
VerifiedUse when creating, writing, or scaffolding a new SquadJS plugin, adding a server-side feature to a Squad server via SquadJS, or deciding whether SquadJS can support a desired behaviour ("can SquadJS detect X / do Y on a Squad server?"). Covers the plugin lifecycle, the full event/RCON capability surface, and the hard limits that make some requests impossible.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.6 KB |
| references/api-reference.md | markdown | 16.8 KB |
| references/event-reliability.md | markdown | 7.0 KB |
| references/installation.md | markdown | 3.1 KB |
| templates/database-plugin.js | script | 3.8 KB |
| templates/discord-plugin.js | script | 2.6 KB |
| templates/minimal-plugin.js | script | 2.7 KB |
templates/minimal-plugin.js
View on GitHubimport BasePlugin from './base-plugin.js';
/**
* MINIMAL SQUADJS PLUGIN TEMPLATE — extends BasePlugin.
*
* Use for event-reactive plugins with no Discord output and no persistence.
* Rename the class, set the three static getters, declare your options, and
* register only the events you actually use.
*
* Place this file in <squadjs>/squad-server/plugins/ so the relative import
* './base-plugin.js' resolves. Register it in config.json under "plugins" with
* "plugin": "MyPlugin" (must equal the class name).
*/
export default class MyPlugin extends BasePlugin {
static get description() {
return 'One-sentence summary of what this plugin does (shown in the SquadJS docs).';
}
static get defaultEnabled() {
return false;
}
static get optionsSpecification() {
return {
commandPrefix: {
required: false,
description: 'Chat command word, without the leading "!".',
default: 'hello'
}
// A `required: true` option must be given a value in config that DIFFERS from
// its `default`, otherwise BasePlugin throws at load.
};
}
constructor(server, options, connectors) {
super(server, options, connectors);
// In-memory state. Clear it in unmount() (and on NEW_GAME if it is per-round).
this.state = new Map();
// Bind EVERY handler so `this` is the plugin instance when the event fires.
this.onChatCommand = this.onChatCommand.bind(this);
this.onNewGame = this.onNewGame.bind(this);
}
async mount() {
// The events registered here MUST be removed 1:1 in unmount().
this.server.on(`CHAT_COMMAND:${this.options.commandPrefix}`, this.onChatCommand);
this.server.on('NEW_GAME', this.onNewGame);
this.verbose(1, 'Mounted.');
}
async unmount() {
// It is removeListener / off — NOT removeEventListener. The server is a Node
// EventEmitter; removeEventListener does not exist on it and throws TypeError,
// leaking the listener. (Many bundled SquadJS plugins get this wrong.)
this.server.removeListener(`CHAT_COMMAND:${this.options.commandPrefix}`, this.onChatCommand);
this.server.removeListener('NEW_GAME', this.onNewGame);
this.state.clear();
this.verbose(1, 'Unmounted.');
}
async onChatCommand(data) {
// data = { player, message (text after the command), chat, steamID, eosID, time, ... }
// Reply privately to the caller. eosID is the primary id; steamID is the fallback.
await this.server.rcon.warn(data.player.eosID, 'Hello from MyPlugin!');
}
async onNewGame(data) {
// data.layer is the resolved layer. teamID is null transiently (~30s) right now,
// so do not trust team assignments here — see references/event-reliability.md.
this.state.clear();
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |