Full Clean Code audit of Swift code covering all principles. Use when the user asks for a complete clean code review, full audit, or comprehensive refactoring of a Swift file or module.
التثبيت
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Full Clean Code audit of Swift code covering all principles. Use when the user asks for a complete clean code review, full audit, or comprehensive refactoring of a Swift file or module.
argument-hint
["file or directory"]
allowed-tools
["Read","Bash","Edit","Glob","Grep"]
Swift Clean Code — Full Review
Perform a complete Clean Code audit of the provided Swift code, covering all principles from Robert Martin's book adapted to Swift.
Arguments
The user provided: $ARGUMENTS
If a file path is given — read it. If a directory — find all .swift files and audit them. If no arguments — ask the user to specify.
Instructions
Step 1: Discover Files
If a directory: find $ARGUMENTS -name "*.swift" -not -path "*/build/*" -not -path "*/.build/*"
Read each file
Step 2: Run All Checks in Order
For each file, check the following categories:
NAMES (Chapter 2)
No single-letter or cryptic names (except loop indices in trivial loops)
No abbreviations (except id, url, uuid, api)
No noise words: Data, Info, Object, Manager added for nothing
Types in PascalCase; values/functions in camelCase
Booleans read as assertions: is*, has*, can*, should*
Functions named as verb phrases: fetchUser(), validateInput()
One consistent word per concept across the codebase: fetch vs load vs get
Magic numbers extracted to named constants
FUNCTIONS (Chapter 3)
Functions ≤ 20 lines (flag anything over 30)
Each function does one thing
One level of abstraction per function
No more than 2 parameters (3+ → wrap in struct)
No Boolean flag parameters
No side effects hidden in query functions
Command–Query Separation respected
DRY: no duplicated logic (extract repeated blocks)
guard used for early returns
COMMENTS (Chapter 4)
No commented-out dead code
No comments that explain what the code does (rename instead)
After showing the report, ask the user: "Apply all fixes automatically, or review file by file?"
If auto: apply all fixes using Edit tool
If file by file: apply fixes one file at a time and confirm after each
Step 5: Summary
After all fixes:
## Clean Code Audit Summary
- Files reviewed: N
- Critical issues fixed: N
- Major issues fixed: N
- Minor issues fixed: N
- Files that need manual refactoring (structural): [list]