---
title: "Discussion on \"Block deprecated packages before your coding agent installs them: a 50-line Claude Code hook\" | Hashnode"
description: "Discussion on \"Block deprecated packages before your coding agent installs them: a 50-line Claude Code hook\". TL;DR: Coding agents often install archived MCP servers from memory, and nothing in a normal toolchain notices. Here's a 50-line Claude Code PreToolUse hook that asks the npm registry before the agent"
url: "https://hashnode.com/posts/block-deprecated-packages-before-your-coding-agent-installs-them-a-50-line-claude-code-hook/6afe9ef196b0e40bfb6bce34"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Block deprecated packages before your coding agent installs them: a 50-line Claude Code hook](https://redliolabs.hashnode.dev/block-deprecated-packages-before-your-coding-agent-installs-them-a-50-line-claude-code-hook?utm_source=hashnode&utm_medium=feed)

TL;DR: Coding agents often install archived MCP servers from memory, and nothing in a normal toolchain notices. Here's a 50-line Claude Code PreToolUse hook that asks the npm registry before the agent

5d ago · 6 min read · redliolabs.hashnode.dev  
Read the article

-   [#mcp](https://hashnode.com/tag/mcp)
-   [#claude-code](https://hashnode.com/tag/claude-code)
-   [#security](https://hashnode.com/tag/security)
-   [#ai-agents](https://hashnode.com/tag/ai-agents)
-   [#npm](https://hashnode.com/tag/npm)

## Written by

[Redlio Labs](https://hashnode.com/@redliolabs)

@redliolabs · Ahmedabad, India

  
[View profile](https://hashnode.com/@redliolabs)

Software development company since 2014. Custom software, ERP, SaaS, web and mobile apps for mid-size and large companies.

Redlio Labs is a software development company in Ahmedabad, India, founded in 2014. We design, build and grow custom software, ERP systems, SaaS products and web and mobile apps for mid-size and large companies, and write here about the engineering problems we solve along the way. Rated 5.0 on Clutch and Google. Website: https://redliolabs.com

## Responses 4

Markdown supported · ⌘↵ to post

[Vic Moreno](https://hashnode.com/@itsvicmoreno)

[1d ago](https://hashnode.com/posts/block-deprecated-packages-before-your-coding-agent-installs-them-a-50-line-claude-code-hook/6afe9ef196b0e40bfb6bce34/comment/6b03fa41553753426234f487)

Failing open on a registry timeout is the right call; a check that stalls work gets switched off fast. One gap that stays open: the regex only sees package names the agent types, so a deprecated version already pinned in the lockfile goes through on the next npm ci untouched. Does your config checker read project lockfiles too, or only MCP configs?

[Redlio Labs](https://hashnode.com/@redliolabs)

[1d ago](https://hashnode.com/posts/block-deprecated-packages-before-your-coding-agent-installs-them-a-50-line-claude-code-hook/6afe9ef196b0e40bfb6bce34/comment/6b03fa41553753426234f487#reply-6b041cf74c8acdf3805b17cc)

Good catch, and you're right: the audit script only reads MCP configs, not lockfiles. We left lockfiles out on purpose because they're already visible to normal dependency tooling, and npm ci prints a "deprecated" warning for those packages. But a warning in CI logs is easy to scroll past. Extending the check is small: walk the "packages" map in package-lock.json and ask the registry about each name@version, then fail the build instead of warning. Might be worth a follow-up post. Thanks, Vic.

[Salman Parvez | ML Systems](https://hashnode.com/@ml-systems)

[5d ago](https://hashnode.com/posts/block-deprecated-packages-before-your-coding-agent-installs-them-a-50-line-claude-code-hook/6afe9ef196b0e40bfb6bce34/comment/6afee3e32d81cc8c28d38a45)

The agent seeing the deprecation notice and installing the package anyway is the part that stuck with me. That's a sub reading the recall notice on a product and putting it in the wall. Checking at the moment of install, against the registry's current answer, beats trusting what anyone remembers. A hook that stops the call and points to a maintained option is the right shape for it.

[Redlio Labs](https://hashnode.com/@redliolabs)

[4d ago](https://hashnode.com/posts/block-deprecated-packages-before-your-coding-agent-installs-them-a-50-line-claude-code-hook/6afe9ef196b0e40bfb6bce34/comment/6afee3e32d81cc8c28d38a45#reply-6afff2db897dbf11d9b64f44)

That recall-notice comparison is spot on. What worried us most wasn't the old package itself. It was that the agent saw the warning and carried on without saying anything. Blocking at install time also makes the agent bring the decision back to a person, which matters as much as the block. Thanks for reading, Salman.
