Skip to content

Server as Code

The layout of your community server (categories, channels, webhooks, roles, who sees what, the welcome screen) lives in holocron.config.ts. Two commands apply it, and one checks it. This page is the order to run them in. The examples use Discord, the provider that implements all of it today.

Credential Where it comes from Stored as
Bot token Developer portal → Bot → Reset Token holocron new token discord.holonet <token>
OAuth client secret (only for link account) Developer portal → OAuth2 → Reset Secret holocron new token discord.holonet.oauth <secret>
GitHub tokens See the Token Reference github.secrets, github.org, github.user-sync

The bot token and the client secret are two different values that look alike; the portal shows neither again once you leave the page. The full list, with the exact GitHub scopes, is in the Token Reference.

--owner is your Discord user id, the long number (17 to 20 digits) that identifies your account. It is not your username and not the server id. To copy it:

  1. Discord → User Settings → Advanced → turn on Developer Mode.
  2. Right-click your name or avatar → Copy User ID.

After link account it is also the member value next to your GitHub login in notifications/discord-links.json in the org’s .github-private repo.

Terminal window
# See the plan first; nothing is called
holocron new server --dry-run --name "The Holocron" --owner 123456789012345678
# Then for real (add --force if holocron.config.ts already has a guildId)
holocron new server --name "The Holocron" --owner 123456789012345678

--name is what the server is called. The command creates the server, writes its id into holocron.config.ts as guildId, applies the whole layout, sends you a single-use invite, waits for you to join, and then makes you the owner. The steps, the failure states and --resume are in new server.

Things to know before you run it:

  • A bot can create a server only while it is in fewer than ten.
  • A new server keeps Discord’s default channels; the layout is added to them.
  • The bot owns the server until you join and the hand-over happens. doctor notifications fails step 16 until then.

Edit layout (or server, welcome, pinned, onboarding, application, everyone) in holocron.config.ts, then:

Terminal window
holocron setup notifications --dry-run # what would change
holocron setup notifications # change it

setup looks everything up by name and changes only what differs, so running it again is safe. It never deletes a channel, category or role that the layout no longer mentions. The fields are described in setup notifications.

Turning community features on is the one step that needs more than the bot keeps (Administrator). Run setup in a terminal and it walks you through it: a link to give Administrator, Enter to retry, a link to take it away, and a check that it is gone. A server the bot created is not affected, because the bot owns it until you take it over.

Terminal window
holocron link account # each person signs in once to tie their Discord account to their GitHub login
holocron sync roles # give roles to the members of the GitHub team a role follows

See link account and sync roles.

Terminal window
holocron doctor notifications

It compares the live server with the layout step by step, posts one 🧪 test: message in the test channel (--built-only skips that, --deliver posts to every channel and removes the posts), and names the command that fixes each failure. It also checks the two feeds that reach Discord from outside it, the Checkly alert channel and the Comlink relay (the Worker, its route and bindings, and the error tracker’s integration and alert rule), without posting anything. See doctor notifications.

To share a result you ran yourself, add --post [channel]: the bot posts the failing steps (or only the counts when every step passed) to #alerts, with each #channel linked. Provider tokens stay on your machine. A weekly reminder in #alerts says when to run it.

Every message below is posted by a workflow, through the channel’s webhook. A channel whose webhook secret is missing is skipped, never an error.

Event Channel Posted by
A repo-sync pull request, or one that needs a person #sync, #alerts sync-repo
A workflow errored on alpha or main (a pull request run is never posted) #alerts, with the gatekeepers pinged notify
A deploy, preview or Sentinel deploy errored, or a Preview Check did #deploys notify
A deploy, preview, Sentinel deploy or Preview Check succeeded (pull requests too), with a link to what was deployed when GitHub has a deployment URL for the commit #deploys notify
A release succeeded, with the tags it made #releases notify
A token is close to expiring #alerts the daily Token Expiry run, through the failure rule above
Time to run the drift check #alerts remind-doctor, Mondays
Sentry errors, Checkly up/down #errors, #uptime their own webhooks (Comlink relay, Checkly)
A command an agent ran from the CLI, with its flag names and exit code #agent-log the CLI itself, see Command log

check-notify (run it from the Actions tab) posts one labelled test message per channel and fails the job of any channel that does not deliver.