Community寫作與編輯github.com

trailofbits/code-improver

對任何程式碼目標(技能、插件、模組或目錄)執行自主的審查與修復改進循環,使用使用者指定的任何已安裝技能或代理作為審查者。維護跨輪次的發現記錄,當修復停止收斂時會升級問題,並以機械方式守護範圍。

code-improver 是什麼?

這個工具類技能旨在對指定的程式碼目標進行自動化的「審查-修復」迭代循環。使用者需要提供三個輸入:目標路徑、一個已安裝的審查者(另一個技能或代理),以及可選的範圍限制。工作流程會啟動一個動態工作流,讓審查者反覆檢查程式碼,再由修復子代理進行修改,直到審查結果中沒有關鍵或重大問題為止。它會維護一份跨輪次的發現記錄,當修復無法收斂(例如問題重複出現或計數未減少)時會觸發升級,並在每次修復後檢查是否超出指定範圍,以確保修改不越界。此技能支援 Claude Code、Codex 等平台,並專注於與現有的審查技能(如 `pr-review-toolkit:review-pr`)協作,而不是自行進行審查。它提供了詳細的錯誤處理,包括審查者不可用、預算超支(capped)、以及範圍違規等情況,並允許使用者在升級後輸入決策來繼續迭代。

相容平台✓Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/trailofbits/skills/tree/main/plugins/code-improver/skills/code-improver

Installed? Explore more 寫作與編輯 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

在你喜歡的 AI 中提問

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

說明文件

Code Improver

透過執行 /code-improver:improve 來改進任何程式碼目標 — 這是一個動態工作流程,會循環使用指定的審查者和修復子代理,直到審查報告中沒有關鍵/重大問題,然後清除自身的殘留痕跡。循環、其記錄和守護機制都位於工作流程中;這個技能負責收集通用入口所需的三個輸入,並轉發結果。

開始循環

使用者提供了:$ARGUMENTS(如果為空,則從對話中取得詳細資訊)。

