safe-change
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: safe-change
Skill: safe-change
WHAT
是什么
Purpose và context
目的与上下文
- Purpose: sửa code dùng chung (hàm/class/module có nhiều caller) mà không làm gãy caller hiện có.
- Trigger (when to use): Modifying any function, class, or module called from more than one place.
- Non-goals: không refactor tiện tay code kề bên, không viết thêm test ngoài phạm vi task, không tự tìm caller bằng tay thay .
impact-check
- 目的: 修改共享代码(被多个 caller 调用的 function/class/module),且不破坏现有 caller。
- 触发条件(何时使用): 修改任何从不止一个位置调用的 function、class 或 module。
- 非目标: 不顺手 refactor 邻近代码;不在 task 范围之外额外编写 test;不手动查找 caller 来替代 。
impact-check
Mental model
思维模型
symbol dùng chung → impact-check (callers + dependents) → hành vi quan sát được hiện tại → thay đổi tối thiểu → từng caller: tương thích ngược hoặc cập nhật tường minh → test (nếu có) → "Changed X. Verified Y" → verify-before-commit共享 symbol → impact-check(callers + dependents)→ 当前可观察行为(observable behavior)→ 最小变更 → 逐个 caller:保持向后兼容或显式更新 → test(如有)→ "Changed X. Verified Y still works." → verify-before-commitInput và output contract
输入与输出约定
| Field | Required? | Ý nghĩa | |
|---|---|---|---|
| In | symbol/module cần sửa + yêu cầu thay đổi | có | thứ có hơn một caller |
| In | test của module | không | có thì chạy; không có thì ghi rõ trong commit message |
| Out | thay đổi tối thiểu + caller đã xác minh/cập nhật | có | mọi caller từ bước 1 đều được xét |
| Out | câu xác nhận "Changed X. Verified Y still works." | có | rồi gọi |
| Out | | có (trừ khi 0 artifact) | output report |
| 字段 | 是否必需? | 含义 | |
|---|---|---|---|
| In | 需要修改的 symbol/module + 变更要求 | 是 | 存在多个 caller 的对象 |
| In | module 的 test | 否 | 如有则运行;如无则在 commit message 中明确注明 |
| Out | 最小变更 + 已验证/更新的 caller | 是 | 第 1 步中的所有 caller 均已处理 |
| Out | 确认语句 | 是 | 随后调用 |
| Out | | 是(除非为 0 个 artifact) | output report |
Rules và capabilities
规则与能力
- RULE-01 (MUST): Backward compatibility impossible → surface to user before proceeding.
- RULE-02 (MUST): Touch only what task requires — no opportunistic refactoring.
- RULE-03 (MUST): No tests exist → acceptable to note — don't add tests outside task scope.
- Capabilities: truy vấn đồ thị caller/dependent; đọc + sửa code trong phạm vi task; chạy test cục bộ; ghi draft wiki.
- RULE-01 (MUST): 无法保持向后兼容性(backward compatibility)→ 在继续之前向用户说明。
- RULE-02 (MUST): 仅修改 task 要求的内容——不进行顺带 refactor。
- RULE-03 (MUST): 没有 test → 可以明确注明——不要在 task 范围之外添加 test。
- 能力:查询 caller/dependent 图;读取并修改 task 范围内的 code;运行本地 test;编写 wiki draft。
Failure boundaries
失败边界
- Không giữ được tương thích ngược → clarify: dừng, báo user trước khi làm tiếp (RULE-01).
- Test đỏ sau khi sửa → blocked, không sang .
verify-before-commit - Không có test → partial hợp lệ: ghi rõ trong commit message, không tự viết test.
- 无法保持向后兼容性 → clarify:停止,在继续之前告知用户(RULE-01)。
- 修改后 test 失败 → blocked,不得进入 。
verify-before-commit - 没有 test → 可接受 partial 结果:在 commit message 中明确注明,不自行编写 test。
HOW
如何
Main workflow
主工作流
| Step | Type | Inputs | Action | Outputs/exit | Failure/next |
|---|---|---|---|---|---|
| W01 | deterministic | symbol | Chạy skill | danh sách callers + dependents | — |
| W02 | judgment | code hiện tại | Ghi lại hành vi quan sát được (return value, side effect) | baseline hành vi | — |
| W03 | effect | yêu cầu | Thay đổi tối thiểu, không đụng code kề bên | diff | không giữ được tương thích → B01 |
| W04 | judgment | callers W01 | Từng caller: xác minh tương thích ngược hoặc cập nhật tường minh | mọi caller đã xét | — |
| W05 | deterministic | test dir | Tìm test, có thì chạy | rc 0 hoặc ghi chú "no tests" | test đỏ → blocked; không test → B02 |
| W06 | effect | kết quả | Xác nhận + gọi | câu xác nhận + draft | — |
Chi tiết từng bước (nguồn chân lý cho W01–W06):
- Run skill — get list of all callers and dependents.
impact-check - Note current observable behaviour (return values, side effects).
- Make minimal change. Don't touch adjacent code.
- For each caller from step 1: verify backward-compatible or explicitly update caller.
- — if tests exist,
CHECK: ls <test-dir>/*<module>* 2>/dev/null | head -3. If none, note explicitly in commit message.RUN: <test-cmd> - Confirm: "Changed X. Verified Y still works." Then invoke .
verify-before-commit
| 步骤 | 类型 | 输入 | 操作 | 输出/退出 | 失败/下一步 |
|---|---|---|---|---|---|
| W01 | 确定性(deterministic) | symbol | 运行 | callers + dependents 列表 | — |
| W02 | 判断(judgment) | 当前 code | 记录可观察行为(return value、side effect) | 行为 baseline | — |
| W03 | 执行(effect) | 变更要求 | 进行最小变更,不触碰邻近 code | diff | 无法保持向后兼容 → B01 |
| W04 | 判断(judgment) | W01 中的 callers | 逐个验证向后兼容性,或显式更新 caller | 所有 caller 均已处理 | — |
| W05 | 确定性(deterministic) | test dir | 查找 test;如有则运行 | rc 0 或注明 | test 失败 → blocked;没有 test → B02 |
| W06 | 执行(effect) | 结果 | 确认 + 调用 | 确认语句 + draft | — |
Branches
各步骤详情(W01–W06 的权威事实来源):
| ID | Kind | Guard | Hành vi | Skip / failure | Rejoin |
|---|---|---|---|---|---|
| B01 | recovery | không thể giữ backward compatibility | dừng, báo user trước khi làm tiếp | user không duyệt → cancelled | W04 sau khi user duyệt |
| B02 | conditional_required | không có test cho module | ghi rõ "no tests" trong commit message, không viết test mới | — | W06 |
- 运行 skill——获取所有 caller 和 dependent 的列表。
impact-check - 记录当前可观察行为(return values、side effects)。
- 进行最小变更。不要触碰邻近代码。
- 对于第 1 步中的每个 caller:验证其向后兼容性,或显式更新 caller。
- ——如果 test 存在,则执行
CHECK: ls <test-dir>/*<module>* 2>/dev/null | head -3。如果没有,则在 commit message 中明确注明。RUN: <test-cmd> - 确认:,然后调用
"Changed X. Verified Y still works."。verify-before-commit
Validation và stopping
分支
Điều kiện đi tiếp: mọi caller trong danh sách đã được xét, và test (nếu có) rc 0. Dừng ở câu xác nhận + ; không tự refactor thêm.
impact-checkverify-before-commit| ID | 类型 | Guard | 行为 | 跳过/失败 | 汇合点 |
|---|---|---|---|---|---|
| B01 | 恢复(recovery) | 无法保持向后兼容性 | 停止,在继续之前告知用户 | 用户未批准 → cancelled | 用户批准后返回 W04 |
| B02 | 条件必需(conditional_required) | module 没有 test | 在 commit message 中明确写明 | — | W06 |
Examples
验证与停止条件
- Positive: thêm tham số optional vào
timeout=30có 4 caller → impact-check liệt kê 4 caller, cả 4 không truyền tham số nên tương thích → test module xanh → "Changed fetch_page signature. Verified 4 callers still work." → verify-before-commit.fetch_page() - Boundary/failure: đổi kiểu trả về từ dict sang object, 2 caller dùng
get_user()→ không giữ được tương thích → dừng, báo user (B01), chưa sửa caller khi chưa được duyệt.user["id"]
继续条件: 列表中的所有 caller 都已处理,且 test(如有)的 rc 为 0。在确认语句 + 处停止;不得自行进行额外 refactor。
impact-checkverify-before-commitDelivery — Output Report
示例
After all main skill tasks complete, write a propose draft to the wiki.
- 正向示例: 为有 4 个 caller 的 添加可选参数
fetch_page()→timeout=30列出 4 个 caller,4 个均不传该参数,因此向后兼容 → module test 通过 →impact-check→"Changed fetch_page signature. Verified 4 callers still work."。verify-before-commit - 边界/失败: 将 的返回类型从 dict 改为 object,2 个 caller 使用
get_user()→ 无法保持向后兼容 → 停止并告知用户(B01);未获批准前不修改 caller。user["id"]
Steps
交付——Output Report
1. Build the filename:
- Format:
DDMMYY-<ten>.md - = today (e.g.,
DDMMYYfor 2 June 2026)020626 - = 2–4 kebab-case words summarising what was done (e.g.,
<ten>,landing-page-coteccons,brand-kit-fintech)ingest-auth-spec
2. Write :
llmwiki/wiki/sources/draft/DDMMYY-<ten>.md---
type: draft
title: "DDMMYY-<ten>"
status: proposed
tags: [<skill-name>, output-report]
timestamp: YYYY-MM-DD
---所有主 skill task 完成后,向 wiki 写入一份 proposed draft。
DDMMYY-<ten>
步骤
Type: draft
Status: proposed
Tags: <skill-name>, output-report
Proposed: YYYY-MM-DD
1. 构建文件名:
- 格式:
DDMMYY-<ten>.md - = 今天(例如,
DDMMYY表示 2026 年 6 月 2 日)020626 - = 2–4 个概括本次完成内容的 kebab-case 单词(例如,
<ten>、landing-page-coteccons、brand-kit-fintech)ingest-auth-spec
2. 写入 :
llmwiki/wiki/sources/draft/DDMMYY-<ten>.md---
type: draft
title: "DDMMYY-<ten>"
status: proposed
tags: [<skill-name>, output-report]
timestamp: YYYY-MM-DD
---What
DDMMYY-<ten>
<One sentence — what this skill invocation produced or decided>
Type: draft
Status: proposed
Tags: <skill-name>, output-report
Proposed: YYYY-MM-DD
Output
What
<Key artefacts, files created/modified, or decisions made>
<One sentence — what this skill invocation produced or decided>
Files
Output
| File | Action |
|---|---|
| created / modified |
<Key artefacts, files created/modified, or decisions made>
Notes
Files
- Invoked via: skill
/<skill-name>
| File | Action |
|---|---|
| created / modified |
Origin
Notes
- Draft:
wiki/sources/draft/DDMMYY-<ten>.md - Commit: (filled by verify-before-commit)
- Date promoted: (filled by verify-before-commit)
**3. Update wiki index & log:**
- `llmwiki/wiki/index.md` — append one row: `| [DDMMYY-<ten>](sources/draft/DDMMYY-<ten>.md) | draft | YYYY-MM-DD |`
- `llmwiki/wiki/log.md` — append: `## YYYY-MM-DD — <skill-name> — <ten>`
> Skip only when the skill produces zero artefacts and zero decisions (e.g., a pure display mode like `/caveman-stats`).- Invoked via: skill
/<skill-name>
—
Origin
—
- Draft:
wiki/sources/draft/DDMMYY-<ten>.md - Commit: (filled by verify-before-commit)
- Date promoted: (filled by verify-before-commit)
**3. 更新 wiki index 与 log:**
- `llmwiki/wiki/index.md`——追加一行:`| [DDMMYY-<ten>](sources/draft/DDMMYY-<ten>.md) | draft | YYYY-MM-DD |`
- `llmwiki/wiki/log.md`——追加:`## YYYY-MM-DD — <skill-name> — <ten>`
> 仅当 skill 未产出任何 artifact 且未作出任何 decision 时才跳过(例如,`/caveman-stats` 这类纯展示模式)。