{
  "id": 9761706,
  "title": "🪝You Should Probably Use Git Hooks",
  "url": "https://urgent.news/2026/09/25/you-should-probably-use-git-hooks",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-25T12:07:23.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lundjrl/you-should-probably-use-git-hooks-2cho"
  },
  "original_language": "en",
  "account": "Git hooks have been a topic of discussion for the author over the years. Initially, as a solo developer, they appreciated the ability to run tests upon commit. However, when working as part of a team, the preference shifted towards formatting and linting code through CI/CD pipelines. While this approach worked for keeping the codebase consistent, the author eventually embraced Git hooks once again. The initial belief was that developers should be responsible for their own git process, regardless of the number of commits or the size of each one.\n\nThe author now believes that Git hooks serve a purpose in protecting us from our own mistakes, especially when fatigued. Even with test-driven development practices, overlooking a test can happen. What's not human is the assistance provided by AI while developing. With more developers relying on agents for code assistance, it's crucial to ensure accountability for the output generated by these tools. Git hooks can catch AI-generated commits and help maintain the quality of the codebase.\n\nThe author shares their setup using essential tools like Husky, Lint-staged, ESLint, Prettier, and Vitest. Installing these tools and configuring Git hooks involves a series of steps, including installing Husky and lint-staged, creating a pre-commit script, and setting up an install script to skip installations in production and CI environments. The .husky/pre-commit.mjs file runs the lint-staged commands, ensuring code formatting and linting before commits. The .husky/install.mjs file is added to avoid installing Husky in production and CI environments.\n\nTo test the setup, save the changes to the repository and make edits to staged files. Upon committing, the Git hooks will execute the lint-staged commands, formatting and linting the code as expected. However, the author emphasizes the importance of using hooks judiciously. While it's acceptable to bypass hooks in certain situations, relying on them consistently helps maintain code quality and prevents mistakes. The article concludes with an invitation for readers to share their Git hook experiences in the comments section.",
  "summary": "🚨 AI WAS NOT USED IN WRITING THIS POST 🚨 I've gone back and forth on this topic quite some time. As a solo dev, I liked it because I could run tests on commit. As a teammate, I liked everyone's code being formatted and linted. For a few years, I was against git hooks. I'd just run everything in CI/CD. Pull requests get formatted and tested before the branch could be accepted. That's similar to…",
  "key_points": [
    "Git hooks initially used for solo testing, later adopted for team formatting and linting.",
    "Developers should be responsible for their own git process, even with AI assistance.",
    "Author's setup includes Husky, Lint-staged, ESLint, Prettier, and Vitest for code quality checks."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}