agentskit.js

@agentskit/templates — for agents

Authoring toolkit — validated factories + secure on-disk scaffolds for custom tools, skills, adapters, memory, embedders, and flows.

#Purpose

Generate AgentsKit extensions as standalone packages with consistent blueprints (tsup, vitest, TypeScript) and runtime validation. Depends only on @agentskit/core. This is a programmatic authoring toolkit — it is not what agentskit init uses under the hood (the CLI has separate app templates).

#Install

npm install @agentskit/templates @agentskit/core

#Primary exports

  • createToolTemplate(config) — build a validated ToolDefinition.
  • createSkillTemplate(config) — build a validated SkillDefinition (optional metadata passthrough).
  • createAdapterTemplate(config) — build an AdapterFactory with display name and optional capabilities.
  • scaffold(config) — write a full package directory (async), atomic + collision-safe.
  • validateScaffoldConfig(config) — runtime config validation (ConfigError / AK_CONFIG_INVALID).
  • validateToolTemplate / validateSkillTemplate / validateAdapterTemplate — assert well-formed definitions.
  • SCAFFOLD_TYPES — the eight allowed scaffold type strings.
  • Types: ToolTemplateConfig, SkillTemplateConfig, AdapterTemplateConfig, ScaffoldType, ScaffoldConfig.

#Scaffold types

tool · skill · adapter · memory-vector · memory-chat · flow · embedder · browser-adapter

#Minimal example

import { createToolTemplate, scaffold } from '@agentskit/templates'

export const rollDice = createToolTemplate({
  name: 'roll_dice',
  description: 'Roll an N-sided die once.',
  schema: {
    type: 'object',
    properties: { sides: { type: 'number', minimum: 2 } },
    required: ['sides'],
  },
  async execute(args) {
    const sides = Number(args.sides)
    return String(1 + Math.floor(Math.random() * sides))
  },
})

await scaffold({
  type: 'tool',
  name: 'roll-dice',
  dir: './packages',
  description: 'Dice tool package',
})

Validation throws ConfigError (AK_CONFIG_INVALID) if required fields fail: trim-non-empty name/description/systemPrompt, function execute/createSource, JSON Schema object (not null/array; type optional), finite temperature when set.

#Scaffold security

  • Validate config before any write.
  • Unscoped kebab-case names only (no @scope/pkg yet — documented beta restriction).
  • Existing destination fails unless overwrite: true.
  • Symlink destination roots rejected; staging sibling + atomic rename; cleanup on failure.
  • Returned paths are final destinations, never staging paths.
  • Generated deps: @agentskit/core ^1.0.0; flow also @agentskit/runtime ^0.10.0. No wildcards.

#Common patterns

  • Tool: createToolTemplate enforces JSON Schema arguments and async execute.
  • Skill: requires name, description, systemPrompt; optional metadata, examples, tools, delegates, onActivate.
  • Adapter: requires name + createSource; optional capabilities.
  • Scaffold: programmatic package generation — distinct from agentskit init.

#Source

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.