Cursor rule
.cursor/rules/mpa-relaxed-rules.mdcMPA-First Development Mandate (Relaxed) - Guidelines for building Multi-Page Applications with jQuery for progressive enhancement
Cursor rules
Quality
77/100
Scores the file, not the repository.Length
696 words
10 headings · 7 code blocksRepository
10
— · pushed 241 days agoLast changed
3 days ago
First indexed 3 days ago.1234567891011# GitHub Copilot Instructions: MPA-First Mandate1213## Core Philosophy1415My primary goal is to build performant, resilient, and maintainable server-rendered **Multi-Page Applications (MPAs)**.1617- **Prioritize the Platform:** Use HTML, CSS, and server-side logic (PHP) first.18- **Simplicity Over Complexity:** Choose simple, durable solutions over complex, trendy ones.19- **Progressive Enhancement:** JavaScript is an enhancement, not a requirement. Core functionality must work without it. I use **jQuery** to implement these enhancements.2021---2223## 1. PRIME DIRECTIVE: MPA-Only Architecture2425- **You MUST build server-rendered MPAs.** Each distinct page or view is its own file (e.g., `.php`, `.html`) at a unique URL.26- **Navigation MUST use standard anchor links (`<a href="...">`)** that trigger a full page load.27- **Core functionality MUST work with JavaScript disabled.**2829### 🚫 BANNED TECHNOLOGIES & PATTERNS3031- **DO NOT** use or reference any Single-Page Application (SPA) frameworks or libraries. This includes **React, Angular, Vue, Svelte, Next.js, and Nuxt.js**.32- **DO NOT** use **JSX, TSX, or any form of client-side routing**.3334---3536## 2. JavaScript Rules (Progressive Enhancement with jQuery)3738- **jQuery is the standard.** Use jQuery for all DOM manipulation, event handling, and AJAX requests.39- **Include jQuery from a CDN** in the base layout file, just before the closing `</body>` tag.40- **Write Unobtrusive JavaScript.** Always ensure the site is fully functional if JavaScript fails or is disabled.41- Wrap all jQuery code in `$(function() { ... });` to ensure the DOM is ready.42- Handle AJAX errors gracefully using `.done()`, `.fail()`, and `.always()`.4344**Correct Pattern: Unobtrusive Toggle with jQuery**45```html46<!-- HTML works on its own -->47<a href="?show_details=true#details" class="toggle-link">Show Details</a>48<div id="details" style="display: none;">49 <p>Here are the details you requested.</p>50</div>51```52```javascript53// JS enhances the experience54$(function() {55 $('.toggle-link').on('click', function(event) {56 event.preventDefault();57 $('#details').slideToggle(300, () => {58 const isVisible = $('#details').is(':visible');59 $(this).text(isVisible ? 'Hide Details' : 'Show Details');60 });61 });62});63```6465---6667## 3. HTML Rules6869- **Semantic HTML is Mandatory:** Use `<header>`, `<nav>`, `<main>`, `<article>`, `<footer>`, etc., correctly.70- **Accessibility (A11Y) is critical (WCAG 2.1 AA):**71 - All form inputs must have a `<label>`.72 - Use descriptive `alt` text for images. `alt=""` for decorative images.73- **Use Speculation Rules** in the `<head>` to prerender links for instant navigation.74```html75 <script type="speculationrules">76 { "prerender": [{"source": "document", "where": {"href_matches": "/*"}, "eagerness": "moderate"}] }77 </script>78```79- **SEO is a top priority.** Every page needs a complete `<head>` with `title`, `meta description`, `canonical` link, and Open Graph tags.8081---8283## 4. CSS Rules8485- **Use Modern CSS:** Use Flexbox and Grid for all layouts.86- **Use Custom Properties (`--var-name`)** for theming and maintainability.87- **Use Native CSS View Transitions** for fluid "app-like" navigation.88```css89 @view-transition { navigation: auto; }9091 ::view-transition-old(root),92 ::view-transition-new(root) {93 animation: fade-out 0.3s ease-out both;94 }9596 @keyframes fade-out {97 from { opacity: 1; }98 to { opacity: 0; }99 }100```101102---103104## 5. PHP Rules105106- **Target PHP 8.1+** and always start files with `declare(strict_types=1);`.107- **Adhere to PSR-12** for clean, standardized code.108- **Use modern PHP features:** constructor property promotion, `readonly` properties, `match` expressions, and enums.109110**Correct Pattern: Modern PHP Class**111```php112<?php113declare(strict_types=1);114namespace App\Models;115116readonly class User117{118 public function __construct(119 public int $id,120 public string $name,121 ) {}122}123```124125---126127## 6. Security Rules128129- **Always use parameterized queries** to prevent SQL injection. No exceptions.130- **All POST forms must have CSRF protection.** Generate a token, store it in the session, and validate it on submission.131- **Implement a strict Content Security Policy (CSP).** Whitelist any CDNs you use (like for jQuery).132133**Correct Pattern: CSP Header with jQuery CDN**134```php135<?php136$csp = "default-src 'self'; " .137 "script-src 'self' https://code.jquery.com; " . // Whitelist the CDN138 "style-src 'self'; " .139 "img-src 'self'; " .140 "form-action 'self'; " .141 "frame-ancestors 'none';";142header("Content-Security-Policy: " . $csp);143?>144```145146---147148## 7. Folder Structure149150Follow this MVC-style folder structure for all projects.151152```153project-root/154├── public/ # Web root155│ ├── assets/156│ │ ├── css/157│ │ ├── js/158│ └── index.php159├── src/ # Application source code160│ ├── controllers/ # Handles user requests161│ ├── models/ # Business logic and data162│ ├── views/ # HTML templates/partials163└── vendor/ # Composer dependencies164```165
Also in RealistSec/mpa-first-guidelines
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| RealistSec/mpa-first-guidelines.github/copilot-instructions.md · 10 | Copilot instructions | styledependenciesuido-not+2 | 59/100 | 3 days ago | |
| RealistSec/mpa-first-guidelines.cursor/rules/mpa-strict-rules.mdc · 10 | Cursor rules | buildstylearchsecurity+4 | 66/100 | 3 days ago |
