frontend-development

A set of front-end coding rules for a web application built with plain HTML, CSS, and JavaScript. It covers structure, naming, mobile-friendly layouts, accessibility, and performance.

In plain words
What is it for?
Use it when building or changing the browser interface, including responsive screens, reusable JavaScript modules, CSS components, keyboard navigation, and loading optimisations.
Why use it?
It gives developers shared conventions, so the interface stays consistent and easier to maintain without relying on a front-end framework.

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/cnwinds/ai-detective/frontend-development
Clone the repo
git clone --depth 1 https://github.com/cnwinds/ai-detective

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 6,501 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00000 $0.06501
Opus 5 $0.00000 $0.03250
Sonnet 5 $0.00000 $0.01300
Haiku 4.5 $0.00000 $0.00650

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

Security

Grade A, and why

frontend-development scanned grade A with 1 finding 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 2d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const response = await fetch(url, {
.cursor/rules/frontend-development.mdc · 989 lines

How it starts

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

前端开发规范

项目架构和设计原则

技术栈和架构

  • 核心技术: 原生HTML/CSS/JavaScript (零框架依赖)
  • 设计理念: 平台独立、响应式、性能优先
  • 支持平台: 桌面端 + 移动端双平台

命名约定

  • JavaScript: 驼峰命名法 (camelCase)
  • CSS: BEM命名规范或基础类+修饰符模式
  • HTML: 语义化标签,kebab-case属性
  • 文件命名: 小写字母加连字符,描述性命名

开发原则

  • 组件化: 模块化的JavaScript类和CSS组件
  • 响应式: 移动端优先的设计
  • 性能优化: 懒加载、缓存、最小化DOM操作
  • 可访问性: 语义化HTML,键盘导航支持

JavaScript开发模式

应用架构模式

// DetectiveGameApp类 - 主应用架构
class DetectiveGameApp {
    constructor() {
        this.sessionId = null;
        this.gameState = {
            phase: 'case-selection',
            selectedCase: null,
            selectedCharacter: null,
            evidenceFound: [],
            conversationHistory: {},
            rounds: 0
        };
        this.apiHelper = new APIHelper();
        this.themeManager = new ThemeManager();
        this.initializeApp();
    }

    // 状态管理
    updateGameState(newState) {
        this.gameState = { ...this.gameState, ...newState };
        this.saveGameState();
        this.updateUI();
        this.emitStateChange();
    }

    // 屏幕切换管理
    showScreen(screenName) {
        document.querySelectorAll('.screen').forEach(screen => {
            screen.style.display = 'none';
        });
        document.getElementById(screenName).style.display = 'block';
        this.gameState.currentScreen = screenName;
    }

    // 事件系统
    emitStateChange() {
        window.dispatchEvent(new CustomEvent('gameStateChanged', {
            detail: this.gameState
        }));
    }
}

工具类架构

// API工具类
class APIHelper {
    constructor() {
        this.baseURL = '/api';
        this.defaultHeaders = {
            'Content-Type': 'application/json'
        };
    }

    async makeRequest(endpoint, data, options = {}) {
        try {
            const response = await fetch(`${this.baseURL}${endpoint}`, {
                method: 'POST',
                headers: this.defaultHeaders,
                body: JSON.stringify(data),
                ...options
            });
            
            if (!response.ok) {
                throw new Error(`HTTP ${response.status}: ${response.statusText}`);
            }
            
            const result = await response.json();
            if (!result.success) {
                throw new Error(result.error || '请求失败');
            }
            
            return result.data;
        } catch (error) {
            console.error('API请求失败:', error);
            throw error;
        }
    }

    // 流式响应处理
    async handleStreamResponse(url, data, onChunk, onComplete) {
        try {
            const response = await fetch(url, {
                method: 'POST',
                headers: this.defaultHeaders,
                body: JSON.stringify(data)
            });
            
            if (!response.ok) {
                throw new Error(`HTTP ${response.status}: ${response.statusText}`);
            }
            
            const reader = response.body.getReader();
            const decoder = new TextDecoder();
            
            while (true) {
                const { done, value } = await reader.read();
                if (done) break;
                
                const chunk = decoder.decode(value);
                const lines = chunk.split('\n');
                
                for (const line of lines) {
                    if (line.startsWith('data: ')) {
                        try {
                            const data = JSON.parse(line.slice(6));
                            if (data.type === 'chunk') {
                                onChunk(data.content);
                            } else if (data.type === 'complete') {
                                onComplete();
                                return;
                            }
                        } catch (e) {
                            console.warn('解析流数据失败:', e);
                        }
                    }
                }
            }
        } catch (error) {
            console.error('流式请求失败:', error);
            throw error;
        }
    }
}

// 主题管理系统
class ThemeManager {
    constructor() {
        this.currentTheme = localStorage.getItem('theme') || 'default';
        this.themes = {};
        this.init();
    }

    async init() {
        await this.loadThemes();
        this.applyStoredTheme();
        this.setupThemeSelector();
    }

    async loadThemes() {
        try {
            const response = await fetch('/static/themes.json');
            this.themes = await response.json();
        } catch (error) {
            console.error('加载主题失败:', error);
        }
    }

    applyTheme(themeName) {
        const theme = this.themes[themeName];
        if (!theme) return;

        const root = document.documentElement;
        
        // 应用颜色变量
        Object.entries(theme.colors).forEach(([key, value]) => {
            root.style.setProperty(`--color-${key}`, value);
        });

        // 应用字体变量
        if (theme.typography) {
            Object.entries(theme.typography).forEach(([key, value]) => {
                root.style.setProperty(`--font-${key}`, value);
            });
        }

        this.currentTheme = themeName;
        localStorage.setItem('theme', themeName);
        
        // 触发主题切换事件
        window.dispatchEvent(new CustomEvent('themeChanged', { 
            detail: { theme: themeName } 
        }));
    }
}

Read the full file on GitHub · 989 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. 2d ago First seen · 989 lines · 0 tokens per session scan A c9e0fa0f2089

Subscribe to this mod's changes

frontend-development is a cursor rule published in the GitHub repository cnwinds/ai-detective (6 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 6,501 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.