mvvm

mvvm is a cursor rule for Cursor from Takt365/Takt.Wpf. It costs 665 tokens per session, scanned A, original, MIT.

A set of coding rules for MVVM, a design pattern that separates the user interface, its state and actions, and the underlying data and business logic.

In plain words
What is it for?
Use it to guide the structure of WPF views, view models, and models, including where files belong and how user actions should be handled.
Why use it?
It reduces the chance that display code becomes mixed with application logic, making the project harder to change or test.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/takt365/takt.wpf/mvvm
Clone the repo
git clone --depth 1 https://github.com/Takt365/Takt.Wpf

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mvvm

README.md
[![agentmods](https://agentmods.dev/badge/rules/takt365/takt.wpf/mvvm.svg)](https://agentmods.dev/rules/takt365/takt.wpf/mvvm)
Your own site
<a href="https://agentmods.dev/rules/takt365/takt.wpf/mvvm"><img src="https://agentmods.dev/badge/rules/takt365/takt.wpf/mvvm.svg" alt="Measured on agentmods" height="20"></a>
Per session 665 This file is loaded in full into every session.
When invoked 665 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00665 $0.00665
Opus 5 $0.00332 $0.00332
Sonnet 5 $0.00133 $0.00133
Haiku 4.5 $0.00067 $0.00067

Measured 4d ago against content hash 3d3c67fd9123, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mvvm scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/mvvm.mdc · 101 lines

How it starts

The opening of the file, as written. The whole thing — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MVVM 模式规范

View(视图层)

职责:仅负责 UI 展示和用户交互,不包含业务逻辑

文件位置:@src/Takt.Fluent/Views/

示例

<!-- ✅ 正确:View 只负责 UI -->
<!-- @src/Takt.Fluent/Views/Identity/UserView.xaml -->
<UserControl x:Class="Takt.Fluent.Views.Identity.UserView">
    <DataGrid ItemsSource="{Binding Users}" 
              SelectedItem="{Binding SelectedUser, Mode=TwoWay}"/>
</UserControl>
// ❌ 错误:View 中包含业务逻辑
// @src/Takt.Fluent/Views/Identity/UserView.xaml.cs
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    // ❌ 不要在 View 中直接调用服务
    var service = App.Services.GetService<IUserService>();
    service.GetUsersAsync();
}

ViewModel(视图模型层)

职责:管理 View 的状态和数据,处理用户交互命令

文件位置:@src/Takt.Fluent/ViewModels/

示例

// ✅ 正确:ViewModel 继承 ViewModelBase
// @src/Takt.Fluent/ViewModels/Identity/UserViewModel.cs
public class UserViewModel : ViewModelBase
{
    private readonly IHbtUserService _userService;
    private ObservableCollection<UserDto> _users = new();
    
    public ObservableCollection<UserDto> Users
    {
        get => _users;
        set => SetProperty(ref _users, value);
    }
    
    public ICommand LoadUsersCommand { get; }
    
    public UserViewModel(IHbtUserService userService)
    {
        _userService = userService;
        LoadUsersCommand = new RelayCommand(async () => await LoadUsersAsync());
    }
    
    private async Task LoadUsersAsync()
    {
        var result = await _userService.GetListAsync();
        if (result.Success)
        {
            Users = new ObservableCollection<UserDto>(result.Data);
        }
    }
}

关键要求

  • ✅ 必须通过构造函数注入依赖服务
  • ✅ 使用 SetProperty 方法更新属性以触发通知
  • ✅ 所有异步操作使用 async/await
  • ✅ 命令使用 ICommand 接口

Model(模型层)

职责:定义数据模型(Entity、DTO)

文件位置

  • Entity:@src/Takt.Domain/Entities/
  • DTO:@src/Takt.Application/Dtos/

示例

// ✅ 正确:Entity 定义
// @src/Takt.Domain/Entities/Identity/User.cs
public class User : EntityBase
{
    [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
    public int Id { get; set; }
    
    [SugarColumn(Length = 50)]
    public string UserName { get; set; } = string.Empty;
}

Read the full file on GitHub · 101 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 101 lines · 665 tokens per session scan A 3d3c67fd9123

Subscribe to this mod's changes

mvvm is a cursor rule published in the GitHub repository Takt365/Takt.Wpf (17 stars, last pushed 8mo ago), licensed MIT. It adds 665 tokens to every session, about $0.0033 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.