threat-for-code

A command for reviewing a file, directory, or Git change and suggesting security threats using a Threatcl threat model.

In plain words
What is it for?
Use it to examine handlers, authentication, data access, network calls, file operations, parsing, templating, or a Git diff, and to suggest updates to the threat model.
Why use it?
It gives code changes a repeatable security review and compares them with existing modeled threats instead of relying only on general code inspection.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/threatcl/claude-plugin/threat-for-code
Clone the repo
git clone --depth 1 https://github.com/threatcl/claude-plugin
Per session 24 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 789 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00024 $0.00789
Opus 5 $0.00012 $0.00394
Sonnet 5 $0.00005 $0.00158
Haiku 4.5 $0.00002 $0.00079

Measured 2d ago against content hash 2bd269349460, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

threat-for-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/threat-for-code.md · 76 lines

How it starts

The opening of the file, as written. The whole thing — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are analyzing code at $ARGUMENTS for security implications and analyzing and comparing against the current threatcl .hcl threat model file. The argument may be a file path, a directory, or a git ref range like HEAD~3..HEAD or main...feature-branch.

1. Read the target and existing Threatcl HCL threat model

  • If $ARGUMENTS looks like a git ref range (contains ..), run git diff $ARGUMENTS and analyze the diff.
  • If it's a directory, list files and focus on code likely to have security relevance (handlers, auth, data access, network, crypto, file I/O, deserialization, templating).
  • If it's a single file, read it directly.

If the argument is empty, run git diff HEAD~1..HEAD against the most recent commit and analyze that.

Also seek out and review the local threatcl .hcl file in this repo. If this doesn't existing, you can still continue, but you can suggest to the user to run /threat-hcl-new

2. Identify security-relevant patterns

Skim for: authentication, authorization, session handling, password/secret handling, cryptography, input parsing, SQL/NoSQL queries, deserialization, file paths, subprocess execution, network calls, templating/rendering, logging of sensitive data, rate limiting, and anything that crosses a trust boundary.

For each pattern you find, note the file and line number — every threat you suggest must be tied to a concrete code location.

3. Match against the library

Use the list_library_items MCP tool (or threatcl cloud library threats or threatcl cloud library controls) with keywords drawn from what you found. For each promising library item, fetch its full detail (get_library_item or threatcl cloud library threat-ref) so you can recommend it accurately.

Prefer ref-based suggestions over generated threats whenever a library item fits — that keeps the org's library doing its job.

4. Identify novel threats

If you found a security-relevant pattern that no library item covers, propose a new threat. Don't propose duplicates of existing library items; if it's almost-but-not-quite a match, note that and suggest extending the library item rather than forking.

Read the full file on GitHub · 76 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 76 lines · 24 tokens per session scan A 2bd269349460

Subscribe to this mod's changes

threat-for-code is a command published in the GitHub repository threatcl/claude-plugin (4 stars, last pushed 17d ago), licensed MIT. It adds 24 tokens to every session and 789 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.