跳到正文
Skillpedia
测试48k · #5096

logic-diff

它能做什么

用来比较两个版本的代码,看它们做的事情是否一样。它会一步一步地分析代码,找出行为上的重要差异。

适用场景

  • ✓当你重构代码,想确认没有出现问题时。
  • ✓当你把代码迁移到新版本,想检查结果是否一致时。
  • ✓当你测试了两种不同的实现(A/B)后,想知道它们的功能是否完全相同时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/logic-diff/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/logic-diff/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请比较这两个版本的代码,看看它们的行为是否还是一样的。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会把两个版本的代码放在一起分析,逐步跟踪每个版本的执行过程。它会记录两者的执行路径或结果从哪里开始不一样。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Logic-Lens — Semantic Diff

When to Use

Use this skill when you need compare two code versions for semantic equivalence via semi-formal tracing of both versions side-by-side. Trigger when the user shares a refactor, rewrite, migration, or A/B implementation and wants to confirm behavior is unchanged — "did I break anything", "is this equivalent", "are...

Setup

Use lazy loading per ../_shared/common.md §13:

  1. Read ../_shared/common.md only for language, Iron Law, Verdict header, scope routing, Remedy discipline, config fields, and loading budget.
  2. Read only the relevant step in logic-diff-guide.md as you reach it.
  3. Load ../_shared/logic-risks.md, ../_shared/semiformal-guide.md, ../_shared/semiformal-checklist.md, and ../_shared/report-template.md on demand when the current step needs them.

Process

Step 0. Language + scope routing. Detect language per common.md §1. Confirm two versions are provided. If only one version, switch to logic-review.

Step 1. Identify the shared specification (guide Step 1) — what inputs should both versions handle; what outputs/side effects are expected. If the user states the refactor intentionally changed behavior in a specific area (e.g., "I changed the error path to raise instead of returning None"), record that as a declared spec change and treat divergences within that area as expected. Flag only divergences outside the declared change as findings.

Step 2. Build independent premises for each version (guide Step 2) — apply the Premises Construction Checklist to Version A and Version B separately.

Step 3. Trace both versions for the common case (guide Step 3) — parallel trace, same input, note the first divergence if any.

Step 4. Trace boundary cases (guide Step 4) — empty/null/zero, max/min, error inputs, first/last of collections. Start with at most three highest-risk boundary scenarios unless the user asks for exhaustive equivalence or the shared specification requires more.

Step 5. Identify and classify semantic divergences (guide Step 5) — each divergence is a finding with Premises → Trace → Divergence → Trigger → Remedy and an L-code.

Step 6. Equivalence verdict (guide Step 6) — one of: ✅ Semantically Equivalent, ⚠️ Conditionally Equivalent (state the condition precisely), ❌ Semantically Divergent.

Step 7. Output (guide Step 7) — Report Template with the Verdict header per common.md §5; localize headers if the user wrote in Chinese. Format is mandatory even for trivially short snippets: every divergence finding MUST use the five labeled fields (Premises / Trace / Divergence / Trigger / Remedy); never substitute with a plain paragraph or table.

Mode line in report: Semantic Diff (Chinese: 语义对比).

Limitations

  • Use this skill only when the task clearly matches its upstream source and local project context.
  • Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.
  • Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
常见问题

“语义等价”是什么意思?

意思是即使代码看起来不一样,或者被重写过,只要对相同的输入产生相同的结果,或者实际效果一致,就算语义等价。

什么是“半形式化追踪”?

这是一种逐步跟踪代码逻辑的方法,就像画一张记录每一步发生了什么的地图,确保不遗漏任何环节。

如果代码本来就故意要有不同的行为怎么办?

如果你事先告诉 AI 计划中的行为变化,它会把这些变化记录下来,只指出那些计划之外的意外差异。

详情

作者的原始描述

Compare two code versions for semantic equivalence via semi-formal tracing of both versions side-by-side.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5096
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能