Skill 详情
cursor-reference-architecture
Covers Cursor project structure and rules, only indirectly relevant to skill setup.
使用前先检查
自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。
SKILL.md
这段内容是审核时保存的快照。外部来源才是完整且最新的版本。
--- name: cursor-reference-architecture description: 'Reference architecture for Cursor IDE projects: directory structure, rules organization, indexing strategy, and team configuration patterns. Triggers on "cursor architecture", "cursor project structure", "cursor best practices", "cursor file structure". ' allowed-tools: Read, Write, Edit, Bash(cmd:*) version: 1.18.0 license: MIT author: Jeremy Longshore <[email protected]> tags: - saas - cursor - cursor-reference compatibility: Designed for Claude Code, also compatible with Codex and OpenClaw --- # Cursor Reference Architecture Reference architecture patterns for optimizing Cursor IDE project setup. Covers directory structure, rules organization, indexing strategy, and multi-project configuration for maximum AI effectiveness. ## Project Layout for Cursor A well-structured project makes AI features significantly more effective: ``` my-project/ ├── .cursor/ │ └── rules/ │ ├── project.mdc # alwaysApply: true (stack, conventions) │ ├── security.mdc # alwaysApply: true (security constraints) │ ├── typescript.mdc # globs: "**/*.ts,**/*.tsx" │ ├── api-routes.mdc # globs: "src/api/**/*.ts" │ ├── database.mdc # globs: "src/db/**/*.ts,prisma/**" │ └── testing.mdc # globs: "**/*.test.ts,**/*.spec.ts" ├── .cursorignore # Exclude from AI + indexing ├── .cursorindexingignore # Exclude from indexing only ├── .gitignore ├── src/ │ ├── api/ # API routes │ ├── services/ # Business logic │ ├── db/ # Database layer │ ├── types/ # Shared TypeScript types │ ├── utils/ # Utility functions │ └── components/ # UI components ├── tests/ ├── prisma/ ├── docs/ # Architecture docs (good for @Docs) └── package.json ``` ### Why This Structure Helps Cursor 1. **Glob patterns work predictably**: `src/api/**/*.ts` cleanly scopes API rules 2. **@Files references are intuitive**: `@src/types/user.ts` is discoverable 3. **Indexing is focused**: clear separation of code vs build output vs data 4. **Rules inheritance**: project-level always-on + directory-scoped rules ## Rules Architecture ### Layer 1: Always-On Global Rules ```yaml # .cursor/rules/project.mdc --- description: "Core project context and conventions" globs: "" alwaysApply: true --- # SaaS Dashboard Application Stack: Next.js 15 (App Router), TypeScript 5.7, PostgreSQL 16, Prisma 6 Auth: NextAuth.js v5 with GitHub OAuth Styling: Tailwind CSS 4 Testing: Vitest + Playwright Package manager: pnpm ## Architecture Decisions - Server Components by default, "use client" only when needed - Repository pattern for database access - Zod schemas for all external input validation - Result types for error handling (never throw from services) ``` ### Layer 2: Security (Always-On) ```yaml # .cursor/rules/security.mdc --- description: "Security constraints for all AI-generated code" globs: "" alwaysApply: true --- # Security Requirements - NEVER hardcode secrets, API keys, or passwords - ALWAYS use parameterized queries (no string interpolation in SQL) - ALWAYS validate and sanitize user input with Zod - NEVER disable CORS, CSRF protection, or TLS verification - Use httpOnly, secure, sameSite cookies for auth tokens - Rate limit all public API endpoints ``` ### Layer 3: Technology-Specific (Glob-Scoped) ```yaml # .cursor/rules/react-components.mdc --- description: "React component patterns" globs: "src/components/**/*.tsx,app/**/*.tsx" alwaysApply: false --- # Component Standards - Named exports only (no default exports) - Props interface: {ComponentName}Props - Use forwardRef for interactive components - Colocate tests: Component.test.tsx next to Component.tsx - Loading states: use Suspense boundaries, not conditional rendering ``` ```yaml # .cursor/rules/api-routes.mdc --- description:在 GitHub 阅读完整来源 (打开外部页面)