Canonfig
Reference

Canonical Folder reference

Look up every file in ~/.canonfig/, every canonfig.jsonc key, the frontmatter each document takes, the local/ folder, and the messages a folder that does not validate produces.

The Canonical Folder, ~/.canonfig/, holds your agent setup in one place. On the Source Machine you edit it, and canonfig source publish signs it as the next Profile Revision. On a Follower Machine, canonfig sync writes the authorized items into the same places in its own ~/.canonfig/ (the mirror) and projects the mirror plus local/ into the harnesses. Which file goes where in each harness is in the harness reference.

Layout

~/.canonfig/
  canonfig.jsonc          harness list, MCP servers, hooks, settings, tools, credentials, groups, schedule, local policy
  AGENTS.md               global instructions
  rules/<id>.md           rules
  skills/<name>/SKILL.md  Agent Skills, one directory each
  agents/<id>.md          subagents
  commands/<id>.md        slash commands
  hooks/...               scripts that hooks in canonfig.jsonc run
  files/...               content of authored resources
  local/                  this machine's own items, never published
  .backups/               takeover snapshots
  .runtime/               the generated hook runner
  state.sqlite  setup.json  canonfig.log  installers/  skills-sources.json  tunnel/  cache/

The first eight entries are the authoring allowlist. Publication reads only those, and a Follower Machine writes only those. Everything else in the folder belongs to the machine it is on: Canonfig never publishes, mirrors, or replaces it.

EntryPublishedContents
canonfig.jsoncYesSee canonfig.jsonc. Required.
AGENTS.mdYesGlobal instructions, in Markdown.
rules/, agents/, commands/YesOne <id>.md document per item. See Documents.
skills/YesOne directory per skill, each with a SKILL.md.
hooks/YesScripts a hook runs. Every file here must be run by a hook.
files/YesContent of authored resources. Every file here must be read by a resource.
local/NoItems only this machine projects. See The local folder.
.backups/NoTakeover snapshots, of harnesses and of folder entries canonfig import --replace replaced. See Restore a harness from a backup.
.runtime/Nohook-runner.mjs, which every projected hook calls.
state.sqliteNoEnrollment, Profile Revisions, run journal, Applied Resource Records, and the export and import journal.
setup.jsonNoThe canonfig setup plan, approval, and progress.
canonfig.logNoThe command log.
installers/NoInstaller bindings.
skills-sources.jsonNoWhere tracked upstream skills came from.
tunnel/, cache/NoThe managed SSH tunnel record and downloaded revision files.

Every file Canonfig reads from the allowlist must be a regular file or directory inside the folder. Symbolic links are refused, so neither a link nor .. can make Canonfig publish content from elsewhere on your disk.

On a Follower Machine the allowlist entries are the mirror of what its Source Machine publishes, and the mirrored canonfig.jsonc starts with a comment saying so. Do not edit mirror files. An edited mirror file is Follower Drift: Canonfig keeps your edit, reports it, and stops with exit 4 while its projections stay as they were last applied. Put this machine's own items in local/. canonfig follower enroll refuses a folder that already holds authored items; see Enrollment.

canonfig.jsonc

{
  "version": 1,
  "profile": { "id": "workstation", "name": "Developer workstation" },
  "harnesses": ["claude-code", "codex", "opencode"],
  "mcp": {
    "docs": {
      "transport": "streamable-http",
      "url": "https://docs.example.com/mcp",
      "headers": { "Authorization": { "fromEnv": "DOCS_MCP_TOKEN" } }
    },
    "git": { "transport": "stdio", "command": "uvx", "args": ["mcp-server-git"], "requires": ["tools/uv"] }
  },
  "hooks": [
    {
      "id": "format",
      "event": "after_tool",
      "matcher": { "capabilities": ["write"] },
      "run": ["hooks/format.sh"],
      "timeoutMs": 5000,
      "onFailure": "warn"
    }
  ],
  "settings": {
    "codex": { "model_reasoning_effort": "high" },
    "claude-code": { "model": "opus" }
  },
  "tools": {
    "uv": {
      "executable": "uv",
      "recipes": [
        { "platform": "macos", "method": "brew", "package": "uv", "version": "0.9.7" }
      ]
    }
  },
  "credentials": { "docs-token": { "reference": "DOCS_MCP_TOKEN" } },
  "groups": { "work": ["mcp/docs"] },
  "scheduleDefault": "daily@09:00",
  "local": { "allow": ["skills", "mcp", "settings"] }
}

