projects/sdk/agents/SKILL.md
name: fluxerly description: Build, configure, diagnose and test Fluxer bots with @neontechspace/fluxerly (Fluxerly.js) in JavaScript, TypeScript or Effect on Node.js
Fluxerly.js bot skill
Use this skill when building, updating, diagnosing or testing a Fluxer bot or application with @neontechspace/fluxerly (Fluxerly.js)
Requirements
- Runtime: Node.js 26.13 or newer, ESM-only (
"type": "module"inpackage.json) - TypeScript: Node.js runs
.tsdirectly without building. Type checking requires TypeScript 7 and@types/node - Entry points:
@neontechspace/fluxerly,@neontechspace/fluxerly/effect,@neontechspace/fluxerly/testingand@neontechspace/fluxerly/effect/testing. Never import fromdistorsrc - Native Effect API (
@neontechspace/fluxerly/effect): Effect 4 matching the installed package'speerDependencies.effectrange
Fast start and CLI commands
Install or scaffold a runnable bot project with tests:
| 1 | npm install @neontechspace/fluxerly |
| 2 | pnpm dlx @neontechspace/fluxerly init --template ts --dir my-bot |
| 3 | # Templates: js | ts | effect. Options: --dir <folder>, --pm npm|pnpm|bun, --no-install |
Run offline project verification, redacted triage, agent instruction sync and invite URL generation:
| 1 | pnpm exec fluxerly doctor --dir my-bot --json --strict |
| 2 | pnpm exec fluxerly triage --print |
| 3 | pnpm exec fluxerly triage --json |
| 4 | cat bot.log | pnpm exec fluxerly triage --log - --print |
| 5 | pnpm exec fluxerly triage --run "node bot.ts" --timeout 60s |
| 6 | pnpm exec fluxerly agents --target all |
| 7 | pnpm exec fluxerly agents --check |
| 8 | pnpm exec fluxerly invite <applicationId> --permissions ViewChannel,SendMessages,ReadMessageHistory |
| 9 | # Pass --help to any subcommand for full flags and options |
Keep FLUXER_BOT_TOKEN in .env (never in code, logs or commits) and start with node --env-file-if-exists=.env bot.ts (or bot.js)
Non-negotiable SDK rules
- Import only from
@neontechspace/fluxerly,@neontechspace/fluxerly/effect,@neontechspace/fluxerly/testingor@neontechspace/fluxerly/effect/testing, never fromdistorsrc - Use
defineBotandrunBotfor bots, starting only underif (import.meta.main)so tests can importbotwithout connecting. UsecreateClient({ token })only for manual lifecycle control - In the default API, every network call returns
ResultAsync. Alwaysawaitand checkresult.isErr(), unwrap withawait orThrow(...), or return theResultAsyncfrom a handler so the SDK reports expected failures - Read the bot token from
process.env.FLUXER_BOT_TOKENand never hardcode or log it - Use only methods declared in
node_modules/@neontechspace/fluxerly/dist/api/default/*.d.ts(ordist/api/effect/*.d.ts) - Test every bot behavior with
createTestBotfrom@neontechspace/fluxerly/testing(or@neontechspace/fluxerly/effect/testing) before running live - Diagnose failures with
FLUXERLY_LOG_FORMAT=json,fluxerly doctor --json --strictandfluxerly triage --print, matching onLogRecord.codeandErrorInfofields rather than log prose
Patterns that do not exist in Fluxerly
- No
new Client()orclient.login(token): UserunBot({ token, ...bot }), orcreateClient({ token })followed byclient.run() - No intents: Fluxer delivers events by permissions, visibility and subscriptions (member presence updates use
client.presence.setMembers) - No slash commands or interactions: Commands are prefix commands under
runBot({ commands: { prefix, commands } }) - Messages and channels are read-only data without methods: No
message.reply(),message.delete()orchannel.send(). Use handler{ reply }orclient.messages.send(channelId, content) - Event handlers in
runBotreceive a context object{ message, reply, client, signal }, not a bare message - Bot authors use
message.author.isBot, notmessage.author.bot(runBotalready skips bot messages unlessignoreBots: false) - Communities are named guilds in SDK identifiers such as
guildId - Voice signaling uses
client.voice(join,leave,updateState) withvoiceStateUpdate,voiceServerUpdate,voiceSignaland opcode 12gatewayErrorevents while keepinggateway.ignoredEvents: "auto". Built-in audio transport is planned for Fluxer's own voice engine, and bots needing audio today pass the typedvoiceServerUpdategrant to their own media client
Minimal testable TypeScript bot
Keep options in an exported defineBot object and start under import.meta.main so tests import bot without connecting:
| 1 | import { EmbedBuilder, commands, defineBot, format, guards, runBot } from "@neontechspace/fluxerly" |
| 2 | |
| 3 | export const bot = defineBot({ |
| 4 | commands: { |
| 5 | prefix: "!", |
| 6 | parse: commands.parseQuoted, |
| 7 | commands: { |
| 8 | ping: { |
| 9 | description: "Reply with Pong", |
| 10 | execute: ({ reply }) => reply("Pong!"), |
| 11 | }, |
| 12 | say: { |
| 13 | guard: [guards.guildOnly(), guards.requirePermissions(["SendMessages"])], |
| 14 | cooldown: { durationMs: 10_000, per: "user" }, |
| 15 | arguments: { text: { type: "text", rest: true } }, |
| 16 | execute: ({ values, reply }) => reply(values.text), |
| 17 | }, |
| 18 | help: { execute: ({ sendHelp }) => sendHelp() }, |
| 19 | }, |
| 20 | }, |
| 21 | events: { |
| 22 | messageCreate: ({ message, reply }) => { |
| 23 | if (message.content !== "!info") return |
| 24 | const embed = new EmbedBuilder().title("Channel").description(format.channelMention(message.channelId)) |
| 25 | return reply({ embeds: [embed] }) |
| 26 | }, |
| 27 | }, |
| 28 | }) |
| 29 | |
| 30 | if (import.meta.main) await runBot({ token: process.env.FLUXER_BOT_TOKEN, ...bot }) |
- Guards and stages:
guards.guildOnly(),dmOnly(),ownerOnly(ids?),guildOwnerOnly(),requirePermissions(names),requireBotPermissions(names),requireRoles(roleIds, options?)and post-parsecanManage(argumentName, options?)inafterParse. Community guards narrowcontext.message.guildIdtostringacrossafterParse,cooldown.keyandexecute - Arguments and command context: Argument schemas support
default(text,boolean,choice,custom),minLength/maxLength(text) andcaseInsensitive(choice). Cooldowns use{ durationMs, per: "user" | "channel" | "guild" }. Context provideshelp()(including focusedhelp({ command })),sendHelp(),confirm(prompt, options?),paginate(pages),clientandsignal - Lifecycle and multi-event queues: The
runBotfunction skips bot messages (ignoreBots: falsedisables), stops cleanly on SIGINT and SIGTERM (processSignals: falsedisables), logs fatal failures once and sets exit code 1. Useclient.onMany(events, handler, { partition })for shared per-key ordered queues (includingthreadMemberUpdate) andusing(Symbol.dispose) orclose()onScheduledTask - Builders and helpers: Pass
MessageBuilder(.tts(),.nonce(),.suppressEmbeds(),.suppressNotifications(), dynamicaddEmbeds) directly to sends and replies, and useEmbedBuilder.from,.clone()and.image(url)/.thumbnail(url)/.footer(text). Helpers includepermissionBits.overwrite,format,links,snowflakes,display,assets,textandcolors(keep IDs as decimal strings) - Attachments, collectors and lookups: Use
client.attachments.download(attachment, { maxBytes })orclient.attachments.stream(attachment, { maxBytes }),client.messages.collect,collectReactions(emoji arrays and opt-inincludeRemovals),confirm,client.roles.fetchCanManageandclient.members.fetchCanManage(withpreferCache),client.gateway.fetchBot,client.application.fetchPublic,oauth.createState()andoauthClient.request
Zero-network bot test
| 1 | import assert from "node:assert/strict" |
| 2 | import { test } from "node:test" |
| 3 | import { createTestBot } from "@neontechspace/fluxerly/testing" |
| 4 | import { bot } from "./bot.ts" |
| 5 | |
| 6 | test("commands answer as expected", async () => { |
| 7 | await using testBot = createTestBot(bot) |
| 8 | await testBot.ready() |
| 9 | |
| 10 | const replies = await testBot.say("!ping") |
| 11 | assert.deepEqual(testBot.failures(), []) |
| 12 | assert.deepEqual( |
| 13 | replies.map((message) => message.content), |
| 14 | ["Pong!"], |
| 15 | ) |
| 16 | }) |
- Controls:
ready(),say(),emit(),fixtures,rest.respond(),requests(),commands(),logs(),counters(),failures(),idle(),disconnect()andclock: "manual"withadvance(ms) - Run tests with a timeout and forced exit:
node --test --test-timeout=30000 --test-force-exit
Results, error handling and raw access
| 1 | import { createClient, describeError, errors, orThrow, type Attachment } from "@neontechspace/fluxerly" |
| 2 | |
| 3 | export async function sendAndInspect(channelId: string, attachment: Attachment) { |
| 4 | await using client = createClient({ token: process.env.FLUXER_BOT_TOKEN }) |
| 5 | |
| 6 | client.on("raw", (dispatch) => { |
| 7 | if (dispatch.documented && dispatch.t === "FORUM_UNREADS") void dispatch.d.channel_id |
| 8 | }) |
| 9 | |
| 10 | const sent = await client.messages.send(channelId, "Hello") |
| 11 | if (sent.isErr()) { |
| 12 | if (errors.isNotFound(sent.error, "channel")) return |
| 13 | if (errors.apiCode(sent.error) === "missingPermissions") return |
| 14 | if (errors.isRetryable(sent.error) && errors.outcome(sent.error) === "notDispatched") { |
| 15 | const waitMs = errors.retryAfterMs(sent.error) |
| 16 | if (waitMs !== undefined) await new Promise((resolve) => setTimeout(resolve, waitMs)) |
| 17 | } |
| 18 | errors.match(sent.error, { |
| 19 | MessageError: (error) => console.warn(error.reason), |
| 20 | _: (error) => console.error(describeError(error, { color: "auto" })), |
| 21 | }) |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | const bytes = await orThrow(client.attachments.download(attachment, { maxBytes: 1_048_576 })) |
| 26 | return { messageId: sent.value.id, byteLength: bytes.byteLength } |
| 27 | } |
- Inspect failures with
errors.apiCode(error),errors.isNotFound(error, resource?)(including"ban"forUNKNOWN_BAN, noting hidden community channels also return HTTP 404UNKNOWN_CHANNEL, with EffectCauseunwrapping),errors.isRetryable(error),errors.retryAfterMs(error),errors.outcome(error)anderrors.match(error, handlers) - Retry safety: Never repeat a write whose
errors.outcome(error)is"unknown"orundefinedwithout checking Fluxer's state first. Waiterrors.retryAfterMs(error)when present, use a fresh stream or bytes whendetails.streamUsedis true, and create a new client after a failedclient.run() - Structured inspection: Read
error.hint,error.inputValidation(path,constraint,explanation),error.apiError(code,providerCode,validationErrors),error.details.requiredPermissionsanderror.details.streamUsed. Format errors withdescribeError(error, { color: "auto" })and failure reports withreport.describe({ color: "auto" }) - Raw access: Use
client.rest.call("METHOD /path/{param}", { params, query, body })(typed Fluxer routes),client.rest.request(unlisted routes),client.gateway.send(raw opcodes) andclient.on("raw", (dispatch) => ...)(checkdispatch.documentedbefore narrowing ondispatch.t)
Logging, error codes and diagnostics
Capture machine-readable logs and run offline diagnostics instead of scraping ANSI output:
| 1 | FLUXERLY_LOG_FORMAT=json FLUXERLY_DEBUG=rest,gateway node --env-file=.env bot.ts |
| 2 | FLUXERLY_LOG_COLOR=0 node --env-file=.env bot.ts |
| 3 | NO_COLOR=1 node --env-file=.env bot.ts |
- Environment controls:
FLUXERLY_LOG_FORMAT=jsonemits one JSONLogRecordper line.FLUXERLY_LOG_COLOR=0or non-emptyNO_COLOR=1disables color (emptyNO_COLOR=""leaves color enabled, andFORCE_COLOR=0orTERM=dumbdisables automatic color).FLUXERLY_DEBUG=1or a comma-separated list enables Debug across the 10 categories:lifecycle,gateway,rest,ratelimit,cache,events,commands,collectors,supervisor,sdk LogRecordfields: Inspectcode,category,requestId(correlates one REST request across attempts, retries, rate limits and payloads),shardId,route,event,command,status,closeCode,delayMsandhintErrorInfofields (record.errorandrecord.otherErrors): Inspecterror.code,error.hint,error.retryable,error.retryAfterMs,error.validationErrors(path,providerCode,explanation) anderror.details- Diagnostics counters: Read
client.diagnostics().countersfor handler failures, drops, retries, rate-limit waits and reconnect totals
First codes to search for in logs:
| Code | Meaning | First place to check |
|---|---|---|
lifecycle.botFailed | The runBot function stopped on an unreported failure and set exit code 1 | error.code, error.hint, error.retryable |
lifecycle.connectionEnded | A shard stopped permanently | closeCode, shardId, error.hint |
rest.rejected | Fluxer rejected a token or permission (HTTP 401/403 or invalid webhook token 404) | requestId, route, status, hint, fields.apiError |
rest.responseRejected | A 2xx Fluxer response did not match the expected shape | requestId, route, status, fields.field |
rest.busy | Local REST queue or upload byte budget is full | fields.budget, fields.queuedRequests, hint |
ratelimit.wait | A 429 response paused a route or the whole client | requestId, route, delayMs, fields.pause, fields.global |
gateway.dispatchRejected | A gateway dispatch failed validation and was skipped | shardId, fields.field, fields.dispatch |
events.handlerFailed | An event handler failed without onError | event, subscriptionId, error.code, error.hint |
events.dropped | A full subscription queue dropped an event | event, subscriptionId, hint |
commands.failed | A prefix command failed without onError | command, error.code, error.hint, error.validationErrors |
Offline diagnostics and catalogues:
- CLI:
fluxerly doctor --json --strict,fluxerly triage --print,fluxerly triage --json,fluxerly triage --log - --printandfluxerly triage --run "..." --timeout 60s - Local catalogue:
node_modules/@neontechspace/fluxerly/src/internal/code-catalogue.ts - Online catalogue: https://fluxerly.neontechspace.com/docs/codes/
Effect entry point
Import @neontechspace/fluxerly/effect when using Effect 4 (within peerDependencies.effect). Compose with Effect.gen and yield*, keep clients in Effect.scoped or FluxerClient.layer / FluxerClient.layerConfig, pass processSignals: true to native runBot when not using NodeRuntime.runMain, and test with @neontechspace/fluxerly/effect/testing (dist/effect-testing.d.ts):
| 1 | import { Effect } from "effect" |
| 2 | import { createClient } from "@neontechspace/fluxerly/effect" |
| 3 | |
| 4 | export function sendWithEffect(token: string, channelId: string, content: string) { |
| 5 | return Effect.runPromise( |
| 6 | Effect.scoped( |
| 7 | Effect.gen(function* () { |
| 8 | const client = yield* createClient({ token }) |
| 9 | const sent = yield* client.messages.send(channelId, content) |
| 10 | return sent.id |
| 11 | }), |
| 12 | ), |
| 13 | ) |
| 14 | } |
Reference map
Read installed declarations first under node_modules/@neontechspace/fluxerly/agents/AGENTS.md, dist/api/default/*.d.ts, dist/api/effect/*.d.ts, dist/testing.d.ts and dist/effect-testing.d.ts. Online AI docs live at: