hook-protect-secrets

Block secret file access and credential exfiltration via PreToolUse hooks.

1|Updated Apr 9, 2026
One-click install
npx skills add https://github.com/hbvg234/jnmt.vn --skill hook-protect-secrets
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-protect-secrets
Source: https://github.com/hbvg234/jnmt.vn/tree/main/.claude/skills/hook-protect-secrets
Command: npx skills add https://github.com/hbvg234/jnmt.vn --skill hook-protect-secrets

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pattern guide for writing PreToolUse hooks that block secret file access, credential exfiltration, and environment variable dumps. Use when auditing token-scope-guard.sh, adding new sensitive file patterns, reviewing what secret paths are protected. Inspired by: karanb192/claude-code-hooks protect-secrets pattern (MIT).

Core Features & Use Cases

  • Provides structured patterns to detect secret file access, sensitive file patterns, and exfiltration attempts across 33 file patterns, 24 Bash patterns, and 15 exfiltration patterns.
  • Includes safe-file exemptions (e.g., .env.example, .env.sample, .env.template) and standard hook exit codes to differentiate allowed vs blocked actions.
  • Step-by-step guidance to add new patterns, run tests, and update review dates in the hook implementation for ongoing security hardening.

Quick Start

Configure and apply PreToolUse hooks to block secret file access and environment-variable exfiltration patterns in token-scope-guard.sh.

Frequently Asked Questions about hook-protect-secrets

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I block secret file access and credential exfiltration using pre-use hooks?

Block secret file access by enforcing PreToolUse hooks that detect sensitive file patterns and environment-variable dumps. This Skill provides structured detection patterns across files, Bash commands, and exfiltration attempts to deny unauthorized access automatically.

What sensitive file patterns should I protect against in a security audit?

Protect against 33 sensitive file patterns, 24 Bash patterns, and 15 exfiltration patterns. The Skill guides you through auditing token-scope-guard.sh, adding new patterns, and reviewing protected secret paths for ongoing security hardening.

Can I exempt safe files like .env.example from secret access blocking hooks?

Yes, safe-file exemptions are included for .env.example, .env.sample, and .env.template files. The hook implementation differentiates allowed vs blocked actions using standard hook exit codes to determine allow/deny outcomes.

How do I add new secret detection patterns to an existing hook implementation?

Add new secret detection patterns by following the step-by-step guidance to update the hook implementation, run tests, and update review dates. This ensures ongoing security hardening as new credential exfiltration techniques emerge.

Does this approach work without external dependencies or components?

Yes, the pattern-based detection requires no external dependencies or components. It relies entirely on enforcing PreToolUse hooks with standard exit codes to determine allow/deny outcomes for sensitive file and environment-variable access.

Why use pattern-based detection instead of other secret blocking methods?

Pattern-based detection provides immediate, deterministic blocking of known sensitive file paths and exfiltration commands. It offers transparent, auditable rules with safe-file exemptions, unlike opaque methods, making it ideal for reviewing and hardening protected secret paths.