anchor.diff:  # Buildkite Agent Hooks
   
  -Every agent installer comes with a hooks directory which can be used to override and extend the built-in agent behavior. For example, you could create an agent `checkout` hook which speeds up a fresh `git clone` on a new build machine, an agent `environment` hook which exports secret API keys as environment variables, or a repository `pre-command` hook which sets up some repository-specific environment variables.
  +Every agent installer comes with a hooks directory which can be used to override and extend the built-in agent behavior. For example, you could create an agent `checkout` hook which speeds up a fresh `git clone` on a new build machine, an agent `environment` hook which exports secret API keys as environment variables, or a repository `pre-command` hook which sets up repository-specific environment variables.
   
   {:toc}
   
  
positive.code: 
  There are three types of hooks:
  
  1. [Agent hooks](#agent-hooks) - these exist on the agent’s machine, and are run for every job on any pipeline.
  1. [Repository hooks](#repository-hooks) - these exist in your pipeline repository’s `.buildkite/hooks` directory.
  1. [Plugin hooks](#plugin-hooks) - these are provided by any [plugins](/docs/plugins) you've defined in your `pipeline.yml`.
  
  ## Available hooks
  
  The following is a complete list of hooks that can be implemented, and the order in which they are called:
  
  <table>
    <thead>
      <tr><th>Hook</th><th>Order</th></th><th>Description</th></tr>
    </thead>
    <tbody>
      <tr>
  
negative.code: 
  ## Creating hook scripts
  
  Hooks are shell scripts you can use to run commands and export environment variables.
  Hooks have access to all the standard [Buildkite environment variables](/docs/pipelines/environment-variables).
  
  Hooks are copied to `$TMPDIR` directory and run by the default shell on the Agent that is running the build, which has a few implications:
  
  * `$BASH_SOURCE` contains the location where the hook is stored
  * `$0` contains the location of the copy of the script that is running
  * the shebang line of the hook script has no effect
  
  To write hooks in another programming language, you need to call them from within the shell script, and explicitly pass any Buildkite environment variables you need to the script when you call it. 
  
  The following is an example of a custom `environment` hook which exports a GitHub API key for the pipeline’s release build step:
  
  