Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Mobile MVC

БесплатноБез исполняемых скриптовНе проверен

Fixes controller-based mobile code: UIKit MVC and Massive View Controllers (child view controllers, coordinators, separate data sources), legacy Android…

ahmadhussain0335от ahmadhussain0335250 установок в других каталогах

Об этом скилле

Mobile MVC and MVP

Keep controller-based screens small, testable and leak-free, and move them to MVVM safely when that pays off. Covers UIKit MVC, legacy Android Activity-as-controller and MVP, and Flutter controllers.

When to use

  • A UIViewController, Activity or Fragment has grown past a few hundred lines and mixes networking, formatting, navigation and view code.
  • Adding a feature to a legacy MVC or MVP screen without rewriting it.
  • Reviewing presenter code for leaks, or a Flutter widget whose State holds all the logic.
  • Deciding whether a screen should stay MVC or move to MVVM.
  • Planning or executing a screen-by-screen migration to ViewModels.

Not for: designing new screens in MVVM or MVI from scratch (use mobile-mvvm, mobile-mvi).

Workflow

  1. Identify the platform and pattern actually in use, and load the matching reference: UIKit, Android legacy and MVP, Flutter controllers.
  2. Map the controller's responsibilities. For each method, tag it: view setup, layout, data source, networking, persistence, formatting, validation, navigation, lifecycle.
  3. Decide: keep, slim down, or migrate (see "When MVC is still fine" below). Prefer the smallest change that fixes the actual pain.
  4. Before moving code, add characterization tests around behaviour that will move (formatting, validation, state transitions). If logic is untestable in place, extract it as a pure function first.
  5. Extract one responsibility at a time, in this order: formatting, networking and persistence behind a service, data source objects, navigation into a coordinator or navigator, child controllers for independent regions.
  6. Fix lifecycle on the way: presenters detach, observers are removed, tasks are cancelled, controllers are disposed.
  7. If migrating, follow migration to MVVM: one screen per MR, ViewModel introduced behind the existing controller, state moved field by field.
  8. Build, run the tests, and exercise the screen on device, including rotation (Android) and background and foreground.

When MVC is still fine

  • Static or nearly static screens: settings lists, about pages, legal text, simple forms.
  • Thin wrappers around system controllers (pickers, mail compose, share sheets, web views).
  • Screens with no business rules and no state that must survive configuration change.
  • Code scheduled for deletion. Do not migrate what is about to be removed.
  • A team or codebase where MVC is consistent and screens stay small. Consistency beats a half-migrated mix.

Migrate when: logic needs unit tests, state is lost on rotation or process death, the same logic is duplicated across screens, or the controller cannot be changed without regressions.

Rules

1. The controller owns views, not networking or persistence

Swift:

// BAD: view controller builds requests and decodes JSON
override func viewDidLoad() {
    super.viewDidLoad()
    URLSession.shared.dataTask(with: URL(string: "https://api.example.com/devices")!) { data, _, _ in
        let devices = try! JSONDecoder().decode([Device].self, from: data!)
        DispatchQueue.main.async { self.devices = devices; self.tableView.reloadData() }
    }.resume()
}

// GOOD: injected service, the controller only renders
final class DevicesViewController: UIViewController {
    private let service: DeviceService
    init(service: DeviceService) {
        self.service = service
        super.init(nibName: nil, bundle: nil)
    }
    required init?(coder: NSCoder) { fatalError("init(coder:) is not supported") }
}

Java:

// BAD: Activity opens sockets and parses responses
new Thread(() -> {
    String json = httpGet("https://api.example.com/devices");
    runOnUiThread(() -> adapter.submit(parse(json)));
}).start();

// GOOD: presenter asks a repository; the Activity only renders
presenter.loadDevices();

2. Navigation is decided outside the screen

Swift:

// BAD: the screen knows the next screen and how to build it
let detail = DeviceDetailViewController(service: DeviceServiceImpl(), device: device)
navigationController?.pushViewController(detail, animated: true)

// GOOD: the screen reports intent; a coordinator decides
var onSelectDevice: ((Device.ID) -> Void)?
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    guard let id = dataSource.itemIdentifier(for: indexPath) else { return }
    onSelectDevice?(id)
}

Kotlin:

// BAD: presenter starts Activities
class DevicesPresenter(private val activity: Activity) {
    fun onDeviceClicked(id: String) = activity.startActivity(Intent(activity, DetailActivity::class.java))
}

// GOOD: presenter calls a view method; the Activity or a navigator performs it
interface DevicesView { fun openDetail(deviceId: String) }

3. Data sources and delegates are separate objects

Swift:

// BAD
Полный SKILL.md на ClawHub

Установить Mobile MVC в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Mobile MVC?

Fixes controller-based mobile code: UIKit MVC and Massive View Controllers (child view controllers, coordinators, separate data sources), legacy Android Activity-as-controller and MVP, and Flutter controllers, plus step-by-step migration to MVVM one screen at a time. Use when working on UIViewController, Activity, Fragment or presenter code, splitting a god class, or deciding whether MVC is still fine.

Как установить скилл Mobile MVC?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Mobile MVC запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Mobile MVC с