mpa-first-guidelines / rules
Cursor rule11 starsChanged 12 months agoMITView on GitHub
MPA-First Development Mandate (Relaxed) - Guidelines for building Multi-Page Applications with jQuery for progressive enhancement
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/mpa-strict-rules.mdcCursor rule
The file
We split this mpa-relaxed-rules.mdc into the rules it gives an agent
11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Prioritize the Platform: Use HTML, CSS, and server-side logic (PHP) first.
- Very specific: line 31
DO NOT: use or reference any Single-Page Application (SPA) frameworks or libraries.
- Distinctive: line 32
DO NOT: use JSX, TSX, or any form of client-side routing.
- Distinctive: line 38
jQuery is the standard: Use jQuery for all DOM manipulation, event handling, and AJAX requests.
- Distinctive: line 40
Write Unobtrusive JavaScript: Always ensure the site is fully functional if JavaScript fails or is disabled.
- Very specific: line 69
Semantic HTML is Mandatory: Use <header>, <nav>, <main>, <article>, <footer>, etc., correctly.
- Very specific: line 71
All form inputs must have a <label>.
- Very specific: line 72
Use descriptive alt text for images.
- Very specific: line 79
SEO is a top priority: Every page needs a complete <head> with title, meta description, canonical link, and Open Graph tags.
- Distinctive: line 85
Use Modern CSS: Use Flexbox and Grid for all layouts.
- Distinctive: line 150
Follow this MVC-style folder structure for all projects.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: MPA-First Development Mandate (Relaxed) - Guidelines for building Multi-Page Applications with jQuery for progressive enhancement
globs:
- "**/*.php"
- "**/*.html"
- "**/*.js"
- "**/*.css"
alwaysApply: false
---
# GitHub Copilot Instructions: MPA-First Mandate
## Core Philosophy
My primary goal is to build performant, resilient, and maintainable server-rendered **Multi-Page Applications (MPAs)**.
- **Prioritize the Platform:** Use HTML, CSS, and server-side logic (PHP) first.
- **Simplicity Over Complexity:** Choose simple, durable solutions over complex, trendy ones.
- **Progressive Enhancement:** JavaScript is an enhancement, not a requirement. Core functionality must work without it. I use **jQuery** to implement these enhancements.
---
## 1. PRIME DIRECTIVE: MPA-Only Architecture
- **You MUST build server-rendered MPAs.** Each distinct page or view is its own file (e.g., `.php`, `.html`) at a unique URL.
- **Navigation MUST use standard anchor links (`<a href="...">`)** that trigger a full page load.
- **Core functionality MUST work with JavaScript disabled.**
### 🚫 BANNED TECHNOLOGIES & PATTERNS
- **DO NOT** use or reference any Single-Page Application (SPA) frameworks or libraries. This includes **React, Angular, Vue, Svelte, Next.js, and Nuxt.js**.
- **DO NOT** use **JSX, TSX, or any form of client-side routing**.
---
## 2. JavaScript Rules (Progressive Enhancement with jQuery)
- **jQuery is the standard.** Use jQuery for all DOM manipulation, event handling, and AJAX requests.
- **Include jQuery from a CDN** in the base layout file, just before the closing `</body>` tag.
- **Write Unobtrusive JavaScript.** Always ensure the site is fully functional if JavaScript fails or is disabled.
- Wrap all jQuery code in `$(function() { ... });` to ensure the DOM is ready.
- Handle AJAX errors gracefully using `.done()`, `.fail()`, and `.always()`.
**Correct Pattern: Unobtrusive Toggle with jQuery**
```html
<!-- HTML works on its own -->
<a href="?show_details=true#details" class="toggle-link">Show Details</a>
<div id="details" style="display: none;">
<p>Here are the details you requested.</p>
</div>
```
```javascript
// JS enhances the experience
$(function() {
$('.toggle-link').on('click', function(event) {
event.preventDefault();
$('#details').slideToggle(300, () => {
const isVisible = $('#details').is(':visible');
$(this).text(isVisible ? 'Hide Details' : 'Show Details');
});
});
});
```
---
## 3. HTML Rules
- **Semantic HTML is Mandatory:** Use `<header>`, `<nav>`, `<main>`, `<article>`, `<footer>`, etc., correctly.
- **Accessibility (A11Y) is critical (WCAG 2.1 AA):**
- All form inputs must have a `<label>`.
- Use descriptive `alt` text for images. `alt=""` for decorative images.
- **Use Speculation Rules** in the `<head>` to prerender links for instant navigation.
```html
<script type="speculationrules">
{ "prerender": [{"source": "document", "where": {"href_matches": "/*"}, "eagerness": "moderate"}] }
</script>
```
- **SEO is a top priority.** Every page needs a complete `<head>` with `title`, `meta description`, `canonical` link, and Open Graph tags.
---
## 4. CSS Rules
- **Use Modern CSS:** Use Flexbox and Grid for all layouts.
- **Use Custom Properties (`--var-name`)** for theming and maintainability.
- **Use Native CSS View Transitions** for fluid "app-like" navigation.
```css
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
animation: fade-out 0.3s ease-out both;
}
@keyframes fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
```
---
## 5. PHP Rules
- **Target PHP 8.1+** and always start files with `declare(strict_types=1);`.
- **Adhere to PSR-12** for clean, standardized code.
- **Use modern PHP features:** constructor property promotion, `readonly` properties, `match` expressions, and enums.
**Correct Pattern: Modern PHP Class**
```php
<?php
declare(strict_types=1);
namespace App\Models;
readonly class User
{
public function __construct(
public int $id,
public string $name,
) {}
}
```
---
## 6. Security Rules
- **Always use parameterized queries** to prevent SQL injection. No exceptions.
- **All POST forms must have CSRF protection.** Generate a token, store it in the session, and validate it on submission.
- **Implement a strict Content Security Policy (CSP).** Whitelist any CDNs you use (like for jQuery).
**Correct Pattern: CSP Header with jQuery CDN**
```php
<?php
$csp = "default-src 'self'; " .
"script-src 'self' https://code.jquery.com; " . // Whitelist the CDN
"style-src 'self'; " .
"img-src 'self'; " .
"form-action 'self'; " .
"frame-ancestors 'none';";
header("Content-Security-Policy: " . $csp);
?>
```
---
## 7. Folder Structure
Follow this MVC-style folder structure for all projects.
```
project-root/
├── public/ # Web root
│ ├── assets/
│ │ ├── css/
│ │ ├── js/
│ └── index.php
├── src/ # Application source code
│ ├── controllers/ # Handles user requests
│ ├── models/ # Business logic and data
│ ├── views/ # HTML templates/partials
└── vendor/ # Composer dependencies
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

