Communitygithub.com

repo-scan

引導腳本,安裝外部 repo-scan 技能(固定提交版本)。用於需先安裝 repo-scan 再執行跨語言原始碼資產審計的場景;本 ECC 指引本身不執行審計。

repo-scan 是什麼?

repo-scan 是一個跨語言原始碼資產審計工具,能一次性分析 C/C++、Java/Android、iOS (OC/Swift) 以及 Web (TS/JS/Vue) 專案,辨識哪些程式碼屬於專案自有、哪些是第三方庫,以及哪些是應該被清理的無效資產。它透過檔案分類、內嵌函式庫偵測(支援 50 多種已知函式庫,如 FFmpeg、Boost、OpenSSL)以及四級評定(核心資產/提取合併/重建/廢棄)來提供結構性風險分析。支援快速、標準、深入及完整四種分析深度,並可產出互動式 HTML 報告。此技能由本 ECC 指向固定提交版本安裝,安裝完成後需手動調用 repo-scan 開始審計。支援 Claude Code、Cursor、Codex 等主要 AI 代理平台。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/repo-scan

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

repo-scan 是做什麼的?

每個生態系統都有自己的依賴管理工具,但沒有任何工具能同時檢視 C++、Android、iOS 和 Web,告訴你:真正屬於你的程式碼有多少、哪些是第三方、哪些是多餘的無效資產。

使用時機

  • 接手大型舊有程式碼庫,需要結構性總覽
  • 在重大重構前,辨識哪些是核心、哪些是重複、哪些是廢棄的程式碼
  • 審計直接嵌在原始碼中的第三方依賴(未在套件管理器中宣告)
  • 準備用於單一儲存庫重組的架構決策記錄

安裝

# 先複製,以便安裝前審閱固定的提交版本
set -euo pipefail

REPO_SCAN_COMMIT=2742664ebcad1450c208eda0ae45d3c17fad5dd8
REPO_SCAN_INSTALL_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills/repo-scan"
REPO_SCAN_INSTALL_PARENT="$(dirname "$REPO_SCAN_INSTALL_DIR")"
mkdir -p "$REPO_SCAN_INSTALL_PARENT"
REPO_SCAN_TMP="$(mktemp -d "$REPO_SCAN_INSTALL_PARENT/.repo-scan-install.XXXXXX")"
REPO_SCAN_TOKEN="${REPO_SCAN_TMP##*.}"
REPO_SCAN_STAGE="$REPO_SCAN_TMP/stage-$REPO_SCAN_TOKEN"
REPO_SCAN_BACKUP="$REPO_SCAN_TMP/backup-$REPO_SCAN_TOKEN"
REPO_SCAN_LOCK="$REPO_SCAN_INSTALL_PARENT/.repo-scan-install.lock"
REPO_SCAN_KEEP_TMP=0
REPO_SCAN_LOCK_HELD=0
REPO_SCAN_MV_HAS_NO_TARGET=0
cleanup_repo_scan_install() {
  if [ "$REPO_SCAN_KEEP_TMP" -eq 0 ]; then
    rm -rf -- "$REPO_SCAN_TMP"
  fi
  if [ "$REPO_SCAN_LOCK_HELD" -eq 1 ] && ! rmdir -- "$REPO_SCAN_LOCK"; then
    printf 'Could not release installation lock at %s\n' "$REPO_SCAN_LOCK" >&2
  fi
}
trap cleanup_repo_scan_install EXIT
mkdir "$REPO_SCAN_TMP/mv-probe-source"
if mv -T -- "$REPO_SCAN_TMP/mv-probe-source" \
  "$REPO_SCAN_TMP/mv-probe-destination" 2>/dev/null; then
  REPO_SCAN_MV_HAS_NO_TARGET=1
  rmdir "$REPO_SCAN_TMP/mv-probe-destination"
else
  rmdir "$REPO_SCAN_TMP/mv-probe-source"
