Fixing Agents Broken Formatting With Pre Commit.mp4

Commits:

# Added Husky pre-commit hooks with lint-staged configured
pnpm reset 06.05.01
pnpm cherry-pick 06.05.01

Fixing Agents Broken Formatting With Pre Commit

Here's the updated version:


1. Install Husky for Pre-commit Hooks

Husky enforces feedback loops before every commit.

Install and initialize Husky:

pnpm install --save-dev husky
pnpm exec husky init

Create a .husky/pre-commit file that runs your checks:

pnpm typecheck
pnpm test
npx lint-staged

If any step fails, the commit is blocked and the AI gets an error message.

2. Set Up Automatic Code Formatting

Use lint-staged with Prettier to auto-format code before commits.

Install lint-staged:

pnpm install --save-dev lint-staged

Configure .lintstagedrc:

{
  "*": "prettier --ignore-unknown --write"
}

This runs Prettier on all staged files and automatically restages them. All AI-generated code now conforms to your formatting standards.