Docs > Factory
Factory definition as code
# Factory definition as code Every organization's Factory repository uses **layout v3**: one root `factory.yaml` manifest separating shared resources under `workspace/` from private user resources under `users/<user-slug>--<user-uuid>/`. Paths carry ownership and authorization. Personal directories under `users/` are strictly private to that user and cannot be shared; shared resources under `workspace/` use path-prefix access grants (`factory_shares`). ## Directory structure (layout v3) ```text factories/<factory-slug>--<fac_id>/ factory.yaml # Root manifest workspace/ # Org-shared scope (ACL-controlled) ontology/ objects/<uid>.yaml # Declarative Zeta ontology documents knowledge/<path> # Shared reference files (no descriptor) views/res_<uuid>.md # Shared Views (named by resource ID) sources/<res_id>/SOURCE.md # Shared source descriptors (admin writes) skills/<res_id>/ # Shared Skills (folder named by resource ID) SKILL.md references/... scripts/... agents/<res_id>/ # Shared Agents (folder named by resource ID) AGENT.md TEAM.md # Optional setup + coordinator body team/ # Live shared notes read/written at HEAD automations/<res_id>.md # Scheduled/manual automation triggers skills/<kebab-slug>/SKILL.md # Agent-scoped skills users/<user-slug>--<user-uuid>/ # Personal private scope (owner only) knowledge/<path> # Personal reference files memory/<path> # Personal memory (MEMORY.md, etc.) views/<kebab-slug>.md # Personal Views sources/<res_id>/SOURCE.md # Personal source descriptors skills/<kebab-slug>/SKILL.md # Personal Skills (+ supporting files) agents/<kebab-slug>/ # Personal Agents AGENT.md automations/<kebab-slug>.md skills/<kebab-slug>/SKILL.md shared-agents/<agent_res_id>/ # Member link to a workspace shared agent AGENT.md # mode: linked, enabled, source notes.md # Optional personal working notes automations/<kebab-slug>.md # Optional personal automation of shared agent shared-skills/<skill_res_id>/ # Member link to a workspace shared skill SKILL.md # mode: linked, enabled, source (no extra files) ``` Shared workspace folders under `workspace/agents/`, `workspace/skills/`, `workspace/sources/`, and `workspace/views/` are named by their canonical resource ID (`res_<uuid>`). Never invent resource IDs on existing resources; preserve server-assigned `resourceId` and `source` fields when editing. ## `factory.yaml` The root manifest names the logical factory. It is a manifest, not a permission grant. ```yaml title="factory.yaml" schemaVersion: v3 name: acme-workspace ``` ## `AGENT.md` and `TEAM.md` `AGENT.md` defines **who runs**. Its Markdown body is appended to the system prompt of every run of the agent. ```markdown title="workspace/agents/res_01.../AGENT.md" --- schemaVersion: 1 title: Account renewal tracker mode: shared harness: dex model: inherit requireWriteApproval: true pendingActionVisibility: admins autoMode: >- Only post internal reminders in Slack channel C04ABC123. Card all external emails and CRM updates. requires: - slack - gmail - attio: - update_record --- Track active customer renewals closing within 60 days. Ground every risk flag in a specific email thread or Slack message permalink. ``` | Field | Required | Default | Description | | --- | --- | --- | --- | | `schemaVersion` | Yes | — | `1` | | `title` | No | Folder slug | Display name (1–200 chars) | | `mode` | No | Omitted | Set `shared` for workspace shared agents | | `harness` | No | `dex` | `dex`, `claude`, or `codex` | | `model` | No | `inherit` | Model ID, or `inherit` for harness default | | `requireWriteApproval` | No | `true` | Routes external writes to Pending Action cards | | `autoMode` | No | Omitted | `true` (default reviewer) or plain-language policy (max 8,000 chars). Requires `requireWriteApproval: true` | | `pendingActionVisibility` | No | `admins` | Shared agents only: `admins` or `self` | | `requires` | No | Omitted | List of app names or `{ <app>: [<tool>, ...] }` entries (max 200) | ### Member link (`shared-agents/<id>/AGENT.md`) Created automatically when a teammate joins a shared agent (`dex agents join <id>`). The link body must stay empty; personal working notes belong in sibling files beside `AGENT.md`. ```yaml title="users/sam--.../shared-agents/res_01.../AGENT.md" --- schemaVersion: 1 mode: linked enabled: true resourceId: res_... source: resourceId: res_01... revision: <commit-sha> --- ``` ### `TEAM.md` Optional file beside a shared agent's `AGENT.md`. `setup` guides Dex when onboarding a new teammate; a non-empty Markdown body enables **coordinator mode**. ```markdown title="workspace/agents/res_01.../TEAM.md" --- schemaVersion: 1 setup: | Ask which customer accounts the teammate owns and add their mapping to team/accounts.md after checking for overlap. --- Run each active member via a Dex workflow calling `agent(prompt, { agent, user })` and publish one deduplicated weekly renewal brief. ``` ## `automations/*.md` Defines **when** its parent agent runs and the per-run task in the Markdown body. Never restate agent-owned fields (`title`, `harness`, `model`, `requireWriteApproval`, `autoMode`) or `instructions` in frontmatter. ```markdown title="users/sam--.../agents/renewal-tracker/automations/monday-brief.md" --- schemaVersion: 4 enabled: true trigger: type: cron schedule: "0 9 * * 1" timezone: America/New_York condition: Only run if at least one active renewal has new email or Slack activity in the last 7 days. --- Review open renewals closing in the next 60 days and draft status updates for any deal missing a confirmed next step. ``` | Trigger `type` | Required fields | Optional fields | Allowed on shared agents? | | --- | --- | --- | --- | | `cron` | `schedule` (cron expr), `timezone` (IANA) | — | Yes | | `datetime` | `at` (future ISO datetime) | `timezone` (IANA) | Yes | | `event` | `integration` | `triggerId`, `delayMinutes` (0–43,200) | No (personal agents only) | | `manual` | — | — | Yes | ## `SKILL.md` Defines a progressive-disclosure skill. Supporting `scripts/`, `references/`, and templates live in the same folder. ```markdown title="users/sam--.../skills/escalation-brief/SKILL.md" --- schemaVersion: 1 name: escalation-brief description: >- Use when summarizing a customer escalation from Slack and Gmail into an executive status update. compatibility: Requires read access to Slack and Gmail. disable-model-invocation: false user-invocable: true metadata: author: support-ops argument-hint: "<customer name>" --- Write an escalation brief for $ARGUMENTS using `references/template.md`. ``` When published, the server normalizes `schemaVersion` to `2` and adds `resourceId`. A teammate's link under `users/<you>/shared-skills/<res-id>/SKILL.md` uses `schemaVersion: 2`, `mode: linked`, `enabled: true`, `resourceId`, `source`, and an empty body (no supporting files). ## `views/*.md` Defines a saved table or board over one Zeta Object type. Shared Views use `workspace/views/res_<uuid>.md` (generate a fresh lowercase UUID for new shared Views); personal Views use `users/<you>/views/<kebab-slug>.md`. ```markdown title="workspace/views/res_550e8400-e29b-41d4-a716-446655440000.md" --- schemaVersion: 1 name: Open Q4 commitments description: Unresolved customer commitments due this quarter, sorted by due date. context: synonyms: - open action items - customer follow-ups examples: - question: Which customer commitments are overdue? sourceSpec: version: 1 kind: object targetScopeId: "<scope-uuid>" objectTypeUid: commitment columns: - fieldId: title - fieldId: status - fieldId: due_date - path: [owner, name] label: Owner filters: - fieldId: status operator: neq value: Done sorts: - fieldId: due_date direction: asc layout: type: table --- ## Meaning One row per tracked commitment linked to an active customer record. ## Usage Use for weekly pipeline and account reviews instead of querying raw messages. ## Caveats Formula sorts cap at 10,000 matching rows; keep filters narrow on large tables. ``` Columns support `fieldId`, `path: [refFieldId, targetFieldId]`, `inverse: { source, fieldId, show }`, and read-time `formula: { key, expression }` (with optional `display: { numberFormat: plain | percent | currency, unit }`). Filters support `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains`, `is_empty`, `is_not_empty`, plus calendar-day operators `on`, `on_or_after`, `on_or_before` (`YYYY-MM-DD`, with `timezone` required on datetime fields). ## `ontology/objects/*.yaml` and `SOURCE.md` - **`workspace/ontology/objects/<uid>.yaml`** (`schemaVersion: 2`) — Stores one Object type's `schemas` (length 1), `mappings`, and pinned `sourceContracts`. Obtain exact `sourceContract` blocks from `dex zeta datasets get --dataset <id>` and validate with `dex factory preview` before pushing. See [Ontology](/context/ontology/). - **`sources/<res_id>/SOURCE.md`** (`schemaVersion: 3`, admin-only writes under `workspace/`) — Describes a connector (`connector`, optional `endpoint` required for `mcp`, `defaultAccount`, `collection: { enabled, config }`, `context.synonyms`) with two required Markdown sections: `## Overview` (system-maintained summary) and `## Instructions` (team-authored guidance). ## Syncing with `dex factory` `dex factory` provides a Git-like workflow over your readable subset of Factory (defaulting to `/workspace/factory` in sandboxes): ```bash # 1. Fetch latest server state dex factory pull # 2. Edit files, inspect status/diff, and stage ONLY the paths you changed dex factory status dex factory diff dex factory add factories/*/workspace/agents/<id>/AGENT.md dex factory commit -m "Tighten renewal tracker autoMode policy" # 3. Validate schemas, permissions, and ontology/view impact without publishing dex factory preview # 4. Publish and verify Apply succeeded dex factory push ``` :::tip Always stage explicit paths (`dex factory add <path>`) instead of `add -A` or `add .` so unrelated local edits are never accidentally published. If a push is rejected because the remote moved, run `dex factory pull`, resolve any conflicting files, commit the merge, and re-run `dex factory preview` before pushing. ::: ## Related pages - [Factory overview](/factory/) - Commit + Apply lifecycle and what stays in Postgres - [Permissions, spaces, and sharing](/factory/sharing-and-installation/) - Sharing paths with people, Spaces, or the workspace - [Shared agents](/agents/shared-agents/) - Designing and operating `workspace/agents/<id>/` - [Ontology](/context/ontology/) - Authoring Object schemas and source mappings - [CLI and SDK](/integrations/cli-and-sdk/) - Complete `dex` CLI referenceComplete reference for the Factory v3 directory layout, YAML and Markdown schemas for agents, skills, automations, views, ontology, and sources, and the dex factory sync workflow.
Every organization’s Factory repository uses layout v3: one root factory.yaml manifest separating shared resources under workspace/ from private user resources under users/<user-slug>--<user-uuid>/.
Paths carry ownership and authorization. Personal directories under users/ are strictly private to that user and cannot be shared; shared resources under workspace/ use path-prefix access grants (factory_shares).
Directory structure (layout v3)
Section titled “Directory structure (layout v3)”factories/<factory-slug>--<fac_id>/ factory.yaml # Root manifest workspace/ # Org-shared scope (ACL-controlled) ontology/ objects/<uid>.yaml # Declarative Zeta ontology documents knowledge/<path> # Shared reference files (no descriptor) views/res_<uuid>.md # Shared Views (named by resource ID) sources/<res_id>/SOURCE.md # Shared source descriptors (admin writes) skills/<res_id>/ # Shared Skills (folder named by resource ID) SKILL.md references/... scripts/... agents/<res_id>/ # Shared Agents (folder named by resource ID) AGENT.md TEAM.md # Optional setup + coordinator body team/ # Live shared notes read/written at HEAD automations/<res_id>.md # Scheduled/manual automation triggers skills/<kebab-slug>/SKILL.md # Agent-scoped skills users/<user-slug>--<user-uuid>/ # Personal private scope (owner only) knowledge/<path> # Personal reference files memory/<path> # Personal memory (MEMORY.md, etc.) views/<kebab-slug>.md # Personal Views sources/<res_id>/SOURCE.md # Personal source descriptors skills/<kebab-slug>/SKILL.md # Personal Skills (+ supporting files) agents/<kebab-slug>/ # Personal Agents AGENT.md automations/<kebab-slug>.md skills/<kebab-slug>/SKILL.md shared-agents/<agent_res_id>/ # Member link to a workspace shared agent AGENT.md # mode: linked, enabled, source notes.md # Optional personal working notes automations/<kebab-slug>.md # Optional personal automation of shared agent shared-skills/<skill_res_id>/ # Member link to a workspace shared skill SKILL.md # mode: linked, enabled, source (no extra files)Shared workspace folders under workspace/agents/, workspace/skills/, workspace/sources/, and workspace/views/ are named by their canonical resource ID (res_<uuid>). Never invent resource IDs on existing resources; preserve server-assigned resourceId and source fields when editing.
factory.yaml
Section titled “factory.yaml”The root manifest names the logical factory. It is a manifest, not a permission grant.
schemaVersion: v3name: acme-workspaceAGENT.md and TEAM.md
Section titled “AGENT.md and TEAM.md”AGENT.md defines who runs. Its Markdown body is appended to the system prompt of every run of the agent.
---schemaVersion: 1title: Account renewal trackermode: sharedharness: dexmodel: inheritrequireWriteApproval: truependingActionVisibility: adminsautoMode: >- Only post internal reminders in Slack channel C04ABC123. Card all external emails and CRM updates.requires: - slack - gmail - attio: - update_record---
Track active customer renewals closing within 60 days. Ground every risk flagin a specific email thread or Slack message permalink.| Field | Required | Default | Description |
|---|---|---|---|
schemaVersion | Yes | — | 1 |
title | No | Folder slug | Display name (1–200 chars) |
mode | No | Omitted | Set shared for workspace shared agents |
harness | No | dex | dex, claude, or codex |
model | No | inherit | Model ID, or inherit for harness default |
requireWriteApproval | No | true | Routes external writes to Pending Action cards |
autoMode | No | Omitted | true (default reviewer) or plain-language policy (max 8,000 chars). Requires requireWriteApproval: true |
pendingActionVisibility | No | admins | Shared agents only: admins or self |
requires | No | Omitted | List of app names or { <app>: [<tool>, ...] } entries (max 200) |
Member link (shared-agents/<id>/AGENT.md)
Section titled “Member link (shared-agents/<id>/AGENT.md)”Created automatically when a teammate joins a shared agent (dex agents join <id>). The link body must stay empty; personal working notes belong in sibling files beside AGENT.md.
---schemaVersion: 1mode: linkedenabled: trueresourceId: res_...source: resourceId: res_01... revision: <commit-sha>---TEAM.md
Section titled “TEAM.md”Optional file beside a shared agent’s AGENT.md. setup guides Dex when onboarding a new teammate; a non-empty Markdown body enables coordinator mode.
---schemaVersion: 1setup: | Ask which customer accounts the teammate owns and add their mapping to team/accounts.md after checking for overlap.---
Run each active member via a Dex workflow calling `agent(prompt, { agent, user })`and publish one deduplicated weekly renewal brief.automations/*.md
Section titled “automations/*.md”Defines when its parent agent runs and the per-run task in the Markdown body. Never restate agent-owned fields (title, harness, model, requireWriteApproval, autoMode) or instructions in frontmatter.
---schemaVersion: 4enabled: truetrigger: type: cron schedule: "0 9 * * 1" timezone: America/New_Yorkcondition: Only run if at least one active renewal has new email or Slack activity in the last 7 days.---
Review open renewals closing in the next 60 days and draft status updates forany deal missing a confirmed next step.Trigger type | Required fields | Optional fields | Allowed on shared agents? |
|---|---|---|---|
cron | schedule (cron expr), timezone (IANA) | — | Yes |
datetime | at (future ISO datetime) | timezone (IANA) | Yes |
event | integration | triggerId, delayMinutes (0–43,200) | No (personal agents only) |
manual | — | — | Yes |
SKILL.md
Section titled “SKILL.md”Defines a progressive-disclosure skill. Supporting scripts/, references/, and templates live in the same folder.
---schemaVersion: 1name: escalation-briefdescription: >- Use when summarizing a customer escalation from Slack and Gmail into an executive status update.compatibility: Requires read access to Slack and Gmail.disable-model-invocation: falseuser-invocable: truemetadata: author: support-ops argument-hint: "<customer name>"---
Write an escalation brief for $ARGUMENTS using `references/template.md`.When published, the server normalizes schemaVersion to 2 and adds resourceId. A teammate’s link under users/<you>/shared-skills/<res-id>/SKILL.md uses schemaVersion: 2, mode: linked, enabled: true, resourceId, source, and an empty body (no supporting files).
views/*.md
Section titled “views/*.md”Defines a saved table or board over one Zeta Object type. Shared Views use workspace/views/res_<uuid>.md (generate a fresh lowercase UUID for new shared Views); personal Views use users/<you>/views/<kebab-slug>.md.
---schemaVersion: 1name: Open Q4 commitmentsdescription: Unresolved customer commitments due this quarter, sorted by due date.context: synonyms: - open action items - customer follow-ups examples: - question: Which customer commitments are overdue?sourceSpec: version: 1 kind: object targetScopeId: "<scope-uuid>" objectTypeUid: commitmentcolumns: - fieldId: title - fieldId: status - fieldId: due_date - path: [owner, name] label: Ownerfilters: - fieldId: status operator: neq value: Donesorts: - fieldId: due_date direction: asclayout: type: table---
## MeaningOne row per tracked commitment linked to an active customer record.
## UsageUse for weekly pipeline and account reviews instead of querying raw messages.
## CaveatsFormula sorts cap at 10,000 matching rows; keep filters narrow on large tables.Columns support fieldId, path: [refFieldId, targetFieldId], inverse: { source, fieldId, show }, and read-time formula: { key, expression } (with optional display: { numberFormat: plain | percent | currency, unit }). Filters support eq, neq, gt, gte, lt, lte, contains, is_empty, is_not_empty, plus calendar-day operators on, on_or_after, on_or_before (YYYY-MM-DD, with timezone required on datetime fields).
ontology/objects/*.yaml and SOURCE.md
Section titled “ontology/objects/*.yaml and SOURCE.md”workspace/ontology/objects/<uid>.yaml(schemaVersion: 2) — Stores one Object type’sschemas(length 1),mappings, and pinnedsourceContracts. Obtain exactsourceContractblocks fromdex zeta datasets get --dataset <id>and validate withdex factory previewbefore pushing. See Ontology.sources/<res_id>/SOURCE.md(schemaVersion: 3, admin-only writes underworkspace/) — Describes a connector (connector, optionalendpointrequired formcp,defaultAccount,collection: { enabled, config },context.synonyms) with two required Markdown sections:## Overview(system-maintained summary) and## Instructions(team-authored guidance).
Syncing with dex factory
Section titled “Syncing with dex factory”dex factory provides a Git-like workflow over your readable subset of Factory (defaulting to /workspace/factory in sandboxes):
# 1. Fetch latest server statedex factory pull
# 2. Edit files, inspect status/diff, and stage ONLY the paths you changeddex factory statusdex factory diffdex factory add factories/*/workspace/agents/<id>/AGENT.mddex factory commit -m "Tighten renewal tracker autoMode policy"
# 3. Validate schemas, permissions, and ontology/view impact without publishingdex factory preview
# 4. Publish and verify Apply succeededdex factory pushRelated pages
Section titled “Related pages”- Factory overview - Commit + Apply lifecycle and what stays in Postgres
- Permissions, spaces, and sharing - Sharing paths with people, Spaces, or the workspace
- Shared agents - Designing and operating
workspace/agents/<id>/ - Ontology - Authoring Object schemas and source mappings
- CLI and SDK - Complete
dexCLI reference