cangjie-macro

Explain Cangjie macros, including AST manipulation via std.ast.

1|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-macro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-macro
Source: https://github.com/SunriseSummer/CangjieDocValidator/tree/main/.github/skills/macro
Command: npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-macro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides comprehensive guidance on understanding and utilizing Cangjie language macros, enabling advanced compile-time code generation and metaprogramming.

Core Features & Use Cases

  • Macro Fundamentals: Learn about Tokens, Tokens types, quote expressions, and interpolation.
  • Macro Implementation: Understand non-attribute, attribute, and nested macros, including context communication.
  • AST Manipulation: Explore the std.ast package for parsing, traversing, and modifying Abstract Syntax Trees.
  • Use Case: Generate boilerplate code, create domain-specific languages (DSLs), or implement compile-time optimizations using Cangjie's powerful macro system.

Quick Start

Use the cangjie-macro skill to learn about Cangjie language macros.

Frequently Asked Questions about cangjie-macro

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

FAQPage Schema
How do I generate boilerplate code at compile time in Cangjie?

Cangjie compile-time code generation uses macros to automatically generate boilerplate. The macro system leverages quote expressions, interpolation, and AST manipulation via the std.ast package to emit code during the build process.

What is the difference between attribute and non-attribute macros in Cangjie?

Cangjie macros include both attribute and non-attribute forms. Non-attribute macros function as standalone code generators, while attribute macros process annotated declarations, allowing for targeted AST transformation and compile-time metaprogramming.

How do I manipulate abstract syntax trees using the Cangjie std.ast package?

Cangjie AST manipulation uses the std.ast package to parse, traverse, and modify abstract syntax trees within macros. Developers access Tokens and quote expressions to programmatically inspect and alter code structures during compilation.

Can I implement nested macros and share context in Cangjie?

Cangjie supports nested macros, enabling complex compile-time code generation. Nested macros can utilize context communication mechanisms to pass data and Tokens between macro levels, facilitating layered metaprogramming.

How do I compile and build a macro package in Cangjie?

Cangjie macro packages are compiled using specific build processes that integrate with the language's compilation pipeline. This involves configuring the macro package correctly so the compiler processes and expands macros at compile time.

When should I use Cangjie macros for metaprogramming instead of regular functions?

Cangjie macros are suited for compile-time metaprogramming when you need to generate boilerplate, build domain-specific languages, or perform AST manipulation. Regular functions execute at runtime, whereas macros operate entirely during compilation.