facet CLI how to materialize a facet’s assets into one AI coding tool. The first-party adapters cover Claude Code, OpenCode, and Codex. This guide builds your own with the @agent-facets/adapter SDK.
An adapter is a small TypeScript package. You write one file, build it, and install it from a directory, from git, or by npm name.
What an adapter does
When you runfacet install, the CLI resolves what the project should have and hands each text asset to every installed adapter. The adapter decides where the file goes and how it is formatted.There are two halves:- Text assets: turn skills, agents, and commands into files your tool reads.
- MCP servers: turn portable server declarations into your tool’s own project configuration.
Scaffold the package
1
Create a package and add the SDK
@agent-facets/common are bundled into the SDK, so that is the only dependency you add.2
Write the adapter
Create
src/index.ts and default-export a defineAdapter call. Each planning method takes one request tagged by assetType. Skills are multi-file bundles; agents and commands are single files. The SDK planners do the work:src/index.ts
Use the SDK planners rather than hand-rolling file writes. They assemble front matter, validate companion paths, capture exact prior state, and produce no mutation when a file already holds the bytes you would write.
MCP server configuration
SetmcpServers: false if your tool has no MCP configuration. That is a complete answer: projects without declarations install normally, and a project that declares servers fails with a message naming your adapter.To support servers, implement the plan capability. It parses your tool’s project document, classifies every desired server, and returns the exact document changes plus every file it read. It writes nothing, and the CLI commits the result.The full request and result shapes, failure codes, equality rules, and the preservation requirements for editing a user’s configuration file are in the Adapter SDK reference.Bundle it
facet adapter add needs a clean single-module entry. Compile with tsdown (what the first-party adapters use) or tsc:package.json exports or main at the compiled entry.Install your adapter
adapter.js, verifies it exports a valid adapter, and installs it under $FACET_DIR/adapters/<name>/. See facet adapter add.Verify it works
buildAssetMetadata with a real schema.facet adapter list also shows each adapter’s declared API version and whether this CLI supports it. When the supported set changes, rebuild against a matching SDK release and reinstall. The list prints the exact command next to any incompatible entry.Publish to npm
Installing by bare name resolves through npm. Declare the API version your SDK release stamps:package.json
latest dist-tag is never consulted. An exact request such as facet adapter add my-adapter@1.4.0 is never substituted and fails if that release is incompatible.See API versions for the canonical constants.