The file accepts // and /* */ comments and trailing commas. A key the table does not list is an error, so a typo fails instead of being ignored.

KeyRequiredTypeMeaning
versionYes1The file format.
profileTo publish{ "id": string, "name": string }The Machine Profile this folder publishes. id starts with a letter or digit and contains letters, digits, ., _, :, and -. Projection does not use it.
harnessesYesarray of harness idsThe Target Harnesses to project into. Ids are listed in the harness reference.
mcpNoobject: name to MCP serverMCP servers every listed harness gets.
hooksNoarray of hooksLifecycle hooks, in the order they run.
settingsNoobject: harness id to object of key path to valueKeys written into that harness's settings file. See Settings.
surfacesNoobject: harness id to array of categoriesGives a listed harness only these categories: any of instructions, rules, skills, agents, commands, hooks, mcp, settings. A harness not named gets every category. Naming a harness that harnesses does not list fails validation. See Give a harness only some categories.
toolsNoobject: id to toolCommand-line tools every Follower Machine installs and verifies.
credentialsNoobject: id to { "reference": string }A credential each Follower Machine must already hold, by name. The value never leaves the Follower Machine.
groupsNoobject: group name to array of item referencesItems only Follower Machines in that Follower Group receive. See Groups.
scheduleDefaultNodaily@HH:mm or weekly:Mon,Thu@HH:mmA suggested schedule. Sync never installs it; a Follower Machine accepts it with canonfig schedule set --default.
localNo{ "allow"?: array, "appendLocal"?: array }allow: which categories machines may add in local/: any of instructions, rules, skills, agents, commands, mcp, settings. appendLocal: instructions, skills, or both; those harness outputs keep each machine's own text and skills (see Keep a machine's own instructions and skills). Default: none.
resourcesNoobject: id to resourceFiles, directories, and config keys outside every harness. See Manage files outside the harnesses.

Names used as object keys (MCP servers, hook ids, tools, credentials, groups) start with a letter or digit and contain only letters, digits, -, and _.

MCP servers

"mcp": {
  "git": { "transport": "stdio", "command": "uvx", "args": ["mcp-server-git"], "env": { "GIT_AUTHOR": "dana" } },
  "docs": { "transport": "streamable-http", "url": "https://docs.example.com/mcp" }
}
FieldTransportTypeMeaning
transportallstdio, streamable-http, or sseRequired.
commandstdiostringRequired. A command name or absolute path.
argsstdioarray of stringsArguments.
envstdioobject of secret valuesEnvironment variables for the server.
cwdstdiostringWorking directory.
urlstreamable-http, ssestringRequired.
headersstreamable-http, sseobject of secret valuesHTTP headers.
enabledallbooleanfalse keeps the server in the file but projects nothing.
timeoutMsallpositive integerTimeout in milliseconds, where the harness has one.
enabledTools, disabledToolsallarray of stringsTool filters, where the harness has them.
requiresallarray of tools/<id>Tools to install and verify before the server is projected. Each must be declared under tools.

A harness that cannot express a field, or the sse transport, gets a warning in the plan naming the server; Canonfig does not write the field somewhere else. The harness reference lists what each harness lacks.

Secret values

An env or headers value is a literal string, an environment reference, or a shared-secret reference:

{ "fromEnv": "DOCS_MCP_TOKEN" }
{ "fromEnv": "DOCS_REGION", "default": "eu" }
{ "fromSecret": "docs-token" }

fromSecret uses the same name as canonfig secrets set: 1 to 128 characters, starting with a letter or digit, followed by letters, digits, ., _, :, or -. It cannot have a default or be combined with fromEnv. Both canonfig.jsonc and allowed local/local.jsonc MCP entries accept it.

If any value uses fromSecret, every harness receives a stdio command for canonfig mcp run <name>, bound to the absolute installed Node executable and CLI entrypoint. The launcher reads this machine's applied folder, honors its local allowlist and explicit overlays, and resolves credentials only at launch. It bridges remote servers through pinned mcp-remote@0.16.6, using an installed npx JavaScript entrypoint with the same Node executable. If npm is unavailable, install it for that Node installation before restarting the server. On Windows, stdio commands must be native executables, not .cmd or .bat wrappers. For a JavaScript server, configure node.exe as the command and its JavaScript entrypoint as the first argument. The launcher does not use a shell. References, never resolved values, go into publications and exports. Harness configs and plans contain the launcher command, not credential values.

