Import
Reverse-engineer existing platform files into an .at topology
Import
import { importFromPlatform } from "agentopology";Import reads existing platform configuration files and reverse-engineers them into an .at topology file. This is the inverse of scaffolding — instead of generating platform files from a topology, it creates a topology from platform files.
Supported platforms
| Binding | What it reads |
|---|---|
claude-code | .claude/ directory — agents, skills, settings, hooks |
openclaw | OpenClaw workspace — openclaw.json, SOUL.md, AGENTS.md, skills, memory |
CLI usage
agentopology import --target claude-code --dir .claude/
agentopology import --target openclaw --dir ~/my-openclaw-project/The CLI reads all files from the specified directory, constructs a topology AST, serializes it to .at format, and writes the output file. It also runs validation on the result.
Programmatic usage
import { importFromPlatform } from "agentopology";
import { readdirSync, readFileSync } from "fs";
import { join } from "path";
// Read all files from the platform directory
function readFiles(dir: string): Array<{ path: string; content: string }> {
const files: Array<{ path: string; content: string }> = [];
for (const entry of readdirSync(dir, { withFileTypes: true, recursive: true })) {
if (entry.isFile()) {
const fullPath = join(entry.parentPath ?? entry.path, entry.name);
const relativePath = fullPath.slice(dir.length);
files.push({ path: relativePath, content: readFileSync(fullPath, "utf-8") });
}
}
return files;
}
const files = readFiles(".claude/");
const atSource = importFromPlatform(files, "claude-code", "my-topology");
console.log(atSource);How it works
Claude Code import
Reads the .claude/ directory structure:
agents/*/AGENT.md— Agent definitions with frontmatter (model, tools, permissions) and markdown body (role, instructions, reads/writes, outputs)skills/*/SKILL.md— Topology-level skill with flow edges, gates, and triggerssettings.json— Tool allow/deny lists and hooks.mcp.json— MCP server configurationscommands/*.md— Trigger definitions
OpenClaw import
Reads the OpenClaw workspace:
openclaw.json— Agent list, models, providers, tools settings, environment variablesSOUL.md— Topology identity, version, patterns, roles, parameters, triggers, interface endpointsAGENTS.md— All agent definitions, group chats, flow edges, gates, schedules, hooksskills/*/SKILL.md— Skill definitions with YAML frontmatterMEMORY.md— Workspace and domain memory structurecron/jobs.json— Scheduled job definitions (fallback)
Round-trip fidelity
Import is designed to preserve as much information as possible. For the best results:
- Scaffold first — If you scaffold a topology to a platform and then import it back, the result should be semantically equivalent to the original.
- Validate after import — Always run validation on the imported topology to catch any structural issues.
- Some fields may be lost — Platform-specific extensions, schemas, and defaults blocks may not survive the round-trip if the binding doesn't emit them.