Community写作与编辑github.com

trailofbits/code-improver

对任意代码目标(技能、插件、模块或目录)运行自主审查与修复的改进循环,使用用户指定的已安装技能或代理作为审查者。维护跨轮次的问题记录,在修复停止收敛时升级处理,并通过机械方式保护作用域。当用户要求“改进代码直至审查通过”、“使用<审查者>运行改进循环”,或需要与特定审查者迭代审查修复时使用。对于技能,推荐使用 skill-improver 入口;对于分支,推荐使用 pr-improver。

code-improver 是什么?

Code Improver 是一个 AI 代理技能,旨在自动化代码改进循环,通过反复审查与修复来提升代码质量。它适用于 Claude Code、Cursor、Codex 等平台,允许用户指定任何已安装的技能或代理作为审查者。该技能通过收集三个关键输入(目标路径、审查者名称和作用域)启动一个动态工作流,该工作流会循环进行审查和修复,直到审查报告显示没有严重或重大问题,然后自动清理自身痕迹。它维护一个跨轮次的发现记录,当修复不再收敛时进行升级,并通过机械方式防止作用域外修改。Code Improver 支持多种结果状态(收敛、封顶、升级、暂停),并能够从升级点继续运行。对于 Claude Code 技能和分支/PR,分别有 skill-improver 和 pr-improver 专用入口。

兼容平台✓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. 目标:要改进的目录的绝对路径。根据工作目录解析相对路径;验证目录存在。
  2. 审查者:执行每次审查的已安装技能或代理。用户必须命名它 —— 没有默认值,也没有捆绑的审查者。确定其类型:
    • 带命名空间的代理(例如 plugin-dev:skill-reviewer)→ "kind": "agent"
    • 已安装的技能(例如 pr-review-toolkit:review-pr)→ "kind": "skill" 如果名称可能属于两者,请检查会话的技能列表;如果仍然有歧义,询问用户。如果没有命名审查者,请询问 —— 不要自行选择。
  3. 作用域:循环可能触碰的仓库相对通配符。通用入口明确要求它;如果用户没有提供,建议目标目录(<仓库相对目标>/**)并在启动前确认。

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": ["<仓库相对通配符>/**"],
  "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,或休眠并重新检查)直到完成,然后传递结果。回答“循环正在运行,稍后报告”的会话会丢失该运行。

传递结果

工作流返回结构化结果。如实报告 —— 区别很重要:

  • converged: true —— 最后操作是审查,没有严重/重大问题。报告使用的轮次、剩余次要问题(open_minor_count)和产物路径(ledger_path、metrics)。
  • capped: true —— 修复预算耗尽,最终审查仍然发现阻塞性问题。明确说明:已封顶,未收敛,并列出 open_blocking。不要将其呈现为成功。
  • escalation —— 循环检测到没有收敛(重复发现、计数不减少、或修复转移了问题)。向用户传递升级消息和发现 ID:这需要设计决策,而非更多轮次。
  • halted —— 守护机制触发(作用域违规、未注册的新文件、审查者死亡或不可用、或最终检查失败)。传递 violations/new_untracked_files 中的路径、finalize_regressions 中的站点以及说明。
  • notes 始终与结果一起传递 —— 显示它们;它们包含重大警告,例如“已初始化 git 仓库”。

升级后继续

循环在升级时按设计停止。当用户做出决定后,使用相同的 target 和 reviewer 启动新的运行,并加上:

{ "decision": "<用户的裁决,原样>" }

新运行重新加载磁盘上的记录,因此每个发现、拒绝和裁决都会延续 —— 轮次重新开始,但不会重复推导。

要停止正在运行的循环,请停止工作流任务(TaskStop);磁盘上的记录更新至最后一轮,重新运行会从中恢复。

何时不使用

  • Claude Code 技能:使用 skill-improver 入口 —— 它会连接正确的审查者
  • 分支/拉取请求:使用 pr-improver 入口 —— 它会从 diff 推导作用域
  • 一次性审查:直接调用审查者;循环的价值在于迭代
  • 快速单次修复:直接编辑文件

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.

相关技能