create-rule
whyymj/page-agent-sdk/.claude/skills/create-rule/SKILL.md
Create Cursor rules for persistent AI guidance. Use when you want to create a rule, add coding standards, set up project conventions, configure file-specific patterns, create RULE.md files, or asks about .cursor/rules/ or AGENTS.md.
Skill1 starsChanged 2 months ago
What's in it
- Creating Cursor Rules
- Gather Requirements
- Inferring from Context
- Required Questions
- Rule File Format
- File Structure
- Frontmatter Fields
- Rule Configurations
- Always Apply
- Apply to Specific Files
- Best Practices
- Keep Rules Concise
- Example Rules
- TypeScript Standards
- React Patterns
- Checklist
---
name: create-rule
description: >-
Create Cursor rules for persistent AI guidance. Use when you want to create a
rule, add coding standards, set up project conventions, configure
file-specific patterns, create RULE.md files, or asks about .cursor/rules/ or
AGENTS.md.
---
# Creating Cursor Rules
Create project rules in `.cursor/rules/` to provide persistent context for the AI agent.
## Gather Requirements
Before creating a rule, determine:
1. **Purpose**: What should this rule enforce or teach?
2. **Scope**: Should it always apply, or only for specific files?
3. **File patterns**: If file-specific, which glob patterns?
### Inferring from Context
If you have previous conversation context, infer rules from what was discussed. You can create multiple rules if the conversation covers distinct topics or patterns. Don't ask redundant questions if the context already provides the answers.
### Required Questions
If the user hasn't specified scope, ask:
- "Should this rule always apply, or only when working with specific files?"
If they mentioned specific files and haven't provided concrete patterns, ask:
- "Which file patterns should this rule apply to?" (e.g., `**/*.ts`, `backend/**/*.py`)
It's very important that we get clarity on the file patterns.
Use the AskQuestion tool when available to gather this efficiently.
---
## Rule File Format
Rules are `.mdc` files in `.cursor/rules/` with YAML frontmatter:
```
.cursor/rules/
typescript-standards.mdc
react-patterns.mdc
api-conventions.mdc
```
### File Structure
```markdown
---
description: Brief description of what this rule does
globs: **/*.ts # File pattern for file-specific rules
alwaysApply: false # Set to true if rule should always apply
---
# Rule Title
Your rule content here...
```
### Frontmatter Fields
| Field | Type | Description |
|-------|------|-------------|
| `description` | string | What the rule does (shown in rule picker) |
| `globs` | string | File pattern - rule applies when matching files are open |
| `alwaysApply` | boolean | If true, applies to every session |
---
## Rule Configurations
### Always Apply
For universal standards that should apply to every conversation:
```yaml
---
description: Core coding standards for the project
alwaysApply: true
---
```
### Apply to Specific Files
For rules that apply when working with certain file types:
```yaml
---
description: TypeScript conventions for this project
globs: **/*.ts
alwaysApply: false
---
```
---
## Best Practices
### Keep Rules Concise
- **Under 50 lines**: Rules should be concise and to the point
- **One concern per rule**: Split large rules into focused pieces
- **Actionable**: Write like clear internal docs
- **Concrete examples**: Ideally provide concrete examples of how to fix issues
---
## Example Rules
### TypeScript Standards
```markdown
---
description: TypeScript coding standards
globs: **/*.ts
alwaysApply: false
---
# Error Handling
\`\`\`typescript
// ❌ BAD
try {
await fetchData();
} catch (e) {}
// ✅ GOOD
try {
await fetchData();
} catch (e) {
logger.error('Failed to fetch', { error: e });
throw new DataFetchError('Unable to retrieve data', { cause: e });
}
\`\`\`
```
### React Patterns
```markdown
---
description: React component patterns
globs: **/*.tsx
alwaysApply: false
---
# React Patterns
- Use functional components
- Extract custom hooks for reusable logic
- Colocate styles with components
```
---
## Checklist
- [ ] File is `.mdc` format in `.cursor/rules/`
- [ ] Frontmatter configured correctly
- [ ] Content under 500 lines
- [ ] Includes concrete examples
More agent context in whyymj/page-agent-sdk
24 other files this repository gives its agents.
CLAUDE.md
Skill
- babysit.claude/skills/babysit/SKILL.md
- browser-e2e-testing.claude/skills/browser-e2e-testing/SKILL.md
- check-res-urls.claude/skills/check-res-urls/SKILL.md
- create-hook.claude/skills/create-hook/SKILL.md
- create-skill.claude/skills/create-skill/SKILL.md
- everything-claude-code.claude/skills/everything-claude-code/SKILL.md
- frontend-design.claude/skills/frontend-design/SKILL.md
- mcp-builder.claude/skills/mcp-builder/SKILL.md
- mermaid-to-png.claude/skills/mermaid-to-png/SKILL.md
- openspec-apply-change.claude/skills/openspec-apply-change/SKILL.md
- openspec-archive-change.claude/skills/openspec-archive-change/SKILL.md
- openspec-explore.claude/skills/openspec-explore/SKILL.md
- openspec-propose.claude/skills/openspec-propose/SKILL.md
- page-agent-sdk-release.claude/skills/page-agent-sdk-release/SKILL.md
- review-bugbot.claude/skills/review-bugbot/SKILL.md
- review-security.claude/skills/review-security/SKILL.md
- split-to-prs.claude/skills/split-to-prs/SKILL.md
- webapp-testing.claude/skills/webapp-testing/SKILL.md
- adaptive-planningskills/adaptive-planning/SKILL.md
- html-fragmentskills/html-fragment/SKILL.md
- page-agent-sdk-integrateskills/page-agent-sdk-integrate/SKILL.md
- precise-value-protectionskills/precise-value-protection/SKILL.md
- rag-searchskills/rag-search/SKILL.md
Also found in 2 other repositories
The same file, byte for byte, in the weekly crawl of public GitHub.
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

