Install
$ agentstack add skill-josephsanjaya-skills-ktor-expert ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Ktor Expert
Delineate Ktor references, enforce client engine selection guidelines, apply token refresh double-check Mutex structures, mandate client disconnect cancellations, and audit with auditktorcode.py.
Index
Use these references for specific Ktor domains:
- Client architecture, engine selection, connection pool tuning, OAuth2 token refresh, certificate pinning: read [client.md](file:///Users/jsanjaya/.gemini/config/skills/ktor-expert/references/client.md)
- Server setup, Netty tuning, first-party DI, HTMX, typed config mapping, request lifecycle cancellation: read [server.md](file:///Users/jsanjaya/.gemini/config/skills/ktor-expert/references/server.md)
- Testing (MockEngine, testApplication, DI overrides, parallel DB isolation, KMP Bearer Auth pitfalls): read [testing.md](file:///Users/jsanjaya/.gemini/config/skills/ktor-expert/references/testing.md)
Core Guidelines (Terse)
Client Engine Choice
- OkHttp (Android) + Darwin (iOS) for mobile. Handles HTTP/2, system proxy, backgrounding, VPN, ATS.
- CIO for server, CLI, Native (if HTTP/2 not required). Note: CIO client is HTTP/1.x only.
Client Lifecycle
- Create one HttpClient singleton, reuse it, close at app shutdown. Per-request client leaks threads/connections.
Token Refresh
- Use
Authplugin withbearerflow. Single-flight refresh is built-in. - Wrap refresh calls in a coroutine
Mutexwith double-check lock. Mark refresh request withmarkAsRefreshTokenRequest()to prevent infinite loops. - 401 responses must carry
WWW-Authenticate: Bearerto trigger the refresh flow. - Use a separate
HttpClientfor the refresh call to avoid nested engine deadlocks.
Server Lifecycle & Cancellation
- Use
HttpRequestLifecycleplugin (cancelCallOnClose = true) to propagate cancellation on client disconnect (CIO/Netty). - Keep route tasks cooperative: use
ensureActive()or checkisActive.
Configuration
- Use
environment.config.getAs()in Ktor 3.5.0+ to deserialize root ApplicationConfig directly into data classes.
Dependency Injection
- Use first-party
ktor-server-diviadependencies { provide { ... } }to avoid external DI overhead.
Code Examples
- Client setup: [clientsetup.kt](file:///Users/jsanjaya/.gemini/config/skills/ktor-expert/examples/clientsetup.kt)
- Server setup: [serversetup.kt](file:///Users/jsanjaya/.gemini/config/skills/ktor-expert/examples/serversetup.kt)
Static Code Audits
- Run Python validator to inspect codebase for Ktor anti-patterns:
``bash python3 /Users/jsanjaya/.gemini/config/skills/ktor-expert/scripts/audit_ktor_code.py ``
Always verify Ktor client engine target compatibility and enforce the double-checked lock Mutex pattern for authentication. Never install HttpTimeout in MockEngine-backed test clients — it causes deadlocks on KMP native targets during auth retries. Always include WWW-Authenticate: Bearer in 401 mock responses to trigger the Auth plugin refresh flow. Use url.pathSegments (not encodedPath) in sendWithoutRequest for KMP compatibility.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: JosephSanjaya
- Source: JosephSanjaya/skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.