Communitygithub.com

安全扫描

使用 AgentShield 扫描你的 Claude Code 配置(.claude/ 目录),检查安全漏洞、错误配置和注入风险。适用于审计 CLAUDE.md、settings.json、MCP 服务器、钩子和智能体定义。

安全扫描 是什么?

安全扫描技能旨在帮助开发者和 AI 智能体用户对 Claude Code 项目配置进行安全审计,确保 `.claude/` 目录中的文件(如 CLAUDE.md、settings.json、mcp.json、hooks/ 和 agents/*.md)不包含安全风险。该技能基于 AgentShield 工具,支持扫描硬编码密钥、提示注入模式、命令注入、过度权限等常见问题。用户可以在终端运行扫描,输出格式包括彩色报告、JSON、Markdown 和 HTML,便于 CI/CD 集成。此外,还提供自动修复功能、Opus 4.6 深度分析(需 API 密钥)以及初始化安全配置的能力。该技能适用于初始化新项目、修改配置后、提交前审计或定期安全巡检,是提升 Claude Code 安全性的实用工具。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/security-scan

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

安全扫描技能

使用 AgentShield 审计你的 Claude Code 配置是否存在安全问题。

何时激活

  • 设置新的 Claude Code 项目时
  • 修改了 .claude/settings.json、CLAUDE.md 或 MCP 配置后
  • 提交配置更改之前
  • 加入现有 Claude Code 配置的仓库时
  • 定期进行安全卫生检查

扫描内容

文件检查项
CLAUDE.md硬编码密钥、自动执行指令、提示注入模式
settings.json过于宽松的允许列表、缺失的拒绝列表、危险的绕过标志
mcp.json危险的 MCP 服务器、硬编码环境变量密钥、npx 供应链风险
hooks/通过插值进行的命令注入、数据外泄、静默错误抑制
agents/*.md无限制的工具访问、提示注入面、缺失的模型规范

前提条件

必须安装 AgentShield。检查并按需安装:

# 检查是否已安装
npx ecc-agentshield --version

# 全局安装(推荐)
npm install -g ecc-agentshield

# 或直接通过 npx 运行(无需安装)
npx ecc-agentshield scan .

使用方法

基本扫描

针对当前项目的 .claude/ 目录运行:

# 扫描当前项目
npx ecc-agentshield scan

# 扫描指定路径
npx ecc-agentshield scan --path /path/to/.claude

# 以最低严重级别过滤
npx ecc-agentshield scan --min-severity medium

输出格式

# 终端输出(默认)— 带等级的颜色报告
npx ecc-agentshield scan

# JSON — 用于 CI/CD 集成
npx ecc-agentshield scan --format json

# Markdown — 用于文档
npx ecc-agentshield scan --format markdown

# HTML — 自包含的深色主题报告
npx ecc-agentshield scan --format html > security-report.html

自动修复

自动应用安全修复(仅修复标记为可自动修复的项):

npx ecc-agentshield scan --fix

这将:

  • 将硬编码密钥替换为环境变量引用
  • 将通配符权限收紧为限定范围
  • 绝不修改仅为手动建议的项

Opus 4.6 深度分析

运行对抗性的三智能体流水线进行更深入的分析:

# 需要 ANTHROPIC_API_KEY
export ANTHROPIC_API_KEY=your-key
npx ecc-agentshield scan --opus --stream

此分析运行:

  1. 攻击者(红队) — 寻找攻击向量
  2. 防御者(蓝队) — 推荐加固措施
  3. 审计者(最终裁决) — 综合双方观点

初始化安全配置

从头搭建一个安全的 .claude/ 配置:

npx ecc-agentshield init

创建:

  • settings.json,包含限定权限和拒绝列表
  • CLAUDE.md,包含安全最佳实践
  • mcp.json 占位符

GitHub Action

添加到你的 CI 流水线:

- uses: affaan-m/agentshield@v1
  with:
    path: '.'
    min-severity: 'medium'
    fail-on-findings: true

严重级别

等级分数含义
A90-100安全配置
B75-89轻微问题
C60-74需要关注
D40-59重大风险
F0-39严重漏洞

解读结果

严重发现(立即修复)

  • 配置文件中硬编码的 API 密钥或令牌
  • 允许列表中的 Bash(*)(无限制的 shell 访问)
  • 通过 ${file} 插值进行的钩子命令注入
  • 运行 shell 的 MCP 服务器

高严重性发现(生产前修复)

  • CLAUDE.md 中的自动执行指令(提示注入向量)
  • 权限中缺失的拒绝列表
  • 具有不必要 Bash 访问权限的智能体

中严重性发现(建议修复)

  • 钩子中的静默错误抑制(2>/dev/null、|| true)
  • 缺失的 PreToolUse 安全钩子
  • MCP 服务器配置中的 npx -y 自动安装

信息性发现(仅供了解)

  • MCP 服务器缺失描述
  • 正确标记为良好实践的禁止性指令

链接

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能