For those servers, projection forwards every fromEnv source name symbolically, including header references. On Linux it also forwards DBUS_SESSION_BUS_ADDRESS and XDG_RUNTIME_DIR so the launcher can reach the login credential store. No environment values are read during projection. fromEnv reads the launcher's environment and honors its optional default. Configured environment keys replace inherited keys case-insensitively on Windows only. Without fromSecret, projection stays unchanged: the harness reads environment references when it starts the server. A literal that looks like a credential stops publication; see Publication failures. See Share MCP credentials for setup.

Hooks

FieldRequiredTypeMeaning
idYesnameUnique in the array.
eventYesevent namesession_start, session_end, prompt_submit, before_agent, after_agent, before_tool, after_tool, before_compact, after_compact, stop, subagent_start, or subagent_stop.
runYesarray of strings, at least oneThe command and its arguments. run[0] is a command name looked up on PATH, an absolute path, or a script under hooks/, such as hooks/format.sh.
matcherNo{ "capabilities"?, "tools"?, "inputRegex"? }Limits a tool event to tools with one of these capabilities (read, write, search, shell, web, mcp, subagent, test, git), these tool names, or input matching the regular expression.
timeoutMsNopositive integerDefault 30000.
onFailureNoblock, warn, or ignoreDefault warn.
enabledNobooleanfalse skips the hook.

Each projected hook calls its versioned runner under ~/.canonfig/.runtime/, which runs run. A script under hooks/ is run by its absolute path in the folder, so it works from any directory. An event a harness does not emit is reported as a warning for that harness.

Settings

"settings": {
  "codex": { "model_reasoning_effort": "high" },
  "claude-code": { "permissions.deny": ["Read(./.env)"] }
}

Each key is a path into the harness's settings file, with . between nested keys: permissions.deny is the deny key inside permissions. Write \. for a dot inside a key name and \\ for a backslash. In JSONC each backslash is itself escaped, so Amp's top-level key amp.mcpServers is the path "amp\\.mcpServers". A value is a string, number, boolean, array, or object. null is not allowed.

Canonfig owns each declared key's whole value and leaves every other key in the file as it is. Two keys for one harness must not overlap: mcp and mcp.git cannot both be declared. A key must not overlap a key Canonfig already writes from the folder (for example mcpServers) or a key the harness keeps for its own credentials. The harness reference lists each harness's settings file and reserved keys.

Tools

"tools": {
  "ripgrep": {
    "executable": "rg",
    "recipes": [
      { "platform": "linux", "method": "apt", "package": "ripgrep", "version": "14.1.0-1" },
      { "platform": "macos", "method": "brew", "package": "ripgrep", "version": "14.1.1" },
      { "platform": "windows", "method": "winget", "package": "BurntSushi.ripgrep.MSVC", "version": "14.1.1" }
    ],
    "verify": { "method": "command", "command": ["rg", "--version"], "expectContains": "ripgrep 14.1" }
  }
}
FieldRequiredMeaning
executableYesThe command name or entry file the tool provides. Planning checks it.
recipesYesOne Installation Recipe per platform: platform (linux, macos, windows), method, package, and version.
loginNo{ "required": false }, or { "required": true, "howTo": string } for a tool that needs a person to sign in.
agentInstallNo{ "paths": [string, ...], "origins"?: [https-origin, ...] }: where a Configuration Agent may install the tool when no recipe fits.
verifyNocommand, executable-present, or mcp-qualification. Default: executable-present on executable.

method is apt, brew, bun, cargo, npm, pnpm, uv, winget, or source. Every method except source needs an exact version. Recipe fields, verification, and logins are explained in How Canonfig installs and verifies tools. canonfig source scan --write adds entries here for you.

Groups

"groups": {
  "work": ["mcp/docs", "skills/deploy", "tools/ripgrep"],
  "design": ["instructions"]
}

An item reference is instructions (the AGENTS.md file) or <category>/<name>, where the category is rules, skills, agents, commands, hooks, mcp, settings (the name is a harness id), tools, credentials, or resources. A grouped item reaches only Follower Machines enrolled in one of its groups. An item no group names reaches every Follower Machine. A hook script reaches the machines that one of its hooks reaches, and a file under files/ the machines that one of the resources reading it reaches. The harness list and local always reach every Follower Machine.

Grant a Follower Group with canonfig source invite --group <name>.

Documents

Rules, subagents, and commands are Markdown files with YAML frontmatter between --- lines. The file name, without .md, is the item's id: letters, digits, -, and _. A frontmatter field the table does not list is an error.

