> ## Documentation Index
> Fetch the complete documentation index at: https://opensandbox-oc-s-762ac928075c46d2828bcb22.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Patches

> Attach scripts to checkpoints from the CLI

## What Patches Do

A patch is a shell script attached to a checkpoint. Patches run in order every time a sandbox is forked from that checkpoint — layer setup without re-creating the checkpoint.

## Creating a Patch

From a file or stdin:

```bash theme={null}
# From a file
oc patch create cp-7f3a1b2c --script ./setup.sh --description "Install deps"

# One-liner from stdin
echo "npm install -g typescript" | oc patch create cp-7f3a1b2c --script=-
```

## Layering Setup

Add multiple patches — they execute in creation order on every fork:

```bash theme={null}
oc patch create cp-7f3a1b2c --script ./install-node.sh --description "Node.js 20"
oc patch create cp-7f3a1b2c --script ./app-config.sh --description "App config"

# Each spawned sandbox gets both patches applied in order
oc cp spawn cp-7f3a1b2c
```

## Inspecting Patches

Review what will run before forking:

```bash theme={null}
oc patch list cp-7f3a1b2c
# ID          SEQ  DESCRIPTION     STRATEGY  CREATED
# pa-abc123   1    Node.js 20      on_wake   2025-01-15T10:30:00Z
# pa-def456   2    App config      on_wake   2025-01-15T10:31:00Z
```

## Removing a Patch

```bash theme={null}
oc patch delete cp-7f3a1b2c pa-abc123
```

<Tip>
  SDK usage: [Patches](/sandboxes/patches). Full flags: [CLI Reference](/reference/cli#oc-patch).
</Tip>
