Skip to main content

AI doctor

swiftpatch doctor --ai is a one-shot project analysis that inspects your React Native codebase for OTA readiness issues. It uses Claude to understand context that purely heuristic checks miss — things like "this asset is imported dynamically but not bundled statically," or "Hermes is enabled but metro.config.js is excluding TypeScript."

Quick start

swiftpatch doctor --ai

You'll be prompted for consent before any code is read. Once you confirm, the doctor:

  1. Scans package.json for native dependencies.
  2. Inspects your Metro / Hermes config.
  3. Reads AppDelegate and MainApplication for correct bundle-loader wiring.
  4. Checks asset imports for dynamic vs. static patterns.
  5. Verifies signing-key configuration.
  6. Cross-references the RN version against known compatibility issues.
  7. Streams findings as they're generated.

At the end you get a report with:

  • Pass — things that look good.
  • Warn — things that are probably fine but worth verifying.
  • Fail — things that will break an OTA update.

Non-AI doctor

The plain swiftpatch doctor (no --ai) runs the deterministic subset of checks. Use this in CI — it's fast, deterministic, and doesn't need a Claude API key:

swiftpatch doctor
CheckWhat it verifies
ios-integrationAppDelegate has the SwiftPatchModule.getBundleURL() override.
android-integrationMainApplication has the SwiftPatchModule.getJSBundleFile() override.
deployment-keyYour native config has a deployment key.
signing-key.swiftpatch/keys/private.pem exists.
rn-versionYour React Native version is supported.
hermesHermes is enabled (recommended).
assetsMetro's asset resolver isn't excluding your asset types.

Pass --json for machine-readable output (exit code non-zero on any fail):

swiftpatch doctor --json > doctor.json

When to use AI mode

Use --ai when:

  • You're onboarding a new project and want a thorough audit before first deploy.
  • A deploy succeeded but the OTA update doesn't apply on-device — the AI can correlate your app's code patterns against common asset/bundler issues.
  • You're migrating from CodePush and want a gap analysis.
  • You're debugging a suspected native-JS mismatch.

Don't use --ai when:

  • You're in CI — use swiftpatch doctor --json instead.
  • You're on a cold machine without a Claude API key configured.
  • You need sub-second turnaround — --ai typically takes 10–60 seconds.

Setting up a Claude API key

swiftpatch doctor --ai requires a Claude API key. Three options:

# Option 1 — encrypted local config (recommended for local dev)
swiftpatch config set claudeApiKey sk-ant-xxxxx

# Option 2 — environment variable (CI-friendly)
export SWIFTPATCH_CLAUDE_API_KEY=sk-ant-xxxxx

# Option 3 — Swiftpatch Pro
# Platform-provisioned key. No setup needed — the CLI pulls a short-lived
# token from the Swiftpatch API when you're on a Pro plan.

Get a key from console.anthropic.com. The key is stored encrypted at rest in ~/.swiftpatch/config.

Data and privacy

Before any local data is read or sent:

  1. The CLI shows exactly what data categories will be accessed.
  2. You must explicitly consent (or pass --yes in CI).
  3. Consent can be remembered or revoked at any time:
    swiftpatch config delete aiConsentScopes

No source code is stored by the Swiftpatch AI service. All transmissions are over TLS. Only the categories you consented to (package.json, native config files, Metro config) are read.

Remove your stored API key any time:

swiftpatch config delete claudeApiKey

The CLI has three other local AI commands:

# Generate a changelog from git log between last tag and HEAD
swiftpatch ai explain

# Safety-review your JS/TS changes before deploying OTA
swiftpatch ai review

# Full doctor via the AI path (same as `swiftpatch doctor --ai`)
swiftpatch ai doctor

All three support -y/--yes to skip consent in CI and --json for machine-readable output.

Backend-side AI commands

Some AI features query the Swiftpatch backend (no Claude API key needed):

# Ask free-form questions about your releases and crashes
swiftpatch ai ask "Why did r_abc crash so much more than r_xyz?"

# Get the AI risk assessment for a release
swiftpatch ai risk-score r_abc

# List AI-clustered crash reports
swiftpatch ai crashes -a my-app

# View AI-generated insights
swiftpatch ai insights -a my-app

These use your Swiftpatch authentication — run swiftpatch login first.

Next steps