- Home
- Skills
- Kaakati
- Rails Enterprise Dev
- Alamofire Patterns
alamofire-patterns_skill
- Shell
6
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill kaakati/rails-enterprise-dev --skill alamofire-patterns- SKILL.md10.1 KB
Overview
This skill provides expert guidance for choosing and applying Alamofire patterns in iOS/tvOS network layers. It explains when Alamofire adds value over URLSession, how to design interceptor chains, retry strategies, and certificate pinning considerations. Use it to make pragmatic architecture decisions and avoid common security and concurrency traps.
How this skill works
The skill inspects your networking requirements (auth complexity, logging, multipart uploads, pinning) and maps them to recommended approaches: URLSession for simple REST, Alamofire with Authenticator and Interceptor composition for coordinated token refresh and retries. It walks through interceptor composition, retry decision trees, and safe Session and trust manager configuration to enforce connection pooling and validation.
When to use it
- Building a network layer that must coordinate token refresh across concurrent requests
- Deciding between lightweight URLSession or adding Alamofire as a dependency
- Implementing retry policies for idempotent vs non-idempotent operations
- Adding centralized request/response logging, metrics, or multipart upload progress
- Enforcing certificate pinning or custom ServerTrust evaluation in production
Best practices
- Reuse a single Session instance across the app to preserve connection pooling and memory efficiency
- Use Alamofire Authenticator for token refresh coordination — never refresh tokens inside generic retry logic
- Retry only idempotent requests and apply exponential backoff; avoid immediate retries that hammer servers
- Always validate status codes before decoding responses to avoid treating error payloads as success
- Scope endpoint-specific behavior to the Router or per-endpoint configuration, not to a monolithic interceptor
Example use cases
- Implement OAuth token refresh that ensures only one network refresh request while other 401s wait
- Choose URLSession async/await for a simple JSON-only app to avoid adding Alamofire dependency
- Compose adapters for auth, logging, and device headers while stacking retriers for auth and transient network errors
- Configure ServerTrustManager with pinned certificates for production and DisabledTrustEvaluator only in DEBUG builds
- Create a retry policy that retries GET requests with exponential backoff and avoids retrying POST without an idempotency key
FAQ
Prefer URLSession for simple REST work with async/await and Codable; it avoids an extra dependency and is sufficient for basic JSON requests.
How do I prevent multiple simultaneous refresh calls?
Use Alamofire's Authenticator pattern — it coordinates a single refresh and resumes waiting requests instead of allowing multiple refresh calls.