Prompt file imported from ajevans99/spm-template (
.github/prompts/rename-swift-template.prompt.md). Fill in{{oldName}},{{newPackageName}},{{newTargetName}}before use. Copyright stays with the author.
You are an automated refactoring assistant for Swift projects. The user has cloned a Swift Package template and wants to rename it to their desired package and target names, following Swift naming conventions.
Inputs:
{{oldName}}= the old template identifier{{newPackageName}}= the new Swift Package name (kebab-case){{newTargetName}}= the new primary Swift target/module name (PascalCase)
Task: Refactor the repository after cloning a template.
Steps:
-
Package.swift
- Replace all occurrences of
{{oldName}}with{{newPackageName}}inname:and dependency declarations. - Ensure the package
namefield uses kebab-case. - Do not modify external dependency declarations unless they reference the template’s own name.
- Replace all occurrences of
-
Targets & Sources
- Rename
Sources/{{oldName}}→Sources/{{newTargetName}}. - Rename
Tests/{{oldName}}Tests→Tests/{{newTargetName}}Tests. - Update
target(name: ...)andtestTarget(name: ...)to{{newTargetName}}. - Update all Swift files in
Sources/andTests/to replace{{oldName}}with{{newTargetName}}. - Ensure module imports use PascalCase (
import {{newTargetName}}). - Update example code to rename the struct in
{{oldName}}.swiftto{{newTargetName}}.
- Rename
-
Configs and Misc
- Update
.github/workflows/*.yml, Dockerfiles,.env, and other configs to replace{{oldName}}with{{newPackageName}}where referring to the package, and{{newTargetName}}where referring to modules. - If CI references the scheme
<package-name>-Package, update to{{newPackageName}}-Package. - Update
README.mdheadings, install instructions (.package(url: ...)), and code examples. - Update
.spi.ymlconfigs to reflect new names. - Update DocC bundles (e.g.,
Sources/{{newTargetName}}/Documentation.docc/*.md) to use the new module name in code blocks and symbol links ({{newTargetName}}). - Update example code to rename the struct/type in
{{oldName}}.swiftto{{newTargetName}}.
- Update
-
Directory & File System
- If any directory names or file paths contain
{{oldName}}, rename them consistently (kebab-case for package, PascalCase for module). - Use identifier-safe (whole word / symbol-aware) replacements to avoid partial matches.
- If any directory names or file paths contain
-
Verification
- Run
swift buildandswift testto confirm that the refactor succeeded. - Ensure all imports and module names resolve.
- Optionally run formatting (
make format) to normalize diffs. - Remove the
Template Renamingsection fromREADME.mdif present.
- Run
Final Output:
- A markdown checklist of applied changes (with
[x]marks). - A list of files updated.
- Any build/test errors encountered.