Exercise 03: Multi-argument Symbol Rename
Create a skill that takes three named arguments and renames a symbol across a specified scope. This exercise focuses on the arguments field, named argument references in the body, and safe find-and-replace logic.
Goal
The skill takes three arguments:
old-name— the current name of the symbolnew-name— the name to replace it withscope— where to search:file,module, orproject
Example invocations:
/rename-symbol MyClass MyService file/rename-symbol getUserById fetchUserById module/rename-symbol legacyConfig appConfig projectWhat to write
The skill must:
- Declare named arguments in frontmatter:
arguments: [old-name, new-name, scope] - Use
$old-name,$new-name, and$scopein the body (not$0,$1,$2) - Set
disable-model-invocation: true— renaming is a side-effect action - Set
argument-hint: [old-name] [new-name] [file|module|project] - Include
allowed-toolsfor the tools it needs (grep, sed, git diff, etc.)
Scope definitions
file: Rename only within the current file or the file explicitly mentioned in the task.
module: Rename within the directory containing the current file and its immediate subdirectories.
project: Rename across the entire project, excluding node_modules/, .git/, dist/, and build/.
Safety requirements
The skill must NOT rename substrings. MyClass must not rename MyClassExtended or loadMyClass. Use word boundary patterns in your grep and sed commands.
The skill must show the user a preview before making any changes, and ask for confirmation.
Validation
Write the skill and test it on a small project:
- Create a file with a symbol used in three places.
- Invoke the skill with
filescope. - Confirm it previews the changes correctly.
- Confirm it does not rename partial matches.
- Confirm
git diffshows only the expected changes after confirmation.
Solution
A worked solution is in solutions/03-rename-symbol/SKILL.md.