Token导航 LogoToken导航TokenDH.com
研究检索只读clawhub未标认证来源可访问clear审计提醒

macros-code-review宏代码审查

Agent Skill

macros-code-review 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

2,880

周安装

120

GitHub Stars

公开资料未说明

下载量

960
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:macros-code-review(宏代码审查)
来源仓库:https://github.com/anderskev/macros-code-review
安装命令:
openclaw skills install macros-code-review
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install macros-code-review

简介

审查 Rust 宏代码的卫生性与编译性能影响。

  • 检测片段滥用、作用域污染及潜在运行时错误。macros-code-review 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 帮助开发者优化 macro_rules! 定义的质量与安全性。
  • 适用于大型项目中宏模块的重构与长期维护支持。
  • 需配合具体代码上下文使用,无法替代人工深度逻辑审查。

SKILL.md

name
macros-code-review
description
Reviews Rust macro code for hygiene issues, fragment misuse, compile-time impact, and procedural macro patterns. Use when reviewing macro_rules! definitions, procedural macros, derive macros, or attribute macros.

Macros Code Review

Review Workflow

  1. Check Cargo.toml -- Note Rust edition (2024 reserves gen keyword, affecting macro output), proc-macro crate dependencies (syn, quote, proc-macro2), and feature flags (e.g., syn with minimal features)
  2. Check macro type -- Determine if reviewing declarative (macro_rules!), function-like proc macro, attribute macro, or derive macro
  3. Check if a macro is needed -- If the transformation is type-based, generics are better. Macros are for structural/repetitive code generation that generics cannot express
  4. Scan macro definitions -- Read full macro bodies including all match arms, not just the invocation site
  5. Check each category -- Work through the checklist below, loading references as needed
  6. Gates -- Complete Gates below before reporting; do not substitute informal “I verified.”

Gates (before reporting findings)

Complete in order. Do not emit findings until Gate 4 passes for each issue.

Gate 1 — Crate context (on disk) PASS when: You opened the reviewed crate’s Cargo.toml (workspace member path if applicable) and recorded Rust edition, whether the crate is proc-macro = true, and relevant proc-macro dependencies or syn / quote feature flags. Blocks rationalization: Edition 2024 findings (gen, unsafe extern, generated unsafe bodies) and syn “full” vs minimal flags require this — do not flag edition-specific macro output without matching edition from the file.

Gate 2 — Macro definitions read PASS when: For every macro you critique, you read the full definition (all macro_rules! arms, or the proc-macro entry plus helpers you rely on), not only call sites or partial expansions. Artifact: At least one path per macro to the defining .rs file(s) you used.

Gate 3 — Per-finding evidence PASS when: Each planned issue has [FILE:LINE] from the current tree for the macro definition, attribute/derive site, or generated code location you are discussing (not from memory, docs-only, or another branch).

Gate 4 — Pre-report protocol PASS when: You loaded and applied beagle-rust:review-verification-protocol, including Macro-Specific Verification for hygiene, fragment type, and proc-macro performance claims. Then add findings.

Output Format

Report findings as:

