agentleFS
pr-pmpr-pm/prpm/.cursor/rules/creating-skills.mdc

prpm / rules

Cursor rule122 starsChanged 9 months agoMITView on GitHub

Meta-guide for creating effective Claude Code skills with proper structure, CSO optimization, and real examples

The file

We split this creating-skills.mdc into the rules it gives an agent

10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Core principle: Default assumption is Claude is already very smart.

    line 14
  2. Very specific:

    Only name and description fields supported (max 1024 chars total)

    line 42
  3. Distinctive:

    Use broad guidance, principles, examples

    line 79
  4. Distinctive:

    Red flag: If skill tries to constrain Claude too much on creative tasks, reduce specificity.

    line 88
  5. Distinctive:

    Use words Claude would search for:

    line 112
  6. Distinctive:

    When: All content fits in ~500 words, no heavy reference needed

    line 213
  7. Very specific:

    SKILL.md: Keep under 500 lines

    line 234
  8. Distinctive:

    Use progressive disclosure (reference additional files as needed)

    line 260
  9. Distinctive:

    Leave gaps in understanding (no examples)

    line 348
  10. Distinctive:

    Golden rule: Default assumption is Claude is already very smart.

    line 357

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
creating-skills.mdc
---
description: Meta-guide for creating effective Claude Code skills with proper structure, CSO optimization, and real examples
tags: [meta, skill-creation, documentation, best-practices]
---

# Creating Skills - Meta Guide

## Overview

**Skills are reference guides for proven techniques, patterns, or tools.** Write them to help future Claude instances quickly find and apply effective approaches.

Skills must be **discoverable** (Claude can find them), **scannable** (quick to evaluate), and **actionable** (clear examples).

**Core principle**: Default assumption is Claude is already very smart. Only add context Claude doesn't already have.

## When to Use

**Create a skill when:**
- Technique wasn't intuitively obvious
- Pattern applies broadly across projects
- You'd reference this again
- Others would benefit

**Don't create for:**
- One-off solutions specific to single project
- Standard practices well-documented elsewhere
- Project conventions (put those in `.claude/CLAUDE.md` or `.cursor/rules`)

## Required Structure

### Frontmatter (YAML)

```yaml
---
name: skill-name-with-hyphens
description: Use when [triggers/symptoms] - [what it does and how it helps]
tags: relevant-tags
---
```

**Rules:**
- Only `name` and `description` fields supported (max 1024 chars total)
- Name: letters, numbers, hyphens only (no special chars). Use gerund form (verb + -ing)
- Description: Third person, starts with "Use when..."
- Include BOTH triggering conditions AND what skill does
- Match specificity to task complexity (degrees of freedom)

### Document Structure

```markdown
# Skill Name

## Overview
Core principle in 1-2 sentences. What is this?

## When to Use
- Bullet list with symptoms and use cases
- When NOT to use

## Quick Reference
Table or bullets for common operations

## Implementation
Inline code for simple patterns
Link to separate file for heavy reference (100+ lines)

## Common Mistakes
What goes wrong + how to fix

## Real-World Impact (optional)
Concrete results from using this technique
```

## Degrees of Freedom

**Match specificity to task complexity:**

- **High freedom**: Flexible tasks requiring judgment
  - Use broad guidance, principles, examples
  - Let Claude adapt approach to context
  - Example: "Use when designing APIs - provides REST principles and patterns"

- **Low freedom**: Fragile or critical operations
  - Be explicit about exact steps
  - Include validation checks
  - Example: "Use when deploying to production - follow exact deployment checklist with rollback procedures"

**Red flag**: If skill tries to constrain Claude too much on creative tasks, reduce specificity. If skill is too vague on critical operations, add explicit steps.

## Claude Search Optimization (CSO)

**Critical:** Future Claude reads the description to decide if skill is relevant. Optimize for discovery.

### Description Best Practices

```yaml
# ❌ BAD - Too vague, doesn't mention when to use
description: For async testing

# ❌ BAD - First person (injected into system prompt)
description: I help you with flaky tests

# ✅ GOOD - Triggers + what it does
description: Use when tests have race conditions or pass/fail inconsistently - replaces arbitrary timeouts with condition polling for reliable async tests

# ✅ GOOD - Technology-specific with explicit trigger
description: Use when using React Router and handling auth redirects - provides patterns for protected routes and auth state management
```

### Keyword Coverage

Use words Claude would search for:
- **Error messages**: "ENOENT", "Cannot read property", "Timeout"
- **Symptoms**: "flaky", "hanging", "race condition", "memory leak"
- **Synonyms**: "cleanup/teardown/afterEach", "timeout/hang/freeze"
- **Tools**: Actual command names, library names, file types

### Naming Conventions

**Use gerund form (verb + -ing):**
- ✅ `creating-skills` not `skill-creation`
- ✅ `testing-with-subagents` not `subagent-testing`
- ✅ `debugging-memory-leaks` not `memory-leak-debugging`
- ✅ `processing-pdfs` not `pdf-processor`
- ✅ `analyzing-spreadsheets` not `spreadsheet-analysis`

**Why gerunds work:**
- Describes the action you're taking
- Active and clear
- Consistent with Anthropic conventions

**Avoid:**
- ❌ Vague names like "Helper" or "Utils"
- ❌ Passive voice constructions

## Code Examples

**One excellent example beats many mediocre ones.**

### Choose Language by Use Case

- Testing techniques → TypeScript/JavaScript
- System debugging → Shell/Python
- Data processing → Python
- API calls → TypeScript/JavaScript

### Good Example Checklist

- [ ] Complete and runnable
- [ ] Well-commented explaining **WHY** not just what
- [ ] From real scenario (not contrived)
- [ ] Shows pattern clearly
- [ ] Ready to adapt (not generic template)
- [ ] Shows both BAD (❌) and GOOD (✅) approaches
- [ ] Includes realistic context/setup code

