Set Up lint-staged and Husky Pre-commit Hooks
Pre-commit hooks that run linting and formatting on staged files are one of the highest-ROI automation investments for any team. Claude can generate the full setup in one shot.
Write a lint-staged and Husky v9 configuration for a TypeScript
Next.js project. On commit: run ESLint --fix on .ts and .tsx files,
run Prettier on everything, and run tsc --noEmit. Fail the commit
if any check doesn't pass.
Claude produces the package.json config, the Husky hook file, and the install commands:
# Install
npm install --save-dev husky lint-staged
npx husky init
// package.json
{
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{js,json,css,md}": ["prettier --write"]
}
}
# .husky/pre-commit
npx lint-staged
npx tsc --noEmit
Claude also handles edge cases you'd otherwise discover the hard way: running tsc on the whole project rather than just staged files (since TypeScript needs the full type graph), and making sure ESLint runs before Prettier to avoid conflicting auto-fixes.
Hooks that run automatically are the only code quality checks that actually get applied consistently.
Log in to leave a comment.
The autoUpdatesChannel setting pins Claude Code to a stable release track that skips versions with major regressions.
The language setting makes Claude respond in your preferred language by default, across every session and project.
The attribution setting lets you customize or completely remove Claude's Co-Authored-By trailer from git commits and pull requests.