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

@mantra-hq/privacy-hook

v0.1.5

Published

Privacy protection hook for AI coding tools - Claude Code, etc.

Readme

@mantra-hq/privacy-hook

Privacy protection hook for AI coding tools - integrates with Mantra client for real-time sensitive information detection.

Overview

This package provides a hook that integrates with AI coding tools (like Claude Code) to detect and block sensitive information before it's sent to AI services. The hook communicates with the Mantra client running locally to perform privacy checks.

Architecture

┌─────────────────┐     HTTP POST      ┌──────────────────────┐
│  Claude Code    │ ───────────────▶   │   Mantra Client      │
│  Hook (thin)    │  /api/privacy/check │  ┌────────────────┐  │
│                 │                    │  │ Detection      │  │
│  - Intercept    │ ◀───────────────   │  │ Engine         │  │
│    prompt       │   {allow/block}    │  │ Rules Manager  │  │
│  - Forward to   │                    │  │ Records        │  │
│    client       │                    │  └────────────────┘  │
└─────────────────┘                    └──────────────────────┘

Installation

npm install -g @mantra-hq/privacy-hook
# or
pnpm add -g @mantra-hq/privacy-hook

Usage

Install Hook to Claude Code

mantra-privacy-hook install

This will register the hook in ~/.claude/settings.json to intercept prompts before they're sent.

Check Status

mantra-privacy-hook status

Shows:

  • Hook installation status
  • Mantra client connection status
  • API endpoint configuration

Uninstall Hook

mantra-privacy-hook uninstall

Removes the hook from Claude Code settings.

How It Works

  1. Claude Code Hook Trigger: When you submit a prompt in Claude Code, the UserPromptSubmit hook is triggered.

  2. Privacy Check: The hook sends your prompt to the Mantra client's local API (http://127.0.0.1:19836/api/privacy/check).

  3. Detection: The Mantra client scans the prompt using its privacy detection engine.

  4. Response:

    • If no sensitive information is found: exit 0 (allow)
    • If sensitive information is detected: exit 2 (block) + warning message
  5. Client Offline Handling: If the Mantra client is not running, the hook shows a warning and allows the prompt to proceed.

Configuration

The hook reads the Mantra client's port configuration from the settings file:

  • macOS: ~/Library/Application Support/com.gonewx.mantra/settings.yaml
  • Linux: ~/.local/share/com.gonewx.mantra/settings.yaml
  • Windows: %APPDATA%\com.gonewx.mantra\settings.yaml

Default port: 19836

You can change the port in the Mantra client's Settings page.

API Reference

Types

interface PrivacyCheckRequest {
  prompt: string;
  context?: {
    tool: string;
    timestamp?: string;
  };
}

interface PrivacyCheckResponse {
  action: "allow" | "block";
  matches?: MatchInfo[];
  message?: string;
}

interface MatchInfo {
  rule_id: string;
  severity: string;
  preview: string;
}

Programmatic Usage

import {
  checkPrivacy,
  checkClientRunning,
  registerHook,
  unregisterHook,
} from "@mantra-hq/privacy-hook";

// Check if Mantra client is running
const isRunning = await checkClientRunning();

// Perform privacy check
const result = await checkPrivacy("Your text to check");
if (result?.action === "block") {
  console.log("Sensitive information detected:", result.matches);
}

// Register/unregister hook programmatically
registerHook();
unregisterHook();

Requirements

  • Node.js >= 18.0.0
  • Mantra client installed and running for privacy protection

License

MIT