An extension’s definition, schema, tag families, and source files live inside a repo’s commit DAG. Every commit that changes an extension publishes it to the organization’s registry: you develop on a branch, where each commit publishes a prerelease that only your repo runs, and merging a version bump to main publishes a release that other repos install.
Authoring takes actions that the default Editor policy doesn’t grant: create, update, delete, and publish on the extension, the schema actions for its custom models, and call on its tools to try them. See Actions. Org owners and the default Admin policy have them all. Anyone else gets Forbidden at the first step until an org policy allows them.
The authoring lifecycle
Follow these steps to take an extension from creation to a release. Work on a branch: a commit on main that raises the version releases it to every repo in the org, so start on main only to change an extension that you mean to release with that commit.
- Create a branch, and the extension on it: Create a branch from
mainwithPOST /repos/:repo_id/branches(forge branches create-branch), then callPOST /repos/:repo_id/branches/:branch/extensions(forge extensions create-extension). A created extension starts at version1.0.0unless you pass an initialversion, with apackage.jsonthat declares the stage’s latest@buildr/sdk. - Add schema, tag families, or source files: Create extension-owned custom models and tag families, or upload TypeScript source files starting at
index.tswithPOST /repos/:repo_id/branches/:branch/extensions/:name/files(forge extensions create-extension-file). Edit the extension’spackage.jsonto add npm packages, and keep its@buildr/sdkentry, as How@buildr/sdkis linked and upgraded shows. - Commit, then check the publication: Save your working state with
forge commits create-commit. The commit publishes the extension in the background: Forge validates its schema, compiles its source files, inspects its declared tools, schedules, triggers, webhooks, mailboxes, workflows, MCP UIs, and requirements in a sandbox, and only then records the version in the org’s registry. List the commit’s publications withGET /repos/:repo_id/commits/:commit_id/extension-publications(forge extensions list-commit-extension-publications --commit "$COMMIT"): each isqueued,published, orfailedwith the refusal that says why, such asExtensionBuildFailed. Then list and call the extension’s tools on the branch withGETandPOST /repos/:repo_id/branches/:branch/extensions/:name/tools...(forge extensions list-extension-toolsandforge extensions call-extension-tool). Branch calls run the version that the branch’s head commit publishes, never its uncommitted edits, so commit each edit before you try it. A call made while that version is still publishing answersExtensionPublicationPending. Retry it shortly. An extension that no commit holds yet answersExtensionNotFound. - Test it: Seed a scratch branch with the data its tools need, and call each tool, run each workflow, and open each page against it. See Testing an extension.
- Raise the version to release: A commit that brings
maina version higher than the extension’s latest release publishes that release, which other repos install. Every other commit publishes a prerelease,MAJOR.MINOR.PATCH-pre.<commit>, that only your repo runs. While the extension’s version is no higher than its latest release, a prerelease numbers the patch after that release, so once1.0.0is released, a branch whose extension still says1.0.0publishes1.0.1-pre.<commit>. To release a change to a released extension, update its version on the branch withPATCH /repos/:repo_id/branches/:branch/extensions/:name(forge extensions update-extension --data '{"version":"1.1.0"}') and commit. An extension’s first version onmainis its first release. - Merge to
main: Open and merge a change request intomain. A change request merges only once every extension version at its head has published (ExtensionPublicationGateFailedotherwise). A version whose publication failed never publishes, so fix it with another commit on the branch before you merge. An extension the branch never changed is judged bymain’s head instead, so a branch cut whilemain’s release had failed merges oncemainis fixed. The merge publishes the release, and deletes the branch it merged, so create a new branch frommainfor the next change.
A version whose publication fails is never recorded in the registry, on a branch or on main. On main, the next commit that changes the extension publishes the same version again, so main releases a version only once its publication succeeds.
Walkthrough with the CLI
The following commands create a directory extension with an index.ts file on a branch, try its tool there, and merge it to main, which releases version 1.0.0. They use the forge CLI, signed in, with the repo’s ID in $REPO:
# 1. Create a branch from main, and declare the extension on it
MAIN=$(forge branches get-branch --repo "$REPO" --branch main | jq -r .id)
forge branches create-branch --repo "$REPO" --data '{"name":"directory","base_branch_id":"'"$MAIN"'"}'
forge extensions create-extension --repo "$REPO" --branch directory \
--data '{"name":"directory","description":"Company lookup tools"}'
# 2. Write index.ts and upload it as an extension file
cat << 'EOF' > index.ts
import { array, defineExtension, object, string, tool } from "@buildr/sdk";
export default defineExtension(
{},
{
tools: {
companies: {
search: tool(
{
description: "Finds companies whose name matches the query",
input: object({ query: string() }),
output: array(string()),
},
async (_ctx, { query }) =>
["Acme Cloud", "Beacon Analytics"].filter((name) =>
name.toLowerCase().includes(query.toLowerCase()),
),
),
},
},
},
);
EOF
jq -Rs '{path: "index.ts", content: .}' index.ts > index.json
forge extensions create-extension-file --repo "$REPO" --branch directory --name directory --data-file index.json
# 3. Commit the branch, which publishes a prerelease, and capture the commit ID
COMMIT=$(forge commits create-commit --repo "$REPO" --branch directory \
--data '{"message":"Add directory extension"}' | jq -r .id)
# 4. Check the commit's publication. Once it's published, a few seconds later,
# try the tool at the branch's head commit
forge extensions list-commit-extension-publications --repo "$REPO" --commit "$COMMIT"
forge extensions list-extension-tools --repo "$REPO" --branch directory --name directory
forge extensions call-extension-tool --repo "$REPO" --branch directory --name directory \
--tool companies.search --data '{"query":"analytics"}'
# 5. Merge the branch to main, which releases 1.0.0
CR=$(forge change-requests create-change-request --repo "$REPO" \
--data '{"branch":"directory","base_branch":"main","title":"Directory extension"}' | jq -r .number)
forge change-requests merge-change-request --repo "$REPO" --number "$CR" --data '{}'A commit that leaves an extension as the commit before it held it publishes nothing, and runs the version that the earlier commit published.
Extension file management
An extension’s files are versioned records in the repo’s DAG. Each file has a path relative to the extension root (such as index.ts, lib/companies.ts, package.json, or ui/web/index.html) and UTF-8 content:
- Create a file:
POST /repos/:repo_id/branches/:branch/extensions/:name/files(forge extensions create-extension-file). Adding a second file at a path that another file on the branch already holds fails withWriteRefused. - Update or move a file:
PATCH /repos/:repo_id/branches/:branch/extensions/:name/files/:file_id(forge extensions update-extension-file --file "$FILE_ID") accepts updatedcontent, a differentpath, or both. - Delete a file:
DELETE /repos/:repo_id/branches/:branch/extensions/:name/files/:file_id(forge extensions delete-extension-file --file "$FILE_ID"). - Sync a folder of files:
PUT /repos/:repo_id/branches/:branch/extensions/:name/files(forge extensions update-extension-files, or the MCP server’ssync_extension_files) takes{"files": [{"path": "...", "content": "..."}], "delete": true}(orattachment_blob_idin place ofcontentfor a binary file) and writes every file in one operation. With"delete": true, files omitted fromfilesare deleted so the extension matches your local folder; without it, omitted files stay. One refused file refuses the whole write. - List files:
GET /repos/:repo_id/branches/:branch/extensions/:name/filesorGET /repos/:repo_id/commits/:commit_id/extensions/:name/files(forge extensions list-extension-files) answers each file’sid,path, and size in UTF-8bytes, without its content. - Read a file:
GET /repos/:repo_id/branches/:branch/extensions/:name/files/:file_id, or the same under/commits/:commit_id(forge extensions get-extension-file --file "$FILE_ID"), answers one file with itscontent. - Read many files:
POST /repos/:repo_id/branches/:branch/extensions/:name/files/search, or the same under/commits/:commit_id, takes{"ids": [...]}and answers{"data": [...], "next_cursor": ...}: the files with their content, in id order, about 2 MiB of content a page. Send the same ids with"cursor"set to each page’snext_cursoruntil it is null.forge extensions read-filesreads every page, of every file unless--filenames some.
Forge formats a TypeScript, JavaScript, or JSON file of up to 256 KiB with Prettier once a read first asks for its content, and later reads answer the result beside it as formatted_content, which the site shows. content stays exactly as you wrote it, and builds read only content, so edit and diff content. formatted_content is null until the file is formatted, while formatting_pending is true, and stays null when the file is already formatted, is larger or in another language, or doesn’t parse.
Agent instructions and skills
An extension can carry agent instructions and agent skills for the agents that work in its repo and in the repos that install it. They’re data in the repo’s DAG, owned by the extension the way its tag families are, not files:
- Agent instructions:
POST /repos/:repo_id/branches/:branch/extensions/:extension_name/agent-instructionswith{"content": "..."}(forge agent-instructions create-extension-agent-instructions) creates the extension’sAGENTS.md. An extension holds one. - Agent skills:
POST /repos/:repo_id/branches/:branch/extensions/:extension_name/agent-skillswith{"name": "..."}(forge agent-skills create-extension-agent-skill) creates a skill in the Agent Skills layout. Add each of its files withPOST /repos/:repo_id/branches/:branch/agent-skills/:skill_id/filesand{"path": "...", "content": "..."}(forge agent-skills create-agent-skill-file). ItsSKILL.mdstarts with frontmatter that gives the skill’snameand adescriptionof when to use it. ASKILL.mdwithout readable frontmatter fails withInvalidAgentSkillFile, and a commit fails with anagent_skillviolation while a skill has noSKILL.mdthat gives its name.
Edit either one as you edit the repo’s own, with forge agent-instructions update-agent-instructions, forge agent-skills update-agent-skill, and forge agent-skills update-agent-skill-file.
Installing or updating an extension copies the instructions and skills of the version the repo pins. The installing repo can edit its copies. An update that meets a skill that both the repo and the version changed reports a conflict, and the resolution keeps all of the repo’s files or takes all of the version’s. A repo’s agents read every owner’s instructions and skills with GET /repos/:repo_id/branches/:branch/agent-instructions (forge agent-instructions list-agent-instructions) and GET /repos/:repo_id/branches/:branch/agent-skills (forge agent-skills list-agent-skills): the repo’s own, those of the extensions it defines, and the copies of the extensions it installs.
How @buildr/sdk is linked and upgraded
Extension code imports defineExtension, tool, workflow, cron, onBranchAdvance, branchAdvance, webhook, mailbox, room, mcpUi, defineProvider, secrets, oauth2, ForgeError, and value types from "@buildr/sdk". Server code can also import "@buildr/sdk/mcp", a web UI imports "@buildr/sdk/client", and an MCP UI imports "@buildr/sdk/mcp-ui".
@buildr/sdk is an npm package with type declarations for each of its modules. Every Forge stage serves its own copy from the org’s registry, and it isn’t on public npm. A new extension’s package.json declares a caret range on the stage’s latest version, and you edit it like any other package’s. npm view @buildr/sdk version, against the registry in your .npmrc, names the latest.
- Keep it in every extension with code: The build refuses code without a
package.jsonthat declares@buildr/sdk, withSourceRefused. Give a version or a range, which an installation checks against the SDK it links. A tag such aslatestor annpm:alias is refused. - The lockfile pins it: The build resolves
@buildr/sdkfrom the stage’s registry like any npm package, links the version that npm resolves, and records that version. Every run of the version loads that SDK, so a Forge deploy doesn’t change how a published version builds or runs. - Upgrade by editing
package.json: To move an extension onto a later SDK, raise its range inpackage.jsonon a branch, raise the extension’s version, and merge it tomainto release it. Nothing else pins the SDK. - A peer runs with its dependent’s SDK: An installation links one SDK, the version that the installed extension’s lockfile pins, and its peers’ code runs with it. Installing an extension whose peer declares a range on
@buildr/sdkthat excludes that version fails withExtensionBuildFailed.
Developing in a local folder
The API serves @buildr/sdk to npm at /npm/ (https://api.onforge.com/npm/ in production), beside every org’s released extensions, so you can edit an extension in a local folder and check it with tsc before pushing its files back:
-
Pull the extension’s files: Run
forge extensions read-files --repo "$REPO" --branch "$BRANCH" --name "$EXT"(which returns the branch’s file records as JSON, including thepackage.jsonthat creating the extension wrote). Write each text file’scontentto itspathin the folder, and keep any binary file’s{ path, attachment_blob_id }to include in step 4’s sync payload. -
Create an npm token with
POST /orgs/:org_id/npm-tokens(forge registry create-npm-token --org "$ORG", or the MCP server’screate_npm_token, which returnsnpmrc), valid for 24 hours, and point both@buildrand@buildr-customat theregistryit returns in.npmrc(withignore-scripts=true, matching Forge’s compiler):ignore-scripts=true @buildr-custom:registry=https://api.onforge.com/npm/ @buildr:registry=https://api.onforge.com/npm/ //api.onforge.com/npm/:_authToken=<token> -
Install dependencies and configure TypeScript: Run
npm installandnpm install --save-dev typescript(plus@types/nodeif your code importsnode:*built-ins;devDependenciesare ignored by the build), write atsconfig.json, and check your code withnpx tsc:{ "compilerOptions": { "target": "es2022", "lib": ["es2022", "dom"], "module": "preserve", "moduleResolution": "bundler", "jsx": "react-jsx", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "skipLibCheck": true }, "exclude": ["node_modules"] } -
Sync and commit: Push the folder (excluding
node_modules,package-lock.json, and dotfiles such as.npmrc) to your branch withforge extensions update-extension-filesor MCP’ssync_extension_files("delete": true), then commit withforge commits create-commit.