跳到正文
cccskills
免费在 GitHub 公开

pharo-refactor

Refactor messy Pharo code safely through the genie MCP tools, working from the live image (no files). Use for renames, method extraction, moving behavior, or general cleanup of existing code.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md2.6 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Pharo refactor loop (live image, via the genie MCP tools)

Refactoring = change structure without changing behavior. The proof that behavior is unchanged is a green test suite before AND after. All reads and writes go through the genie MCP tools; there are no files. Change code only via define_method / define_class / rename_class / remove_method / eval, and read every change back to confirm it.

Loop

  1. Green baseline. Run run_test on the relevant class/package. If the code you're about to touch has NO test coverage, STOP and write characterization tests first (use the pharo-tdd skill) — you cannot refactor safely without a safety net.

  2. Map impact. Before any rename/move/extract, find every caller and implementor:

    • search_references / search_references_to_class — who uses it
    • search_implementors — who else defines this selector
    • search_methods_like — similar code that may need the same change Make a list. Every item gets updated in this same session.
  3. One small change. Make a single structured edit. Read changed methods back with get_method_source.

  4. Re-test. Run run_test (class, then package). Green → keep going. Red → the trace shows what broke; fix or revert this one step before moving on. Never batch unverified edits.

  5. Repeat steps 3–4 in small increments until the cleanup is complete.

  6. Done. Persist with save_image gated on the test package. Summarize the before/after shape.

Common moves

  • Rename class: use rename_class — it updates every code reference and symbol literal via the refactoring engine. It does NOT touch string literals, so fix stringly-typed names by hand; and in a test that renames a class, refer to the old name as 'Foo' asSymbol, never #Foo, or the test rewrites its own assertion and self-mangles.
  • Remove method: remove_method. Remove class: remove_class.
  • Rename method: install the new selector via define_method, repoint every sender (from search_references), then remove_method the old one.
  • Extract method: add the new helper, call it from the original, re-test.

Rules

  • Behavior-preserving only. If a test changes meaning, that's a feature change — do it under pharo-tdd, not here.
  • Small steps, tests between each. A long unverified refactor is a bug factory.
  • Modern class API only (ShiftClassInstaller / define_class).

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Use when modifying a Genie-backed Pharo project through the live MCP server on localhost:8087; includes project ownership, image read/change/test/save workflow, and first steps for new user projects.

中文简介正在准备中。当前显示原文说明。

KentBeck/SmalltalkGenie202026年7月20日 更新

Rename Pharo methods safely through Genie's `rename_method` MCP refactoring tool. Use when a selector should be renamed while preserving behavior, updating senders and symbol references across the live image, including as one step in larger refactorings such as clarify API names, split responsibilities, or move behavior behind better messages.

中文简介正在准备中。当前显示原文说明。

KentBeck/SmalltalkGenie202026年7月20日 更新

pharo-tdd

免费

Drive a Genie change test-first through the genie MCP tools, working entirely from the live image (no files). Use when adding behavior or fixing a bug in the image — anything where a test should lead.

中文简介正在准备中。当前显示原文说明。

KentBeck/SmalltalkGenie202026年7月20日 更新

Use when reviewing or refactoring code that pulls apart another object's private representation, such as raw limb/byte/slot access, slice constructors, or helper methods that expose internal storage. Guides agents to find representation envy and suggest moving behavior onto the object that owns the representation, using live-image Genie tools when working in Pharo.

中文简介正在准备中。当前显示原文说明。

KentBeck/SmalltalkGenie202026年7月20日 更新

查看 KentBeck 的全部技能

报告此技能的问题