mbtorch-refactor

Refactor MbTorch source code with test-first atomic steps and layering rules.

1|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/c-tomioka/mbtorch --skill mbtorch-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mbtorch-refactor
Source: https://github.com/c-tomioka/mbtorch/tree/main/.claude/skills/mbtorch-refactor
Command: npx skills add https://github.com/c-tomioka/mbtorch --skill mbtorch-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a disciplined, test-first approach to refactoring the MbTorch codebase so that internal structure, readability, and layering are improved without changing external behavior or breaking tests. It turns vague impulses to "clean up code" into concrete, auditable steps that respect project layering and TDD requirements.

Core Features & Use Cases

  • Refactoring coach: Guides the developer through safety rules, explicit problem statements, and small, test-verified change units.
  • Layering & dependency enforcement: Highlights and prevents layer-violation refactors (core, nn, optim, io) and suggests correct extraction locations.
  • TDD integration: Requires adding or strengthening tests before structural changes and prescribes atomic steps that keep tests green at every checkpoint.
  • Typical refactorings: File/function splitting for large tensor modules, consolidating scattered I/O into io/, and moving pure numeric ops from nn to core.
  • Use case: When core/tensor.mbt exceeds maintainable size or duplicated logic appears across modules, the skill produces a test-first plan to split, move, and re-export pieces safely.

Quick Start

Ask the assistant to analyze the target files, list concrete problems in the prescribed "問題/影響/対象/提案" format, and propose the first atomic refactoring step with required tests.

Frequently Asked Questions about mbtorch-refactor

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

FAQPage Schema
How do I safely refactor large MbTorch tensor modules without breaking existing tests?

Safely refactoring MbTorch source code requires a test-first workflow that adds or strengthens tests before structural changes, using atomic steps to keep tests green at every checkpoint.

What is the best way to prevent layer violations when moving pure numeric ops from nn to core?

Preventing layer violations when moving numeric ops requires enforcing layering dependency rules across core, nn, optim, and io modules, pausing to present dependency-violation proposals until user confirmation.

When do I need to split files in a MoonBit on-device ML framework?

You need to split files in a MoonBit ML framework when source files grow large, dependencies risk layer violations, or duplicated logic appears across modules like tensor and io.

Can I consolidate scattered I/O operations into a single module using TDD?

Yes, you can consolidate scattered I/O operations into the io module using TDD by prescribing atomic steps that keep tests green and verifying external behavior remains unchanged.

Does this refactoring approach work with existing test suites for MoonBit code?

Yes, this refactoring approach works with existing MoonBit test suites by requiring tests to pass at every checkpoint and integrating TDD workflows before any structural changes are applied.

Why does the refactoring process pause before applying dependency changes?

The refactoring process pauses before applying dependency changes to present dependency-violation proposals explicitly, ensuring the user confirms layering adjustments before any code modifications proceed.