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" in package.json)
  • TypeScript: Node.js runs .ts directly without building. Type checking requires TypeScript 7 and @types/node
  • Entry points: @neontechspace/fluxerly, @neontechspace/fluxerly/effect, @neontechspace/fluxerly/testing and @neontechspace/fluxerly/effect/testing. Never import from dist or src
  • Native Effect API (@neontechspace/fluxerly/effect): Effect 4 matching the installed package's peerDependencies.effect range

Fast start and CLI commands

Install or scaffold a runnable bot project with tests:

sh
1npm install @neontechspace/fluxerly
2pnpm 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:

sh
1pnpm exec fluxerly doctor --dir my-bot --json --strict
2pnpm exec fluxerly triage --print
3pnpm exec fluxerly triage --json
4cat bot.log | pnpm exec fluxerly triage --log - --print
5pnpm exec fluxerly triage --run "node bot.ts" --timeout 60s
6pnpm exec fluxerly agents --target all
7pnpm exec fluxerly agents --check
8pnpm 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

  1. Import only from @neontechspace/fluxerly, @neontechspace/fluxerly/effect, @neontechspace/fluxerly/testing or @neontechspace/fluxerly/effect/testing, never from dist or src
  2. Use defineBot and runBot for bots, starting only under if (import.meta.main) so tests can import bot without connecting. Use createClient({ token }) only for manual lifecycle control
  3. In the default API, every network call returns ResultAsync. Always await and check result.isErr(), unwrap with await orThrow(...), or return the ResultAsync from a handler so the SDK reports expected failures
  4. Read the bot token from process.env.FLUXER_BOT_TOKEN and never hardcode or log it
  5. Use only methods declared in node_modules/@neontechspace/fluxerly/dist/api/default/*.d.ts (or dist/api/effect/*.d.ts)
  6. Test every bot behavior with createTestBot from @neontechspace/fluxerly/testing (or @neontechspace/fluxerly/effect/testing) before running live
  7. Diagnose failures with FLUXERLY_LOG_FORMAT=json, fluxerly doctor --json --strict and fluxerly triage --print, matching on LogRecord.code and ErrorInfo fields rather than log prose

Patterns that do not exist in Fluxerly

  • No new Client() or client.login(token): Use runBot({ token, ...bot }), or createClient({ token }) followed by client.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() or channel.send(). Use handler { reply } or client.messages.send(channelId, content)
  • Event handlers in runBot receive a context object { message, reply, client, signal }, not a bare message
  • Bot authors use message.author.isBot, not message.author.bot (runBot already skips bot messages unless ignoreBots: false)
  • Communities are named guilds in SDK identifiers such as guildId
  • Voice signaling uses client.voice (join, leave, updateState) with voiceStateUpdate, voiceServerUpdate, voiceSignal and opcode 12 gatewayError events while keeping gateway.ignoredEvents: "auto". Built-in audio transport is planned for Fluxer's own voice engine, and bots needing audio today pass the typed voiceServerUpdate grant 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:

ts
1import { EmbedBuilder, commands, defineBot, format, guards, runBot } from "@neontechspace/fluxerly"
2
3export 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
30if (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-parse canManage(argumentName, options?) in afterParse. Community guards narrow context.message.guildId to string across afterParse, cooldown.key and execute
  • Arguments and command context: Argument schemas support default (text, boolean, choice, custom), minLength/maxLength (text) and caseInsensitive (choice). Cooldowns use { durationMs, per: "user" | "channel" | "guild" }. Context provides help() (including focused help({ command })), sendHelp(), confirm(prompt, options?), paginate(pages), client and signal
  • Lifecycle and multi-event queues: The runBot function skips bot messages (ignoreBots: false disables), stops cleanly on SIGINT and SIGTERM (processSignals: false disables), logs fatal failures once and sets exit code 1. Use client.onMany(events, handler, { partition }) for shared per-key ordered queues (including threadMemberUpdate) and using (Symbol.dispose) or close() on ScheduledTask
  • Builders and helpers: Pass MessageBuilder (.tts(), .nonce(), .suppressEmbeds(), .suppressNotifications(), dynamic addEmbeds) directly to sends and replies, and use EmbedBuilder.from, .clone() and .image(url) / .thumbnail(url) / .footer(text). Helpers include permissionBits.overwrite, format, links, snowflakes, display, assets, text and colors (keep IDs as decimal strings)
  • Attachments, collectors and lookups: Use client.attachments.download(attachment, { maxBytes }) or client.attachments.stream(attachment, { maxBytes }), client.messages.collect, collectReactions (emoji arrays and opt-in includeRemovals), confirm, client.roles.fetchCanManage and client.members.fetchCanManage (with preferCache), client.gateway.fetchBot, client.application.fetchPublic, oauth.createState() and oauthClient.request

Zero-network bot test

ts
1import assert from "node:assert/strict"
2import { test } from "node:test"
3import { createTestBot } from "@neontechspace/fluxerly/testing"
4import { bot } from "./bot.ts"
5
6test("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() and clock: "manual" with advance(ms)
  • Run tests with a timeout and forced exit: node --test --test-timeout=30000 --test-force-exit

Results, error handling and raw access

ts
1import { createClient, describeError, errors, orThrow, type Attachment } from "@neontechspace/fluxerly"
2
3export 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" for UNKNOWN_BAN, noting hidden community channels also return HTTP 404 UNKNOWN_CHANNEL, with Effect Cause unwrapping), errors.isRetryable(error), errors.retryAfterMs(error), errors.outcome(error) and errors.match(error, handlers)
  • Retry safety: Never repeat a write whose errors.outcome(error) is "unknown" or undefined without checking Fluxer's state first. Wait errors.retryAfterMs(error) when present, use a fresh stream or bytes when details.streamUsed is true, and create a new client after a failed client.run()
  • Structured inspection: Read error.hint, error.inputValidation (path, constraint, explanation), error.apiError (code, providerCode, validationErrors), error.details.requiredPermissions and error.details.streamUsed. Format errors with describeError(error, { color: "auto" }) and failure reports with report.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) and client.on("raw", (dispatch) => ...) (check dispatch.documented before narrowing on dispatch.t)

Logging, error codes and diagnostics

Capture machine-readable logs and run offline diagnostics instead of scraping ANSI output:

sh
1FLUXERLY_LOG_FORMAT=json FLUXERLY_DEBUG=rest,gateway node --env-file=.env bot.ts
2FLUXERLY_LOG_COLOR=0 node --env-file=.env bot.ts
3NO_COLOR=1 node --env-file=.env bot.ts
  • Environment controls: FLUXERLY_LOG_FORMAT=json emits one JSON LogRecord per line. FLUXERLY_LOG_COLOR=0 or non-empty NO_COLOR=1 disables color (empty NO_COLOR="" leaves color enabled, and FORCE_COLOR=0 or TERM=dumb disables automatic color). FLUXERLY_DEBUG=1 or a comma-separated list enables Debug across the 10 categories: lifecycle, gateway, rest, ratelimit, cache, events, commands, collectors, supervisor, sdk
  • LogRecord fields: Inspect code, category, requestId (correlates one REST request across attempts, retries, rate limits and payloads), shardId, route, event, command, status, closeCode, delayMs and hint
  • ErrorInfo fields (record.error and record.otherErrors): Inspect error.code, error.hint, error.retryable, error.retryAfterMs, error.validationErrors (path, providerCode, explanation) and error.details
  • Diagnostics counters: Read client.diagnostics().counters for handler failures, drops, retries, rate-limit waits and reconnect totals

First codes to search for in logs:

CodeMeaningFirst place to check
lifecycle.botFailedThe runBot function stopped on an unreported failure and set exit code 1error.code, error.hint, error.retryable
lifecycle.connectionEndedA shard stopped permanentlycloseCode, shardId, error.hint
rest.rejectedFluxer rejected a token or permission (HTTP 401/403 or invalid webhook token 404)requestId, route, status, hint, fields.apiError
rest.responseRejectedA 2xx Fluxer response did not match the expected shaperequestId, route, status, fields.field
rest.busyLocal REST queue or upload byte budget is fullfields.budget, fields.queuedRequests, hint
ratelimit.waitA 429 response paused a route or the whole clientrequestId, route, delayMs, fields.pause, fields.global
gateway.dispatchRejectedA gateway dispatch failed validation and was skippedshardId, fields.field, fields.dispatch
events.handlerFailedAn event handler failed without onErrorevent, subscriptionId, error.code, error.hint
events.droppedA full subscription queue dropped an eventevent, subscriptionId, hint
commands.failedA prefix command failed without onErrorcommand, error.code, error.hint, error.validationErrors

Offline diagnostics and catalogues:

  • CLI: fluxerly doctor --json --strict, fluxerly triage --print, fluxerly triage --json, fluxerly triage --log - --print and fluxerly 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):

ts
1import { Effect } from "effect"
2import { createClient } from "@neontechspace/fluxerly/effect"
3
4export 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: