npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@a16njs/glob-hook

v0.4.0

Published

CLI tool for glob-based file path matching in Claude Code hooks

Readme

@a16njs/glob-hook

npm version codecov

CLI tool for glob-based file path matching in Claude Code hooks. Part of the a16n project.

Why This Package?

Claude Code hooks use a matcher field that matches tool names (Read, Write), not file paths. To apply rules to specific file patterns (like **/*.tsx for React files), you need external tooling.

glob-hook bridges this gap:

  • Reads hook input from stdin (JSON with tool_input.file_path)
  • Matches the file path against glob patterns using micromatch
  • Outputs additionalContext if matched, enabling pattern-based rule injection

Installation

# Via npx (recommended for hooks)
npx @a16njs/glob-hook --globs "**/*.tsx" --context-file "rules.txt"

# Or install globally
npm install -g @a16njs/glob-hook

Usage

Basic Usage

# Pipe hook JSON to glob-hook
echo '{"tool_input":{"file_path":"src/Button.tsx"}}' | \
  npx @a16njs/glob-hook \
    --globs "**/*.tsx" \
    --context-file ".a16n/rules/react.txt"

In Claude Code Hooks

Configure in .claude/settings.local.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Write|Edit|MultiEdit",
        "hooks": [
          {
            "type": "command",
            "command": "npx @a16njs/glob-hook --globs '**/*.tsx,**/*.ts' --context-file '.a16n/rules/typescript.txt'"
          }
        ]
      }
    ]
  }
}

Options

| Option | Required | Description | |--------|----------|-------------| | --globs | Yes | Comma-separated glob patterns (e.g., "**/*.ts,**/*.tsx") | | --context-file | Yes | Path to file containing context to inject when matched |

Output Format

When Pattern Matches

{
  "hookSpecificOutput": {
    "additionalContext": "<contents of context file>"
  }
}

When Pattern Doesn't Match

{}

On Error

Always outputs {} (empty object) and logs errors to stderr. This ensures hook failures don't break Claude Code.

Glob Pattern Examples

| Pattern | Matches | |---------|---------| | **/*.tsx | All .tsx files in any directory | | **/*.ts,**/*.tsx | All TypeScript files | | src/components/** | All files under src/components/ | | *.config.js | Config files in root | | **/*.test.ts | All test files |

Patterns use micromatch syntax with dot: true (matches dotfiles).

Requirements

  • Node.js >= 18.0.0

Documentation

Full documentation available at https://texarkanine.github.io/a16n/glob-hook.