Inkdown
Start writing

Claude-Code

62 filesยท4 subfolders

Shared Workspace

Claude-Code
codex

08-services

Shared from "Claude-Code" on Inkdown

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.

Plain text
0000_start_here_index_and_recommended_reading_order.md
0100_project_overview_tech_stack_runtime_modes_and_folder_map.md
0200_startup_flow_entry_points_and_cold_start_sequence.md
0300_codebase_modules_layers_state_models_and_schemas.md
0400_system_architecture_and_design_rationale.md
0500_interactive_repl_request_flow_end_to_end.md
0600_headless_sdk_and_print_mode_request_flow_end_to_end.md
0700_mcp_integration_connection_and_tool_call_flow.md
0800_external_services_sdks_storage_and_local_dependencies.md
0900_environment_variables_settings_feature_flags_and_failure_modes.md
1000_non_obvious_patterns_gotchas_and_debugging_traps.md
1100_full_codebase_file_inventory_grouped_by_directory.md
kimi
00-overview.md
01-entrypoints.md
02-state-management.md
03-query-system.md
04-tools-system.md
05-tasks-system.md
06-ui-components.md
07-bridge-remote.md
08-services.md
09-skills-plugins.md
10-commands.md
11-testing-architecture.md
12-permission-system.md
13-build-system.md
14-ink-internals.md
15-git-internals.md
16-context-compaction.md
17-vim-mode.md
18-mailbox-notifications.md
19-session-persistence.md
20-hooks-system.md
21-error-recovery.md
README.md
qwen
00-overview.md
01-entry-points.md
02-query-engine.md
03-tools-and-tasks.md
04-commands-and-skills.md
05-state-management.md
06-ink-rendering.md
07-bridge-remote.md
08-mcp-services.md
09-services-overview.md
10-multi-agent.md
11-system-prompt-constants.md
12-tool-interface.md
13-memory-system.md
14-buddy-companion.md
15-keybindings.md
16-stop-hooks.md
17-vim-mode.md
18-upstreamproxy.md
19-cost-tracking-history.md
20-contexts-styles-onboarding.md
21-hooks.md
22-screens.md
tweets-explain
claude-code-memory-analysis.md
compact
memory-system
agentic-architecture

Core Services

Anthropic API Service

File: services/api/claude.ts

TypeScript
Key Features
FeatureDescription
StreamingReal-time token streaming
Retry LogicExponential backoff on failures
Rate LimitingHandles 429s gracefully
Error CategorizationClassifies retryable vs fatal errors
Token TrackingReal-time usage monitoring
Error Handling
TypeScript

GrowthBook (Feature Flags)

File: services/analytics/growthbook.ts

TypeScript
Feature Flag Types
TypeDescriptionExample
Build-timeDead code eliminationfeature('BRIDGE_MODE')
RuntimeDynamic enablementisFeatureEnabled('new_ui')
UserPer-user gatesisClaudeAISubscriber()

OAuth & Authentication

File: services/oauth/index.ts

TypeScript
Secure Storage
TypeScript

Policy Limits

File: services/policyLimits/index.ts

Enterprise policy enforcement:

TypeScript

Protocol Services

MCP (Model Context Protocol)

File: services/mcp/client.ts

TypeScript
MCP Architecture
Plain text
LSP (Language Server Protocol)

File: services/lsp/manager.ts

TypeScript

Infrastructure Services

Analytics (PostHog)

File: services/analytics/index.ts

TypeScript
Privacy
  • No file contents sent
  • No user code sent
  • Only metadata (tool names, durations, counts)
  • Opt-out available in settings
Files API

File: services/api/filesApi.ts

TypeScript
Settings Sync

File: services/settingsSync/index.ts

TypeScript

Service Initialization Order

Plain text

Service Configuration

Environment Variables
Bash
Config Files
JSON

Error Handling

Service Error Categories
CategoryExamplesHandling
NetworkTimeout, DNS failureRetry with backoff
Auth401, token expiredRe-auth prompt
Rate Limit429, quota exceededWait + retry
Server500, 503Retry limited times
Client400, 404Log and continue
Retry Decorator
TypeScript

Testing Services

Mock Pattern
TypeScript
VCR Recording

File: services/vcr.ts

Records and replays API interactions for tests:

TypeScript

Key Concepts

1. Lazy Initialization

Services start only when needed. LSP servers connect on first file open.

2. Graceful Degradation

If a service fails (e.g., analytics), the app continues.

3. Retry Everything

Network is unreliable. All external calls retry with backoff.

4. Privacy First

No sensitive data in analytics. Local processing preferred.

5. Feature Gating

Services check GrowthBook before initializing (e.g., bridge mode).


Related Documentation

  • Entrypoints - Service initialization
  • Query System - API service usage
  • Bridge & Remote - Bridge services