~/.canonfig/rules/typescript.md
---
description: TypeScript conventions
paths: ["src/**/*.ts"]
---
Use `unknown` instead of `any`, and narrow it before use.
DocumentFieldRequiredValue
rules/<id>.mddescriptionNoOne line about the rule.
pathsNoGlob patterns the rule applies to.
activationNoalways, path, manual, or model. Default: path when paths is set, else always.
agents/<id>.mddescriptionYesWhen to use the subagent.
modelNoA model name the harness understands. Default inherit, the harness default.
toolsNoCapabilities: read, write, search, shell, web, mcp, subagent, test, git. Each harness maps them to its own tool names.
writableNotrue lets the subagent change files. Default false.
commands/<id>.mddescriptionYesWhat the command does.
argumentHintNoThe argument hint the harness shows, for example <file>.
skills/<name>/SKILL.mdnameYesEqual to the directory name: lowercase letters, digits, and -.
descriptionYesWhen to use the skill.

A skill's SKILL.md may carry other Agent Skills fields, such as license or metadata; Canonfig reads only name and description. Every file in the skill directory is published, with its executable bit.

The local folder

~/.canonfig/local/ holds what only this machine projects. It is never published and never replaced by a sync.

~/.canonfig/local/
  rules/<id>.md
  AGENTS.md
  skills/<name>/SKILL.md
  agents/<id>.md
  commands/<id>.md
  local.jsonc

Documents use the same frontmatter as in the folder itself. local.jsonc takes these keys:

KeyTypeMeaning
mcpobject: name to MCP serverMCP servers only this machine adds.
settingsobject: harness id to object of key path to valueSettings keys only this machine adds.
excludeHarnessesarray of harness idsHarnesses this machine never projects, even when listed. canonfig harnesses exclude and canonfig restore edit it.
excludeResourcesarray of resource idsAuthored resources this machine never projects. canonfig restore adds the ones it gives back.
excludeSkillsarray of skill namesSkill directories this machine keeps local in every harness, including shared skills. Requires Source local.appendLocal to include skills. Excluded skills are not written, checked, or deleted, even if previously managed. Source copies can remain in the canonical mirror. Removing an exclusion does not adopt a local copy; overlapping local content stops sync. Use canonfig local skills list, add <name>, or remove <name>, or Kept on this machine in the machine-local settings page.
preserveMcpboolean or non-empty array of harness idstrue keeps every harness's native MCP configuration outside projection on this machine. false or absent projects MCP everywhere. An array such as ["codex"] preserves only those harnesses; other harnesses still receive Source MCP. Unknown ids and empty arrays are rejected. Native options the canonical format cannot represent stay untouched, including on later Source additions. Other settings still follow the Source. Use canonfig local mcp status, preserve or project with repeatable --harness <id>, or Native MCP under Kept on this machine in the browser. Preserved is not disabled or verified connectivity.
overlaysarray of <category>/<name> or settings/<harness>#<key>Local Overlays: published items this machine's local item replaces. Key claims: settings keys Canonfig never writes, removes, or checks on this machine, while the other keys of that settings file follow the Source. canonfig overlay set and remove edit it. See Replace a published item on one machine.
backupsbooleanfalse turns harness takeover snapshots off on this machine; canonfig import --replace still snapshots the folder entries it replaces. Default true.

The Source Machine decides which categories local items may add, with local.allow in canonfig.jsonc. A local category that local.allow does not name is skipped and reported in the plan:

local/skills/ is not admitted by canonfig.jsonc local.allow and was not projected

excludeHarnesses and backups always apply: a Source Machine cannot turn off a Follower Machine's exclusions or backups. On the Source Machine itself, local.allow applies the same way. See Add items only one machine uses.

A local item with the same name as a published one stops the run with Human Action Required (exit 3), because Canonfig will not choose between them:

MessageFix
<path>: local <kind> <name> has the same name as a published one; rename or remove one of them, or let yours replace it on this machine with 'canonfig overlay set <category>/<name>' (kind is rule, skill, agent, command, or MCP server)Rename the local item, ask the Source Machine to drop the published one, or set a Local Overlay.
<path>: local setting <harness> <key> overlaps published setting <key>; remove one of them, or let yours replace it on this machine with 'canonfig overlay set settings/<harness>'Remove the local key, or set a Local Overlay.

Enrollment

