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
- Parse a
.atfile into an AST - Validate the AST
- 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";| Binding | Platform | Generated files |
|---|---|---|
claudeCodeBinding | Claude Code | CLAUDE.md files, agent prompts, directory structure |
codexBinding | OpenAI Codex | Codex config, agent definitions |
geminiCliBinding | Gemini CLI | Gemini config files, agent prompts |
copilotCliBinding | GitHub Copilot CLI | Copilot workspace configs |
openClawBinding | OpenClaw | OpenClaw 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 ./outputWhat's next
- Learn about the bindings API and the
BindingTargetinterface - Create a custom binding for your own platform
- Visualize your topology as an interactive graph