Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Mvc Pattern

ASecurity

Separate user interface logic into Model (data), View (presentation), and Controller (input handling) for maintainable, testable GUI applications

22 stars
0 votes
0 copies
0 views
Added 9/20/2026
developmentgodjangorailsspringtestingrefactoringapifrontendbackend

Works with

cliapi

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add lev-os/agents --skill mvc-pattern --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mvc Pattern?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Mvc Pattern
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lev-os-mvc-pattern/badge)](https://www.skillsdirectory.com/skills/lev-os-mvc-pattern)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: mvc-pattern
description: Separate user interface logic into Model (data), View (presentation), and Controller (input handling) for maintainable, testable GUI applications
---

# Model-View-Controller (MVC)

## Overview

Model-View-Controller is a foundational architectural pattern for user interfaces that divides program logic into three interconnected components: Model (business logic and data), View (presentation and display), and Controller (input handling and coordination). Originally developed by Trygve Reenskaug for Smalltalk in the late 1970s, MVC became widely adopted across web frameworks (Rails, Django, ASP.NET), desktop applications, and mobile development.

Martin Fowler codified MVC in "Patterns of Enterprise Application Architecture" (2003) as a pattern where an input controller receives requests, sends messages to model objects, takes responses, and passes them to views for display. The core principle is Separated Presentation - keeping presentation objects distinct from domain model objects. This separation enables independent evolution of UI and business logic, improves testability by isolating concerns, and allows multiple views of the same data.

## When to Use

- Building user interfaces with complex business logic that must be tested independently
- Applications requiring multiple views of the same data (desktop + mobile + API)
- Web applications needing clear separation between routing, business logic, and templates
- Teams with specialized roles (frontend, backend, domain experts) working in parallel
- Systems where UI frequently changes but business rules remain stable
- Retrofitting testability into legacy GUI applications
- Frameworks that enforce MVC conventions (Rails, Django, Spring MVC)

## The Process

### Step 1: Define the Model - Business Logic and Data

The Model represents domain concepts, business rules, and data. It has no knowledge of views or controllers.

**Ask:** "What are the core business entities and their rules? What data needs to persist?"

**Implementation:** Create classes for domain objects (User, Product, Order) with business logic methods. Models notify observers of state changes but don't render UI.

**Example:** `OrderModel` calculates totals, validates inventory, enforces business rules. Exposes `getTotal()`, `addItem()`, `validatePayment()` - no HTML/UI code.

### Step 2: Build the View - Presentation Layer

The View displays data from the Model. It observes Model changes and updates display. Contains no business logic.

**Ask:** "How should this data appear to users? What formatting and layout are needed?"

**Implementation:** Create templates, HTML, or UI components that render Model data. Views subscribe to Model change events for automatic updates.

**Example:** `OrderView` renders order items as HTML table, displays total. When Model updates, View refreshes automatically. No calculation logic - purely presentation.

### Step 3: Implement the Controller - Input Coordinator

The Controller handles user input, updates Models, and selects Views to render. It's the "glue" coordinating Models and Views.

**Ask:** "What user actions are possible? How do inputs translate to Model changes and View updates?"

**Implementation:** Map user actions (button clicks, HTTP requests) to Controller methods. Controller invokes Model methods, then tells View what to render.

**Example:** `OrderController.addItem(productId)` receives user action, calls `OrderModel.addItem()`, selects `OrderView` to display updated order. Routes `/orders/:id` to `OrderController.show()`.

### Step 4: Establish Communication Flow

Connect the three components following MVC communication rules.

**Flow:** User interacts with View → Controller handles input → Controller updates Model → Model notifies observers → View updates display.

**Implementation:** Use observer pattern for Model-View communication. Controller directly calls Model methods and explicitly selects Views.

**Example:** User clicks "Add to Cart" → `OrderController.addToCart()` → Updates `OrderModel` → Model fires `orderChanged` event → `OrderView` listens, re-renders cart display.

### Step 5: Maintain Separation of Concerns

Enforce boundaries: Models know nothing of Views/Controllers, Views know Models but not Controllers, Controllers know both.

**Validation:** Can you test Model business logic without any UI? Can you swap View implementations without changing Model? Can you change routing without touching business rules?

**Refactoring:** If Model has HTML generation, move to View. If View has calculations, move to Model. If business logic is in Controller, move to Model.

## Example Application

**Situation:** E-commerce product catalog with web interface, mobile app, and REST API - all displaying the same inventory data with different presentations.

**Application of MVC:**
- **Model:** `ProductCatalog` manages inventory, pricing rules, search logic. `Product` entities with SKU, price, stock validation. Notifies observers when inventory changes.
- **View:** `WebProductView` renders HTML grid, `MobileProductView` optimizes for touch, `JSONProductView` serializes for API. All observe same `ProductCatalog` Model.
- **Controller:** `ProductController` handles search requests, filters, sort orders. Routes `/products/search?q=laptop` to `searchAction()`, updates Model with query, selects appropriate View (HTML vs JSON based on Accept header).

**Outcome:** Business logic tested independently (Model unit tests). Design team iterated UI rapidly without touching business rules. API and web UI share 100% of domain code. Mobile team joined later - reused Models, built new Views/Controllers.

## Anti-Patterns

- "Fat Controllers" with business logic - violates separation, makes testing harder (move to Model)
- Models importing View libraries - breaks independence, creates circular dependencies
- Views performing calculations or data manipulation - pollutes presentation layer (move to Model)
- Direct View-to-View communication bypassing Controller - creates hidden dependencies
- Treating MVC as strict dogma when simpler patterns suffice (over-engineering small apps)
- Controllers directly manipulating View internals rather than passing data
- Models with no observers - defeats automatic View updates, requires manual refresh
- Confusing MVC with similar patterns (MVP, MVVM) - understand the differences

## Related

- mvvm-pattern (evolution adding data binding and ViewModel)
- hexagonal-architecture (ports and adapters, similar separation)
- clean-architecture (extends MVC principles to system architecture)
- observer-pattern (mechanism for Model-View communication)
- separation-of-concerns (underlying design principle)
- dependency-injection (for wiring Controllers and Models)

Attribution

lev-oslev-os
View sourceMore from lev-os →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

281612 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2132 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →