1.9 KiB
description, allowed-tools
| description | allowed-tools | ||||
|---|---|---|---|---|---|
| Format and lint Swift code using swift-format |
|
To keep the codebase clean, execute the following workflow:
Step 1: Check for Periphery
Before formatting and linting, check if Periphery (unused code detector) is available:
-
Run
which peripheryto check if periphery is installed -
If installed, check if the project is configured by looking for:
.periphery.ymlconfiguration file in the project root, OR- An Xcode project/workspace file (
.xcodeprojor.xcworkspace)
-
If periphery is installed AND the project has either a
.periphery.ymlconfig or Xcode project files, use AskUserQuestion to prompt:- Question: "Periphery is available for detecting unused code. Would you like to run it before formatting and linting?"
- Header: "Run Periphery"
- Options:
- "Yes" - "Run periphery scan first to identify unused code"
- "No" - "Skip periphery and proceed with formatting/linting"
-
If user selects "Yes", launch a general-purpose subagent to run
periphery scanand report findings. Wait for it to complete before proceeding.
Step 2: Format and Lint with swift-format
Execute the following workflow using subagents for context isolation:
IMPORTANT: Launch TWO separate subagents sequentially. Do NOT run them in parallel. Formatting often fixes issues that would be flagged by the linter, so linting must happen AFTER formatting is complete.
-
First, launch a general-purpose subagent to run
swift-format format --in-place --recursiveto format all Swift code. Wait for it to complete. -
Then, launch a second general-purpose subagent to run
swift-format lint --recursiveon the project and resolve all remaining lint issues until clean.
Use the Task tool for all subagent steps to keep output isolated from the main agent context.
Report a brief summary of results after all steps are complete.