| name | swift-codebase-health |
| description | Use for a retrospective audit of a Swift codebase or target to identify prioritized correctness, architecture, modernization, safety, and performance improvements. It is read-only unless the user requests implementation. |
Swift codebase health
Produce an evidence-backed backlog, not a rewrite manifesto. Inspect broadly enough to find systemic patterns and narrowly enough to keep recommendations actionable.
Workflow
- Establish scope, toolchain, targets, repository rules, recent failures, and what “health” means for this codebase.
- Map modules and dependency direction; identify policy/core, effects, resource ownership, concurrency domains, wire boundaries, tests, and build gates.
- Sample representative code and search for high-risk patterns: unchecked concurrency, raw handles, unsafe pointers, global mutable state, duplicated policy, erased types, unmeasured optimizations, and weak tests.
- Validate candidate findings against call sites, compiler/test output, runtime evidence, or a measured baseline. Do not infer a systemic problem from one unusual line.
- Rank recommendations P0–P4 by user impact, confidence, scope, and leverage. Give each a concrete location, invariant, smallest next action, and proof plan.
- Separate immediate correctness/security work, architectural sequencing, modernization opportunities, and optional performance experiments.
Read references/health-rubric.md for the report shape.
Guardrails
- Do not change code during an audit without explicit implementation scope.
- Do not recommend a language feature because it is new; recommend it when it improves a demonstrated invariant or measured cost.
- Do not call compile success proof of runtime, hardware, security, or protocol behavior.
Completion contract
Deliver scope and evidence, a prioritized backlog, confidence and proof gaps, sequencing dependencies, and explicit “not assessed” areas.