Community程式設計與開發github.com

trailofbits/pr-improver

在目前分支上執行自動審查與修正循環,直到 PR 審查結果乾淨為止,並將範圍限定在分支所觸及的目錄。

pr-improver 是什麼?

`trailofbits/pr-improver` 技能會根據目前分支的變更,自動執行「審查-修正-再審查」的循環,直到審查報告中不再有嚴重或主要問題。它會解析分支的差異,將範圍限定在變更檔案所在的目錄,並使用一個動態工作流程(`workflows/improve.js`)來協調審查員與修正子代理。此技能支援互動式與非互動式執行環境,並提供多種結果狀態(收斂、達上限、升級、暫停),以便開發者清楚了解循環的結果。它特別適合在開啟或更新 Pull Request 之前,清理分支上的審查發現,但不適用於一次性審查——這類任務應直接執行 PR 審查技能。

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

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

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

說明文件

PR 改善器 (PR Improver)

透過執行 /code-improver:improve 來改善目前分支——這是一個動態工作流程,會反覆執行 PR 審查員與修正子代理,直到審查報告中不再有嚴重或主要問題。此循環、其紀錄帳本及安全防護機制均位於工作流程中;本技能則根據分支差異推導範圍,並傳遞最終結果。

啟動循環

使用者提供:$ARGUMENTS(若為空,則從對話中取得基底分支與偏好設定)。

1. 解析分支及其變更表面

  1. 儲存庫根目錄:git rev-parse --show-toplevel。若不在儲存庫內,則明確失敗。
  2. 基底分支:若引數已提供則使用之,否則使用儲存庫的預設分支(git symbolic-ref refs/remotes/origin/HEAD → 取其短名稱,若失敗則回退為 main)。若目前分支即為基底分支,則拒絕執行——因為沒有差異需要改善。
  3. 變更的檔案:git diff --name-only <base>...HEAD。若結果為空,則說明並停止。
  4. 範圍:變更檔案所在的目錄,並進行擴展——每個檔案的 glob 過於嚴格(PR 修正通常會在變更程式碼旁新增測試)。將每個變更檔案映射至其相對於儲存庫的目錄 glob <dir>/**(僅當根目錄有檔案變更時才使用 **),然後去除重複項,並移除已被其他 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": "skill",
    "name": "pr-review-toolkit:review-pr",
    "notes": "以 Pull Request 的形式審查工作目錄相對於 <base> 的變更:正確性、測試、錯誤處理,以及該技能所規定的審查面向。"
  },
  "scope": ["<衍生的目錄 glob>/**"],
  "pluginRoot": "<步驟 2 中的套件目錄>",
  "maxRounds": 5
}
  • reviewer——上述預設值需要 pr-review-toolkit 套件。當使用者指定不同的 PR 審查員(技能或代理)時,請使用該審查員,並相應設定 kind。
  • maxRounds 僅在使用者要求不同上限時才設定。
  • pluginRoot 讓執行作業能找到其指標收集器;僅當步驟 2 回退至工作流程名稱時才省略此鍵——此時工作流程會自行搜尋。
  • finalize 的預設值適用於 PR:除非分支位於套件內,否則不進行版本號提升;敘述移除與文件傳遞保持啟用。
  • decision 僅在繼續執行時使用(如下所述)。

循環的基準快照為循環開始時的工作目錄狀態——其範圍保護機制會保護分支的未提交工作;PR 自身的提交才是審查員審查的對象。

工作流程在背景執行,無需持續監控:它會審查、修正、重新審查,在每次修正回合後檢查範圍,並且只有在審查結果乾淨時才能完成。它永遠不會提交;所有變更都保留在工作目錄中。

如果 Workflow 工具不可用或遭拒絕,請停止並說明。 請不要透過直接編輯來內聯拼湊循環——帳本、範圍保護與升級保證都位於工作流程中,內聯模仿將完全缺少這些機制。

如果結果為 halted: "reviewer-unavailable",請傳達並停止。 此工作階段未安裝審查員;請告知使用者哪個套件提供它(預設需要 pr-review-toolkit),並在安裝後重新執行。請勿自行審查分支。

當循環正在執行時,請勿結束您的回合。 Workflow 工具會立即傳回任務 ID;結果會在稍後送達。在互動式工作階段中,完成通知會重新呼叫您——請等待它。在非互動式執行(腳本、CI、評估)中,沒有後續回合:停止會使循環在回合中途被放棄,因此在啟動後,請輪詢任務(使用傳回的任務 ID 呼叫 TaskOutput,或 sleep 後重新檢查)直到完成,然後傳達結果。一個回答「循環正在執行,我稍後回報」的工作階段,實際上已經失去了該次執行。

傳達結果

工作流程會傳回結構化的結果。請如實報告——其中的區別很重要:

  • converged: true——最後一個動作是審查,且未發現嚴重或主要問題。報告使用的回合數、剩餘次要問題數量(open_minor_count),以及工件路徑(ledger_path、metrics)。
  • capped: true——修正預算耗盡,且最終審查仍發現阻礙性問題。請明確說明:已達上限,未收斂,並列出 open_blocking。請勿將其視為成功。
  • escalation——循環偵測到未收斂(重複出現的發現、數量未減少,或修正導致問題搬移)。請將升級訊息與發現 ID 傳達給使用者:這需要設計決策,而非更多輪迴。
  • halted——某個防護機制被觸發(範圍違規、未註冊的新增檔案、審查員無回應或不可用,或是完成階段導致其後續檢查失敗)。請傳達 violations/new_untracked_files 中的路徑、finalize_regressions 中的位置,以及備註。
  • notes 總是伴隨結果——請展示它們;它們包含重要的警告,例如「已建立一個 git 儲存庫」。

在升級後繼續執行

依設計,循環在升級發生時會停止。當使用者做出決定後,使用相同的參數啟動一次新的執行,並額外加上:

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

新的執行會重新載入磁碟上的帳本,因此所有發現、拒絕與裁決都會繼承——回合重新開始,但推導不會重複。

若要停止正在執行的循環,請停止工作流程任務(TaskStop);磁碟上的帳本會保留到最後一個回合,重新執行時會從該處繼續。

何時不應使用

  • 一次性審查:直接執行 PR 審查技能;循環的價值在於迭代
  • 技能:請使用 skill-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-improver

Runs an autonomous review-and-fix improvement loop over any code target — a skill, plugin, module, or directory — using a reviewer the user names: any installed skill or agent. Keeps a cross-round findings ledger, escalates when fixes stop converging, and guards scope mechanically. Use when asked to 'improve this code until review passes', 'run an improvement loop with <reviewer>', or to iterate review-and-fix with a specific reviewer. For skills prefer the skill-improver entry; for a branch prefer pr-improver.

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.

相關技能