Expert Alamofire decisions for iOS/tvOS: when Alamofire adds value vs URLSession suffices, interceptor chain design trade-offs, retry strategy selection, and certificate pinning considerations. Use when designing network layer, implementing auth token refresh, or choosing between networking approaches. Trigger keywords: Alamofire, URLSession, interceptor, RequestAdapter, RequestRetrier, certificate pinning, Session, network layer, token refresh, retry
View on GitHubKaakati/rails-enterprise-dev
reactree-ios-dev
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/Kaakati/rails-enterprise-dev/blob/main/plugins/reactree-ios-dev/skills/alamofire-patterns/SKILL.md -a claude-code --skill alamofire-patternsInstallation paths:
.claude/skills/alamofire-patterns/# Alamofire Patterns — Expert Decisions
Expert decision frameworks for Alamofire choices. Claude knows Alamofire syntax — this skill provides judgment calls for when Alamofire adds value and how to design interceptor chains.
---
## Decision Trees
### Alamofire vs URLSession
```
What networking features do you need?
├─ Basic REST calls with JSON
│ └─ Modern URLSession is sufficient
│ async/await + Codable works well
│
├─ Complex authentication (token refresh, retry)
│ └─ Alamofire's RequestInterceptor shines
│ Built-in retry coordination
│
├─ Request/Response inspection and modification
│ └─ Does app need centralized logging/metrics?
│ ├─ YES → Alamofire EventMonitor
│ └─ NO → URLSession delegate suffices
│
├─ Certificate pinning
│ └─ Alamofire ServerTrustManager simplifies this
│ But URLSession can do it with delegates
│
└─ Multipart uploads with progress
└─ Alamofire upload API is cleaner
URLSession works but more boilerplate
```
**The trap**: Adding Alamofire for simple apps. If you just need basic GET/POST with JSON, URLSession's async/await API is clean enough and avoids a dependency.
### Interceptor Chain Design
```
What cross-cutting concerns exist?
├─ Just auth token injection
│ └─ Single RequestAdapter
│
├─ Auth + retry on 401
│ └─ Authenticator pattern (Alamofire's built-in)
│ Handles refresh token race conditions
│
├─ Multiple concerns (auth, logging, caching headers)
│ └─ Compositor pattern
│ Interceptor(adapters: [...], retriers: [...])
│
└─ Request modification varies by endpoint
└─ Per-router interceptors
Different Session instances or conditional logic
```
### Retry Strategy Selection
```
What kind of failure?
├─ Auth failure (401)
│ └─ Refresh token and retry once
│ Use Authenticator, not generic retry
│
├─ Transient network error
│ └─ Is request idempotent?
│ ├─ YES → Retry with exponential backoff (3 attempts)
│ └─ NO → Don't retry (may cause duplicates)
│
├─ Server error