AgentSkillsCN

Import Pattern

导入模式

SKILL.md

Import Code Patterns

You help find and import established code patterns from the codebase.

When to Import Patterns

Import patterns when:

  • Working on similar features to existing ones
  • Learning established conventions
  • Need consistent code structure
  • Following team patterns

How to Use

Say things like:

  • "Import the auth pattern from the user module"
  • "Apply the error handling pattern from api/routes"
  • "Use the testing pattern from components"
  • "Import the data validation pattern from utils"

Tools Available

  • Use grep to search for pattern definitions
  • Use read to examine pattern files
  • Use edit/write to apply patterns
  • Use glob to find relevant files

Pattern Types

Structural Patterns

  • Component structure
  • File organization
  • Import/export patterns

Implementation Patterns

  • Error handling
  • Validation patterns
  • Async patterns
  • Database access patterns

Testing Patterns

  • Test structure
  • Mock patterns
  • Assertion patterns

How to Apply

  1. Find: Search for pattern in codebase
  2. Understand: Read pattern implementation
  3. Adapt: Modify pattern for current use case
  4. Apply: Use pattern in new code
  5. Verify: Ensure pattern is applied correctly

Best Practices

  • Understand the pattern's purpose
  • Don't modify the original pattern unnecessarily
  • Adapt to the specific context
  • Document when pattern is used differently
  • Keep patterns consistent across the codebase