Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

creating-cursor-rules-skillcreating Cursor rules 技能

Agent Skill

creating-cursor-rules-skill 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

353

周安装

15

GitHub Stars

106

下载量

124
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:creating-cursor-rules-skill(creating Cursor rules 技能)
来源仓库:https://github.com/pr-pm/prpm
仓库路径:skills/creating-cursor-rules-skill
安装命令:
npx skills add https://github.com/pr-pm/prpm --skill creating-cursor-rules-skill
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/pr-pm/prpm --skill creating-cursor-rules-skill

简介

用于查找、检索和筛选相关信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词、任务场景或来源线索快速定位候选结果。
  • 通过 npx skills add 命令从指定仓库安装使用。
  • 安装前需确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • creating-cursor-rules-skill 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Creating Cursor Rules

You are an expert at creating effective .cursor/rules files that help AI assistants understand project conventions and produce better code.

When to Apply This Skill

Use when:

  • User is starting a new project and needs .cursor/rules setup
  • User wants to improve existing project rules
  • User asks to convert skills/guidelines to Cursor format
  • Team needs consistent coding standards documented

Don't use for:

  • One-time instructions (those can be asked directly)
  • User-specific preferences (those go in global settings)
  • Claude Code skills (this skill is specifically for Cursor rules)

Core Principles

1. Be Specific and Actionable

Rules should provide concrete guidance, not vague advice.

❌ BAD - Vague:

Write clean code with good practices.
Use proper TypeScript types.

✅ GOOD - Specific:

Use functional components with TypeScript.
Define prop types with interfaces, not inline types.
Extract custom hooks when logic exceeds 10 lines.

2. Focus on Decisions, Not Basics

Don't document what linters handle. Document architectural decisions.

❌ BAD - Linter territory:

Use semicolons in JavaScript.
Indent with 2 spaces.
Add trailing commas.

✅ GOOD - Decision guidance:

Choose Zustand for global state, React Context for component trees.
Use Zod for runtime validation at API boundaries only.
Prefer server components except for: forms, client-only APIs, animations.

3. Organize by Concern

Group related rules into clear sections:

## Tech Stack
- Next.js 14 with App Router
- TypeScript strict mode
- Tailwind CSS for styling

## Code Style
- Functional components only
- Named exports (no default exports)
- Co-locate tests with source files

## Patterns
- Use React Server Components by default
- Client components: mark with "use client" directive
- Error handling: try/catch + toast notification

## Project Conventions
- API routes in app/api/
- Components in components/ (flat structure)
- Types in types/ (shared), components/*/types.ts (local)

Rule Anatomy

MDC Format and Metadata

Cursor rules are written in MDC (.mdc) format, which supports YAML frontmatter metadata and markdown content. The metadata controls how and when rules are applied.

Required YAML Frontmatter

Every Cursor rule MUST start with YAML frontmatter between --- markers:

---
description: Brief description of when and how to use this rule
globs: ["**/*.ts", "**/*.tsx"]
alwaysApply: false
---

Frontmatter Properties

PropertyTypeRequiredDescription
descriptionstringYesBrief description of the rule's purpose. Used by AI to decide relevance. Never use placeholders like --- or empty strings.
globsarrayNoFile patterns that trigger auto-attachment (e.g., ["**/*.ts"]). Leave empty or omit if not using Auto Attached type.
alwaysApplybooleanNoIf true, rule is always included in context. If false or omitted, behavior depends on Rule Type.

Rule Types

Control how rules are applied using the type dropdown in Cursor:

Rule TypeDescriptionWhen to Use
AlwaysAlways included in model contextCore project conventions, tech stack, universal patterns that apply everywhere
Auto AttachedIncluded when files matching globs pattern are referencedFile-type specific rules (e.g., React components, API routes, test files)
Agent RequestedAvailable to AI, which decides whether to include it based on descriptionContextual patterns, specialized workflows, optional conventions
ManualOnly included when explicitly mentioned using @ruleNameRarely-used patterns, experimental conventions, legacy documentation

Examples by Rule Type

Always Rule (Core conventions):

---
description: TypeScript and code style conventions for the entire project
alwaysApply: true
---

Auto Attached Rule (File pattern-specific):

---
description: React component patterns and conventions
globs: ["**/components/**/*.tsx", "**/app/**/*.tsx"]
alwaysApply: false
---

Agent Requested Rule (Contextual):

---
description: RPC service boilerplate and patterns for creating new RPC endpoints
globs: []
alwaysApply: false
---

Manual Rule (Explicit invocation):

---
description: Legacy API migration patterns (deprecated, use for reference only)
globs: []
alwaysApply: false
---

Best Practices for Frontmatter

  1. Description is mandatory - AI uses this to determine relevance. Be specific:

