AgenTopology

Scaffold

Generate platform-specific config files from a topology AST using bindings

Scaffold

import { claudeCodeBinding } from "agentopology";

Scaffolding generates platform-specific config files from a parsed and validated topology. Each platform has a binding that knows how to produce the right directory structure, prompts, and configs.

How scaffolding works

  1. Parse a .at file into an AST
  2. Validate the AST
  3. Call binding.scaffold(ast, outputDir) with your target platform's binding

The binding generates all files the platform needs to run your agent team.

Usage

import { parse, validate, claudeCodeBinding } from "agentopology";
import { readFileSync } from "fs";

const source = readFileSync("my-topology.at", "utf-8");
const ast = parse(source);
const result = validate(ast);

if (!result.valid) {
  console.error("Topology has errors:", result.errors);
  process.exit(1);
}

const files = claudeCodeBinding.scaffold(ast, "./output");
console.log("Generated files:", files.map(f => f.path));

Available bindings

Each binding targets a specific platform:

import {
  claudeCodeBinding,
  codexBinding,
  geminiCliBinding,
  copilotCliBinding,
  openClawBinding,
} from "agentopology";
BindingPlatformGenerated files
claudeCodeBindingClaude CodeCLAUDE.md files, agent prompts, directory structure
codexBindingOpenAI CodexCodex config, agent definitions
geminiCliBindingGemini CLIGemini config files, agent prompts
copilotCliBindingGitHub Copilot CLICopilot workspace configs
openClawBindingOpenClawOpenClaw topology configs

Scaffold return value

scaffold() returns an array of GeneratedFile objects:

interface GeneratedFile {
  path: string;
  content: string;
}

Each entry contains the file path (relative to the output directory) and the file content as a string. The scaffold function writes the files to disk and returns the list for inspection.

Example: scaffolding to multiple platforms

import {
  parse,
  validate,
  claudeCodeBinding,
  codexBinding,
} from "agentopology";
import { readFileSync } from "fs";

const source = readFileSync("my-topology.at", "utf-8");
const ast = parse(source);
const result = validate(ast);

if (result.valid) {
  claudeCodeBinding.scaffold(ast, "./output/claude-code");
  codexBinding.scaffold(ast, "./output/codex");
}

CLI equivalent

The CLI wraps this API:

agentopology scaffold my-topology.at --target claude-code --output ./output

What's next

On this page