What the agent does
The agent reads package.json and the hook files, because husky 9 prints two different deprecations and each has its own fix. In cabinjs/cabin, a logging library for Node, line 48 of package.json declares "husky": "^9.0.11" and line 154 keeps the husky 8 script, "prepare": "husky install". .husky/pre-commit and .husky/commit-msg each start with a sh shebang line and . "$(dirname "$0")/_/husky.sh" before their commands, npx --no-install lint-staged && npm test and npx --no-install commitlint --edit $1. The CI workflow runs npm install and then npm run test on Node 18 and 20, so every CI log carries the first message.
Then it reads what husky 9 does with the old script, in the installed node_modules/husky/bin.js. husky install prints husky - install command is DEPRECATED to stderr and then does what plain husky does; add, set and uninstall print the same and exit 1; init writes "prepare": "husky" and a .husky/pre-commit. The _/husky.sh file that husky writes on every prepare is no longer a library but a shim that prints husky - DEPRECATED, asks for the two lines to be removed from the hook that sourced it, and warns that they will fail in v10.0.0. The sandbox's npm install printed the first message from the prepare step, and a commit printed the second for .husky/pre-commit before lint-staged ran.
The fix is small and in two files plus one script. prepare becomes husky, which prints nothing; each hook keeps only its command line, since husky 9 runs the file with sh itself and sets the hooks path on prepare. The .husky/_ directory is generated and ignored by the .gitignore husky writes there, so nothing else is committed.
Proof is a commit. On the branch npm run prepare prints nothing, git commit --allow-empty runs lint-staged, which reports no staged files, and commits, and a commit with the message bad message is refused by the commit-msg hook with commitlint's two problems and husky - commit-msg script failed (code 1), so both hooks still fire without the legacy lines. The agent keeps npm test in the pre-commit command as it found it and notes in the pull request that the hook runs the full build before every commit.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This repository prints \"husky - install command is DEPRECATED\" on install and a \"husky - DEPRECATED\" block on every commit. Read package.json and every file under .husky, say which husky a clean install resolves, and read the installed husky's bin to confirm what each deprecated command does now. Change the prepare script to the current form, remove the shebang and the husky.sh source line from each hook while keeping its commands exactly, and check that nothing generated under .husky/_ is committed. Prove the hooks still run: run the prepare script and show it prints nothing, make an empty commit and show the pre-commit hook's command ran, and make a commit with a message that violates the commit-msg hook's rule and show it was refused. Open a pull request with the before-and-after output.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that changes one line of package.json and removes two lines from each of two hook files. The description quotes both deprecation messages as the sandbox saw them, cites the lines of husky's bin.js and _/husky.sh that print them, and shows the prepare output, the empty commit and the refused commit on the branch.
A reviewer checks that each hook's command line is unchanged, that no file under .husky/_ was added, and that the refused commit really came from the commit-msg hook rather than from a missing commitlint. If the repository's CI runs npm ci, the reviewer notes that the prepare script runs there too and the message disappears from those logs.
The pull request does not change what the hooks run, so a slow pre-commit stays slow; it names the npm test in the hook and leaves that decision to the team.
Run it on every repository with a husky hook
The message appears in every repository that upgraded husky with a bot and kept the old script, so the useful unit is the repository, not the event. From a list of repositories, your server starts one run per repository with the same request, each with its own UUID as request_id so a retry returns the run it already started, and reads each result when its run.completed webhook arrives. A key starts at most max_concurrent runs at once and queues the rest, so a long list needs no throttling of its own.
To catch the next upgrade instead, an automation with a github trigger on pull requests starts a run when a bot bumps husky across a major version, with the event appended to the prompt.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
The two messages look alike and have different fixes, and the second only shows on a commit. In a Rush sandbox the agent installs the project, makes commits with the hooks enabled, and reads husky's own source in node_modules to confirm what each command does now, with every line of output kept, so the pull request quotes evidence rather than a changelog.
Hook changes are the kind of edit people merge without running, because running them means committing. The agent commits twice on a branch in its sandbox, once to show the pre-commit hook fires and once to show the commit-msg hook refuses a bad message, and the pull request shows both.
Frequently asked questions
What does husky 9 want the prepare script to be?
"prepare": "husky", with no subcommand. husky install still works in 9 but prints the deprecation, and husky add, set and uninstall print it and exit with status 1.
Why remove the two lines from each hook?
Because husky 9 runs each hook file with sh itself and _/husky.sh is now only a shim that prints the deprecation. The shim says the lines will fail in v10.0.0. A hook file that holds only its commands works on husky 9 today and on 10 later.
Will the hooks still run after the change?
Yes, and the pull request shows it: an empty commit runs the pre-commit command, and a commit with a non-conforming message is refused by the commit-msg hook. Nothing about which commands run changes.
Does this change the lint-staged or commitlint configuration?
No. The hook commands and the .lintstagedrc.js and .commitlintrc.js files are untouched. Only the prepare script and the two legacy lines at the top of each hook change.
More husky jobs
More jobs like this: Fix a bug from an alert
- Fix "AttributeError: 'ImageDraw' object has no attribute 'textsize'" in Pillow 10 (Pillow)
- Fix imageio GIFs That Play With No Frame Delay After Upgrading (mimsave duration) (imageio)
- Fix "SyntaxError: Unexpected identifier 'assert'" in rollup.config.js on Node.js 22 (Rollup)
- Fix "error TS5102: Option 'importsNotUsedAsValues' has been removed" in tsconfig.json (TypeScript)
- Fix "ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape" (NumPy)