AgentSkillsCN

pattern-extraction

从对话与代码中提炼可复用的模式。识别模式特征,明确资产类型,并提出合理的组织与存放位置。当您在分析内容时,若需寻找可用于创建资产的模式,可参考本指南。

SKILL.md
--- frontmatter
name: pattern-extraction
description: "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."

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

  1. Identify patterns: Find recurring themes, instructions, or workflows
  2. Abstract patterns: Extract generalizable patterns from specific instances
  3. Determine type: Decide if pattern should be rule, skill, command, or subagent
  4. Suggest location: Recommend where artifact should be placed
  5. 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

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

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