fi
move_repo_scan_dir() {
  REPO_SCAN_MOVE_SOURCE=$1
  REPO_SCAN_MOVE_DESTINATION=$2
  REPO_SCAN_MOVE_NAME=${REPO_SCAN_MOVE_SOURCE##*/}
  if [ -e "$REPO_SCAN_MOVE_DESTINATION" ] || [ -L "$REPO_SCAN_MOVE_DESTINATION" ]; then
    return 1
  fi
  if [ "$REPO_SCAN_MV_HAS_NO_TARGET" -eq 1 ]; then
    mv -T -- "$REPO_SCAN_MOVE_SOURCE" "$REPO_SCAN_MOVE_DESTINATION"
    return
  fi
  if ! mv -- "$REPO_SCAN_MOVE_SOURCE" "$REPO_SCAN_MOVE_DESTINATION"; then
    return 1
  fi
  if [ -e "$REPO_SCAN_MOVE_DESTINATION/$REPO_SCAN_MOVE_NAME" ] || \
    [ -L "$REPO_SCAN_MOVE_DESTINATION/$REPO_SCAN_MOVE_NAME" ]; then
    if ! mv -- "$REPO_SCAN_MOVE_DESTINATION/$REPO_SCAN_MOVE_NAME" \
      "$REPO_SCAN_MOVE_SOURCE"; then
      REPO_SCAN_KEEP_TMP=1
      printf 'Move conflict recovery failed; staged data remains at %s\n' \
        "$REPO_SCAN_MOVE_DESTINATION/$REPO_SCAN_MOVE_NAME" >&2
    fi
    return 1
  fi
}

git clone --filter=blob:none --no-checkout \
  https://github.com/haibindev/repo-scan.git "$REPO_SCAN_TMP/source"
git -C "$REPO_SCAN_TMP/source" checkout --detach "$REPO_SCAN_COMMIT"
mkdir -p "$REPO_SCAN_STAGE"
git -C "$REPO_SCAN_TMP/source" archive "$REPO_SCAN_COMMIT" | \
  tar -xf - -C "$REPO_SCAN_STAGE"

# 在批准安裝前,請先審閱 "$REPO_SCAN_TMP/source"。
printf '輸入 install 以將 %s 替換為已審閱的固定原始碼:' \
  "$REPO_SCAN_INSTALL_DIR" >&2
read -r REPO_SCAN_CONFIRM
if [ "$REPO_SCAN_CONFIRM" != install ]; then
  printf '安裝已取消。\n' >&2
  exit 1
fi
if ! mkdir -- "$REPO_SCAN_LOCK" 2>/dev/null; then
  printf '另一個 repo-scan 安裝程序正持有鎖定 %s\n' \
    "$REPO_SCAN_LOCK" >&2
  exit 1
fi
REPO_SCAN_LOCK_HELD=1

if [ -e "$REPO_SCAN_INSTALL_DIR" ] || [ -L "$REPO_SCAN_INSTALL_DIR" ]; then
  move_repo_scan_dir "$REPO_SCAN_INSTALL_DIR" "$REPO_SCAN_BACKUP"
fi
if ! move_repo_scan_dir "$REPO_SCAN_STAGE" "$REPO_SCAN_INSTALL_DIR"; then
  if [ -e "$REPO_SCAN_BACKUP" ] || [ -L "$REPO_SCAN_BACKUP" ]; then
    if [ -e "$REPO_SCAN_INSTALL_DIR" ] || [ -L "$REPO_SCAN_INSTALL_DIR" ]; then
      REPO_SCAN_KEEP_TMP=1
      printf '替換失敗且目標已被重新建立;先前的安裝已保留於 %s\n' \
        "$REPO_SCAN_BACKUP" >&2
    elif ! move_repo_scan_dir "$REPO_SCAN_BACKUP" "$REPO_SCAN_INSTALL_DIR"; then
      REPO_SCAN_KEEP_TMP=1
      printf '替換與回滾均失敗;先前的安裝已保留於 %s\n' \
        "$REPO_SCAN_BACKUP" >&2
    fi
  fi
  exit 1
fi

安裝任何代理技能前,請先審閱原始碼。

安裝完成僅代表引導腳本執行完畢。請重新載入您的代理框架,然後再次呼叫 repo-scan。此 ECC 指引僅安裝外部技能,不會自行執行掃描。

核心功能

功能說明
跨語言掃描一次性掃描 C/C++、Java/Android、iOS (OC/Swift)、Web (TS/JS/Vue)
檔案分類每個檔案都標記為專案程式碼、第三方或建置產物
函式庫偵測支援 50 多種已知函式庫(FFmpeg、Boost、OpenSSL…)並提取版本
四級評定核心資產 / 提取合併 / 重建 / 廢棄
HTML 報告深色主題互動式頁面,支援逐層深入導覽
單一儲存庫支援階層式掃描,提供摘要與子專案報告

分析深度層級

層級讀取檔案數使用案例
fast每個模組 1-2 個大型目錄的快速盤點
standard每個模組 2-5 個預設審計,含完整依賴與架構檢查
deep每個模組 5-10 個增加執行緒安全、記憶體管理、API 一致性檢查
full所有檔案合併前的全面性審查

運作方式

  1. 分類儲存庫表層:列舉所有檔案,將每個檔案標記為專案程式碼、內嵌第三方程式碼或建置產物。
  2. 偵測內嵌函式庫:檢查目錄名稱、標頭檔、授權檔案及版本標記,找出捆綁的依賴項及其疑似版本。
  3. 為每個模組評分:依模組或子系統對檔案進行分組,根據所有權、重複性及維護成本,為每個模組分配四級評定之一。
  4. 突顯結構性風險:指出無效產物、重複的包裝程式、過時的供應商程式碼以及應提取、重建或廢棄的模組。
  5. 產生報告:回傳簡潔摘要及互動式 HTML 輸出,每個模組可逐層深入了解,以便非同步審閱審計結果。

範例

在 50,000 個檔案的 C++ 單一儲存庫中:

  • 發現 FFmpeg 2.x(2015 年版)仍用於生產環境
  • 發現同一 SDK 包裝程式重複了 3 次
  • 找出 636 MB 已提交的 Debug/ipch/obj 建置產物
  • 分類結果:3 MB 專案程式碼 vs 596 MB 第三方程式碼

最佳實踐

  • 首次審計時,從 standard 深度開始
  • 對於含 100 個以上模組的單一儲存庫,使用 fast 取得快速盤點
  • 對標記為需重構的模組,增量執行 deep 掃描
  • 跨模組分析有助於檢測子專案間的重複項目

連結

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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

相關技能