PromptTesting and QAOpen

Xcode MCP prompt tool usage guidelines

xcode-mcp is a skill for developers whose AI assistant has the Xcode MCP tools available. It explains when to reach for those tools and when the standard file and search tools are cheaper, since every Xcode MCP call consumes a lot of tokens.

What it does

Xcode MCP is meant only for build, test, simulator, preview and SourceKit diagnostics, never for file reads, writes or grep. A reference table lists each tool with a token cost, for example XcodeListWindows (low), BuildProject and GetBuildLog (medium), GetTestList (low) and RunAllTests (medium).

How to use it

Keep it loaded while working on an Xcode project so the assistant picks the cheaper tool for each step.

More in Testing and QA and the Business prompt library.

Full text

Front matter
name: xcode-mcp
description: - name: xcode-mcp description: Guidelines for efficient Xcode MCP tool usage. This skill should be used to understand when to use Xcode MCP tools vs standard tools. Xcode MCP consumes many tokens - use only for build, test, simulator, preview, and SourceKit diagnostics. Never use for file read/wri
kind: Prompt

xcode-mcp


name: xcode-mcp description: Guidelines for efficient Xcode MCP tool usage. This skill should be used to understand when to use Xcode MCP tools vs standard tools. Xcode MCP consumes many tokens - use only for build, test, simulator, preview, and SourceKit diagnostics. Never use for file read/write/grep operations. ---

Xcode MCP Usage Guidelines

Xcode MCP tools consume significant tokens. This skill defines when to use Xcode MCP and when to prefer standard tools.

Complete Xcode MCP Tools Reference

Window & Project Management

ToolDescriptionToken Cost
mcp__xcode__XcodeListWindowsList open Xcode windows (get tabIdentifier)Low ✓

Build Operations

ToolDescriptionToken Cost
mcp__xcode__BuildProjectBuild the Xcode projectMedium ✓
mcp__xcode__GetBuildLogGet build log with errors/warningsMedium ✓
mcp__xcode__XcodeListNavigatorIssuesList issues in Issue NavigatorLow ✓

Testing

ToolDescriptionToken Cost
mcp__xcode__GetTestListGet available tests from test planLow ✓
mcp__xcode__RunAllTestsRun all testsMedium
mcp__xcode__RunSomeTestsRun specific tests (preferred)Medium ✓

Preview & Execution

ToolDescriptionToken Cost
mcp__xcode__RenderPreviewRender SwiftUI Preview snapshotMedium ✓
mcp__xcode__ExecuteSnippetExecute code snippet in file contextMedium ✓

Diagnostics

ToolDescriptionToken Cost
mcp__xcode__XcodeRefreshCodeIssuesInFileGet compiler diagnostics for specific fileLow ✓
mcp__ide__getDiagnosticsGet SourceKit diagnostics (all open files)Low ✓

Documentation

ToolDescriptionToken Cost
mcp__xcode__DocumentationSearchSearch Apple Developer DocumentationLow ✓

File Operations (HIGH TOKEN - NEVER USE)

ToolAlternativeWhy
mcp__xcode__XcodeReadRead toolHigh token consumption
mcp__xcode__XcodeWriteWrite toolHigh token consumption
mcp__xcode__XcodeUpdateEdit toolHigh token consumption
mcp__xcode__XcodeGreprg / Grep toolHigh token consumption
mcp__xcode__XcodeGlobGlob toolHigh token consumption
mcp__xcode__XcodeLSls commandHigh token consumption
mcp__xcode__XcodeRMrm commandHigh token consumption
mcp__xcode__XcodeMakeDirmkdir commandHigh token consumption
mcp__xcode__XcodeMVmv commandHigh token consumption

Recommended Workflows

1. Code Change & Build Flow

1. Search code      → rg "pattern" --type swift
2. Read file        → Read tool
3. Edit file        → Edit tool
4. Syntax check     → mcp__ide__getDiagnostics
5. Build            → mcp__xcode__BuildProject
6. Check errors     → mcp__xcode__GetBuildLog (if build fails)

2. Test Writing & Running Flow

1. Read test file   → Read tool
2. Write/edit test  → Edit tool
3. Get test list    → mcp__xcode__GetTestList
4. Run tests        → mcp__xcode__RunSomeTests (specific tests)
5. Check results    → Review test output

3. SwiftUI Preview Flow

1. Edit view        → Edit tool
2. Render preview   → mcp__xcode__RenderPreview
3. Iterate          → Repeat as needed

4. Debug Flow

1. Check diagnostics → mcp__ide__getDiagnostics (quick syntax check)
2. Build project     → mcp__xcode__BuildProject
3. Get build log     → mcp__xcode__GetBuildLog (severity: error)
4. Fix issues        → Edit tool
5. Rebuild           → mcp__xcode__BuildProject

5. Documentation Search

1. Search docs       → mcp__xcode__DocumentationSearch
2. Review results    → Use information in implementation

Fallback Commands (When MCP Unavailable)

If Xcode MCP is disconnected or unavailable, use these xcodebuild commands:

Build Commands

# Debug build (simulator) - replace <SchemeName> with your project's scheme
xcodebuild -scheme <SchemeName> -configuration Debug -sdk iphonesimulator build

# Release build (device)
xcodebuild -scheme <SchemeName> -configuration Release -sdk iphoneos build

# Build with workspace (for CocoaPods projects)
xcodebuild -workspace <ProjectName>.xcworkspace -scheme <SchemeName> -configuration Debug -sdk iphonesimulator build

# Build with project file
xcodebuild -project <ProjectName>.xcodeproj -scheme <SchemeName> -configuration Debug -sdk iphonesimulator build

# List available schemes
xcodebuild -list

Test Commands

# Run all tests
xcodebuild test -scheme <SchemeName> -sdk iphonesimulator \
  -destination "platform=iOS Simulator,name=iPhone 16" \
  -configuration Debug

# Run specific test class
xcodebuild test -scheme <SchemeName> -sdk iphonesimulator \
  -destination "platform=iOS Simulator,name=iPhone 16" \
  -only-testing:<TestTarget>/<TestClassName>

# Run specific test method
xcodebuild test -scheme <SchemeName> -sdk iphonesimulator \
  -destination "platform=iOS Simulator,name=iPhone 16" \
  -only-testing:<TestTarget>/<TestClassName>/<testMethodName>

# Run with code coverage
xcodebuild test -scheme <SchemeName> -sdk iphonesimulator \
  -configuration Debug -enableCodeCoverage YES

# List available simulators
xcrun simctl list devices available

Clean Build

xcodebuild clean -scheme <SchemeName>

Quick Reference

USE Xcode MCP For:

  • ✅ BuildProject - Building
  • ✅ GetBuildLog - Build errors
  • ✅ RunSomeTests - Running specific tests
  • ✅ GetTestList - Listing tests
  • ✅ RenderPreview - SwiftUI previews
  • ✅ ExecuteSnippet - Code execution
  • ✅ DocumentationSearch - Apple docs
  • ✅ XcodeListWindows - Get tabIdentifier
  • ✅ mcp__ide__getDiagnostics - SourceKit errors

NEVER USE Xcode MCP For:

  • ❌ XcodeRead → Use Read tool
  • ❌ XcodeWrite → Use Write tool
  • ❌ XcodeUpdate → Use Edit tool
  • ❌ XcodeGrep → Use rg or Grep tool
  • ❌ XcodeGlob → Use Glob tool
  • ❌ XcodeLS → Use ls command
  • ❌ File operations → Use standard tools

Token Efficiency Summary

OperationBest ChoiceToken Impact
Quick syntax checkmcp__ide__getDiagnostics🟢 Low
Full buildmcp__xcode__BuildProject🟡 Medium
Run specific testsmcp__xcode__RunSomeTests🟡 Medium
Run all testsmcp__xcode__RunAllTests🟠 High
Read fileRead tool🟠 High
Edit fileEdit tool🟠 High
Search coderg / Grep🟢 Low
List filesls / Glob🟢 Low

Contributor: ilkerulusoy

Source and license

Source: https://github.com/f/prompts.chat/blob/main/prompts/01143.md

Author: f, prompts.chat prompt library. License: CC0-1.0.

Shown here with formatting for the web. Keep the author and license notice when you reuse it.

Related entries

There are more like this in the members library

The Business prompt library holds 3,008 entries. Members can search all of them by meaning and read every one in full.