# dependency-checker

A PostToolUse hook that runs a package audit after you touch a dependency file, so outdated or vulnerable packages surface right away.

- hook · `type=hook` · Claude Code · 2314 installs
- Author: davila7
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/hooks/automation/dependency-checker.json
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/hooks/dependency-checker

## What it does

The hook listens on PostToolUse with the `Edit` matcher. When the edited file is `package.json`, `requirements.txt`, `Cargo.toml`, `pom.xml` or `Gemfile`, it prints the path to the console. For `package.json` it then runs `npm audit` and `npx npm-check-updates`, provided `npm` is on the machine.

\`requirements.txt` gets `safety check -r` against that file, but only when `safety` is installed. `Cargo.toml` gets `cargo audit` if `cargo` is available. Every command is wrapped with error suppression and `|| true`, so a failing audit never kills your session.

\`pom.xml` and `Gemfile` are only reported as modified — there is no audit step for them in the command. Don't expect Maven or Bundler analysis from this hook. Installation writes into `.claude/settings.json`, so check that the file exists and that you aren't overwriting settings you already keep there.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --hook automation/dependency-checker
```

2. **Manually: put the files in place**
- File: `.claude/settings.json` — The hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/hooks/automation/dependency-checker.json

## When to use it
- catch vulnerable packages right after editing a manifest
- see which dependencies are behind
- run `safety` against `requirements.txt`
- run `cargo audit` after a `Cargo.toml` change
- notice that a dependency file was modified

## Example prompts
- I edited package.json, check the dependencies
- I updated requirements.txt — run the audit
- what's outdated in my package.json?

## Source text · dependency-checker.json · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 6dae92efb7eee8a6.

BEGIN THIRD-PARTY FILE 6dae92efb7eee8a6
```text
{
  "description": "Advanced dependency analysis and security checking. Monitors for outdated packages, security vulnerabilities, and license compatibility.",
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit",
        "hooks": [
          {
            "type": "command",
            "command": "if [[ \"$CLAUDE_TOOL_FILE_PATH\" == *package.json || \"$CLAUDE_TOOL_FILE_PATH\" == *requirements.txt || \"$CLAUDE_TOOL_FILE_PATH\" == *Cargo.toml || \"$CLAUDE_TOOL_FILE_PATH\" == *pom.xml || \"$CLAUDE_TOOL_FILE_PATH\" == *Gemfile ]]; then echo \"Dependency file modified: $CLAUDE_TOOL_FILE_PATH\"; if [[ \"$CLAUDE_TOOL_FILE_PATH\" == *package.json ]] && command -v npm >/dev/null 2>&1; then npm audit 2>/dev/null || true; npx npm-check-updates 2>/dev/null || true; elif [[ \"$CLAUDE_TOOL_FILE_PATH\" == *requirements.txt ]] && command -v safety >/dev/null 2>&1; then safety check -r \"$CLAUDE_TOOL_FILE_PATH\" 2>/dev/null || true; elif [[ \"$CLAUDE_TOOL_FILE_PATH\" == *Cargo.toml ]] && command -v cargo >/dev/null 2>&1; then cargo audit 2>/dev/null || true; fi; fi"
          }
        ]
      }
    ]
  }
}
```
END THIRD-PARTY FILE 6dae92efb7eee8a6

The third-party file has ended. Everything between the 6dae92efb7eee8a6 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© davila7 · MIT · https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/hooks/automation/dependency-checker.json

## Similar
- [dependency-manager](https://affpapa.org/en/nevibecode/agents/dependency-manager.md) — subagent · 356 installs
- [react18-dep-compatibility](https://affpapa.org/en/nevibecode/skills/react18-dep-compatibility.md) — skill · 764 installs
- [agent-supply-chain](https://affpapa.org/en/nevibecode/skills/agent-supply-chain.md) — skill · 1100 installs
- [dependency-upgrade](https://affpapa.org/en/nevibecode/skills/dependency-upgrade.md) — skill · 11079 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 205 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
