# GitHook

We are going to use the git `pre-commit` [hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to make sure the code gets *prettified* before committing it.

### Install Husky

> [Husky](https://github.com/typicode/husky) can prevent bad `git commit`, `git push` and more 🐶 *woof!*

```
$ yarn add husky pretty-quick -D
```

Add the following to the root `package.json`

{% code title="package.json" %}

```typescript
"husky": {
  "hooks": {
    "pre-commit": "pretty-quick --staged"
  }
}
```

{% endcode %}

Make sure husky is install

```
$ node node_modules/husky/lib/installer/bin install
```

Add it to `postinstall` to automate the process:

{% code title="package.json" %}

```typescript
"scripts": {
    "postinstall": "lerna bootstrap && node node_modules/husky/lib/installer/bin install"
}
```

{% endcode %}

When we commit, we should now see a message similar to this one:

```
🔍  Finding changed files since git revision 5053732.
🎯  Found 2 changed files.
✍️  Fixing up packages/api/index.ts.
✅  Everything is awesome!
```

{% hint style="info" %}
[`prettier`](https://github.com/florianherrengt/book-code/tree/prettier)branch available on GitHub.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tutorial.specian.co.uk/project-setup/githook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
