# code-x-rahul/claude-focus-vscode architecture

> Architecture diagram of the GitHub repository code-x-rahul/claude-focus-vscode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/code-x-rahul/claude-focus-vscode
- Repository: https://github.com/code-x-rahul/claude-focus-vscode

## Overview

Claude Focus is a VS Code extension that installs a Claude Code notification hook, receives its localhost focus request, and brings VS Code forward. The main path is Claude Code → local HTTP endpoint → focus behavior and user notification; users can also set up/remove the hook or trigger focus manually. The sampled implementation places most responsibilities in src/extension.ts, so nodes distinguish runtime responsibilities rather than implying separate modules. Platform-specific behavior and optional Linux helpers are documented, but only the sampled source supports the implementation links shown.

Main entry points: [`src/extension.ts`](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts) (Focus dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hook["Hook management"]
  node_settings[("Claude settings<br/>[extension.ts]")]
  node_hook_ops["Hook setup/removal<br/>[extension.ts]"]
  node_hook_command["Hook command<br/>[extension.ts]"]
end

subgraph group_runtime["Request runtime"]
  node_command_registration["Command registration<br/>[extension.ts]"]
  node_http_server["Local HTTP server<br/>[extension.ts]"]
  node_request_handler["Focus request handler<br/>[extension.ts]"]
end

subgraph group_focus["Focus and alerts"]
  node_focus_dispatch["Focus dispatcher<br/>[extension.ts]"]
  node_vscode_window["VS Code window"]
  node_platform_tools["Platform window tools"]
  node_notifications["User notifications<br/>[extension.ts]"]
  node_linux_helpers["Linux helpers"]
end

node_user(("VS Code user"))
node_claude(("Claude Code"))

node_user -->|"invokes commands"| node_command_registration
node_command_registration -->|"invokes focus"| node_focus_dispatch
node_command_registration -->|"invokes setup/removal"| node_hook_ops
node_hook_ops -->|"reads/writes"| node_settings
node_hook_ops -->|"registers command"| node_hook_command
node_claude -->|"posts notification"| node_http_server
node_hook_command -->|"posts request"| node_http_server
node_http_server -->|"routes request"| node_request_handler
node_request_handler -->|"invokes focus"| node_focus_dispatch
node_focus_dispatch -->|"raises window"| node_vscode_window
node_focus_dispatch -->|"executes platform action"| node_platform_tools
node_focus_dispatch -->|"shows alert"| node_notifications
node_focus_dispatch -.->|"may invoke"| node_linux_helpers
node_notifications -->|"alerts"| node_user

click node_settings "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"
click node_hook_ops "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"
click node_hook_command "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"
click node_command_registration "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"
click node_http_server "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"
click node_request_handler "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"
click node_focus_dispatch "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"
click node_notifications "https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_settings,node_hook_ops,node_hook_command,node_user toneBlue
class node_command_registration,node_http_server,node_request_handler toneAmber
class node_focus_dispatch,node_vscode_window,node_platform_tools,node_notifications,node_linux_helpers toneMint
class node_claude toneIndigo
```

## Components

### Hook management

- [Claude settings](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`
- [Hook setup/removal](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`
- [Hook command](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`

### Request runtime

- [Command registration](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`
- [Local HTTP server](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`
- [Focus request handler](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`

### Focus and alerts

- [Focus dispatcher](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`
- **VS Code window**
- **Platform window tools**
- [User notifications](https://github.com/code-x-rahul/claude-focus-vscode/blob/master/src/extension.ts): `src/extension.ts`
- **Linux helpers**

### Other components

- **VS Code user**
- **Claude Code**

## Connections

- VS Code user → Command registration: invokes commands (evidence: `src/extension.ts`)
- Command registration → Focus dispatcher: invokes focus (evidence: `src/extension.ts`)
- Command registration → Hook setup/removal: invokes setup/removal (evidence: `src/extension.ts`)
- Hook setup/removal → Claude settings: reads/writes (evidence: `src/extension.ts`)
- Hook setup/removal → Hook command: registers command (evidence: `src/extension.ts`)
- Claude Code → Local HTTP server: posts notification (evidence: `README.md`)
- Hook command → Local HTTP server: posts request (evidence: `src/extension.ts`)
- Local HTTP server → Focus request handler: routes request (evidence: `src/extension.ts`)
- Focus request handler → Focus dispatcher: invokes focus (evidence: `src/extension.ts`)
- Focus dispatcher → VS Code window: raises window (evidence: `src/extension.ts`)
- Focus dispatcher → Platform window tools: executes platform action (evidence: `src/extension.ts`)
- Focus dispatcher → User notifications: shows alert (evidence: `src/extension.ts`)
- Focus dispatcher → Linux helpers: may invoke (evidence: `README.md`)
- User notifications → VS Code user: alerts (evidence: `src/extension.ts`)