[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.

Quick Reference

Issue TypeReference
Fragment types, repetition, hygiene, declarative patternsreferences/declarative-macros.md
Proc macro types, syn/quote, spans, testingreferences/procedural-macros.md

Review Checklist

Declarative Macros (macro_rules!)

  • [ ] Correct fragment types used (:expr vs :tt vs :ident -- wrong choice causes unexpected parsing)
  • [ ] Repetition separators match intended syntax (, vs ; vs none, * vs +)
  • [ ] Trailing comma/semicolon handled (add $(,)? or $(;)? at end of repetition)
  • [ ] Matchers ordered from most specific to least specific (first match wins)
  • [ ] No ambiguous expansions -- each metavariable appears in the correct repetition depth in the transcriber
  • [ ] Variables defined in the macro use macro-internal names (hygiene protects variables, not types/modules/functions)
  • [ ] Exported macros (#[macro_export]) use $crate:: for crate-internal paths, never crate:: or self::
  • [ ] Standard library paths use ::core:: and ::alloc:: (not ::std::) for no_std compatibility
  • [ ] compile_error! used for meaningful error messages on invalid input patterns
  • [ ] Macro placement respects textual scoping (defined before use) unless #[macro_export]

Procedural Macros

  • [ ] syn features minimized (don't enable full when derive suffices -- reduces compile time)
  • [ ] Spans propagated from input tokens to output tokens (errors point to user code, not macro internals)
  • [ ] Span::call_site() used for identifiers that should be visible to the caller
  • [ ] Span::mixed_site() used for identifiers private to the macro (matches macro_rules! hygiene)
  • [ ] Error reporting uses syn::Error with proper spans, not panic!
  • [ ] Multiple errors collected and reported together via syn::Error::combine
  • [ ] proc-macro2 used for testing (testable outside of compiler context)
  • [ ] Generated code volume is proportionate -- proc macros that emit large amounts of code bloat compile times

Derive Macros

  • [ ] Derivation is obvious -- a developer could guess what it does from the trait name alone
  • [ ] Helper attributes (#[serde(skip)] style) are documented
  • [ ] Trait implementation is correct for all variant shapes (unit, tuple, struct variants)
  • [ ] Generated impl blocks use fully qualified paths (::core::, $crate::)

Attribute Macros

  • [ ] Input item is preserved or intentionally transformed (not accidentally dropped)
  • [ ] Attribute arguments are validated with clear error messages
  • [ ] Test generation patterns (#[test_case] style) produce unique test names
  • [ ] Framework annotations document what code they generate

Edition 2024 Awareness

  • [ ] Macro output does not use gen as an identifier (reserved keyword -- use r#gen or rename)
  • [ ] Generated unsafe fn bodies use explicit unsafe {} blocks around unsafe ops
  • [ ] Generated extern blocks use unsafe extern

Generics vs Macros

Flag a macro when the same result is achievable with generics or trait bounds. Macros are appropriate when:

  • The generated code varies structurally (not just by type)
  • Repetitive trait impls for many concrete types
  • Test batteries with configuration variants
  • Compile-time computation that const fn cannot express

Severity Calibration

Critical (Block Merge)

  • Macro generates unsound unsafe code
  • Hygiene violation in macro that outputs unsafe blocks (caller's variables leak into unsafe context)
  • Proc macro panics instead of returning compile_error! (crashes the compiler)
  • Derive macro generates incorrect trait implementation (violates trait contract)

Major (Should Fix)

  • Exported macro uses crate:: or self:: instead of $crate:: (breaks for downstream users)
  • Exported macro uses ::std:: instead of ::core::/::alloc:: (breaks no_std users)
  • Wrong fragment type causing unexpected parsing (:expr where :tt needed, or vice versa)
  • Proc macro enables syn full features unnecessarily (compile time cost)
  • Missing span propagation (errors point to macro definition, not invocation)
  • No error handling in proc macro (panics on bad input instead of compile_error!)

Minor (Consider Fixing)

  • Missing trailing comma/semicolon tolerance in repetition patterns
  • Matcher arms not ordered most-specific-first
  • Macro used where generics would be clearer and equally expressive
  • Missing compile_error! fallback arm for invalid patterns
  • Helper attributes undocumented

Informational (Note Only)

  • Suggestions to split complex macro_rules! into a proc macro
  • Suggestions to reduce generated code volume
  • TT munching or push-down accumulation patterns that could be simplified

Valid Patterns (Do NOT Flag)

  • macro_rules! for test batteries -- Generating repetitive test modules from a list of types/configs
  • macro_rules! for trait impls -- Implementing a trait for many concrete types with identical bodies
  • TT munching -- Valid advanced pattern for recursive token processing
  • Push-down accumulation -- Valid pattern for building output incrementally across recursive calls
  • #[macro_export] with $crate -- Correct way to make macros usable outside the defining crate
  • Span::call_site() for generated functions -- Intentionally making generated items visible to callers
  • syn::Error::to_compile_error() -- Correct error reporting pattern in proc macros
  • trybuild tests for proc macros -- Standard compile-fail testing approach
  • Attribute macros on test functions -- Common pattern for test setup/teardown
  • compile_error! in impossible match arms -- Good practice for catching invalid macro input

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

79.14%
按下载量换算760

安全审计

VirusTotal

通过

ClawScan

可疑

Static analysis

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills