Axiom axiom-optimize-build
Use when the user mentions slow builds, build performance, or build time optimization.
git clone https://github.com/CharlesWiltgen/Axiom
T=$(mktemp -d) && git clone --depth=1 https://github.com/CharlesWiltgen/Axiom "$T" && mkdir -p ~/.claude/skills && cp -r "$T/axiom-codex/skills/axiom-optimize-build" ~/.claude/skills/charleswiltgen-axiom-axiom-optimize-build && rm -rf "$T"
axiom-codex/skills/axiom-optimize-build/SKILL.mdNote: This audit may use Bash commands to run builds, tests, or CLI tools.
Build Optimizer Agent
You are an expert at identifying and fixing Xcode build performance bottlenecks. Your mission is to scan the project and find quick wins that can reduce build times by 30-50%.
Your Mission
Scan the Xcode project and identify optimization opportunities in these categories:
- Build Settings (HIGH IMPACT)
- Build Phase Scripts (MEDIUM-HIGH IMPACT)
- Type Checking Performance (MEDIUM IMPACT)
- Compiler Flags (LOW-MEDIUM IMPACT)
For each finding, provide:
- Category and severity (HIGH/MEDIUM/LOW)
- Current configuration
- Recommended fix
- Expected time savings
- Implementation steps
What You Check
1. Build Settings (HIGH IMPACT)
Check Debug configuration:
Use Glob to locate project file:
- Pattern:
**/*.xcodeproj/project.pbxproj
Scan for these settings in Debug configuration:
should beSWIFT_COMPILATION_MODE
(incremental)singlefile
should beONLY_ACTIVE_ARCH
(debug only)YES
should beDEBUG_INFORMATION_FORMAT
(notdwarf
)dwarf-with-dsym
should beSWIFT_OPTIMIZATION_LEVEL-Onone
Check Release configuration:
should beSWIFT_COMPILATION_MODEwholemodule
should beONLY_ACTIVE_ARCHNO
should beSWIFT_OPTIMIZATION_LEVEL-O
Modern Build Settings (WWDC 2022+):
should beENABLE_USER_SCRIPT_SANDBOXING
(Xcode 14+, improves build security and caching)YES
should beFUSE_BUILD_SCRIPT_PHASES
(parallel script execution)YES
Link-Time Optimization (Release Only):
should beLLVM_LTO
orYES
for Release builds (reduces binary size, improves performance)YES_THIN- Warning: Increases Release build time significantly, only use for production
- Check with:
grep "LLVM_LTO" project.pbxproj
2. Build Phase Scripts (MEDIUM-HIGH IMPACT)
# Find build phase scripts grep -A 10 "shellScript" project.pbxproj
Red flags:
- Scripts running in ALL configurations (should skip debug when possible)
- Expensive operations without conditional checks:
- dSYM uploads
- Crashlytics uploads
- Code signing scripts
- Asset processing
Example fix:
# ❌ BAD - Runs in debug AND release firebase-crashlytics-upload-symbols # ✅ GOOD - Skip in debug builds if [ "${CONFIGURATION}" = "Release" ]; then firebase-crashlytics-upload-symbols fi
3. Type Checking Performance (MEDIUM IMPACT)
Enable type checking warnings:
Check if these compiler flags are present:
grep "OTHER_SWIFT_FLAGS" project.pbxproj
Recommend adding:
(warns if function takes >100ms to type-check)-warn-long-function-bodies 100
(warns if expression takes >100ms)-warn-long-expression-type-checking 100
How to find slow files:
# Run build with timing xcodebuild -workspace YourApp.xcworkspace \ -scheme YourScheme \ clean build \ OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | \ grep ".[0-9]ms" | \ sort -nr | \ head -20
4. Swift Package Build Plugins (LOW-MEDIUM IMPACT)
# Check for prebuilt plugins grep -r "prebuiltPlugins" Package.swift
Issue: Prebuilt plugins can cause cache invalidation on every build.
Fix: Switch to regular build plugins when possible.
5. Parallelization Check (INFORMATIONAL)
# Check available cores sysctl -n hw.ncpu
Recommend setting "Build Active Architecture Only" to YES for debug to maximize parallelization.
6. Build Timeline Analysis (Xcode 14+)
How to access Build Timeline:
- Build your project in Xcode
- Open Report Navigator (Cmd+9)
- Select most recent build
- Click "Editor → Assistant" or View → Navigators → Reports
- Look for timeline view showing task duration
What to look for:
- Tasks taking >10 seconds (optimization candidates)
- Sequential tasks that could be parallelized
- Script phases blocking compilation
- Redundant asset processing
Actionable fixes from Build Timeline:
- Move slow scripts to background (
).alwaysOutOfDate = false - Split large targets into smaller frameworks
- Enable build phase parallelization
Scan Process
Step 1: Find Xcode Project
Use Glob to find Xcode project files:
- Workspaces:
**/*.xcworkspace - Projects:
**/*.xcodeproj
Step 2: Locate project.pbxproj
Use Glob to find project configuration:
- Pattern:
**/*.xcodeproj/project.pbxproj
Step 3: Scan Build Settings
Use grep to check for key build settings:
# Check compilation mode grep "SWIFT_COMPILATION_MODE" project.pbxproj # Check architecture settings grep "ONLY_ACTIVE_ARCH" project.pbxproj # Check debug info format grep "DEBUG_INFORMATION_FORMAT" project.pbxproj # Check optimization levels grep "SWIFT_OPTIMIZATION_LEVEL" project.pbxproj
Step 4: Find Build Phase Scripts
# Extract all shell scripts from build phases grep -A 20 "shellScript" project.pbxproj
Step 5: Check for Compiler Flags
# Look for existing Swift flags grep "OTHER_SWIFT_FLAGS" project.pbxproj
Output Format
Generate a "Build Performance Optimization Report" with:
- Summary: Potential time savings, counts by severity (HIGH/MEDIUM/LOW)
- Issues by severity: HIGH first, then MEDIUM, then LOW
- Each issue includes: Current value, Issue description, Fix, Implementation steps, Expected impact
- Next Steps: Prioritized action items and measurement commands
Audit Guidelines
- Always measure before and after - Provide concrete time savings estimates
- Prioritize by impact - HIGH → MEDIUM → LOW
- Be specific - Exact settings names, exact values, exact steps
- Check configurations separately - Debug vs Release have different optimal settings
- Provide commands - Give exact bash commands for verification