cangjie-extension

Extend Cangjie types with new functions, interfaces, and generic constraints.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the need to enhance and customize the Cangjie programming language by adding new functionalities and implementing interfaces, allowing for more expressive and tailored code.

Core Features & Use Cases

  • Direct Extension: Add new member functions, operator overloads, and properties to existing types.
  • Interface Implementation: Enable types to fulfill contracts defined by interfaces, even if the original type didn't declare it.
  • Generic Extensions: Apply extensions to generic types with flexible constraints.
  • Access Control & Rules: Understand and apply Cangjie's specific rules for visibility, access, and the orphan rule.
  • Use Case: You can extend a built-in String type to add a reverse() method or make a custom User struct conform to a Displayable interface.

Quick Start

Use the cangjie-extension skill to add a printSize function to the String type.

Frequently Asked Questions about cangjie-extension

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

FAQPage Schema
How do I extend an existing type in Cangjie with new functions?

To extend an existing type in Cangjie, use direct extensions to add new member functions, operator overloads, and properties to types like built-in String. This allows you to attach custom behaviors such as a reverse method without modifying the original type definition.

Can I implement an interface for a type I did not define in Cangjie?

Yes, you can implement interfaces for existing types in Cangjie using interface extensions. This enables types to fulfill contracts defined by interfaces, even if the original type did not explicitly declare it, allowing custom structs to conform to protocols like Displayable.

Does Cangjie support generic type extensions with constraints?

Cangjie supports applying extensions to generic types with flexible constraints. This allows you to define new functionalities that apply across generic types while respecting specific type boundaries, ensuring type-safe code modularity and extensibility.

What is the orphan rule in Cangjie extensions?

The orphan rule in Cangjie governs access control and visibility for extensions. It defines specific rules for how extensions interact with existing types, ensuring that extension implementations respect boundaries for access, export, and import mechanisms within the ecosystem.

When do I need to use extensions in the Cangjie programming language?

You need to use extensions in the Cangjie programming language when you want to enhance or customize existing types with new functionalities. This is particularly useful for adding tailored methods or interface implementations without altering the original source code.

Are there limitations on extending Cangjie built-in types with new properties?

When extending Cangjie built-in types, you must adhere to specific access rules and the orphan rule. These constraints ensure that adding new properties or member functions respects the language's visibility, export, and import mechanisms for safe code modularity.