- ❌ Bad: Backend code - ✅ Good: Fastify API route patterns, error handling, and validation using Zod

  1. Use globs strategically - Auto-attach to relevant file types:

- React components: ["**/*.tsx", "**/*.jsx"] - API routes: ["**/api/**/*.ts", "**/routes/**/*.ts"] - Tests: ["**/*.test.ts", "**/*.spec.ts"]

  1. Avoid always applying everything - Use alwaysApply: true sparingly:

- ✅ Good for: Tech stack, core conventions, project structure - ❌ Bad for: Framework-specific patterns, specialized workflows

  1. Make Agent Requested rules discoverable - Write descriptions that help AI understand when to use:

- Include keywords: "boilerplate", "template", "pattern for X" - Mention specific use cases: "when creating new API routes"

Required Sections

Every Cursor rule file should include these sections:

1. Tech Stack Declaration

## Tech Stack
- Framework: Next.js 14
- Language: TypeScript 5.x (strict mode)
- Styling: Tailwind CSS 3.x
- State: Zustand
- Database: PostgreSQL + Prisma
- Testing: Vitest + Playwright

Why: Prevents AI from suggesting wrong tools/patterns.

2. Code Style Guidelines

## Code Style
- **Components**: Functional with TypeScript
- **Props**: Interface definitions, destructure in params
- **Hooks**: Extract when logic > 10 lines
- **Exports**: Named exports only (no default)
- **File naming**: kebab-case.tsx

3. Common Patterns

Always include code examples, not just descriptions:

## Patterns

### Error Handling

