Prompts
A prompt is named text a person can insert into the composer. It has no model, tool set, or handler.
Declare reusable instructions
import { function agent(input: AgentInput): AgentThis describes an agent, it does not run one. There is no handler, and nothing executes when the mod activates. Put the result under `ai.agents` and the host registers it so the user or another agent can call it by id, `<extensionId>/<name>`. That is the line between this and the rest of the AI surface. To actually run something, use `ctx.ai.ask` for a single answer or `ctx.ai.sessions` for a conversation. To give the model a capability it can invoke, write a `tool`, which does have a handler.agent, function defineMod(definition: ModDefinition): ModThe entry point of the SDK. A mod's module default-exports one `defineMod` call and nothing else. The returned value is data. It registers nothing, starts nothing, and touches no host state. The host folds it twice. At build time it runs the module in a throwaway sandbox and reads the value to derive the serializable manifest. At runtime it folds the same value again to wire your handlers into their lanes: ext-host for commands, tools, effects, and hooks; the sandboxed renderer for views. That double fold is why the module must be pure. It is re-executed to produce the manifest, so anything at the top level, a file read, a network call, a timer, a `console` line, runs during a build with no host attached. Put behavior inside handlers: `run`, `activate`, `handle`.defineMod, function prompt(input: PromptInput): PromptDeclare reusable prompt text the user can drop into the composer. Put the result in the mod's top-level `prompts` array. It is text and nothing more: no model, no handler, no execution. An agent is the next step up, it binds prompt text to a model under a callable name. The same `Prompt` value can serve both, handed to `agent({ prompt })` and listed in `prompts`, so the agent and the user work from one wording.prompt } from '@modular/sdk'; const const releaseReview: PromptreleaseReview = function prompt(input: PromptInput): PromptDeclare reusable prompt text the user can drop into the composer. Put the result in the mod's top-level `prompts` array. It is text and nothing more: no model, no handler, no execution. An agent is the next step up, it binds prompt text to a model under a callable name. The same `Prompt` value can serve both, handed to `agent({ prompt })` and listed in `prompts`, so the agent and the user work from one wording.prompt({ PromptInput.name: stringname: 'release-review', PromptInput.description: stringdescription: 'Insert the release review checklist.', PromptInput.content: stringcontent: ` # Task Review the release candidate. # Check - Correctness - Migration risk - Rollback - Observability Separate confirmed defects from open questions. `, }); const const releaseReviewer: AgentreleaseReviewer = function agent(input: AgentInput): AgentThis describes an agent, it does not run one. There is no handler, and nothing executes when the mod activates. Put the result under `ai.agents` and the host registers it so the user or another agent can call it by id, `<extensionId>/<name>`. That is the line between this and the rest of the AI surface. To actually run something, use `ctx.ai.ask` for a single answer or `ctx.ai.sessions` for a conversation. To give the model a capability it can invoke, write a `tool`, which does have a handler.agent({ AgentInput.name: stringname: 'release-reviewer', AgentInput.description: stringdescription: 'Reviews a release candidate against the shared checklist.', AgentInput.prompt: string | Promptprompt: const releaseReview: PromptreleaseReview, AgentInput.model: AgentModelmodel: { kind: "inherit"kind: 'inherit' }, }); export default function defineMod(definition: ModDefinition): ModThe entry point of the SDK. A mod's module default-exports one `defineMod` call and nothing else. The returned value is data. It registers nothing, starts nothing, and touches no host state. The host folds it twice. At build time it runs the module in a throwaway sandbox and reads the value to derive the serializable manifest. At runtime it folds the same value again to wire your handlers into their lanes: ext-host for commands, tools, effects, and hooks; the sandboxed renderer for views. That double fold is why the module must be pure. It is re-executed to produce the manifest, so anything at the top level, a file read, a network call, a timer, a `console` line, runs during a build with no host attached. Put behavior inside handlers: `run`, `activate`, `handle`.defineMod({ metadata: ModMetadatametadata: { ModMetadata.displayName: stringdisplayName: 'Release Review', ModMetadata.description: stringdescription: 'Shared release-review instructions', }, prompts?: readonly Prompt[] | undefinedprompts: [const releaseReview: PromptreleaseReview], ai?: AiModDefinition | undefinedai: { AiModDefinition.agents?: readonly Agent[] | undefinedagents: [const releaseReviewer: AgentreleaseReviewer] }, });
Prompts live in the top-level prompts array because a person selects them
in the composer. Agents live under ai.agents because they are callable AI
roles.
The same Prompt value can serve both surfaces. Listing it in prompts makes
it selectable. Passing it to agent({ prompt }) makes it the agent's system
prompt.
Members
Prompt contains four fields:
| Member | Meaning |
|---|---|
name | Stable short identity |
description | What a person reads before inserting it |
content | The instruction text, normalized by prompt |
kind | The factory-owned prompt discriminator |
Write description for the chooser and content for the model. Do not repeat
the description as the first sentence of the content.
Identity and updates
name is the stable identity within the mod. Promotion replaces a prompt with
the same name and unregisters a removed prompt. Keep the name stable when the
wording changes so composer references continue to address the same concept.
A prompt has no runtime handle and accepts no arguments. prompt removes the
common indentation and surrounding whitespace from content, then the
normalized text is inserted unchanged. This keeps multiline template literals
readable without leaking TypeScript indentation into the composer.
If authors need variables, workspace reads, or branching logic, that work belongs in an executable primitive rather than an informal template syntax.
Pick the right primitive
| Need | Primitive |
|---|---|
| Static text a person inserts | prompt |
| A reusable model role | agent |
| Computation the model may invoke | tool |
If the text depends on workspace state, user input, or a network result, it is not a prompt. Put the computation in a tool and keep the prompt static.
A slash command is the user-triggered alternative when dynamic text belongs inside the current conversation. A tool is the model-triggered alternative when the model should decide whether to compute it.