lint-staged is a command-line tool that runs linters against staged git files. It prevents committing broken code by ensuring only clean and compliant changes are added to the repository. By running linters before each commit, lint-staged improves code quality and maintains a consistent style across the codebase. Configure your linters in package.json to automatically format and validate code upon git commit, reducing manual linting efforts and promoting a cleaner, more maintainable project.