moonbit-refactoring

Refactor MoonBit code into idiomatic APIs, methods, and pattern matching.

4|1|Updated Feb 15, 2026
One-click install
npx skills add https://github.com/Haoxincode/MoonBash --skill moonbit-refactoring-haoxincode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moonbit-refactoring
Source: https://github.com/Haoxincode/MoonBash/tree/main/.agents/skills/moonbit-refactoring
Command: npx skills add https://github.com/Haoxincode/MoonBash --skill moonbit-refactoring-haoxincode

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill streamlines the process of improving MoonBit code quality by making it more idiomatic, maintainable, and efficient, reducing technical debt and enhancing developer productivity.

Core Features & Use Cases

  • API Minimization: Shrinks public APIs to essential exports, improving modularity.
  • Code Transformation: Converts free functions to methods and encourages fluent chaining.
  • Pattern Matching: Promotes the use of expressive pattern matching over simple functions.
  • Idiomatic Constructs: Guides adoption of view types, loop invariants, and explicit qualification.
  • Use Case: Refactor a large MoonBit module to split it into smaller, more focused packages, making the codebase easier to understand and manage.

Quick Start

Use the moonbit-refactoring skill to convert the free function reader_next into a method on the Reader type.

Frequently Asked Questions about moonbit-refactoring

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

FAQPage Schema
How do I refactor MoonBit code to use pattern matching with views?

To refactor MoonBit code with pattern matching, this Skill transforms simple functions into expressive pattern matching constructs using view types. It guides adoption of idiomatic views while ensuring behavioral preservation throughout the refactoring process.

What is API minimization in MoonBit and how does it improve modularity?

API minimization in MoonBit shrinks public APIs to essential exports, significantly improving modularity. This Skill automates the refactoring of MoonBit packages to expose only necessary functions, reducing technical debt and enhancing maintainability.

How to convert free functions to methods in MoonBit?

Converting free functions to methods in MoonBit involves transforming standalone functions like `reader_next` into methods on their corresponding types. This Skill performs code transformation to enable fluent chaining and ensure idiomatic code structure.

Can I refactor a large MoonBit module into smaller focused packages?

Yes, you can refactor large MoonBit modules into smaller, focused packages using this Skill. It targets scenarios involving updates to MoonBit packages and modules, ensuring behavioral preservation while making the codebase easier to understand and manage.

Does refactoring MoonBit APIs preserve existing code behavior?

Refactoring MoonBit APIs with this Skill ensures behavioral preservation while enhancing code quality. It targets updates to MoonBit modules, APIs, and tests, applying idiomatic practices like loop invariant addition without altering functional outcomes.

When should I add loop invariants to MoonBit code?

You should add loop invariants to MoonBit code when adopting idiomatic constructs for enhanced code quality. This Skill guides the explicit qualification and addition of loop invariants during refactoring to improve maintainability and reduce technical debt.