One ~/.canonfig/ is either the folder a Source Machine authors or a Follower Machine's mirror, so a machine holds one role. canonfig follower enroll and canonfig setup plan --role follower refuse a Source Machine, and the Source commands that create, scan, publish, serve or grant access refuse an enrolled Follower Machine. Each exits 2 and changes nothing; the CLI reference lists the messages.

A Follower Machine's allowlist entries hold its Source Machine's mirror, so canonfig follower enroll also refuses a folder that already holds authored items:

/home/dana/.canonfig already holds authored items (AGENTS.md, skills), where a follower keeps its Source's mirror; move what this machine should keep into /home/dana/.canonfig/local (rules, skills, agents and commands as files, MCP servers and settings in local.jsonc) or remove them, then enroll again

Empty directories do not count. The command exits 2 and nothing is enrolled.

Validation failures

Canonfig checks the folder when it publishes, plans, and syncs. A failure exits 2 and names the file, in the form <path>: <message>.

MessageCause
does not exist; scaffold the folder with 'canonfig setup plan --role source', or enroll this machine as a followerThere is no canonfig.jsonc.
is not valid JSONC: <error> at offset <n>canonfig.jsonc or local/local.jsonc does not parse.
A schema message naming the keyA key has the wrong type or value, or is unknown.
is not valid UTF-8A text file holds invalid bytes.
resolves outside the Canonical FolderA path resolves to somewhere outside ~/.canonfig/.
is not a regular file; links and special files are not authoring inputAn authored path is a link or a special file.
is a link; links are not authoring inputA directory entry is a symbolic link.
is not a directoryrules, skills, agents, commands, or hooks is a file.
only <id>.md documents belong hererules/, agents/, or commands/ holds a directory or a file without .md.
file names must be letters, digits, '-' or '_' followed by .mdA document's file name has other characters.
has invalid frontmatter: <detail>The YAML between the --- lines does not parse.
every entry of skills/ is a skill directoryskills/ holds a file.
skill directory names are lowercase letters, digits and '-'A skill directory name has other characters.
has no SKILL.mdA skill directory has no SKILL.md.
needs a name and a description: <detail>SKILL.md lacks name or description.
names the skill <name>, but its directory is <directory>name differs from the directory name.
hook id <id> is declared twiceTwo hooks share an id.
hook command <command> must be a command name, an absolute path, or a script under hooks/run[0] is a relative path outside hooks/.
hook script <script> does not existrun[0] names a missing file under hooks/.
settings names unknown harness <name>A settings key is not a harness id.
settings.<harness> key <key>: <issue>A settings key path is malformed, for example an unknown \ escape.
settings.<harness> keys <key> and <key> overlapOne declared key contains another.
settings.<harness>: <harness> has no settings file Canonfig writesThe harness has no settings file; see the harness reference.
settings.<harness>.<key> overlaps <reserved>, which <harness> keeps for itselfThe key names harness credentials or provider keys.
settings.<harness>.<key> overlaps <key>, which Canonfig already writes from the folderThe key overlaps a key Canonfig projects from mcp or hooks.

Publication failures

canonfig source publish --reviewer <name> checks more before it signs. Each failure exits 2 and nothing is signed. Most messages start with the publication input is not valid:, followed by the reason below.

ReasonFix
<path> needs "profile": { "id": ..., "name": ... } to publish; the id names the Machine Profile followers syncAdd profile to canonfig.jsonc.
this Source publishes profile <id>; set "profile.id" in canonfig.jsonc back to <id>One Source Machine publishes one Machine Profile. Restore the original id.
<path> hook <id> runs <script>, which does not existAdd the script under hooks/, or fix run.
<path> is not run by any hook in canonfig.jsonc, so it would never reach a follower; reference it from a hook or remove itA file under hooks/ is unused.
<path> <file> needs path segments of letters, digits, '.', '_' or '-', none of them only dotsRename the file under hooks/ or files/. A : or a name of only dots cannot reach a follower.
<path> mcp.<name> requires <tools/id>, which "tools" does not declareDeclare the tool, or drop it from requires.
<path> groups.<group> names <reference>, which the folder does not declareFix the reference, or add the item.
config resource <id> at <path> contains a literal credential [REDACTED]; ...Replace the value with a { "fromEnv": ... } reference, or store it with canonfig secrets set.
installer <method> requires an exact "version" so every follower installs the same buildAdd the exact version to the recipe.

Publishing content equal to the latest Profile Revision returns that revision. Any other content, including an older revision's, becomes the next sequence number, which is how you roll back. See Publish changes from the folder.

On this page