### Example Template

```typescript
// ✅ GOOD - Clear, complete, ready to adapt
interface RetryOptions {
  maxAttempts: number;
  delayMs: number;
  backoff?: 'linear' | 'exponential';
}

async function retryOperation<T>(
  operation: () => Promise<T>,
  options: RetryOptions
): Promise<T> {
  const { maxAttempts, delayMs, backoff = 'linear' } = options;

  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    try {
      return await operation();
    } catch (error) {
      if (attempt === maxAttempts) throw error;

      const delay = backoff === 'exponential'
        ? delayMs * Math.pow(2, attempt - 1)
        : delayMs * attempt;

      await new Promise(resolve => setTimeout(resolve, delay));
    }
  }

  throw new Error('Unreachable');
}

// Usage
const data = await retryOperation(
  () => fetchUserData(userId),
  { maxAttempts: 3, delayMs: 1000, backoff: 'exponential' }
);
```

### Don't

- ❌ Implement in 5+ languages (you're good at porting)
- ❌ Create fill-in-the-blank templates
- ❌ Write contrived examples
- ❌ Show only code without comments

## File Organization

### Self-Contained (Preferred)

```
typescript-type-safety/
  SKILL.md    # Everything inline
```

**When:** All content fits in ~500 words, no heavy reference needed

### With Supporting Files

```
api-integration/
  SKILL.md           # Overview + patterns
  retry-helpers.ts   # Reusable code
  examples/
    auth-example.ts
    pagination-example.ts
```

**When:** Reusable tools or multiple complete examples needed

## Token Efficiency

Skills load into every conversation. Keep them concise.

### Target Limits

- **SKILL.md**: Keep under 500 lines
- Getting-started workflows: <150 words
- Frequently-loaded skills: <200 words total
- Other skills: <500 words

**Challenge each piece of information**: "Does Claude really need this explanation?"

### Compression Techniques

```markdown
# ❌ BAD - Verbose (42 words)
Your human partner asks: "How did we handle authentication errors in React Router before?"
You should respond: "I'll search past conversations for React Router authentication patterns."
Then dispatch a subagent with the search query: "React Router authentication error handling 401"

# ✅ GOOD - Concise (20 words)
Partner: "How did we handle auth errors in React Router?"
You: Searching...
[Dispatch subagent → synthesis]
```

**Techniques:**
- Reference tool `--help` instead of documenting all flags
- Cross-reference other skills instead of repeating content
- Show minimal example of pattern
- Eliminate redundancy
- Use progressive disclosure (reference additional files as needed)

## Common Mistakes

| Mistake | Why It Fails | Fix |
|---------|--------------|-----|
| Narrative example | "In session 2025-10-03..." | Focus on reusable pattern |
| Multi-language dilution | Same example in 5 languages | One excellent example |
| Generic labels | helper1, helper2, step3 | Use semantic names |
| Missing description triggers | "For testing" | "Use when tests are flaky..." |
| First-person description | "I help you..." | "Use when... - provides..." |
| Offering too many options | 10 different approaches | Focus on one proven approach |
| Time-sensitive information | "As of 2025..." | Keep content evergreen |

## Workflow Recommendations

For multi-step processes, include:

1. **Clear sequential steps**: Break complex tasks into numbered operations
2. **Feedback loops**: Build in verification/validation steps
3. **Error handling**: What to check when things go wrong
4. **Checklists**: For processes with many steps

**Example structure:**
```markdown
## Workflow

1. **Preparation**
   - Check prerequisites
   - Validate environment

2. **Execution**
   - Step 1: [action + expected result]
   - Step 2: [action + expected result]

3. **Verification**
   - [ ] Check 1 passes
   - [ ] Check 2 passes

4. **Rollback** (if needed)
   - Steps to undo changes
```

## Skill Creation Checklist

**Before writing:**
- [ ] Technique isn't obvious or well-documented elsewhere
- [ ] Pattern applies broadly (not project-specific)
- [ ] I would reference this across multiple projects

**Frontmatter:**
- [ ] Name uses only letters, numbers, hyphens
- [ ] Description starts with "Use when..."
- [ ] Description includes triggers AND what skill does
- [ ] Description is third person
- [ ] Total frontmatter < 1024 characters

**Content:**
- [ ] Overview states core principle (1-2 sentences)
- [ ] "When to Use" section with symptoms
- [ ] Quick reference table for common operations
- [ ] One excellent code example (if technique skill)
- [ ] Common mistakes section
- [ ] Keywords throughout for searchability

**Quality:**
- [ ] Word count appropriate for frequency
- [ ] SKILL.md under 500 lines
- [ ] No narrative storytelling
- [ ] Supporting files only if needed (100+ lines reference)
- [ ] No time-sensitive information
- [ ] Consistent terminology throughout
- [ ] Concrete examples (not templates)
- [ ] Degrees of freedom match task complexity

## Real-World Impact

**Good skills:**
- Future Claude finds them quickly (CSO optimization)
- Can be scanned in seconds (quick reference)
- Provide clear actionable examples
- Prevent repeating same research
- Stay under 500 lines (token efficient)
- Match specificity to task needs

**Bad skills:**
- Get ignored (vague description)
- Take too long to evaluate (no quick reference)
- Leave gaps in understanding (no examples)
- Waste token budget (verbose explanations)
- Over-constrain creative tasks
- Include time-sensitive or obsolete information

---

**Remember:** Skills are for future Claude, not current you. Optimize for discovery, scanning, and action.

**Golden rule:** Default assumption is Claude is already very smart. Only add context Claude doesn't already have.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.