一键导入
creating-viewmodel
Scaffolds a ViewModel with @MainActor, ObservableObject, async/await, and Swinject DI. Use when creating a new ViewModel.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffolds a ViewModel with @MainActor, ObservableObject, async/await, and Swinject DI. Use when creating a new ViewModel.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | creating-viewmodel |
| description | Scaffolds a ViewModel with @MainActor, ObservableObject, async/await, and Swinject DI. Use when creating a new ViewModel. |
Scaffolds a ViewModel following project patterns from docs/PATTERNS.md.
{Feature}ViewModel.swift → placed in {App}/Presentation/{Feature}/
//
// {Feature}ViewModel.swift
// {App}
//
// Created by Man Tran on DD/MM/YY.
//
import Foundation
@MainActor
final class {Feature}ViewModel: ObservableObject {
@Published var state: {Feature}State = .loading
@Published var isLoading = false
@Published var errorMessage: String?
private let dependencies: {Feature}Dependencies
init(dependencies: {Feature}Dependencies) {
self.dependencies = dependencies
}
func onAppear() async {
await loadData()
}
func loadData() async {
isLoading = true
errorMessage = nil
do {
let result = try await dependencies.someUseCase.execute()
state = .loaded(result)
} catch {
state = .error
errorMessage = error.localizedDescription
}
isLoading = false
}
}
Every ViewModel must have a corresponding {Feature}Dependencies.swift:
//
// {Feature}Dependencies.swift
// {App}
//
// Created by Man Tran on DD/MM/YY.
//
struct {Feature}Dependencies {
let someUseCase: SomeUseCaseProtocol
let anotherUseCase: AnotherUseCaseProtocol
}
Dependencies struct, not individual parameters (when > 2 dependencies).@Published for all observable state.enum {Feature}State {
case loading
case loaded(DomainModel)
case empty
case error
}
async.@Published properties.func performAction() async {
do {
let result = try await dependencies.useCase.execute()
state = .loaded(result)
} catch {
errorMessage = error.localizedDescription
}
}
Separate concerns into extensions for tracking, performance:
{Feature}ViewModel+Tracking.swift for analytics{Feature}ViewModel+SaleFunnelPerfTrace.swift for performance@MainActor final class + ObservableObject@Published for all observable stateSee docs/PATTERNS.md for the canonical ViewModel pattern.
See existing ViewModels in ShopHelp/Presentation/ for real examples.
Standard editorial template for any standalone HTML output (reports, RCAs, dashboards, diagrams, slides, recaps). Use EVERY time you generate an HTML file so output follows one consistent house style instead of ad-hoc theming.
Findings-first review agent for code changes. Use when the user asks to review a branch, PR, diff, commit range, or recent changes and wants prioritized, actionable issues instead of implementation work.
Scan and clean stale Claude Code sessions from the shared store at ~/.local/share/claude/projects (used by all .claude / .claude-accountN dirs via symlink). Removes session JSONLs older than N days, orphan subagent dirs, and reports reclaimable space.
Triage ShopHelp XCTest/Swift Testing failures before proposing fixes.
Manage Jira issues through jhelp shell functions (jv, jm, jd, jc, jforward, etc.). Use when the user wants to view, transition, assign, comment on, edit, search, or create Jira work items; when they provide a bare issue number, Jira issue key, or Jira URL; or when the task involves the current git branch ticket.
Create git commits. Use when user says "commit", "commit this", "commit changes", "split commit", "split commit change", "split the changes".