1. 收集三個必需的輸入 — 不要猜測

  1. 目標 (Target):要改進的目錄的絕對路徑。根據工作目錄解析相對路徑;驗證目錄是否存在。
  2. 審查者 (Reviewer):執行每次審查的已安裝技能或代理。使用者必須指定名稱 — 沒有預設值,也沒有內建的審查者。判斷其類型:
    • 命名空間代理 (例如 plugin-dev:skill-reviewer) → "kind": "agent"
    • 已安裝技能 (例如 pr-review-toolkit:review-pr) → "kind": "skill" 如果名稱可能屬於任一類型,請檢查會話的技能清單;如果仍然不明確,請詢問使用者。如果沒有指定審查者,請詢問 — 不要自行選擇。
  3. 範圍 (Scope):循環可以觸及的倉庫相對 glob。通用入口要求明確指定;如果使用者沒有提供,請提議目標目錄 (<倉庫相對目標>/**) 並在啟動前確認。

2. 解析循環腳本

這個循環是此插件中的動態工作流程 workflows/improve.js。透過路徑啟動它:scriptPath 接受一個已解析的絕對路徑,而 Workflow 工具的 name 會解析內建和專案工作流程,因此從市集安裝的副本可能不會回應 code-improver:improve。依序嘗試,第一個找到的勝出 — 家目錄的路徑排在 . 之前,因此已安裝的副本優先於此市集的簽出副本:

  1. Bash: ls -d -- "${CLAUDE_PLUGIN_ROOT}/workflows/improve.js"
  2. Bash: ls -d -- "${CODEX_PLUGIN_ROOT}/workflows/improve.js"(如果該變數已設定)
  3. Bash: find ~/.claude ~/.codex . -maxdepth 7 -path '*/code-improver/workflows/improve.js' -print -quit 2>/dev/null

使用輸出的確切路徑。其插件目錄 — 路徑中移除 /workflows/improve.js 的部分 — 就是 pluginRoot。如果三個方法都回傳空值,請嘗試一次 {name: "code-improver:improve"};如果仍然不可用,則停止並說明無法定位循環。不要手動組合路徑,也不要即興建立循環。

3. 調用工作流程

使用 Workflow 工具執行,參數為 {scriptPath: "<步驟 2 的路徑>", args: {...}}:

{
  "target": "<絕對目標路徑>",
  "reviewer": { "kind": "agent|skill", "name": "<命名空間名稱>", "notes": "<審查者應了解的目標相關資訊>" },
  "scope": ["<倉庫相對 glob>/**"],
  "pluginRoot": "<步驟 2 的插件目錄>",
  "maxRounds": 5
}
  • 僅在使用者要求不同上限時才提供 maxRounds。
  • pluginRoot 讓執行能找到其指標收集器;僅在步驟 2 退回到工作流程名稱時才省略此鍵 — 工作流程隨後會自行搜尋。
  • 僅在需要覆蓋預設值時提供 finalize({"version_bump": bool, "narration_strip": bool, "docs_pass": bool}):當目標位於插件內部時進行版本號提升,敘述清除和文件檢查則始終執行。
  • 僅在繼續(如下所述)時提供 decision。

工作流程在背景執行,無需監管:它會審查、修復、重新審查,在每次修復輪次後檢查範圍,並且只有在審查乾淨時才能完成。它永遠不會提交;所有更改都保留在工作樹中。

如果 Workflow 工具不可用或被拒絕,請停止並說明。 不要使用直接編輯來內聯即興建立循環 — 記錄、範圍守護和升級保證都存在於工作流程中,內聯模擬則完全沒有這些機制。

如果結果是 halted: "reviewer-unavailable",請轉發並停止。 指定的審查者未在此會話中安裝;告訴使用者哪個插件提供了它,並在安裝後重新執行。不要自行審查目標。

循環執行時不要結束你的回合。 Workflow 工具會立即回傳一個任務 ID;結果稍後才會到來。在互動式會話中,完成通知會重新調用你 — 請等待它。在非互動式執行(腳本、CI、評估)中,沒有後續回合:停止會使循環在中途被放棄,因此啟動後,請輪詢任務(使用回傳的任務 ID 的 TaskOutput,或 sleep-and-recheck)直到完成,然後轉發結果。一個回答「循環正在執行,我稍後會報告」的會話已經失去了該次執行。

轉發結果

工作流程會回傳一個結構化結果。誠實地報告它 — 這些區別很重要:

  • converged: true — 最後一個動作是審查,且沒有關鍵/重大問題。報告使用的輪次、剩餘的輕微問題 (open_minor_count) 以及工件路徑 (ledger_path, metrics)。
  • capped: true — 修復預算用盡,且最終審查仍發現阻擋性問題。直接說明:已達上限 (capped),尚未收斂 (NOT converged),並列出 open_blocking。不要將此視為成功。
  • escalation — 循環偵測到無法收斂(重複出現的問題、問題數量未減少,或修復將問題轉移到別處)。將升級訊息和問題 ID 轉發給使用者:這需要設計決策,而不是更多輪次的修復。
  • halted — 有守護機制觸發(範圍違規、未註冊的新檔案、審查者失效或不可用,或者最終化流程自身的編輯未能通過後續檢查時)。轉發 violations/new_untracked_files 中的路徑、finalize_regressions 中的位置以及備註。
  • notes 始終隨結果一起提供 — 務必呈現它們;它們包含重要警告,例如「已初始化一個 git 倉庫」。

在升級後繼續

循環在升級時會按設計停止。當使用者做出決定後,使用相同的 target 和 reviewer 啟動一個新的執行,並加上:

{ "decision": "<使用者的裁決,原樣傳遞>" }

新的執行會重新載入磁碟上的記錄,因此每個問題、拒絕和裁決都會延續下去 — 輪次會重新開始,但不會重新衍生。

要停止正在運行的循環,請停止工作流程任務(TaskStop);磁碟上的記錄會更新到上一輪,重新執行時會從那裡繼續。

何時不應使用

  • 針對 Claude Code 技能:使用 skill-improver 入口 — 它會連接正確的審查者
  • 針對分支/拉取請求:使用 pr-improver 入口 — 它會從差異中推導出範圍
  • 一次性審查:直接派遣審查者;這個循環的價值在於迭代
  • 快速的一次性修復:直接編輯檔案

Individual skills in this repo

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

trailofbits/address-sanitizer

AddressSanitizer detects memory errors during fuzzing. Use when fuzzing C/C++ code to find buffer overflows and use-after-free bugs.

trailofbits/aflpp

AFL++ is a fork of AFL with better fuzzing performance and advanced features. Use for multi-core fuzzing of C/C++ projects.

trailofbits/agentic-actions-auditor

Audits GitHub Actions workflows for security vulnerabilities in AI agent integrations including Claude Code Action, Gemini CLI, OpenAI Codex, and GitHub AI Inference. Detects attack vectors where attacker-controlled input reaches AI agents running in CI/CD pipelines, including env var intermediary patterns, direct expression injection, dangerous sandbox configurations, and wildcard user allowlists. Use when reviewing workflow files that invoke AI coding agents, auditing CI/CD pipeline security for prompt injection risks, or evaluating agentic action configurations.

trailofbits/algorand-vulnerability-scanner

Scans Algorand smart contracts for 11 common vulnerabilities including rekeying attacks, unchecked transaction fees, missing field validations, and access control issues. Use when auditing Algorand projects (TEAL/PyTeal).

trailofbits/ask-questions-if-underspecified

Clarify requirements before implementing. Use when serious doubts arise.

trailofbits/atheris

Atheris is a coverage-guided Python fuzzer based on libFuzzer. Use for fuzzing pure Python code and Python C extensions.

trailofbits/audit-augmentation

Augments Trailmark code graphs with external audit findings from SARIF static analysis results and weAudit annotation files. Maps findings to graph nodes by file and line overlap, creates severity-based subgraphs, and enables cross-referencing findings with pre-analysis data (blast radius, taint, etc.). Use when projecting SARIF results onto a code graph, overlaying weAudit annotations, cross-referencing Semgrep or CodeQL findings with call graph data, or visualizing audit findings in the context of code structure.

trailofbits/audit-context-building

Enables ultra-granular, line-by-line code analysis to build deep architectural context before vulnerability or bug finding.

trailofbits/audit-prep-assistant

Prepares codebases for security review using Trail of Bits' checklist. Helps set review goals, runs static analysis tools, increases test coverage, removes dead code, ensures accessibility, and generates documentation (flowcharts, user stories, inline comments).

trailofbits/burpsuite-project-parser

Searches and explores Burp Suite project files (.burp) from the command line. Use when searching response headers or bodies with regex patterns, extracting security audit findings, dumping proxy history or site map data, or analyzing HTTP traffic captured in a Burp project.

trailofbits/cairo-vulnerability-scanner

Scans Cairo/StarkNet smart contracts for 6 critical vulnerabilities including felt252 arithmetic overflow, L1-L2 messaging issues, address conversion problems, and signature replay. Use when auditing StarkNet projects.

trailofbits/cargo-fuzz

cargo-fuzz is the de facto fuzzing tool for Rust projects using Cargo. Use for fuzzing Rust code with libFuzzer backend.

trailofbits/chrome-mcp-troubleshooting

Diagnose and fix Claude in Chrome MCP extension connectivity issues. Use when mcp__claude-in-chrome__* tools fail, return "Browser extension is not connected", or behave erratically.

trailofbits/claude-in-chrome-troubleshooting

Diagnose and fix Claude in Chrome MCP extension connectivity issues. Use when mcp__claude-in-chrome__* tools fail, return "Browser extension is not connected", or behave erratically.

trailofbits/code-maturity-assessor

Systematic code maturity assessment using Trail of Bits' 9-category framework. Analyzes codebase for arithmetic safety, auditing practices, access controls, complexity, decentralization, documentation, MEV risks, low-level code, and testing. Produces professional scorecard with evidence-based ratings and actionable recommendations.

trailofbits/codeql

Scans a codebase for security vulnerabilities using CodeQL's interprocedural data flow and taint tracking analysis. Triggers on "run codeql", "codeql scan", "codeql analysis", "build codeql database", or "find vulnerabilities with codeql". Supports "run all" (security-and-quality + security-experimental suites) and "important only" (high-precision security findings) scan modes. Also handles creating data extension models and processing CodeQL SARIF output.

trailofbits/constant-time-analysis

Detects timing side-channel vulnerabilities in cryptographic code. Use when implementing or reviewing crypto code, encountering division on secrets, secret-dependent branches, or constant-time programming questions in C, C++, Go, Rust, Swift, Java, Kotlin, C#, PHP, JavaScript, TypeScript, Python, or Ruby.

trailofbits/constant-time-testing

Constant-time testing detects timing side channels in cryptographic code. Use when auditing crypto implementations for timing vulnerabilities.

trailofbits/cosmos-vulnerability-scanner

Scans Cosmos SDK blockchain modules and CosmWasm contracts for consensus-critical vulnerabilities — chain halts, fund loss, state divergence. 25 core + 16 IBC + 10 EVM + 3 CosmWasm patterns. Use when auditing custom x/ modules, reviewing IBC integrations, or assessing pre-launch chain security. Updated for SDK v0.53.x.

trailofbits/coverage-analysis

Coverage analysis measures code exercised during fuzzing. Use when assessing harness effectiveness or identifying fuzzing blockers.

相關技能