Documenting a Module
Somebody choosing a module for their definition file reads about it before loading it: what it gives them, what it costs, and which later edit destroys what it holds. None of that is in the input schema. It goes in the JSDoc on the module class, which is where the API reference of a library comes from, and where an AI agent working with the Octo MCP server reads your modules from.
This page documents ShopQueueServiceModule, the shop's queue for order events from
Create a Module. It takes a region, a queue
name, and how long a message survives, and it produces one SQS queue.
The docblock
The finished docblock sits on the module class:
/**
* `ShopQueueServiceModule` gives the shop one SQS queue for order events, named by `queueName`, that
* keeps each message for `messageRetentionSeconds`.
*
* @cost SQS bills each request: the first million a month are free, then about $0.40 per million.
* An idle queue costs nothing.
*
* @downtime None for a change made in place. A replacement deletes the queue, and sending to it
* fails until the new one exists.
*
* @example
* ```yaml
* modules:
* - moduleId: orders-queue-module
* moduleClass: ShopQueueServiceModule
* moduleInputs:
* region: "${{region-module.model.region}}"
* queueName: shop-orders
* messageRetentionSeconds: 86400
* ```
*
* @group Modules/Service/ShopQueueService
*
* @limit A message is kept at most 14 days: SQS refuses a `messageRetentionSeconds` above 1209600.
*
* @limit It creates no dead-letter queue: a message that keeps failing stays in the queue until it
* expires.
*
* @losesData Deleting the module, or a change that replaces the queue, loses every message still
* in it.
*
* @replaces Changing `queueName` or `region` replaces the queue. `messageRetentionSeconds` changes
* in place.
*/
@Module<ShopQueueServiceModule>('@shop', ShopQueueServiceModuleSchema)
export class ShopQueueServiceModule extends AModule<ShopQueueServiceModuleSchema, ShopQueueService> {
// onInit and registerMetadata, as Create a Module writes them.
}
Each part has one job: the first paragraph is what a reader chooses by, @group files the module,
the five fact tags say what loading it commits somebody to, and @example shows it loaded.
The first paragraph
Wherever modules are listed, in the API reference or in the list an agent reads to choose among them, each one is shown by its name and the first paragraph of its docblock. Say in it what the module gives whoever loads it, and name the inputs that shape it, in the words somebody would look it up by. An agent looks modules up by the exact words in their names, first paragraphs and groups, so a queue module whose first paragraph never says "queue" is not found by somebody asking for one.
Leave out which model the module implements: the group says that. Everything after the first blank line is detail, read once somebody opens the module.
The group
@group Modules/Service/ShopQueueService files the module. The first part is the collection the
module is listed in, Modules. The rest divides it: the model type the module builds, the same type
octo create-module -t took, then the module's name without Module. Our AWS library files every
module this way, such as Modules/Service/AwsS3StorageService, so yours is listed beside its
modules for the same model. An agent reads a division whole, so put the module and its input schema
under one @group, along with anything else a reader of the module needs.
Give the input schema the same group, so the module and its inputs are listed together, and export
it from src/index.ts beside the module, as create-module writes both. An agent reads a module's
inputs only from a schema the project exports:
/**
* The inputs of `ShopQueueServiceModule`: the region the queue lives in, its name, and how long it
* keeps a message.
*
* @group Modules/Service/ShopQueueService
*/
export class ShopQueueServiceModuleSchema {
// queueName, messageRetentionSeconds and region, as Create a Module writes them.
}
export { ShopQueueServiceModule } from './modules/service/shop-queue-service/index.js';
export { ShopQueueServiceModuleSchema } from './modules/service/shop-queue-service/index.schema.js';
A comment on each input, above its Schema<...>(), is shown beside that input.
An exported class without a @group is listed under Project Ungrouped, apart from the modules it
belongs with. Give every class src/index.ts exports a group.
The facts
Somebody choosing a queue module wants to know what it will cost, how far it goes, and which later
edit destroys the queue and the messages in it. The person who knows is whoever wrote the
resource's diffProperties, so the module states it once, in five tags:
| Tag | States |
|---|---|
@cost | what the provider bills for what the module creates, and when |
@limit | a bound, with its number, or something the module never does |
@replaces | which input changes recreate a resource |
@downtime | when a change interrupts what the module serves |
@losesData | what a deletion or a replacement loses |
Each tag holds one fact in plain sentences. A second fact of the same kind is a second tag, as the
queue's two @limit tags above. A fact that does not apply says so rather than going missing: a
module that creates nothing writes @cost Nothing: it creates no resources.
@limit also states what the module will never do that somebody may want later, such as the
queue's missing dead-letter queue, so whoever outgrows the module later learns it before building
on it.
@replaces is the one to get right, because it separates an edit somebody can make at any time
from one that loses what the resource held. Read it off the diffProperties of every resource the
module creates, and add every input the resource ID is built from, since a new ID is a replacement
too. That is why queueName is on the list above although diffProperties never compares it.
The modules of our AWS library state the same five on their API pages, such as AwsS3StorageServiceModule.
The example
@example shows the module as a definition file loads it, with every required input. One example
that runs is worth more than a paragraph describing the inputs, which the schema already lists.
Keeping it current
The docblock describes the module as it is today. When an input, a resource or a limit changes, change the docblock in the same commit, so it never describes a module that no longer exists.
An agent working with the Octo MCP server reads your modules from this JSDoc once it has indexed them, and indexes again when a source file changed since.