---
title: "Event-Driven Refactor Tutorials"
source: https://docs.autohand.ai/tutorials/automations/event-driven-refactor
---

# Event-Driven Refactor

This tutorial builds an event-driven refactor workflow. When a dependency is updated, an Autohand agent runs a migration script and opens a pull request with the changes.

## What you will build

-   A webhook receiver that listens for Dependabot or Renovate updates.
-   An Autohand agent that applies migration rules.
-   A script that commits changes and opens a follow-up pull request.

## Prerequisites

-   A repository with dependency update automation.
-   A server or Worker that can receive webhooks.
-   Git credentials configured for the agent environment.

## Step 1: receive the webhook

Extract the dependency name and new version from the webhook payload.

## Step 2: run the refactor agent

Use the Autohand CLI in headless mode with a focused prompt.

## Step 3: commit and open a pull request

## Next steps

Add a human approval step before merging, or run the workflow on a schedule to catch missed updates.