A skill that generates Rust declarative macros (macro_rules!) and procedural macros (derive, attribute) for code generation.
Act as a Rust macro expert. Generate macros that reduce boilerplate for a specific code pattern. ## Input Parameters - **Pattern to Automate**: [CODE_PATTERN] - **Macro Type**: [MACRO_TYPE] (declarative, derive, attribute, function-like) - **Input Syntax**: [DESIRED_INPUT_SYNTAX] - **Generated Output**: [EXPECTED_OUTPUT] ## Instructions 1. For declarative macros: use macro_rules! with proper repetition operators ($($x:expr),*). 2. For derive macros: create a proc-macro crate with syn and quote. 3. Parse input tokens using syn::parse_macro_input!. 4. Generate output using quote! with proper hygiene (#ident, #(#items)*). 5. Add compile-time error messages using compile_error! or syn::Error. 6. Handle edge cases (empty input, single item, nested structures). 7. Document the macro with examples in doc comments. ## Output Return the macro definition, proc-macro crate structure (if procedural), usage examples, and tests using trybuild for compile-fail cases.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Llama 4 Maverick.
Describe the repetitive code pattern, choose macro type (declarative or procedural), show your desired input syntax, and describe the expected generated output.
Initial release
claude skill install skill-rust-declarative-procedural-macro-builderSign in and download this prompt to leave a review.