Pattern Extraction Skill
Extract reusable patterns from conversations and code, determine appropriate artifact types, and suggest organization locations.
When to Use
- Use when extracting patterns from conversations
- Use when identifying reusable patterns in code
- Use when determining what artifacts to create
- Use when organizing patterns into categories
Instructions
Pattern Extraction Process
- Identify patterns: Find recurring themes, instructions, or workflows
- Abstract patterns: Extract generalizable patterns from specific instances
- Determine type: Decide if pattern should be rule, skill, command, or subagent
- Suggest location: Recommend where artifact should be placed
- Document pattern: Document the pattern clearly
Pattern Types
Instruction Patterns
- Repeated instructions or corrections
- User preferences and style choices
- Domain-specific conventions
- Team standards
Workflow Patterns
- Common sequences of actions
- Standardized processes
- Multi-step procedures
- Recurring task flows
Error Patterns
- Systematic errors and corrections
- Common mistakes and fixes
- Prevention strategies
- Error handling approaches
Context Patterns
- Context-specific behaviors
- File-type specific patterns
- Domain-specific knowledge
- Environment-specific configurations
Hook Patterns (Cursor agent loop)
- Gating: What the agent is allowed or forbidden to do (shell commands, file reads, MCP calls) →
beforeShellExecution, beforeReadFile, beforeMCPExecution, etc.
- Post-edit automation: Run something after every file edit (format, lint) →
afterFileEdit, afterTabFileEdit
- Auditing: Log or observe agent actions →
postToolUse, afterShellExecution, afterMCPExecution
- Session context: Inject env or context at conversation start →
sessionStart
- Tab vs Agent policy: Different rules for inline Tab vs Agent → Tab-specific hooks (
beforeTabFileRead, afterTabFileEdit)
When a pattern fits hook behavior, suggest hooks as the outcome (with event(s) and command-based vs prompt-based). See Cursor Hooks.
Artifact Type Determination
Use decision framework:
- Rule: Persistent guidance, domain knowledge, standards
- Skill: Domain knowledge with scripts, automation needs
- Command: Manual workflows, checklists, step-by-step
- Subagent: Complex tasks, context isolation, parallel work
- Hooks: Behavior that must run automatically in the agent loop (gate, format after edit, audit, inject context)—configure via
.cursor/hooks.json and scripts
Organization Suggestions
- Category selection: Choose appropriate category (meta, organization, etc.)
- Naming: Suggest name following conventions
- Location: Recommend full path for artifact
- Relationships: Identify related artifacts
Examples
Example 1: Instruction Pattern
Pattern: "Always use async/await instead of promises"
Extraction:
- Type: Rule
- Location:
cursor/rules/organization/async-await.mdc
- Content: Rule enforcing async/await usage
- Related: JavaScript/TypeScript rules
Example 2: Workflow Pattern
Pattern: Standard code review process with checklist
Extraction:
- Type: Command
- Location:
cursor/commands/meta/code-review-checklist.md
- Content: Step-by-step review checklist
- Related: Review-related artifacts
Best Practices
- Extract generalizable patterns, not one-off instances
- Consider frequency and significance
- Validate pattern worth creating artifact
- Document pattern clearly
- Suggest appropriate organization
Related Artifacts
- Conversation Analysis Skill
- Artifact Creation Skill
- Artifact Creation Rule
- Cursor Hooks – When to recommend hooks (agent-loop automation, gating, auditing)
- Pattern Extraction Research
1---2name: pattern-extraction3description: Extract reusable patterns from conversations and code. Identify patterns, determine artifact type, and suggest organization location. Use when analyzing content to find patterns for artifact creation.4---56# Pattern Extraction Skill78Extract reusable patterns from conversations and code, determine appropriate artifact types, and suggest organization locations.910## When to Use1112- Use when extracting patterns from conversations13- Use when identifying reusable patterns in code14- Use when determining what artifacts to create15- Use when organizing patterns into categories1617## Instructions1819### Pattern Extraction Process20211. **Identify patterns**: Find recurring themes, instructions, or workflows222. **Abstract patterns**: Extract generalizable patterns from specific instances233. **Determine type**: Decide if pattern should be rule, skill, command, or subagent244. **Suggest location**: Recommend where artifact should be placed255. **Document pattern**: Document the pattern clearly2627### Pattern Types2829#### Instruction Patterns3031- Repeated instructions or corrections32- User preferences and style choices33- Domain-specific conventions34- Team standards3536#### Workflow Patterns3738- Common sequences of actions39- Standardized processes40- Multi-step procedures41- Recurring task flows4243#### Error Patterns4445- Systematic errors and corrections46- Common mistakes and fixes47- Prevention strategies48- Error handling approaches4950#### Context Patterns5152- Context-specific behaviors53- File-type specific patterns54- Domain-specific knowledge55- Environment-specific configurations5657#### Hook Patterns (Cursor agent loop)5859- **Gating**: What the agent is allowed or forbidden to do (shell commands, file reads, MCP calls) → `beforeShellExecution`, `beforeReadFile`, `beforeMCPExecution`, etc.60- **Post-edit automation**: Run something after every file edit (format, lint) → `afterFileEdit`, `afterTabFileEdit`61- **Auditing**: Log or observe agent actions → `postToolUse`, `afterShellExecution`, `afterMCPExecution`62- **Session context**: Inject env or context at conversation start → `sessionStart`63- **Tab vs Agent policy**: Different rules for inline Tab vs Agent → Tab-specific hooks (`beforeTabFileRead`, `afterTabFileEdit`)6465When a pattern fits hook behavior, suggest **hooks** as the outcome (with event(s) and command-based vs prompt-based). See [Cursor Hooks](docs/research/cursor-hooks.md).6667### Artifact Type Determination6869Use decision framework:70- **Rule**: Persistent guidance, domain knowledge, standards71- **Skill**: Domain knowledge with scripts, automation needs72- **Command**: Manual workflows, checklists, step-by-step73- **Subagent**: Complex tasks, context isolation, parallel work74- **Hooks**: Behavior that must run automatically in the agent loop (gate, format after edit, audit, inject context)—configure via `.cursor/hooks.json` and scripts7576### Organization Suggestions7778- **Category selection**: Choose appropriate category (meta, organization, etc.)79- **Naming**: Suggest name following conventions80- **Location**: Recommend full path for artifact81- **Relationships**: Identify related artifacts8283## Examples8485### Example 1: Instruction Pattern8687**Pattern**: "Always use async/await instead of promises"8889**Extraction**:90- Type: Rule91- Location: `cursor/rules/organization/async-await.mdc`92- Content: Rule enforcing async/await usage93- Related: JavaScript/TypeScript rules9495### Example 2: Workflow Pattern9697**Pattern**: Standard code review process with checklist9899**Extraction**:100- Type: Command101- Location: `cursor/commands/meta/code-review-checklist.md`102- Content: Step-by-step review checklist103- Related: Review-related artifacts104105## Best Practices106107- Extract generalizable patterns, not one-off instances108- Consider frequency and significance109- Validate pattern worth creating artifact110- Document pattern clearly111- Suggest appropriate organization112113## Related Artifacts114115- [Conversation Analysis Skill](.cursor/skills/meta/conversation-analysis/SKILL.md)116- [Artifact Creation Skill](.cursor/skills/meta/artifact-creation/SKILL.md)117- [Artifact Creation Rule](.cursor/rules/meta/artifact-creation.mdc)118- [Cursor Hooks](docs/research/cursor-hooks.md) – When to recommend hooks (agent-loop automation, gating, auditing)119- [Pattern Extraction Research](docs/research/ai-agent-patterns.md)