# Ready Hook

MergeQueue supports user-defined *ready hooks* which can execute custom JavaScript code to finely control how MergeQueue behaves.

The ready hook is executed once whenever a pull request is marked as ready-to-merge (usually via adding the repository's configured label, by using a [slash command](https://docs.aviator.co/mergequeue/reference/slash-commands), or using the [Aviator API](https://docs.aviator.co/api)).

The ready hook is defined by creating a file in your GitHub repository at `.aviator/mergequeue/ready.js` and should define a function `ready` that will be called by the [Pilot JavaScript runtime](https://docs.aviator.co/pilot-automated-actions/js-execution).

{% hint style="info" %}
See how you can use [<mark style="color:blue;">Ready Hook to reduce queue failures due to staleness</mark>](https://docs.aviator.co/mergequeue/concepts/reducing-queue-failures-due-to-staleness).
{% endhint %}
