git404hub

what is claude-code-cred-guard fr?

yodaisgaming/claude-code-cred-guard — explained in plain English

Analysis updated 2026-05-18

0JavaScriptAudience · developerComplexity · 2/5Setup · moderate

tl;dr

A zero-dependency Claude Code hook that blocks an AI agent from reading credential files like .env or SSH keys into its conversation, without false positives.

vibe map

mindmap
  root((cred-guard))
    What it does
      Blocks credential reads
      Target-based matching
      Fail-open on errors
    Tech stack
      JavaScript
      Node.js
      Claude Code hooks
    Use cases
      Protect .env files
      Block env dumps
      Guard SSH keys
    Audience
      Developers
      Claude Code users

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Prevent an AI coding agent from accidentally reading .env or credential files into its context.

VIBE 2

Block bulk environment variable dumps like printenv or env from an agent's shell commands.

VIBE 3

Allow legitimate mentions of credential filenames in searches, notes, or scripts.

VIBE 4

Protect API keys, SSH keys, and cloud credential files from leaking into session logs.

what's the stack?

JavaScriptNode.jsClaude Code hooks

how it stacks up fr

yodaisgaming/claude-code-cred-guard00kaku/gallery-slider-block0xkinno/vellum
Stars00
LanguageJavaScriptJavaScriptJavaScript
Last pushed2021-05-19
MaintenanceDormant
Setup difficultymoderateeasyhard
Complexity2/52/54/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · moderate time til it works · 30min

Requires Node.js 18+ and correctly registering an absolute path in Claude Code's settings.json hooks config.

in plain english

claude-code-cred-guard is a safety hook for Claude Code, an AI coding agent, that stops the agent from reading credential files, such as passwords or API keys stored in a dot env file, directly into its conversation. The problem it solves is that once a secret's plaintext is read into the conversation, it gets sent to the AI model's provider and saved in local session logs, which is a privacy and security risk even if the agent means no harm. The tool works as a single JavaScript file with no external dependencies, plugged into Claude Code's PreToolUse hook system, which lets it inspect a command before it runs and block it if needed. Its key design choice is checking whether a credential file is actually the target being read, rather than simply checking whether the filename appears anywhere in the command. This avoids two common failure modes seen in simpler versions of this idea: blocking harmless commands that merely mention a credential filename, such as a search pattern or a note, and missing sneaky reads such as a Python one liner that opens the file or a command run inside another interpreter. By default it recognizes many common credential file types, including dot env files, WordPress config files, SSH private keys, cloud credential files for AWS and Kubernetes, and certificate files, along with commands that dump the whole environment variable list at once. It deliberately allows reading a single named environment variable and allows scripts that consume credentials internally without printing them out. The author is explicit that this tool defends against accidental exposure by a well meaning agent, not a determined attacker trying to hide a read, which would need different defenses like sandboxing. Installing it means copying one JavaScript file to a stable location and registering it in a Claude Code settings file, matching it against the Bash, Read, and Grep tools, using an absolute file path since a shortcut like a tilde is not expanded inside the hook command. It requires Node.js 18 or later and is tested on Linux, macOS, and Windows. If the hook itself ever fails, it is designed to allow the command through rather than block the agent entirely.

prompts (copy fr)

prompt 1
Help me install this hook into my ~/.claude/settings.json PreToolUse configuration.
prompt 2
Explain the difference between target-based matching and a simple filename substring check.
prompt 3
Walk me through adding a new credential filename to CRED_TOKEN and isCredPath().
prompt 4
How do I customize this hook to also recognize .npmrc or .pypirc as credential files?

Frequently asked questions

what is claude-code-cred-guard fr?

A zero-dependency Claude Code hook that blocks an AI agent from reading credential files like .env or SSH keys into its conversation, without false positives.

What language is claude-code-cred-guard written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js, Claude Code hooks.

How hard is claude-code-cred-guard to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is claude-code-cred-guard for?

Mainly developer.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.