try { const result = await operation(); toast.success('Operation completed'); return result; } catch (error) { const message = error instanceof Error ? error.message : 'Unknown error'; toast.error(message); throw error; // Re-throw for caller to handle }


### API Route Structure

// app/api/users/route.ts export async function GET(request: Request) { try { // 1. Parse/validate input // 2. Check auth/permissions // 3. Perform operation // 4. Return Response } catch (error) { return new Response(JSON.stringify({ error: 'Message' }), { status: 500 }); } }

What NOT to Include

Avoid these common mistakes:

❌ Too obvious:

- Write readable code
- Use meaningful variable names
- Add comments when necessary
- Follow best practices

❌ Too restrictive:

- Never use any third-party libraries
- Always write everything from scratch
- Every function must be under 5 lines

❌ Language-agnostic advice:

- Use design patterns
- Think before you code
- Test your code
- Keep it simple

Structure Template

Use this template for new Cursor rules:

# Project Name - Cursor Rules

## Tech Stack
[List all major technologies with versions]

## Code Style
[Specific style decisions]

## Project Structure
[Directory organization]

## Patterns
[Common patterns with code examples]

### Pattern Name
[Description + code example]

## Conventions
[Project-specific conventions]

## Common Tasks
[Frequent operations with step-by-step snippets]

### Task Name
1. Step one
2. Step two
[Code example]

## Anti-Patterns
[What to avoid and why]

## Testing
[Testing approach and patterns with examples]

Example Sections

Tech Stack Section

## Tech Stack

**Framework:** Next.js 14 (App Router)
**Language:** TypeScript 5.x (strict mode enabled)
**Styling:** Tailwind CSS 3.x with custom design system
**State:** Zustand for global, React Context for component trees
**Forms:** React Hook Form + Zod validation
**Database:** PostgreSQL with Prisma ORM
**Testing:** Vitest (unit), Playwright (E2E)
**Deployment:** Vercel

**Key Dependencies:**
- `@tanstack/react-query` for server state
- `date-fns` for date manipulation (not moment.js)
- `clsx` + `tailwind-merge` for conditional classes

Anti-Patterns Section

## Anti-Patterns

### ❌ Don't: Default Exports

// ❌ BAD export default function Button() { }

// ✅ GOOD export function Button() { }


**Why:** Named exports are more refactor-friendly and enable better tree-shaking.

### ❌ Don't: Inline Type Definitions

// ❌ BAD function UserCard({ user }: { user: { name: string; email: string } }) { }

// ✅ GOOD interface User { name: string; email: string; }

function UserCard({ user }: { user: User }) { }


**Why:** Reusability and discoverability.

Common Tasks

Include shortcuts for frequent operations:

## Common Tasks

### Adding a New API Route

1. Create `app/api/[route]/route.ts`
2. Define HTTP method exports (GET, POST, etc.)
3. Validate input with Zod schema
4. Use try/catch for error handling
5. Return `Response` object

import { z } from 'zod';

const schema = z.object({ name: z.string().min(1) });

export async function POST(request: Request) { try { const body = await request.json(); const data = schema.parse(body);

// Process...

return Response.json({ success: true }); } catch (error) { if (error instanceof z.ZodError) { return Response.json( { error: error.errors }, { status: 400 } ); } return Response.json( { error: 'Internal error' }, { status: 500 } ); } }

Best Practices

Keep Rules Under 500 Lines

  • Split large rules into multiple, composable files
  • Each rule file should focus on one domain or concern
  • Reference other rule files when needed (e.g., "See backend-api.mdc for API patterns")
  • Why: Large files become unmanageable and harder for AI to process effectively

Split Into Composable Rules

Break down by concern rather than creating one monolithic file:


.cursor/rules/ ├── tech-stack.mdc # Core technologies ├── typescript-patterns.mdc # Language-specific patterns ├── api-conventions.mdc # API route standards ├── component-patterns.mdc # React/UI patterns └── testing-standards.mdc # Testing approaches

Why: Easier to maintain, update, and reuse across similar projects.

Provide Concrete Examples or Referenced Files

Instead of vague guidance, always include:

  • Complete, runnable code examples
  • References to actual project files: See components/auth/LoginForm.tsx for example
  • Links to internal docs or design system
  • Specific file paths and line numbers when relevant

❌ BAD - Vague:

Use proper error handling in API routes.

✅ GOOD - Concrete:

API routes must use try/catch with typed errors. Example:

// app/api/users/route.ts (lines 10-25) export async function POST(request: Request) { try { const data = await request.json(); return Response.json({ success: true }); } catch (error) { return handleApiError(error); // See lib/errors.ts } }


See `app/api/products/route.ts` for complete implementation.

Write Rules Like Clear Internal Docs

Rules should read like technical documentation, not casual advice:

  • Be precise and unambiguous
  • Include the "why" behind decisions
  • Document exceptions to rules
  • Reference architecture decisions
  • Link to related rules or documentation

Think: "Could a new engineer understand this without asking questions?"

Reuse Rules When Repeating Prompts

If you find yourself giving the same instructions repeatedly in chat:

  1. Document that pattern in .cursor/rules/
  2. Include the specific guidance you keep repeating
  3. Add examples of correct implementation
  4. Update existing rule files rather than creating new ones

Common scenarios to capture:

  • "Always use X pattern for Y"
  • "Don't forget to Z when doing W"
  • Corrections you make frequently
  • Patterns specific to your team/codebase

Keep It Scannable

  • Use clear section headers
  • Bold important terms
  • Include code examples (not just prose)
  • Use tables for comparisons
  • Add table of contents for files over 200 lines

Update Regularly

  • Review monthly or after major changes
  • Remove outdated patterns
  • Add new patterns as they emerge
  • Keep examples current with latest framework versions
  • Archive deprecated rules rather than deleting (for reference)

Test with AI

After creating rules, test them:

  1. Ask AI: "Create a new API route following our conventions"
  2. Ask AI: "Add error handling to this component"
  3. Ask AI: "Refactor this to match our patterns"

Verify AI follows rules correctly. Update rules based on gaps found.

Real-World Example

The PRPM registry .cursor/rules demonstrates:

  • Clear tech stack declaration (Fastify, TypeScript, PostgreSQL)
  • Specific TypeScript patterns
  • Fastify-specific conventions
  • Error handling standards
  • API route patterns
  • Database query patterns

Checklist for New Cursor Rules

Project Context:

  • [ ] Tech stack clearly defined with versions
  • [ ] Key dependencies listed
  • [ ] Deployment platform specified

Code Style:

  • [ ] Component style specified (functional/class)
  • [ ] Export style (named/default)
  • [ ] File naming convention
  • [ ] Specific to project (not generic advice)

Patterns:

  • [ ] At least 3-5 code examples
  • [ ] Cover most common tasks
  • [ ] Include error handling pattern
  • [ ] Show project-specific conventions

Organization:

  • [ ] Logical section headers
  • [ ] Scannable (not wall of text)
  • [ ] Examples are complete and runnable
  • [ ] Anti-patterns included with rationale

Testing:

  • [ ] Tested with AI assistant
  • [ ] AI follows conventions correctly
  • [ ] Updated after catching mistakes

Helpful Prompts for Users

When helping users create Cursor rules:

Discovery:

  • "What's your tech stack?"
  • "What patterns do you want AI to follow?"
  • "What mistakes does AI currently make?"

Refinement:

  • "Are there anti-patterns you want documented?"
  • "What are your most common coding tasks?"
  • "Do you have naming conventions?"

Validation:

  • "Let me test these rules by asking you to generate code..."
  • "Does this match your team's style?"

Remember

  • Cursor rules are living documents - update as project evolves
  • Focus on decisions, not basics
  • Include runnable code examples, not descriptions
  • Test rules with AI to verify effectiveness
  • Keep it scannable - use headers, bold, lists

Goal: Help AI produce code that matches project conventions without constant correction.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.42%
按下载量换算43

Claude

31.62%
按下载量换算39

Cursor

20.52%
按下载量换算25

Gemini CLI

9.21%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills