macro-expander
Skill17 starsChanged 9 months agoApache-2.0View on GitHub
Implement macro systems for syntactic abstraction and code generation at compile time.
In this repository98 other files it gives its agents.
- abstract-interpretation-engineSkill
- abstract-machineSkill
- acsl-annotation-assistantSkill
- actor-model-implementerSkill
- algebraic-effectsSkill
- alias-and-points-to-analysisSkill
- axiomatic-semanticsSkill
- bidirectional-type-checkingSkill
- bisimulation-checkerSkill
- capability-systemSkill
- closure-converterSkill
- common-subexpression-eliminatorSkill
- concurrency-verifierSkill
- constant-propagation-passSkill
- contextual-equivalenceSkill
- control-flow-analysisSkill
- coq-proof-assistantSkill
- cps-transformerSkill
- dafny-verifierSkill
- dataflow-analysis-frameworkSkill
- dead-code-eliminatorSkill
- defunctionalizationSkill
- denotational-semantics-builderSkill
- dependent-type-implementerSkill
- dsl-embeddingSkill
- effect-handlers-implementerSkill
- effect-systemSkill
- effect-type-systemSkill
- escape-analysisSkill
- existential-typesSkill
- ffi-designerSkill
- fuzzer-generatorSkill
- gadt-implementerSkill
- garbage-collector-implementerSkill
- graalvm-truffle-implementerSkill
- gradual-typing-implementerSkill
- higher-order-abstract-syntaxSkill
- hoare-logic-verifierSkill
- incremental-computationSkill
- information-flow-analyzerSkill
- inline-expanderSkill
- interprocedural-analysisSkill
- invariant-generatorSkill
- jit-compiler-builderSkill
- lambda-calculus-interpreterSkill
- language-server-protocolSkill
- lean-proverSkill
- lexer-generatorSkill
- linear-type-implementerSkill
- liveness-analysisSkill
- llvm-backend-generatorSkill
- lock-free-data-structureSkill
- loop-optimizerSkill
- loop-termination-proverSkill
- memory-allocatorSkill
- message-passing-systemSkill
- mlir-dialect-designerSkill
- model-checkerSkill
- module-systemSkill
- monad-transformerSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 43
Use hygiene to prevent capture
- Distinctive: line 44
Prefer pattern-based macros for clarity
- Distinctive: line 46
Test macro expansion thoroughly
- Distinctive: line 85
When debugging is important
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Macro Expander
Macro systems enable syntactic abstraction by transforming code at compile time. They allow programmers to extend the language with new syntactic constructs.
When to Use This Skill
- Building DSLs (Domain-Specific Languages)
- Reducing boilerplate code
- Implementing language extensions
- Code generation
- Compile-time computation
What This Skill Does
- Macro Definition: Define syntax transformers
- Macro Expansion: Transform macro calls into base syntax
- Hygiene: Prevent unintended variable capture
- Pattern Matching: Match macro input patterns
- Recursive Expansion: Handle nested macros
Key Concepts
| Concept | Description |
| Macro | Syntax transformer |
| Hygiene | Prevents unintended variable capture |
| Pattern Variable | Placeholder in macro pattern |
| Expansion | Transform macro call to base syntax |
| Template | Output pattern for macro |
Tips
- Use hygiene to prevent capture
- Prefer pattern-based macros for clarity
- Document macro contracts
- Test macro expansion thoroughly
- Consider compile-time errors
Common Use Cases
- DSL implementation
- Boilerplate reduction
- Language extensions
- Conditional compilation
- Code generation
Related Skills
parser-generator- Macros need ASTdsl-embedding- DSLs via macrosmulti-stage-programming- Staged computation
Canonical References
| Reference | Why It Matters |
| Kohlbecker et al. "Hygienic macro expansion" | Original hygiene paper |
| Dybvig et al. "Syntactic abstraction in Scheme" | Scheme macros |
| Rust macro documentation | Modern procedural macros |
Tradeoffs and Limitations
Approach Tradeoffs
| Approach | Pros | Cons |
| Textual macros | Simple | Unhygienic |
| Hygienic macros | Safe | Complex |
| Procedural macros | Powerful | Hard to debug |
When NOT to Use This Skill
- When functions suffice
- For simple syntactic sugar
- When debugging is important
Limitations
- Hygiene is hard to get right
- Error messages can be cryptic
- Macro expansion can be slow
Assessment Criteria
A high-quality implementation should have:
| Criterion | What to Look For |
| Hygiene | Prevents capture |
| Composability | Macros expand macros |
| Error handling | Clear error messages |
| Efficiency | Reasonable expansion time |
Quality Indicators
✅ Good: Hygienic, pattern-based, good errors ⚠️ Warning: Sometimes captures variables ❌ Bad: Unhygienic, cryptic errors
Research Tools & Artifacts
Real-world macro systems:
| Tool | Why It Matters |
| Racket macros | Advanced macro system |
| Rust proc-macros | Rust macro system |
| C preprocessor | Original textual macros |
| Clang/LLVM | Macro system for C |
Key Systems
- Racket: Scheme macros
- Julia macros: Lisp-style macros
Research Frontiers
Current macro research:
| Direction | Key Papers | Challenge |
| ** hygiene** | "Hygienic Macros" | Sound hygiene |
| Generative | "Generative Macros" | Type generation |
| Typed | "Typed Macros" | Type-safe macros |
Hot Topics
- Macro ML: ML with macros
- Wasm macros: WebAssembly macros
Implementation Pitfalls
Common macro bugs:
| Pitfall | Real Example | Prevention |
| Capture | Variable capture | Hygiene |
| Order | Macro order | Phase separation |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

