anchor.diff:  docker-compose run --rm lint
   ```
   
  -### Publish to the directory
  -
  -To add your plugin to the [Buildkite Plugin Directory](https://buildkite.com/plugins), publish your repository to a public GitHub repository and add the `buildkite-plugin` repository topic tag. For full instructions, see the [Plugin Directory documentation](/docs/plugins/directory).
  -
  -## Plugin schema
  -
  -Each plugin must have a `plugin.yml` file, which describes the plugin, what it requires, and what configuration options it accepts.
  -
  -For example:
  +## Add a hook
  +
  +Plugins can implement a number of [plugin hooks](/docs/agent/v3/hooks). For this plugin, we’ll create a `post-command` hook in a `hooks` directory:
  +
  +```shell
  +mkdir hooks
  +touch hooks/post-command
  +chmod +x hooks/post-command
  +```
  +
  +```shell
  +#!/bin/bash
  +set -euo pipefail
  +
  +PATTERN="$BUILDKITE_PLUGIN_FILE_COUNTER_PATTERN"
  +
  +echo "--- \:1234\: Counting the number of files"
  +
  +COUNT=$(find . -name "$PATTERN" | wc -l)
  +
  +echo "Found ${COUNT} files matching ${PATTERN}"
  +
  +buildkite-agent annotate "Found ${COUNT} files matching ${PATTERN}"
  +```
  +  {: codeblock-file="hooks/post-command"}
  +
  +## Add a test
  +
  +Next step is to test the `post-command` hook using BATS, and the `buildkite/plugin-tester` Docker image.
  +
  +```shell
  +mkdir tests
  +touch tests/post-command.bats
  +chmod +x tests/post-command.bats
  +```
  +
  +Create the following `tests/post-command.bats` file:
  +
  +```shell
  +#!/usr/bin/env bats
  +
  +load '/usr/local/lib/bats/load.bash'
  +
  +# Uncomment the following line to debug stub failures
  +# export BUILDKITE_AGENT_STUB_DEBUG=/dev/tty
  +
  +@test "Creates an annotation with the file count" {
  +  export BUILDKITE_PLUGIN_FILE_COUNTER_PATTERN="*.bats"
  +
  +  stub buildkite-agent 'annotate "Found 1 files matching *.bats" : echo Annotation created'
  +
  +  run "$PWD/hooks/post-command"
  +
  +  assert_success
  +  assert_output --partial "Found 1 files matching *.bats"
  +  assert_output --partial "Annotation created"
  +
  +  unstub buildkite-agent
  +}
  +```
  +{: codeblock-file="tests/post-command.bats"}
  +
  +
  +To run the test, run the following Docker command:
  +
  +```shell
  +docker run -it --rm -v "$(PWD):/plugin:ro" buildkite/plugin-tester
  +```
  +
  +```
  + ✓ Creates an annotation with the file count
  +
  +1 test, 0 failures
  +```
  +
  +To make it easier to run this command, create a Docker Compose file:
   
   ```yml
  -name: File Counter
  -description: Annotates the build with a file count
  -author: https://github.com/a-github-user
  -requirements: []
  -configuration:
  -  pattern:
  -    type: string
  -  additionalProperties: false
  -```
  -{: codeblock-file="plugin.yml"}
  -
  -
  -Valid `plugin.yml` properties:
  -
  -<table>
  -  <thead>
  -    <tr>
  -      <th>Property</th>
  -      <th>Description</th>
  -    </tr>
  -  </thead>
  -  <tbody>
  -    <tr>
  -      <td>name</th>
  -      <td>The name of the plugin, in Title Case.</th>
  -    </tr>
  -    <tr>
  -      <td>description</th>
  -      <td>A short sentence describing what the plugin does.</th>
  -    </tr>
  -    <tr>
  -      <td>author</th>
  -      <td>A URL to the plugin author (e.g. website or GitHub profile).</th>
  -    </tr>
  -    <tr>
  -      <td>requirements</th>
  -      <td>An array of commands that are expected to exist in the agent’s <code>$PATH</code>.</th>
  -    </tr>
  -    <tr>
  -      <td>configuration</th>
  -      <td>A <a href="https://json-schema.org">JSON Schema</a> describing the valid configuration options available.</th>
  -    </tr>
  -  </tbody>
  -</table>
  +version: '2'
  +services:
  +  tests:
  +    image: buildkite/plugin-tester
  +    volumes:
  +      - ".:/plugin:ro"
  +```
  +{: codeblock-file="docker-compose.yml"}
  +
  +You can now run the tests using the following command:
  +
  +```shell
  +docker-compose run --rm tests
  +```
  +
  +## Add a readme
  +
  +Next we'll add a `README.md` file to introduce the plugin to the world:
  +
  +<%= render 'plugins/tutorial_readme' %>
  +
  +## Publish to the directory
  +
  +To add your plugin to the [Buildkite Plugin Directory](https://buildkite.com/plugins), publish your repository to a public GitHub repository and add the `buildkite-plugin` repository topic tag. For full instructions, see the [Plugin Directory documentation](/docs/plugins/directory).
positive.code: This page shows you how to write your own Buildkite plugin, and how to validate the `plugin.yml` file which describes it against the plugin schema.
  
  {:toc}
  
  ## Plugin tutorial
  
  In this tutorial we'll create a Buildkite plugin called "File Counter", which counts the number of files in the build directory once the command has finished, and creates a build annotation with the count.
  
  
negative.code: ```
  {: codeblock-file="pipeline.yml"}
  
  ## Create a new git repository
  
  Every Buildkite plugin is a Git repository, ending in `-buildkite-plugin`. Let's create a new Git repository following these naming conventions:
  
  