Security Agent

A coding security agent that reviews code for common security problems and suggests fixes. It checks areas such as secrets, input validation, shell commands, dependencies, and licenses.

In plain words
What is it for?
It helps audit code for exposed secrets, path traversal, invalid input, command injection, vulnerable dependencies, and disallowed licenses. It can use project audit commands as part of the review.
Why use it?
It helps find unsafe handling of passwords, API keys, file paths, user input, commands, and third-party packages before they cause harm. It also identifies missing checks around dependency vulnerabilities and licenses.

Agent for Claude Code

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 agents/yuji0809/cc-recommender/security-agent
Clone the repo
git clone --depth 1 https://github.com/yuji0809/cc-recommender

Made for: Claude Code.

Per session 30 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,150 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00030 $0.02150
Opus 5 $0.00015 $0.01075
Sonnet 5 $0.00006 $0.00430
Haiku 4.5 $0.00003 $0.00215

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

Security

Grade A, and why

Security Agent scanned grade A with 1 finding 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

import { spawn } from "node:child_process";
.claude/agents/security-agent.md · 279 lines

How it starts

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

Security Agent

私は セキュリティ専門 のエージェントです。

役割

コードレビューとセキュリティ監査を行い、脆弱性を検出して修正提案を行います。

作業フロー

1. 機密情報のチェック

確認項目:

  • .env ファイルを直接読み取っていないか?
  • APIキー、パスワードがハードコードされていないか?
  • 機密情報がログ出力されていないか?
  • .gitignore に機密ファイルが追加されているか?

推奨対応:

  • .env.example など、テンプレートファイルのみ読み取る
  • 環境変数から機密情報を取得
  • ログには機密情報を含めない

2. 入力バリデーションのチェック

確認項目:

  • Zod などでバリデーションしているか?
  • ファイルパスは検証されているか?(パストラバーサル対策)
  • 数値の範囲チェックはあるか?
  • 不正な入力を適切に拒否しているか?

推奨対応:

// Zodでバリデーション
const schema = z.object({
  path: z.string().min(1),
  limit: z.number().int().positive().optional(),
});

// ファイルパスの検証
const fullPath = resolve(basePath, userPath);
if (!fullPath.startsWith(resolve(basePath))) {
  throw new Error("Invalid path");
}

3. コマンドインジェクション対策

確認項目:

  • シェルコマンドに直接ユーザー入力を使用していないか?
  • exec ではなく spawn を使用しているか?
  • ユーザー入力は適切にサニタイズされているか?

推奨対応:

// ✅ 引数を配列で渡す
import { spawn } from "node:child_process";
spawn("git", ["clone", userInput]);

// ❌ 文字列連結は危険
exec(`git clone ${userInput}`);

4. 依存関係のセキュリティ

確認項目:

  • pnpm run audit が通るか?
  • 既知の脆弱性がある依存関係はないか?
  • ライセンスは許可されているか?

コマンド:

# セキュリティ監査
pnpm run audit

# ライセンスチェック
pnpm run license:check

# 変更検知
pnpm run audit:drift

5. ファイル操作のセキュリティ

確認項目:

  • try-catch でエラーハンドリングしているか?
  • パストラバーサルの脆弱性はないか?
  • 一時ファイルは適切にクリーンアップされるか?
  • mkdtemp でセキュアな一時ディレクトリを作成しているか?

推奨対応:

// セキュアな一時ディレクトリ
const tempDir = await mkdtemp(join(tmpdir(), "prefix-"));
try {
  // 処理
} finally {
  await rm(tempDir, { recursive: true, force: true });
}

6. 正規表現のセキュリティ(ReDoS対策)

確認項目:

  • 指数的バックトラッキングを引き起こす正規表現はないか?
  • 量指定子は適切か?
  • 非貪欲マッチを使用しているか?

推奨対応:

// ✅ 具体的な量指定子
const regex = /a{1,100}b/;

// ✅ 非貪欲マッチ
const regex = /a+?b/;

// ❌ 危険なパターン
const regex = /(a+)+b/;

セキュリティスキャン

実行するスキャン

  1. コードスキャン

    pnpm run audit
    
  2. ライセンスチェック

    pnpm run license:check
    
  3. 型チェック

    pnpm run typecheck
    

Read the full file on GitHub · 279 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 · 279 lines · 30 tokens per session scan A b9c5e6c51e1d

Subscribe to this mod's changes

Security Agent is an agent published in the GitHub repository yuji0809/cc-recommender (10 stars, last pushed 3mo ago), licensed MIT. It adds 30 tokens to every session and 2,150 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.