rust-macro

Design, implement, and debug Rust declarative and procedural macros.

44|7|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/huiali/rust-skills --skill rust-macro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-macro
Source: https://github.com/huiali/rust-skills/tree/main/.codex/skills/rust-macro
Command: npx skills add https://github.com/huiali/rust-skills --skill rust-macro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill helps developers reduce boilerplate code and generate complex Rust code at compile time, improving efficiency and maintainability.

Core Features & Use Cases

  • Macro Design: Expert guidance on choosing between declarative (macro_rules!) and procedural macros (proc-macro).
  • Code Generation: Patterns for derive, function-like, and attribute macros.
  • Debugging: Strategies and tools like cargo expand for inspecting macro output.
  • Use Case: Automatically derive Debug or Clone implementations for custom structs, or create domain-specific languages (DSLs) within Rust.

Quick Start

Use the rust-macro skill to generate a derive macro for a simple struct.

Frequently Asked Questions about rust-macro

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce boilerplate code in Rust using compile-time code generation?

Rust macro programming reduces boilerplate by generating complex code at compile time, improving efficiency and maintainability through declarative and procedural metaprogramming techniques.

When should I choose declarative macro_rules! over procedural macros in Rust?

Choose declarative macro_rules! for simple pattern-based code generation, and procedural macros for complex derive implementations, attribute macros, and domain-specific language extensions requiring custom parsing logic.

What is the best way to debug Rust procedural macros to inspect generated code?

Use cargo expand to inspect macro output, applying strategies to debug procedural and declarative macros, ensuring correct hygiene, error handling, and performance in compile-time code generation.

How do I automatically derive Debug or Clone implementations for custom Rust structs?

Implement derive macros using procedural macros to automatically generate Debug, Clone, or other trait implementations for custom structs, reducing boilerplate and enabling compile-time code generation.

What are the limitations of Rust macros regarding hygiene and error handling?

Rust macros require careful attention to hygiene to avoid identifier conflicts and need robust error handling for invalid syntax, with procedural macros having higher implementation complexity than declarative alternatives.