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:
- Scans
package.jsonfor native dependencies. - Inspects your Metro / Hermes config.
- Reads
AppDelegateandMainApplicationfor correct bundle-loader wiring. - Checks asset imports for dynamic vs. static patterns.
- Verifies signing-key configuration.
- Cross-references the RN version against known compatibility issues.
- 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
| Check | What it verifies |
|---|---|
ios-integration | AppDelegate has the SwiftPatchModule.getBundleURL() override. |
android-integration | MainApplication has the SwiftPatchModule.getJSBundleFile() override. |
deployment-key | Your native config has a deployment key. |
signing-key | .swiftpatch/keys/private.pem exists. |
rn-version | Your React Native version is supported. |
hermes | Hermes is enabled (recommended). |
assets | Metro'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 --jsoninstead. - You're on a cold machine without a Claude API key configured.
- You need sub-second turnaround —
--aitypically 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:
- The CLI shows exactly what data categories will be accessed.
- You must explicitly consent (or pass
--yesin CI). - 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
Related AI commands
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
- F8 PR agent — turn crash clusters into draft PRs.
- Troubleshooting — the manual equivalents of what the AI doctor checks.
- CLI commands — full command reference.