# Use Patching for Safe Workflow Upgrades

> Use DBOS.patch() to safely deploy breaking workflow changes. Breaking changes alter what steps run or their order.

- Skill: `tools-only/use-patching-for-safe-workflow-upgrades` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/use-patching-for-safe-workflow-upgrades`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/use-patching-for-safe-workflow-upgrades/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-29
- Page: https://skillmd.com/skills/tools-only/use-patching-for-safe-workflow-upgrades

---


## Use Patching for Safe Workflow Upgrades

Use `DBOS.patch()` to safely deploy breaking workflow changes. Breaking changes alter what steps run or their order.

**Incorrect (breaking change without patch):**

```python
# Original
@DBOS.workflow()
def workflow():
    foo()
    bar()

# Updated - breaks in-progress workflows!
@DBOS.workflow()
def workflow():
    baz()  # Replaced foo() - checkpoints don't match
    bar()
```

**Correct (using patch):**

```python
# Enable patching in config
config: DBOSConfig = {
    "name": "my-app",
    "enable_patching": True,
}
DBOS(config=config)

@DBOS.workflow()
def workflow():
    if DBOS.patch("use-baz"):
        baz()  # New workflows use baz
    else:
        foo()  # Old workflows continue with foo
    bar()
```

Deprecating patches after all old workflows complete:

```python
# Step 1: Deprecate (runs all workflows, stops inserting marker)
@DBOS.workflow()
def workflow():
    DBOS.deprecate_patch("use-baz")
    baz()
    bar()

# Step 2: Remove entirely (after all deprecated workflows complete)
@DBOS.workflow()
def workflow():
    baz()
    bar()
```

`DBOS.patch(name)` returns:
- `True` for new workflows (started after patch deployed)
- `False` for old workflows (started before patch deployed)

Reference: [Patching](https://docs.dbos.dev/python/tutorials/upgrading-workflows#patching)

