Skip to main content
AgentMark provides type safety through JSON Schema definitions in your prompt files. agentmark generate-types compiles those schemas to TypeScript types you can pass to createAgentMark<T>() for compile-time validation and IDE autocomplete.

Defining types

Define input and output types in your prompt files using JSON Schema:
math/addition.prompt.mdx

Generating types

Generate TS types with the CLI:
For the prompt above, the generator emits:
agentmark.types.ts
Note two things:
  1. The wrapper (Math$Addition) is a type alias, while Math$AdditionIn / Math$AdditionOut are interfaces.
  2. Each prompt gets three key aliases: the full path with .prompt.mdx, the path ending in .prompt, and the bare name. Any of the three resolves to the same type when you call loadTextPrompt / loadObjectPrompt.

Using generated types

Pass the generated AgentmarkTypes interface as the generic parameter to createAgentMark<AgentmarkTypes>({ loader }). TypeScript then type-checks prompt names, props, and outputs on the neutral render. The client returns AgentMark’s neutral shape ({ messages, object_config } for object prompts); you pass that to your own model call or an executor.

Benefits

  1. Compile-time safety: TypeScript flags prop-shape mismatches before runtime.
  2. IDE support: autocomplete and inline descriptions on props and outputs.
  3. Consistent interfaces: the same AgentmarkTypes drives both the loader and the caller.
  4. Documentation: JSON Schema descriptions flow through to TS JSDoc comments.

Best practices

  1. Define both input_schema and object_config.schema (when the prompt is an object prompt) in your prompt files.
  2. Use descriptive property names and add description fields; they become JSDoc comments.
  3. Mark required properties using required.
  4. Regenerate types after any schema edit: agentmark generate-types --root-dir ./agentmark > agentmark.types.ts.
  5. Commit agentmark.types.ts to version control so CI type-checks the contract.

Have questions?

Reach out any time: