AgentSkillsCN

code-comparison

代码比较

SKILL.md

Code Comparison

Compare code implementations for equivalence, similarity, or differences with accurate classification.

Comparison Dimensions

DimensionQuestion
BehavioralSame outputs for same inputs? Same side effects?
SemanticSame intent/purpose? Same business logic?
SyntacticSimilar names, structure, formatting?
AlgorithmicSame approach? Same complexity (Big O)?
StyleFunctional vs imperative? Recursive vs iterative?

Common Scenarios

ScenarioFocus
RefactoringBehavioral equivalence (must match)
Bug fixSpecific case differs, normal matches
API compatSignature, returns, errors, side effects
PlagiarismStructure, naming, logic patterns

Output Format

Start with [YES] or [NO] immediately.

Then provide justification with specific examples from both items.

Analysis Checklist

  • Inputs (same params, types?)
  • Outputs (same returns?)
  • Side effects (same state changes?)
  • Error handling (same exceptions?)
  • Edge cases (null, empty, boundary?)
  • Performance (same complexity?)

Example

code
[YES] Behaviorally equivalent

Both functions:
1. Return same results for all inputs
2. Handle null by returning empty array
3. Use same filtering logic

The refactoring improves readability (modern array methods) without changing behavior.

Pitfalls

  • Don't stop at surface differences (naming != different behavior)
  • Check edge cases (factorial(-1) may differ)
  • Consider context (Promise vs callback may be equivalent in modern Node)