AgentSkillsCN

feature-injection-rules

在现有代码库中安全注入新功能的规则与模式。确保代码与项目约定及 SOLID 原则保持一致。

SKILL.md
--- frontmatter
description: Rules and patterns for safely injecting new features into existing codebases. Ensures consistency with project conventions and SOLID principles.
name: feature-injection-rules
allowed-tools: ["Read", "Grep", "Glob", "Edit", "Write", "Task"]

Feature Injection Rules

Core Principle

Inject features that blend seamlessly with existing code while maintaining architectural integrity.


Pre-Injection Checklist

CheckSerena ToolRequired
Project knowledge loadedread_memoryYes
Target location identifiedfind_symbolYes
Conventions extractedKnowledge graphYes
Impact scope analyzedfind_referencing_symbolsYes
SOLID compliance verifiedSOLID rulesYes

Injection Types Summary

TypeUse CaseKey Tool
New SymbolAdd new class/functioninsert_after_symbol
ExtensionAdd method to classinsert_after_symbol
ImplementationNew interface implinsert_before_symbol
ModificationChange existingreplace_symbol_body

Detailed templates: Read("references/injection-templates.md")


Convention Matching Rules

Naming Conventions

ElementCommon Patterns
ClassPascalCase, suffix (Service, Controller)
MethodcamelCase, verb prefix (get, set, is)
VariablecamelCase or snake_case
ConstantUPPER_SNAKE_CASE
InterfaceI-prefix or -able/-er suffix

Structure Conventions

  1. Import Ordering: External → Internal → Local
  2. Method Ordering: Constructor → Public → Private → Static
  3. File Organization: Match existing patterns

SOLID Compliance for Injection

PrincipleInjection Rule
SRPOne clear purpose per symbol
OCPPrefer new implementations over modifications
LSPHonor interface contracts
ISPDon't bloat existing interfaces
DIPInject dependencies, depend on abstractions

Post-Injection Verification

  1. Syntax Check: Run linter/type checker
  2. Import Resolution: Verify all imports valid
  3. Reference Check: No broken references
  4. SOLID Check: Validate against SOLID rules
  5. Test Suggestion: Propose test cases

Code templates: Read("references/code-templates.md")