Skip to content

CIRCE / DOCUMENTATION

Project structure

How folder location decides what a file is, and the naming rules that keep discovery deterministic.

Documentation menu
On this page

Location is semantic

Circe scans scanRoot (default ./src) and decides what each file is from the folder it lives in. Everything outside is yours: domain logic, models and scripts are unconstrained.

<bot-root>/
├── circe.config.ts
└── src/
    ├── commands/           # /ban, /ping
    ├── command-groups/     # /config roles add
    ├── context-menus/
    │   ├── users/
    │   └── messages/
    ├── events/             # ready, guild-member-add
    ├── components/         # buttons and select menus
    ├── modals/
    ├── middleware.ts       # global before/after hooks
    ├── error.ts            # central error boundary
    └── localization.ts     # translation resolver (or legacy i18n.ts)

Folders

Path Contains
commands/ Top-level slash commands. Subfolders are cosmetic; the file name is the command name.
command-groups/ Nested subcommand trees. Folder depth is the routed path, up to Discord’s two levels. _group.ts declares the parent and its shared guards.
context-menus/users/ · messages/ Right-click commands. The folder sets the command type and the type of ctx.target.
events/ One listener per file, found recursively. The name inside the file decides the event, so subfolders (events/guild-member-add/) are only for organizing. Listeners for one event run concurrently and isolate each other’s errors.
components/ Buttons and select menus, routed by customId prefix or typed pattern.
modals/ Modal-submit handlers, routed by longest customId prefix.
middleware.ts · error.ts · localization.ts Optional single files at the scan root.

Guards you write yourself can live anywhere you like; circe add guard puts them in src/guards/.

Naming rules

  • kebab-case for every file and folder inside the scan root.
  • One file, one module, one default export, produced by a define* helper.
  • A leading underscore marks a metadata file (_group.ts) that is never registered as a leaf command.
  • The file name is the default identifier unless the builder overrides it.

Command groups

command-groups/
└── config/
    ├── _group.ts       # /config
    └── roles/
        ├── _group.ts   # /config roles
        ├── add.ts      # /config roles add
        └── remove.ts   # /config roles remove

Group guards run before the guards of the subcommands under them.

Validation

Every discovered file is checked against its category contract before anything starts:

✗ src/commands/moderation/ban.ts
  Does not export a valid CommandDefinition: missing `builder`.
  Scanned as a command because it is located under `commands/`.

Run circe routes to see the discovered hierarchy and any prefix collisions, and circe build to validate everything without logging in.