dimitriremoiville/cc-mobile/retrofit-networking
Claude Code and agent skill by dimitriremoiville/cc-mobile
- community
Checking that the SKILL.md file is still in the repository.
Project-specific Retrofit + OkHttp + kotlinx.serialization conventions — the `toOutcome(::toDomainError)` rule at the repository boundary, the shared-`OkHttpClient`-with-Coil pattern, debug-only logging, and the `ignoreUnknownKeys = true` rationale. Load when adding or editing any API call, interceptor, or serializer.
Install
npx vskill@latest install dimitriremoiville/cc-mobile/retrofit-networkingSKILL.md
The same SKILL.md was published earlier as dimitriremoiville/cc-mobile/retrofit-networking.
Networking (project delta)
For Retrofit / OkHttp / kotlinx.serialization fundamentals — @GET/@POST annotations, suspend functions, converter factory setup, Interceptor mechanics — read the Retrofit docs and the OkHttp docs. The canonical templates for NetworkModule, SampleApi, and OrderRepositoryImpl live in .claude/skills/android-app-skeleton/references/core-data.md. This file documents only the project's specific decisions.
When this applies
Retrofit + OkHttp + kotlinx.serialization. On an existing app:
- Ktor client (
io.ktor.client.*) → skip; Ktor's plugin model is different. Apply only the principles below: one shared HTTP client with image loading, DTOs separated from domain, error mapping at the repository boundary. - Apollo GraphQL (
com.apollographql.apollo3) → GraphQL types replace REST DTOs; therunCatching → toOutcomewrap still applies. - Moshi or Gson → don't migrate; adapt the converter setup to the existing serializer.
- Retrofit without Hilt → wiring is the same, hand-roll the singleton instead of
@Provides.
The pipeline
Repository boundary — toOutcome(::toDomainError)
The single most important rule in this skill:
- `withContext(io)` in the repository, not the ViewModel. The repository owns its concurrency policy; the VM just launches into
viewModelScope. - `runCatching { ... }.toOutcome(::toDomainError)` — the canonical helpers in
core/data/network/Outcomes.kt.toOutcomerethrowsCancellationException; open-codedrunCatching { ... }.fold(...)swallows it and silently breaks coroutine cancellation. The reviewer flags this every time. - `HttpException` / `IOException` never escape `data/`. They map to
DomainError.Network/Unauthorized/NotFound/Server/UnknowninsidetoDomainError.
Why not Result<T> all the way up? (a) Result.failure requires a Throwable, which forces DomainError to extend Throwable and leaks an exception type into the domain; (b) runCatching swallows CancellationException. toOutcome does both correctly in one place.
Feature-local mapper
When a feature has a custom error envelope (e.g. an OrderConflictException distinct from a 409), pass a feature-local mapper instead of editing the global toDomainError:
Service definitions
Project rules on top of standard Retrofit:
- Always `suspend`. No
Call<T>, noSingle<T>, noObservable<T>. The reviewer flags non-suspend service methods. - Return the DTO directly. Let Retrofit throw
HttpExceptionon non-2xx; the repository catches it. - Typed `@Path`/`@Query`/`@Body`. Avoid
@Body Map<String, Any>— define a typed request class.
DTOs
- Suffix `Dto`, kept in
<feature>/data/remote/. @Serializable(kotlinx.serialization). Use@SerialName("snake_case_name")for fields whose wire name differs from the Kotlin name.- Nullability reflects the wire format, not what the domain wants. Map nullable wire fields to domain defaults in the
toDomain()mapper. - One-way
DtoX.toDomain(): Xmapper colocated with the DTO. Never expose DTOs beyond `data/`. Promote to amapper/package only when several DTOs map to the same domain type.
OkHttp configuration (project shape)
- One `OkHttpClient` singleton shared between Retrofit and Coil. Coil's
OkHttpNetworkFetcherFactory(wired in{{APP_CLASS}}.newImageLoader) reuses this client so any futureAuthInterceptorreaches image requests automatically. - Logging only in `BuildConfig.DEBUG`.
Level.BODYin release would leak PII into Logcat. The scaffold'sNetworkModulealready gates this — don't remove the guard. - Auth header via `Interceptor`, reading from a token store. Never put the token in the URL.
kotlinx.serialization configuration
The Retrofit converter is com.squareup.retrofit2:converter-kotlinx-serialization (Retrofit 2.10+). The older com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter artifact does not export asConverterFactory and is incompatible with the scaffolded NetworkModule. See .claude/skills/android-app-skeleton/references/root-files.md → "Compatibility traps" for the symptom.
Hard nos
- No open-coded `runCatching { ... }.fold(...)` at any data-layer boundary — use
toOutcome(::toDomainError). - No `HttpException` / `IOException` leaking out of `data/`.
- No `Result<T>` in any
domain/interface signature —Outcome<T>only. - No `HttpLoggingInterceptor` at `Level.BODY` reachable in release.
- No Retrofit instance per call. It's a
@Singleton; building it is expensive. - No `Call<T>` / `Single<T>` / `Observable<T>` on Retrofit services —
suspendonly.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingandroid/.claude/skills/retrofit-networking/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dimitriremoiville/cc-mobile/retrofit-networking)