Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

macros-code-review宏代码审查

Agent Skill

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

总安装

259

周安装

11

GitHub Stars

54

下载量

91
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/existential-birds/beagle --skill macros-code-review

简介

macros-code-review 用于 Rust 宏代码审查,识别声明式与过程式宏的使用问题。

  • 检查 Cargo.toml 配置、宏类型及是否需要替代方案如泛型。
  • 验证 syn/quote 依赖和 feature flags 设置是否合理。
  • 适用于复杂代码生成场景,但应优先评估 generics 是否足够。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

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. Verify before reporting -- Load beagle-rust:review-verification-protocol before submitting 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

Before Submitting Findings

Load and follow beagle-rust:review-verification-protocol before reporting any issue.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

37.33%
按下载量换算34

Claude

30.83%
按下载量换算28

Cursor

19.65%
按下载量换算18

Gemini CLI

8.84%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

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

安装前确认

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

来源信息

继续浏览同类 Skills