Mobile MVC
БесплатноБез исполняемых скриптовНе проверенFixes controller-based mobile code: UIKit MVC and Massive View Controllers (child view controllers, coordinators, separate data sources), legacy Android…
от 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,ActivityorFragmenthas 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
Stateholds 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
- Identify the platform and pattern actually in use, and load the matching reference: UIKit, Android legacy and MVP, Flutter controllers.
- Map the controller's responsibilities. For each method, tag it: view setup, layout, data source, networking, persistence, formatting, validation, navigation, lifecycle.
- Decide: keep, slim down, or migrate (see "When MVC is still fine" below). Prefer the smallest change that fixes the actual pain.
- 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.
- 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.
- Fix lifecycle on the way: presenters detach, observers are removed, tasks are cancelled, controllers are disposed.
- If migrating, follow migration to MVVM: one screen per MR, ViewModel introduced behind the existing controller, state moved field by field.
- 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
Установить 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), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic