by Zazel-pixel
A small, dependency-free prompt-injection guard for coding-agent hooks (Claude Code, Codex), measured on public datasets and real sessions.
Available after the catalog security scan passes.
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM lists this project for discovery and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
# Add to your Claude Code skills
git clone https://github.com/Zazel-pixel/injection-guardGuides for using ai agents skills like injection-guard.
See how injection-guard compares with popular alternatives.
A small prompt-injection guard for the hooks of coding agents (Claude Code, Codex). One Python file, standard library only, no network. It has been measured on public datasets and on three months of real agent sessions, and it is honest about what it misses.
It does two things:
PostToolUse), it scans what came back (a web
page, a file, a command's output, an MCP response) for text that tries to
pass itself off as an instruction, and tells the agent. It never blocks.PreToolUse), it blocks the common forms
of curl ... | sh, the step where fetched content becomes code that runs.
It parses shell quoting, so a note that merely mentions that command is
not blocked. Many other forms still get through: see the next section.Read this before relying on it.
curl ... | sh, | bash,
| sudo sh, | /bin/sh, eval "$(curl ...)", bash -c '... | sh' and a
python -c that downloads. An adversarial review found forms that it does
not stop, all checked against the current version:
bash -c "$(curl ...)", bash <(curl ...), source <(curl ...),
eval `curl ...` , a bare $(curl ...), an intermediate stage
(| tee file | bash, | base64 -d | bash), launchers (| sudo -E bash,
| env bash), other interpreters (| python3), PowerShell (iwr ... | iex)
and downloading to a file, then running it. Closing these is the next piece
of work.It is an alarm for naive injections, not a wall. It complements, and does not replace, sandboxing, least-privilege credentials and asking the human before side effects.
Everything below is reproduced by python3 evaluate.py. "Before" is the
version this repository started from, and "after" is this one.
Public datasets (corpus/external, see corpus/external/NOTICE.md): share
of documents that produce at least one alert shown to the agent.
| documents | count | before | after |
|---|---|---|---|
| InjecAgent tool outputs, injection prefixed with "ignore previous instructions" | 1,054 | 100 % | 100 % |
| InjecAgent tool outputs, attacker instruction alone | 1,054 | 0 % | 1.6 % |
| Lakera Gandalf prompts, held-out test split | 112 | 41.1 % | 45.5 % |
| deepset injections, English | 174 | 4.0 % | 4.0 % |
| deepset injections, German | 89 | 0 % | 0 % |
| deepset benign prompts | 399 | 0.5 % | 0 % |
| InjecAgent tool outputs without the injection | 17 | 0 % | 0 % |
| hand-written regressions of past false alarms | 20 | 15 | 4 |
| this repository's own source and docs | 6 | 2 | 0 |
Real use. The guard was replayed on every tool output of one person's Claude Code and Codex sessions from 14 August to 7 November 2026, about 86,400 outputs. That data stays private. Only these counts are published.
| before | after | |
|---|---|---|
| alerts shown to the agent | 323 | 53 |
| of which on 7 November, when attack datasets were printed on purpose | 48 | 37 |
| over the 85 days before, per day | 3.2 | 0.19 |
| real injections found among them | 0 | 0 |
"Real injections found" comes from reading the alerts: the rare patterns in
full, the frequent ones by sampling and by grouping them by cause. Before the
changes, most alerts came from ordinary code and documentation: process.env
and .env.example, curl commands in API references, curl's -D option, HTML
login forms, model chat templates and emoji. The high-severity ones came from
notes and articles that quote injections, and from the guard's own test
output. Over the 85 days before the measurement, 16 alerts remain.
Known false alarms that remain: documentation that tells a human to "enter
the password" (the largest group), plain-text instructions to cat a secret
file, a README that says to run a script before going on, and fine-tuning
templates with an ### Instruction: heading. A quotation is also missed when
a pattern's match runs past the closing quote, for instance up to a keyword
just after it.
It needs Python 3.10 or later and nothing else.
python3 install.py
It copies injection_guard.py to ~/.local/share/injection-guard/ and points
the hook file of each agent it finds (~/.claude/hooks, ~/.codex/hooks) at
that one copy with a symlink, keeping any file it replaces as *.bak-DATE.
One copy means a fix cannot reach one agent and miss the other.
python3 install.py --check verifies that every hook runs that copy and that
it matches the checkout.
It never edits settings. python3 install.py --config prints the two hook
entries to add to ~/.claude/settings.json (and to ~/.codex/hooks.json):
PreToolUse on Bash, PostToolUse on WebFetch|WebSearch|Read|Grep|Bash|Task|mcp__.*.
To switch it off for one command: CLAUDE_INJECTION_GUARD=off.
Each finding has a severity:
override-instructions, identity-reassign, fake-authority,
conceal-from-user, chat-delimiter, hidden tag characters).exfiltration, credential-bait,
tool-coercion, bidirectional overrides, long runs of zero-width
characters).A match is a citation when it sits inside inline code, a fenced block,
typographic quotes, or straight double quotes that follow words in a
sentence, and the quoted span is at most 200 characters. A match next to
regular-expression syntax is a citation too. Quotes that open a value ("key": "...", a
list, a function call) and long quoted strings are content, not citations,
so injections inside JSON and MCP responses are still reported.
Invisible characters are removed before matching, so a zero-width space in the middle of a word does not hide it. Emoji joiners and byte-order marks are ignored.
A finding is shown once per session. Repeats are logged, not shown.
The log, ~/.claude/hooks/injection-guard.jsonl, keeps one JSON line per
event with a short excerpt of each finding, redacted first (assignments
of keys and passwords, known token prefixes, JWTs, long opaque strings).
python3 tools/audit_log.py summarises it, and --list prints the excerpts
so that each alert can be judged as real or false.
Other tools address the same problem with trained classifiers or hosted services, and detect paraphrases this guard cannot:
What this one offers instead: no model, no dependency, no network call, a
few milliseconds per tool output, rules you can read in one file, and a hook
interface made for coding agents, with a shell-aware block on curl | sh.
python3 -m unittest discover -s tests # blocking, patterns, hook, install, corpus bar
python3 evaluate.py # detection and false alarms, per group and pattern
python3 evaluate.py --guard OLD.py # the same numbers for another version
python3 evaluate.py --transcripts ~/.claude/projects ~/.codex/sessions --samples 5
The rule: no change to a pattern without the numbers before and after.
tests/test_corpus.py holds the current numbers as thresholds, so a change
that lowers detection or adds false alarms fails until the threshold is moved
on purpose. Every alternative of every pattern has a test case that must
match: three of them could never match anything until November 2026, and
nothing had noticed.
When you tune a pattern, read only the train splits and keep the test
splits as the held-out measure.
MIT, see LICENSE. The datasets in corpus/external keep their own licences
(MIT and Apache-2.0), listed in corpus/external/NOTICE.md.
injection-guard is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by Zazel-pixel. A small, dependency-free prompt-injection guard for coding-agent hooks (Claude Code, Codex), measured on public datasets and real sessions. It has 194 GitHub stars.
injection-guard's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/Zazel-pixel/injection-guard" and add it to your Claude Code skills directory (see the Installation section above).
injection-guard is primarily written in Python. It is open-source under Zazel-pixel on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh injection-guard against similar tools.
No comments yet. Be the first to share your thoughts!