---
title: customize
description: Retune the parts that a Machine carries, without a change to the module that exports it.
---

# `customize`

Function, in `@jr2/orchestrator/src/customize.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Composition.

```ts
function customize<M extends AnyStateMachine>(machine: M, parts: Customize<M>): M
```

Retune the parts that a Machine carries, without a change to the module that exports it. Use it
where you register a Machine as a Workflow. It binds the parts that a packaged Machine leaves
Open: its Repo Slots, an Agent's model, or an Effect's url, argv or secret. It also changes the
parts that its author fixed: an Agent's instructions, the Sandbox Image, or the Size.

It gives back a new Machine of the same type. The original does not change, so two
`customize()` calls on one import give two Machines. Only the parts the Machine declares can be
retuned. You cannot add a part: a Machine that needs another Agent is a new Machine. The types
refuse most mistakes when you compile. At run time, `customize()` also throws:

- `customize(): machine "<id>" carries no Agent slot "<slot>" — its Agents are: <slots>`
- `customize(): machine "<id>" composes no Machine under "<slot>" — the Machines it composes are: <slots>`
- `customize(): machine "<id>" carries no Effect slot "<slot>" — its Effects are: <slots>`
- `customize(): machine "<id>" declares no Repo Slot "<slot>" — its slots are: <slots>`
- `customize(): machine "<id>" declares its Repo Slots open as a map — name at least one`
- `` customize(): `repos` say what a SANDBOX is made of, how big it is and which Repos it
  attaches, and machine "<id>" composes none `` (for `resources`, the text starts
  `` customize(): `resources` ``; for `image` or `user`, it starts `` customize(): `image`/`user` ``)
- `customize(): machine "<id>": <errors>`, when an Effect argv that you bind fails the checks
  that the Machine passed when it was built
- the refusals of [`EffectBinding`](type-effectbinding.md), [`RepoSlot`](type-reposlot.md), [`Size`](type-size.md) and
  [`UserContainer`](type-usercontainer.md), which start with `customize()`

**Parameters**

- `machine`: The Machine to retune: one you import from a package, or one you wrote. When
  its root is a `workspace()` or a `pool()`, `customize()` reaches through to the Machine inside,
  so you never name the wrapper's own slot.
- `parts`: The parts to change. See [`Customize`](type-customize.md).

**Returns**: A new Machine of the same type, with the parts changed.

**Example**

```ts
import { customize } from "@jr2/orchestrator";
import { task } from "@jr2/machines";

export const machine = customize(task, {
  repos: { app: { url: "https://github.com/you/app.git" } },
  agents: { coder: { model: "anthropic/claude-haiku-5-5" } },
  resources: { limits: { memory: "4Gi" } },
});
```

**See also**

- [Bind a shipped Machine's Open parts](../../guides/bind-open-parts.md)
- [Composition](../../concepts/composition.md)
- [ADR-0049: A Machine carries its parts and composes by invoke](../decisions/0049-a-machine-carries-its-parts-and-composes-by-invoke.md)
- [ADR-0054: The kit ships Machines, and a shipped Machine leaves its parts Open](../decisions/0054-the-kit-ships-machines-and-a-shipped-machine-leaves-its-parts-open.md)
