swift-clean-errors
Installation
SKILL.md
Swift Clean Errors
Audit and fix error handling in Swift code per Clean Code (Robert Martin), adapted to Swift's error system.
Arguments
The user provided: $ARGUMENTS
If a file path is given — read it. If no arguments — ask the user to paste the code or specify a file.
Checklist to Apply
1. Use throws Instead of Returning Optional or Bool
- Functions that can fail due to an external condition should
throw, not returnnil nilreturn hides the reason for failure; a thrownErrorexplains it
// BAD
func parseJSON(from data: Data) -> User? { ... }