# Factory

URL: https://docs.usestitch.ai/docs/factory



Store `stitch-factory.yaml` at the repository root, with no leading dot.
Stitch reconciles it from the connected repository's default branch.
Use local `key` values to link each trigger to a harness and sandbox.

## Schema [#schema]

[Factory JSON Schema](/schema/factory.json) · [Environment schema](/schema/environment.json)

| Field                            | Contract                                                                |
| -------------------------------- | ----------------------------------------------------------------------- |
| `schemaVersion`                  | `1`                                                                     |
| `name`, `description`            | Factory name and optional description                                   |
| `execution.environmentVariables` | Inline values or managed secret references; required array              |
| `harnesses`                      | At least one harness; unique `key`                                      |
| `sandboxes`                      | At least one sandbox; unique `key`                                      |
| `triggers`                       | At least one trigger; unique `key`; existing harness/sandbox references |

Keys match `^[a-z][a-z0-9_-]{0,63}$`. Unknown fields are rejected.
Environment bindings have a `key`, `source`, and `targets` (`setup`, `harness`, or both).
Use `value` for `source: inline`; use `secretName` for `source: managed`.

```yaml
execution:
  environmentVariables:
    - key: SERVICE_TOKEN
      source: managed
      secretName: SERVICE_TOKEN
      targets: [harness]
```

## Apply changes [#apply-changes]

Validate offline, validate against the connected repository, then push approved changes
to the default branch. Inspect the application for sync errors.
`enabled: false` keeps a trigger inactive. Validation alone never starts a run.

* [Supported repositories](/docs/factory/repositories)
* [CLI](/docs/factory/cli)
