moonbit-refactoring

Refactor MoonBit code to idiomatic patterns while preserving behavior and public contracts.

74|11|Updated Sep 15, 2025
One-click install
npx skills add https://github.com/moonbitlang/moonbit-agent-guide --skill moonbit-refactoring-moonbitlang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moonbit-refactoring
Source: https://github.com/moonbitlang/moonbit-agent-guide/tree/main/moonbit-refactoring
Command: npx skills add https://github.com/moonbitlang/moonbit-agent-guide --skill moonbit-refactoring-moonbitlang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams refactor MoonBit code to idiomatic patterns while preserving behavior and public contracts.

Core Features & Use Cases

  • API minimization: Reduce public surface area to only what callers need, improving maintainability.
  • Incremental refactors: Move behavior onto owning types, convert free functions to methods, and split large files/packages.
  • Documentation and tests: Update docs and tests in the same patch to prevent regressions.

Quick Start

Apply the MoonBit Refactoring Skill to a small module: convert a free function to a method, minimize the public API, add or adjust tests and docs, then run moon check and moon test to verify.

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 idiomatic patterns without breaking public contracts?

To refactor MoonBit code safely, apply incremental changes while preserving behavior and public API contracts. You should review package structure, move behavior onto owning types, and keep tests green throughout the process.

What is the best way to minimize the public API surface in MoonBit packages?

API minimization in MoonBit involves reducing the public surface area to only what callers need. This improves maintainability by applying small, safe changes within package boundaries and verifying with moon check and moon test.

How do I convert free functions to methods during a MoonBit module reorganization?

Converting free functions to methods in MoonBit requires moving behavior onto owning types incrementally. You must keep changes within package boundaries, update tests and docs in the same patch, and run moon check and moon test to verify.

Does MoonBit refactoring require running tests and updating documentation in the same patch?

MoonBit refactoring requires updating docs and tests in the same patch to prevent regressions. You must run moon check and moon test after each change to ensure the refactored package maintains green tests and correct behavior.

When do I need to split large MoonBit files and packages, and what are the limitations?

You should split large MoonBit files and packages when maintaining complex modules, but changes must stay within package boundaries. Limitations include ensuring tests remain green and public contracts are preserved during the incremental split.

Can I use this MoonBit refactoring workflow for incremental package maintenance?

Yes, this MoonBit refactoring workflow applies to package maintenance by guiding small, safe changes. It requires reviewing package structure and using moon check and moon test after each change to verify behavior preservation.