Skip to main content
An adapter teaches the 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 run facet 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.
Adapters never write to disk. They return exact file transitions and the CLI commits them, which is what gives every change the same rollback and concurrency guarantees. See the Adapter SDK reference.

Scaffold the package

1

Create a package and add the SDK

The shared types from @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

Set mcpServers: 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.
Configuring a server is not running one. Never launch the command, connect to the URL, health-check, or collect credentials.

Bundle it

facet adapter add needs a clean single-module entry. Compile with tsdown (what the first-party adapters use) or tsc:
Point your package.json exports or main at the compiled entry.

Install your adapter

The CLI prepares a self-contained adapter.js, verifies it exports a valid adapter, and installs it under $FACET_DIR/adapters/<name>/. See facet adapter add.
While developing, rerun facet adapter add ./my-adapter after each rebuild to test end to end.

Verify it works

Check that files landed where your path helpers put them, then harden 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
The CLI reads this field before downloading, so a release without it is never selected. Among compatible releases the highest package version wins, and the npm 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.

Share it upstream

If your adapter targets a widely used tool, open a pull request on the facets repository. First-party adapters are installable by name for everyone.