Extensions
Extensions let third-party developers add new capabilities to AI Factory — custom CLI commands, MCP servers, skill injections, runtime definitions, runtime-specific agent files, scoped tool requests, and more. Extensions survive ai-factory update (injections, tool requests, and managed agent files are automatically re-applied after skills are refreshed).
For Users
Installing an Extension
# From a local directory
ai-factory extension add ./my-extension
# From a git repository
ai-factory extension add https://github.com/user/aif-ext-example.git
# From npm
ai-factory extension add aif-ext-example
Managing Extensions
# List installed extensions
ai-factory extension list
# Update extensions from their sources
ai-factory extension update
# Update a specific extension
ai-factory extension update aif-ext-example
# Force refresh even if version unchanged
ai-factory extension update --force
# Remove an extension (cleans up injections, MCP servers, and files)
ai-factory extension remove aif-ext-example
What Happens on Install
- Extension files are copied to
.ai-factory/extensions/<name>/ - Extension is recorded in
.ai-factory.jsonunderextensions - Extension skills (from
skills) are installed into configured agents - Runtime definitions from
agentsare added to the effective registry for futureai-factory initruns - Agent files from
agentFilesare copied into matching runtimeagentsDirlocations - Agent-file tracking is updated immediately:
installedAgentFiles,agentFileSources, andmanagedAgentFilesare written together for affected runtimes - Injections are applied to matching skill files (e.g. appending extra instructions to
/aif-implement) - MCP servers are merged into each agent's settings file (e.g.
.mcp.json) - Custom CLI commands become available immediately
What Happens on Update
Running ai-factory update:
- Self-update check — prompts to update the CLI if a newer version exists
- Extension refresh — checks installed extensions for updates from their sources:
- npm packages: queries registry for latest version
- GitHub repos: fetches
extension.jsonvia GitHub API (faster than cloning) - Local paths: requires
--forceto refresh - Extensions with unchanged versions are skipped
- Base skill update — updates installed base skills, reports per-agent status (
changed,unchanged,skipped,removed) - Reinstall replacement skills — re-installs skills from extension manifests
- Reinstall tracked extension agent files — refreshes extension-managed runtime files and reports them in the per-agent agent-file section
- Re-apply injections — re-applies all extension injections automatically
ai-factory update --force forces a clean reinstall of base skills AND forces extension refresh regardless of version changes.
If an installed extension manifest is temporarily missing or invalid during ordinary ai-factory update, AI Factory keeps the tracked installedAgentFiles, agentFileSources, and managedAgentFiles entries instead of clearing them. In that case it warns and skips only the source-driven healing it can no longer prove safe.
Extension Update Behavior
| Source Type | Version Check | --force Behavior |
|---|---|---|
| npm | Registry lookup, skip if unchanged | Always re-download |
| GitHub | API fetch of extension.json, skip if unchanged |
Always re-clone |
| GitLab / other git | Requires --force |
Always re-clone |
| Local path | Requires --force |
Re-copy from source |
GitHub API Rate Limits
GitHub API requests use GITHUB_TOKEN if present (5000 req/hr). Without a token, you're limited to 60 req/hr. If rate-limited, the extension refresh is skipped with a warning — the broader update continues.
# Set GITHUB_TOKEN for higher rate limits
export GITHUB_TOKEN=ghp_xxxx
ai-factory update
Updating Extensions Separately
Use ai-factory extension update to refresh extensions without updating base skills:
# Update all extensions
ai-factory extension update
# Update a specific extension
ai-factory extension update aif-ext-example
# Force refresh regardless of version
ai-factory extension update --force
The command outputs per-extension status:
✓ aif-ext-example: v1.0.0 → v1.1.0
- aif-ext-other: v1.0.0 (unchanged)
⚠ aif-ext-local: source type requires --force
Summary:
Updated: 1
Unchanged: 1
Skipped: 1
What Happens on Remove
- Injection markers are stripped from all skill files
- MCP server entries are removed from agent settings files
- Extension-owned agent files are deleted from runtime
agentsDirlocations and pruned frominstalledAgentFiles,agentFileSources, andmanagedAgentFiles - Extension directory is deleted from
.ai-factory/extensions/ - Extension record is removed from
.ai-factory.json
For Developers
Extension Structure
An extension is a directory (or npm package, or git repo) with extension.json in the root:
my-extension/
├── extension.json # Manifest (required)
├── package.json # Required for npm packages
├── commands/ # Custom CLI commands
│ └── hello.js
├── injections/ # Content to inject into existing skills
│ └── implement-extra.md
├── skills/ # Custom and replacement skills
│ ├── my-skill/
│ │ └── SKILL.md
│ └── my-commit/ # Replaces built-in aif-commit
│ └── SKILL.md
└── mcp/ # MCP server templates
└── my-server.json
Note: If you plan to publish your extension as an npm package, you must include a
package.jsonalongsideextension.json. Thenpm packcommand used during installation requires it. A minimalpackage.jsonis sufficient:{ "name": "aif-ext-example", "version": "1.0.0", "description": "Example extension", "type": "module" }For local directory and git sources, only
extension.jsonis required.
Manifest: extension.json
{
"$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json",
"name": "aif-ext-example",
"version": "1.0.0",
"description": "Example extension",
"commands": [
{
"name": "hello",
"description": "Say hello",
"module": "./commands/hello.js"
}
],
"agents": [
{
"id": "my-agent",
"displayName": "My Agent",
"configDir": ".my-agent",
"skillsDir": ".my-agent/skills",
"agentsDir": ".my-agent/agents",
"agentFileExtension": ".toml",
"settingsFile": null,
"supportsMcp": false,
"skillsCliAgent": null
}
],
"agentFiles": [
{
"runtime": "claude",
"source": "agent-files/claude/review-helper.md",
"target": "review-helper.md"
},
{
"runtime": "my-agent",
"source": "agent-files/my-agent/coordinator.toml",
"target": "coordinator.toml"
}
],
"injections": [
{
"target": "aif-implement",
"position": "append",
"file": "./injections/implement-extra.md"
}
],
"skills": [
"skills/my-skill",
"skills/my-commit"
],
"replaces": {
"skills/my-commit": "aif-commit"
},
"mcpServers": [
{
"key": "my-server",
"template": "./mcp/my-server.json",
"instruction": "My Server: Set MY_API_KEY environment variable"
}
]
}
Only name and version are required. All other fields are optional.
AI Factory publishes the extension manifest schema at schemas/extension.schema.json in the npm package. Extension authors may add an optional $schema property for editor/tooling validation.
Use the public schema URL when the extension should work regardless of whether the ai-factory CLI is installed locally or globally:
{
"$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json"
}
If your extension project installs ai-factory as a local dependency and you want offline or package-version-aligned validation, use the package-local schema path instead, adjusting the relative path from your extension.json location:
{
"$schema": "./node_modules/ai-factory/schemas/extension.schema.json"
}
The schema validates the public manifest shape: commands, runtime definitions, runtime-aware agentFiles, injections, toolPermissions, skills, replacements, and MCP server templates. Install-time semantics still run in AI Factory itself, including runtime existence, safe relative paths, extension matching, duplicate ownership, and whether a runtime supports managed agent files.
Manifest Fields
| Field | Type | Description |
|---|---|---|
$schema |
string |
Optional schema reference for editor and tooling validation. |
name |
string |
Required. Unique extension name. Allowed characters: letters, digits, _, -, ., @, /. No .. or absolute paths. |
version |
string |
Required. Version string (SemVer is recommended). |
description |
string |
Human-readable description. |
commands |
array |
CLI commands to register. |
agents |
array |
Runtime definitions that become available to ai-factory init, --agents, and core runtime lookups once the extension is installed. |
agentFiles |
array |
Runtime-aware agent assets copied into agentsDir for built-in or extension-defined runtimes. |
injections |
array |
Content to inject into existing skill files. |
toolPermissions |
array |
Native tool requests for specific skills and runtimes; currently Claude Code only. |
skills |
array |
Paths to skill directories within the extension. |
replaces |
object |
Maps extension skill paths to base skill names they replace (e.g. {"skills/my-commit": "aif-commit"}). |
mcpServers |
array |
MCP server configurations to merge into agent settings. |
Commands
A command module is a JavaScript (ESM) file that exports a register function receiving the Commander.js program instance:
// commands/hello.js
export function register(program) {
program
.command('hello')
.description('Say hello from my extension')
.option('--name <name>', 'Name to greet', 'World')
.action((opts) => {
console.log(`Hello, ${opts.name}!`);
});
}
After installation, the command is available as:
ai-factory hello
ai-factory hello --name Alice
Commands are loaded dynamically at CLI startup. A broken command module won't crash the CLI — it will log a warning to stderr and continue.
Injections
Injections append or prepend content to existing skill files. This lets extensions augment built-in workflows without replacing them entirely.
Injection Definition
{
"target": "aif-implement",
"position": "append",
"file": "./injections/implement-extra.md"
}
| Field | Values | Description |
|---|---|---|
target |
Any skill name | The skill to inject into (e.g. aif-implement, aif-commit, aif-plan). |
position |
append or prepend |
Where to insert the content. prepend inserts after YAML frontmatter. |
file |
Relative path | Path to the markdown file within the extension directory. |
How Injections Work
Injected content is wrapped in HTML comment markers for tracking:
<!-- aif-ext:my-extension:aif-implement:append:start -->
Your injected content here.
<!-- aif-ext:my-extension:aif-implement:append:end -->
These markers enable:
- Idempotent application — re-installing the same extension won't duplicate content
- Clean removal —
extension removestrips exactly the injected blocks - Update survival —
ai-factory updateoverwrites base skills, then re-applies all injections
Example Injection File
## Post-Implementation Checklist (from my-extension)
After completing each task:
1. Run the linter: `npm run lint`
2. Check for console.log statements left in production code
3. Verify error messages are user-friendly
Skill Tool Permissions
Instructions injected into a skill do not change its YAML frontmatter. An extension can separately declare the native tool permissions needed by a specific skill:
{
"toolPermissions": [
{
"target": "aif-implement",
"agents": {
"claude": ["Bash(ai-factory hello *)"]
}
}
]
}
Declare each target once, with a non-empty agents map of runtime IDs to tool
arrays. The target is an installed skill name, not a path. The CLI reports requested
skills/runtimes/tools before applying them. Missing targets are reported and skipped.
Extensions without this field retain their existing behavior.
Runtime support: Claude Code receives the exact declared entries in that skill's
allowed-tools. Other runtimes are explicitly reported as unsupported and receive no
permission changes. AI Factory does not translate an unsupported request into broad
shell access or write global/session permission settings. A Claude root shared with
another configured runtime is rejected because a runtime-specific grant cannot be
isolated there.
Claude requests support native tool names such as Read or mcp__server__tool,
scoped non-shell rules such as Read(src/**), and literal Bash executable/subcommand prefixes such as Bash(ai-factory hello *).
Unrestricted Bash, Bash(*), wildcard tool names, command chaining, multiline rules,
and unsupported rule syntax are rejected. Existing broader user entries are preserved;
AI Factory does not infer additional permissions from injected prose.
Claude's field provides native pre-approvals during the invoking turn; it does not restrict the available tool pool. Managed settings, deny/ask rules, and other native policies still apply. See Claude Code's skill permission documentation.
Ownership and updates: the field is rendered as a YAML flow list with an
aif-ext-tools comment containing its original field and extension requests. Keep this
comment intact. Entries already present in the original field stay user/base-owned;
an extension never claims them. Shared requests produce one entry and remain until
all requesting extensions are removed. Removing an extension removes only its owned
entries, including when its installed manifest is missing. User additions, duplicate
entries, and edited entries are preserved. Removing the ownership comment relinquishes
automatic cleanup rather than authorizing deletion of unproven entries.
Reinstall, extension refresh, init, update (including --force), and upgrade
preserve the existing unowned field while the source owner and its extension-native
tool declaration remain unchanged, and recompose active requests. This includes user
removals; changed bundled package defaults for that field require manual reconciliation.
Removing a replacement uses the restored bundled skill's own declaration. Refreshing a replacement with a different source or native tool declaration uses the new source field, including on same-version local refreshes. Captured native grants and edits from the previous source are not carried over; remaining extensions' requests are recomposed with their ownership intact.
Applied replacement records and installed extension sources establish the source identity, rather than a manifest claim alone.
Permission targets participate in extension rollback. Managed receipts include the exact known permission composition; user changes are not promoted into proven package ownership.
String, quoted-string, flow-list, and block-list fields are accepted. Invalid or ambiguous YAML, permission aliases/anchors, unsafe paths, and symbolic/hard-linked skill entries fail without granting permissions. Other frontmatter fields and the skill body retain their bytes.
MCP Servers
Extensions can provide MCP (Model Context Protocol) server configurations that are automatically merged into each agent's settings file.
MCP Server Definition
{
"key": "my-server",
"template": "./mcp/my-server.json",
"instruction": "My Server: Set MY_API_KEY environment variable"
}
| Field | Description |
|---|---|
key |
Unique key for the MCP server entry in the agent's settings. |
template |
Path to a JSON template file within the extension directory. |
instruction |
Optional. Shown to the user after installation (e.g. what env vars to set). |
MCP Template Format
Same format as built-in MCP templates:
{
"command": "npx",
"args": ["-y", "@my-org/my-mcp-server"],
"env": {
"MY_API_KEY": "${MY_API_KEY}"
}
}
The template is merged into the agent's settings file under mcpServers.<key> (or servers.<key> for GitHub Copilot, mcp.<key> for OpenCode, [mcp_servers.<key>] in .codex/config.toml for Codex app). Only agents with supportsMcp: true are configured. On extension remove, the key is deleted from the settings file; for Codex app, the matching TOML server table and all nested subtables are removed.
Agents
Extensions can declare new runtime configurations. Once the extension is installed, these runtime ids are loaded into the effective registry before ai-factory init, --agents validation, MCP routing, injections, and installer lookups.
{
"id": "my-agent",
"displayName": "My Agent",
"configDir": ".my-agent",
"skillsDir": ".my-agent/skills",
"settingsFile": ".my-agent/mcp.json",
"supportsMcp": true,
"skillsCliAgent": "my-agent"
}
| Field | Description |
|---|---|
id |
Unique agent identifier (used in config and CLI). |
displayName |
Human-readable name shown in prompts. |
configDir |
Directory for agent configuration (e.g. .my-agent). |
skillsDir |
Where skills are installed (e.g. .my-agent/skills). |
settingsFile |
Path to the agent's MCP settings file, or null. |
supportsMcp |
Whether this agent supports MCP server configuration. |
skillsCliAgent |
Value for --agent flag in skills CLI, or null. |
When a runtime supports custom agent files, set both:
| Field | Description |
|---|---|
agentsDir |
Runtime-local directory for custom agents (for example .codex/agents). |
agentFileExtension |
Required file extension for agent assets (.md or .toml). |
Agent Files
Use agentFiles to provide runtime-specific custom agent assets without conflating them with runtime definitions:
{
"agentFiles": [
{ "runtime": "claude", "source": "agent-files/claude/review-helper.md", "target": "review-helper.md" },
{ "runtime": "codex", "source": "agent-files/codex/committee.toml", "target": "committee.toml" }
]
}
Rules:
runtimemust exist in the effective registry (built-in or provided by an installed extension, including the current manifest).- Codex app is skills-first and does not define a runtime-global
agentsDir; extensionagentFilescannot targetcodex-appunless that runtime contract is added later. sourceandtargetmust be safe relative paths.- Source and target extensions must match the runtime's
agentFileExtension. - Ownership is exclusive per
runtime + target; conflicts with bundled Claude files or another extension are rejected before install. - Bundled Claude filenames are reserved by target path from the package
subagents/claude/agents/inventory; an extension cannot claim the sameclaudetarget filename even if the local managed copy was later edited or removed. - AI Factory validates ownership, path safety, runtime existence, and file extension, then copies the asset verbatim. Runtime-specific internals of the file remain the runtime's responsibility.
- After install, AI Factory tracks the target in
installedAgentFiles, records its source inagentFileSources, and stores source/install hashes inmanagedAgentFiles. - For Codex
.tomlhelpers, keep runtime-local settings such asmodel,model_reasoning_effort,sandbox_mode, anddeveloper_instructionsinside the agent file instead of assuming an extension injection or workflow skill can pass them dynamically. - Prefer read-only one-shot helpers for Codex-style support workers. If a helper is allowed to write, document the owned artifact scope explicitly in
developer_instructions.
Skills
Extensions can bundle custom skills. List them in the manifest skills array as relative paths:
{
"skills": ["skills/my-custom-skill"]
}
Each skill follows the standard Agent Skills format — a directory with SKILL.md:
skills/my-custom-skill/
└── SKILL.md
On ai-factory extension add, these skills are installed into each configured agent's skills directory (using the same agent transformer logic as built-in skills). The original extension copy remains in .ai-factory/extensions/<name>/.
Skill Replacements
Extensions can replace built-in skills with their own versions using the replaces field. This maps extension skill paths to the base skill names they replace:
{
"skills": ["skills/my-commit"],
"replaces": {
"skills/my-commit": "aif-commit"
}
}
| Field | Type | Description |
|---|---|---|
replaces |
Record<string, string> |
Maps extension skill path (from skills array) to the base skill name it replaces. |
How Replacements Work
The replacement skill is installed under the base skill name. For example, skills/my-commit from the extension will be installed as aif-commit/SKILL.md in the agent's skills directory. The user still invokes /aif-commit — but the content comes from the extension.
On install (extension add):
- The extension skill overwrites the base skill directory (installed under the base name)
- The replacement is recorded in
.ai-factory.json
On update (ai-factory update):
- Replaced base skills are skipped during reinstallation
- Extension replacement skills are re-installed from
.ai-factory/extensions/ - If the extension manifest is missing/broken, the ordinary update can restore the base skill. A pending skill-directory migration instead stops before changing installed files because it cannot prove the replacement's source.
On remove (extension remove):
- The replacement skill is removed (by its base name)
- The original base skill is restored — unless another extension still replaces it
Shared Skill Targets
When Codex CLI and Codex app share a physical skill directory, each installation phase groups work by target. Results still count both runtimes, and each append/prepend injection marker occurs once.
During update, a replacement installed by a successful extension refresh is retained; otherwise it is installed in the replacement phase, with base-skill fallback on failure.
Installing or refreshing an extension captures each replacement's pre-install state: a partial write failure restores that state, including an initially absent skill, while successful sibling replacements remain installed.
Final composition retries custom skills only on targets where refresh did not install them successfully, then restores injections. Re-init and upgrade also restore the registered extension composition after base installation.
Extensions must have unambiguous skill ownership. Two different custom sources with the same basename conflict, even within one extension. A custom skill cannot claim a bundled name unless the manifest explicitly declares replaces. These conflicts and incompatible shared renderers are checked before installed skill changes.
During skill migration, the installed extension version and actual replacement/custom/injection bytes must be provable. Old bundled helpers left beneath a replacement are removed only when their source can also be verified. Unknown or modified files block migration. A failed extension refresh restores the previous shared skill bytes; failure after a completed migration keeps the committed target.
The shared profile applies only when CLI and app use the same physical directory. Singleton metadata and runtime-specific MCP support remain unchanged. Removing an extension restores eligible base skills and removes its injection markers from the actual target, including name-based marker cleanup when the manifest is missing and no migration is pending.
Example
An extension that replaces aif-commit with a custom commit workflow:
my-extension/
├── extension.json
└── skills/
└── my-commit/
└── SKILL.md
{
"name": "aif-ext-custom-commit",
"version": "1.0.0",
"skills": ["skills/my-commit"],
"replaces": {
"skills/my-commit": "aif-commit"
}
}
After installation, the extension's my-commit/SKILL.md is installed as aif-commit/SKILL.md. The user invokes /aif-commit as before — the replacement is transparent.
Storage Layout
your-project/
├── .ai-factory/
│ ├── extensions/
│ │ └── aif-ext-example/ # Installed extension
│ │ ├── extension.json
│ │ ├── commands/
│ │ ├── injections/
│ │ ├── skills/
│ │ └── mcp/
│ └── ...
├── .ai-factory.json # extensions[] array tracks installed extensions
└── .mcp.json # MCP servers merged here (for Claude Code)
Extensions are stored in .ai-factory/extensions/ — this keeps them separate from the project's package system and works with any language (Python, Go, Rust, etc.).
Config Format
Extensions are tracked in .ai-factory.json:
{
"version": "2.2.0",
"agents": [...],
"extensions": [
{
"name": "aif-ext-example",
"source": "https://github.com/user/aif-ext-example.git",
"version": "1.0.0"
}
]
}
Security Considerations
Extensions can call the opt-in instruction manifest recorder to register invocations, provide composition/dependency declarations, and append load evidence. The recorder does not evaluate dependency conditions or authenticate runtime events. No context.provider contract is needed.
- Extension names are validated — names containing
.., absolute paths, or special characters are rejected to prevent path traversal. - Only registered extensions are loaded — extensions must be listed in
.ai-factory.jsonto have their commands executed. A rogue directory in.ai-factory/extensions/is ignored. - Shell commands use argument arrays —
git cloneandnpm packuseexecFileSync(no shell interpolation) to prevent command injection via malicious source URLs. - Extensions execute code — command modules are dynamically imported. Only install extensions you trust, just as you would with npm packages.
Community Extensions
Extensions built by the community. To add yours, submit a PR to this file.
| Extension | Description | Install |
|---|---|---|
| Remote Skills | Install and manage skills from GitHub repositories. Supports branch selection, interactive removal, and sync with active agents. | ai-factory extension add https://github.com/dealenx/ai-factory-extension-remote-skills.git |
| aif-ext-memlab | Project memory via the memlab MCP server (local, Apache 2.0): past decisions (ADRs, postmortems, notes) and the code a change touches. Registers the server and adds an optional memory step to /aif-warmup, /aif-explore, /aif-plan and /aif-fix; without memlab each skill behaves as in core. Requires pip install git+https://github.com/sattva2020/memlab (Python 3.11+). |
ai-factory extension add https://github.com/sattva2020/aif-ext-memlab.git |
| AIF Extension Creator | An AI Factory extension that provides an interactive skill for scaffolding new AI Factory extensions. | ai-factory extension add https://github.com/dealenx/ai-factory-extension-aif-extension-creator-skill.git |
| aif-ext-sattva | Extension bundle. implementation-notes: append-only decision journal for /aif-implement (markdown canon + auto-generated HTML view), fed into /aif-commit bodies, WARN-only coverage gate in /aif-verify, archived with the plan via /aif-archive. loop-budget: optional best-effort token budget for /aif-loop (stop reason token_budget_exceeded; complements the core time budget). Supersedes aif-ext-implementation-notes: if it is installed, run ai-factory extension remove aif-ext-implementation-notes first — keeping both applies the journal injections twice. |
ai-factory extension add https://github.com/sattva2020/aif-ext-sattva.git |
See Also
- Configuration —
.ai-factory.jsonformat, MCP servers, project structure - Core Skills — all built-in slash commands
- Security — two-level security scanning for external skills