# Automatic tagging

Sleuth allows you to setup rules to automatically tag your deploys. Tagging deploys allows you to flag deploys that may require a different level of attention, such as a database migration. Tags are also a quick way to organize and quickly search similar deploys.

The tags are added by looking for patterns in the files deployed in your code repositories. For example, if Sleuth finds a **pom.xml** file in your deploy, it automatically adds the tag **#dependencies** to the deploy.

Tags are searchable via everywhere [search](https://help.sleuth.io/modeling-your-deployments/code-deployments/search) is exposed. See the table below for more patterns and tags Sleuth automatically applies to your deploys based on pattern matching.

![The \`migration\` tag was automatically added to the deploy](https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2Fgit-blob-634d9f967a66ff39b8899de3fc1bd3fe76dbf098%2FSleuth%20-%20Sleuth%202021-01-31%2014-01-42.png?alt=media)

If tags are not explicitly defined for a deployment, Sleuth detects tags by matching files using patterns either from the *\*\*.sleuth/TAGS \*\** file in your repository, or a set of default patterns:

| Pattern             | Tag           |
| ------------------- | ------------- |
| \*\*/migration/\*\* | #migration    |
| Pipfile.lock        | #dependencies |
| requirements.txt    | #dependencies |
| package-lock.json   | #dependencies |
| pom.xml             | #dependencies |
| Dockerfile          | #docker       |
| \*\*/db/\*\*        | #database     |
| \*tf                | #terraform    |

### Adding custom tags

In addition to having Sleuth automatically detect patterns and add tags to your deploys, you can add your own patterns that Sleuth can then use to help you search for your previous deploys. This is easily done by editing the ***.sleuth/TAGS*** in your code repository.

#### To add your own pattern/tag pair:

1. Create a \_\*\*.sleuth/ \*\*\_directory in the root directory of your repo. This repo must be connected as a [code deployment](https://help.sleuth.io/settings/project/code-deployments) in Sleuth.
2. Create a file **TAGS** in the ***.sleuth*** directory.
3. Create a matching pattern/tag pair; create additional pairs on new lines.\
   For example:\
   `/db #database`
4. Save the file.

In the example above, a directory with the name `db` would generate a tag `database` in the Sleuth deploy card, which you can then search for quickly using the Sleuth search.
