Services Architecture
Overview
The Services layer handles all external integrations - APIs, authentication, analytics, and third-party protocols. This is where Claude Code talks to the outside world.
Shared from "Claude-Code" on Inkdown
The Services layer handles all external integrations - APIs, authentication, analytics, and third-party protocols. This is where Claude Code talks to the outside world.
File: services/api/claude.ts
| Feature | Description |
|---|---|
| Streaming | Real-time token streaming |
| Retry Logic | Exponential backoff on failures |
| Rate Limiting | Handles 429s gracefully |
| Error Categorization | Classifies retryable vs fatal errors |
| Token Tracking | Real-time usage monitoring |
File: services/analytics/growthbook.ts
| Type | Description | Example |
|---|---|---|
| Build-time | Dead code elimination | feature('BRIDGE_MODE') |
| Runtime | Dynamic enablement | isFeatureEnabled('new_ui') |
| User | Per-user gates | isClaudeAISubscriber() |
File: services/oauth/index.ts
File: services/policyLimits/index.ts
Enterprise policy enforcement:
File: services/mcp/client.ts
File: services/lsp/manager.ts
File: services/analytics/index.ts
File: services/api/filesApi.ts
File: services/settingsSync/index.ts
| Category | Examples | Handling |
|---|---|---|
| Network | Timeout, DNS failure | Retry with backoff |
| Auth | 401, token expired | Re-auth prompt |
| Rate Limit | 429, quota exceeded | Wait + retry |
| Server | 500, 503 | Retry limited times |
| Client | 400, 404 | Log and continue |
File: services/vcr.ts
Records and replays API interactions for tests:
Services start only when needed. LSP servers connect on first file open.
If a service fails (e.g., analytics), the app continues.
Network is unreliable. All external calls retry with backoff.
No sensitive data in analytics. Local processing preferred.
Services check GrowthBook before initializing (e.g., bridge mode).