legostin

Claude Code Secret Guard — AI skill for Claude Code

AI community

Claude Code mod that keeps API keys, tokens and passwords out of the model's context: gitleaks scans every tool output, prompt and attachment before Claude reads it, and you decide what it sees.

How to install Claude Code Secret Guard

This entry records only its repository, not the path inside it, so there is no exact command to give. Open legostin/claude-code-secret-guard and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Code Secret Guard does

Claude Code mod that keeps API keys, tokens and passwords out of the model's context: gitleaks scans every tool output, prompt and attachment before Claude reads it, and you decide what it sees.

Alternatives in AI

  • Hol Guard — Open-source antivirus for AI agents: block risky tools, secret access, prompt injection, malicious packages, M 485 ★
  • Tokentab — A CLI that reads Claude Code, Codex, and Gemini CLI session logs and works out how much they cost, by model, p 226 ★
  • Context Attachment Manager — Codex and Claude Code plugin (works in Claude Desktop): choose which past images go to the model with your nex 221 ★

README

secret-guard: keep secrets out of Claude Code's context

[![CI](https://github.com/legostin/claude-code-secret-guard/actions/workflows/ci.yml/badge.svg)](https://github.com/legostin/claude-code-secret-guard/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

**secret-guard** is a [Claude Code](https://claude.com/claude-code) mod (a plugin of function hooks) that stops API keys, tokens, passwords and private keys from reaching the model. Every tool output, prompt and attachment is scanned with [gitleaks](https://github.com/gitleaks/gitleaks) *before* the model reads it. When a secret turns up, the agent pauses and you decide: cut the secret out, hide the whole output, or let it through.

[Русская версия](README.ru.md) · [Website](https://legostin.github.io/claude-code-secret-guard/)

Bash: cat .env: secrets found (github-pat ghp_…[40]). What should the model see?
  1. Cut the secrets
  2. Hide the whole output
  3. Let the model see it
  4. Not a secret, allow

The model then reads `GITHUB_TOKEN=[SECRET:github-pat#1]` instead of the token, and never learns the value.

Why

A coding agent reads whatever is in front of it: `cat .env`, a config file, a `curl -v` with an `Authorization` header, a stack trace, a log. Everything it reads is sent to the model and kept in the session transcript. A secret that gets in once is in the conversation for good.

secret-guard puts a checkpoint between your machine and the model:

  • Before the model reads anything. It hooks the points where text enters the context, not the transcript afterwards. Once a secret has been sent, removing it later does not take it back.
  • The value never reaches the model. Dialogs and the journal show a mask (ghp_…[40]) and a hash. The pane shows the value itself only when you press show the value, and hides it again after 30 seconds. The value is kept in the mod's memory alone: not in the session state, not on disk, never in a d