legacy-safe-edit

legacy-safe-edit is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 29 tokens per session (2,464 once invoked), scanned A, original, MIT.

A set of practices for changing existing or old codebases safely. It focuses on finding dependencies, following local coding conventions, and making small changes that can be checked and reverted.

In plain words
What is it for?
Use it when fixing bugs, adding features, or refactoring unfamiliar repositories, especially when test coverage is incomplete.
Why use it?
It reduces the chance that a new change quietly breaks code elsewhere or introduces a second, inconsistent way of doing the same thing.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/legacy-safe-edit
Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill legacy-safe-edit
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for legacy-safe-edit

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/legacy-safe-edit.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/legacy-safe-edit)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/legacy-safe-edit"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/legacy-safe-edit.svg" alt="Measured on agentmods" height="20"></a>
Per session 29 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,464 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00029 $0.02464
Opus 5 $0.00015 $0.01232
Sonnet 5 $0.00006 $0.00493
Haiku 4.5 $0.00003 $0.00246

Measured 4d ago against content hash ce074d2cfb55, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

legacy-safe-edit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/legacy-safe-edit/SKILL.md · 170 lines

How it starts

The opening of the file, as written. The whole thing — 170 lines — stays where its author put it; the contents beside it link to each section on GitHub.

改老项目不崩

何时用

  • 接手别人的项目,第一次在陌生仓库里加功能或修 bug。
  • 在大型存量仓库里改动,不清楚某段代码被多少地方依赖。
  • 需要在没有完整测试覆盖的老代码里动手,改错了难以发现。
  • 产品要求在已上线系统里追加功能,不能影响现有用户流程。

核心规则

1. 先摸地形

规则: 改动前用搜索把所有调用点、依赖关系、相似实现全部找出来,弄清影响面再动手。

为什么: AI 拿到任务后习惯直接写代码,不会主动去确认"这个函数还有哪些调用方"。结果改了函数签名,三个其他模块悄悄挂掉;或者重写了一段逻辑,却不知道旁边已经有一个功能完全一样的工具函数。常见事故:在 utils/format.ts 里新写了 formatDate,没发现 helpers/date.ts 里已有同名函数,两套逻辑并存,下次维护的人一头雾水。

怎么做:

  • 用 Grep 搜索要改动的函数名、类名、常量名,确认所有引用位置。
  • 用 Glob 扫描目录结构,了解仓库的模块划分和文件命名规律。
  • 改动前在脑中(或明文写出)画出依赖链:「A 调用 B,B 被 C 和 D 引用,改 B 要同步检查 C 和 D」。
  • 若发现影响面超出预期,先向用户确认范围,不要默默扩大改动。

2. 跟随既有约定

规则: 完全模仿该仓库现有的命名风格、文件结构、错误处理方式,不引入个人偏好或"更好的写法"。

为什么: AI 有自己的代码风格偏好,在老库里容易不自觉地引入新的写法:项目用 callback 风格,AI 改成 async/await;项目用 snake_case,AI 写成 camelCase;项目统一用 if (err) return callback(err) 处理错误,AI 换成抛异常。这些风格切换单独看无害,但会让代码库出现多套约定并存的割裂感,后续维护者不知道该以哪种为准,技术债积累加速。

怎么做:

  • 改动前先读目标文件和它的邻居文件,摸清命名规范和代码结构。
  • 有现成的同类代码就对着抄格式,不要凭记忆写"我觉得更好的写法"。
  • 错误处理方式(返回错误码、抛异常、Result 类型)严格沿用仓库已有方式。
  • 若发现现有约定确实有问题,新建 issue 记录,不在当前任务里顺手"修正"。

3. 小步可回退

规则: 把改动拆成尽可能小的提交,每一步都能独立验证功能,出问题可以精确定位并回滚。

为什么: AI 倾向于一次性生成大段代码,一个 PR 改动几十个文件。当测试挂掉或功能出问题时,没人能快速判断是哪一步引入的问题,只能整体回滚,浪费大量时间。老代码库尤其危险——缺乏测试覆盖意味着问题可能只在特定场景下才暴露,小步提交是唯一能把"发现问题"和"引入问题的那次改动"对应起来的手段。

怎么做:

  • 每次提交只做一件事:改逻辑、改命名、调整结构,分开提交,不混在一起。
  • 提交前本地跑一遍相关测试(哪怕只是冒烟测试),确认当前步骤没有破坏已有功能。
  • 写清楚提交信息,说明"改了什么"和"为什么改",方便事后用 git bisect 定位问题。
  • 若一次改动无法拆小(比如大规模重命名),使用专门的 rename commit,不要把重命名和逻辑改动混进同一个提交。

4. 不动公共接口除非必要

规则: 修改对外暴露的函数签名、导出接口、HTTP 端点、数据库字段前,先评估所有下游影响;非必要则保持向后兼容。

为什么: AI 在改内部实现时容易顺手调整函数签名——加个参数、改个返回值类型——觉得"反正我会把调用方也一起改掉"。但老项目里,调用方可能散布在文档里、第三方 SDK 里、甚至客户端的缓存配置里,AI 根本不知道这些存在。常见翻车:把 REST API 的响应字段从 user_id 改成 userId,前端代码全部 undefined,但 AI 只改了后端,以为没问题。

怎么做:

  • 改公共函数前,用 Grep 全局搜索函数名,确认所有调用方都在可控范围内。
  • 若必须修改签名,优先采用兼容性方案:新增可选参数而非改变已有参数、保留旧函数并标注 @deprecated、新旧端点并存一段时间。
  • 数据库字段变更(尤其是重命名、类型变更)单独评估迁移方案,不要在业务逻辑 PR 里夹带。
  • 拿不准下游影响时,向用户明确说明风险,不要默默改掉。

5. 保留并复用既有工具

规则: 优先使用仓库里已有的工具函数、组件、常量,不重复造轮子,不引入同功能的新依赖。

Read the full file on GitHub · 170 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 170 lines · 29 tokens per session scan A ce074d2cfb55

Subscribe to this mod's changes

legacy-safe-edit is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (6 stars, last pushed 2mo ago), licensed MIT. It adds 29 tokens to every session and 2,464 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

chinese-documentation

中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-git-workflow

国内 Git 平台配置参考——Gitee、Coding.net、极狐 GitLab、CNB 的 SSH/HTTPS/凭据/CI 接入差异与镜像同步配置。仅在用户显式 /chinese-git-workflow 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 69 tokens

brainstorming

在任何创造性工作之前必须使用此技能——创建功能、构建组件、添加功能或修改行为。在实现之前先探索用户意图、需求和设计。.

jnMetaCode/superpowers-zh · 40 tokens

chinese-code-review

中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-commit-conventions

中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 65 tokens

mcp-builder

MCP 服务器构建方法论 — 系统化构建生产级 MCP 工具,让 AI 助手连接外部能力.

jnMetaCode/superpowers-zh · 32 tokens