How thjyneg/claude-code-rev works
1. This is a terminal-first Claude Code client, not a web app. The runtime is TypeScript on Bun, with a custom Ink-based terminal UI under src/ink and React components under src/components to render the interactive experience.
2. The top-level application flow starts in src/main.tsx, src/bootstrap-entry.ts, and src/dev-entry.ts, then fans into the CLI entrypoints in src/entrypoints and the command registry in src/commands.ts. The CLI command tree in src/commands/** is the primary user-facing surface.
3. The core conversation engine lives around src/QueryEngine.ts, src/Task.ts, and src/Tool.ts. These files represent the central loop: user input becomes a task/query, the model responds, and tool calls are executed and folded back into the session state.
4. Tool execution is a major subsystem. Concrete tools live in src/tools/** such as Bash, file read/write/edit, web fetch/search, LSP, MCP, task management, and agent spawning. Shared orchestration and streaming happen in src/services/tools, which acts as the execution boundary between model output and side effects.
5. The UI is organized by concern rather than by screen. src/components/messages, src/components/permissions, src/components/tasks, src/components/PromptInput, and src/components/Settings are the main panes/dialog families. These render model turns, permission prompts, background activity, configuration, and status overlays.
6. State management is centralized in src/state, with app-wide state, selectors, and stores feeding both the UI and the tool/query loop. Supporting context providers in src/context and src/components/design-system make cross-cutting concerns like notifications, overlays, modal state, and theming available across the app.
7. Permissions and safety are first-class boundaries. src/hooks/toolPermission, src/utils/permissions, and src/components/permissions/** implement approval flows, rule matching, denial tracking, and mode selection. Tool handlers consult these layers before running potentially destructive shell, filesystem, or computer-use actions.
8. Session and multi-session coordination are split across several paths: src/assistant, src/history.ts, src/remote, src/bridge, src/server, src/ssh, and src/tasks. These modules cover resume/discovery, remote sessions, repl/bridge transport, direct-connect/server coordination, SSH-backed execution, and background task lifecycle.
9. Integrations with Anthropic, plugins, MCP, skills, and LSP are separate subsystems. Network/API access lives in src/services/api and src/services/oauth; plugin loading/validation in src/services/plugins and src/utils/plugins; MCP in src/services/mcp and src/components/mcp; skills in src/skills and src/services/skillSearch; language tooling in src/services/lsp and src/tools/LSPTool.
10. The repo also contains substantial platform-specific and degraded-mode compatibility code. The shims/ directory and src/native-ts, plus helpers under src/utils/computerUse, src/utils/claudeInChrome, and src/utils/teleport, stand in for native modules and private integrations that were not fully recoverable. This is important architecturally because some features are restored through fallbacks rather than original native binaries.
11. Persistent behavior is mostly file- and cache-based, not database-driven. Memory, settings, sessions, permissions, plugin metadata, and task output are stored through utilities in src/utils/* such as sessionStorage, settings, memdir, filePersistence, cachePaths, and secureStorage.
12. Telemetry, analytics, and operational safeguards are separate cross-cutting layers. src/services/analytics, src/utils/telemetry, src/services/internalLogging, and src/services/notifier capture usage, diagnostics, and events, while update, rate-limit, and sleep-prevention code keeps the CLI responsive and within policy.
Main entry points: tools Tool exec · cli.tsx CLI entry · QueryEngine.ts Query engine · components UI panes
Components 22
Runtime & CLI
Bun/TypeScript startup, CLI routing, and command surfaces.
- App start · Primary process entry and bootstrapping.
src/main.tsx - Bootstrap · Startup bootstrap entrypoints.
src/bootstrap-entry.ts - Dev entry · Developer-mode entrypoint.
src/dev-entry.ts - CLI entry · Command-line entry and transport setup.
src/entrypoints/cli.tsx - Commands · Top-level command registry and dispatch.
src/commands.ts - Command tree · User-facing slash-command and CLI command implementations.
src/commands
Terminal UI
Ink shell, React panes, and interactive overlays.
Core Loop
Conversation engine, tasks, and tool orchestration.
- Query engine · Main conversation/task loop around model responses and tool calls.
src/QueryEngine.ts - Task model · Task/session abstractions used by the conversation loop.
src/Task.ts - Tool core · Shared tool interface and execution contracts.
src/Tool.ts - Tool exec · Streaming execution boundary between model output and side effects.
src/services/tools - Shell tools · Bash/PowerShell command execution and filesystem editing tools.
src/tools/BashTool - Content tools · File, grep, glob, notebook, web, and LSP tools.
src/tools/FileReadTool - Agent tools · Subagent, workflow, task, and message tools.
src/tools/AgentTool
Sessions & Remote
Local, remote, SSH, bridge, and resume paths.
- Session net · Resume, remote, bridge, SSH, and direct-connect coordination.
src/assistant - Remote server · Direct-connect server and remote session manager.
src/server
Integrations
API, MCP, plugins, skills, LSP, and computer-use integrations.
- MCP/API · Anthropic/API, OAuth, MCP, plugin, and skill integration layers.
src/services/api
Cross-cutting
State, permissions, persistence, telemetry, and platform compatibility.
- App state · Central app state, selectors, and stores.
src/state - Permissions · Approval rules, denial tracking, and permission prompts.
src/hooks/toolPermission - Fallbacks · Native shims and degraded-mode compatibility for private/native integrations.
shims - Persist & telemetry · File-backed persistence, analytics, logging, and operational safeguards.
src/utils
Connections 25
- App start → Bootstrap: boot · Main startup can route into bootstrap initialization.
- App start → Dev entry: dev · Development startup follows a separate entry path.
- Bootstrap → CLI entry: launch · Bootstrap hands off to CLI runtime setup.
- Dev entry → CLI entry: launch · Dev entry also reaches the CLI runtime.
- CLI entry → Commands: register · CLI wires the command registry.
- Commands → Command tree: dispatch · Command registry dispatches into command implementations.
- CLI entry → Ink shell: render · CLI initializes the terminal UI runtime.
- Ink shell → UI panes: host · Ink hosts the React component tree.
- UI panes → App state: reads/writes · UI panes consume and update global app state.
- Query engine → Task model: creates · The conversation loop materializes tasks and queries.
- Query engine → Tool core: invokes · Model responses are translated into tool calls.
- Tool core → Tool exec: executes · Tool contracts are executed through shared orchestration.
- Tool exec → Shell tools: runs · Shell and filesystem tools are a major execution branch.
- Tool exec → Content tools: runs · Read/search/edit and code-assist tools flow through the executor.
- Tool exec → Agent tools: runs · Subagents, tasks, and workflow tools also run through the executor.
- Permissions → Tool exec: gates · Permission policy gates potentially dangerous tool actions.
- Session net → Remote server: syncs · Session coordination spans remote and direct-connect servers.
- Session net → Query engine: feeds · Resume and remote session state feed the main loop.
- MCP/API → Tool exec: extends · MCP, plugins, skills, and API integrations expand available tools and context.
- Persist & telemetry → App state: stores · State is persisted through file/cache-backed utilities.
- Persist & telemetry → Query engine: observes · Telemetry and logging observe session and tool behavior.
- Fallbacks → Shell tools: adapts · Native shims and fallbacks support shell/computer-use paths.
- Fallbacks → MCP/API: adapts · Fallback modules restore missing native/private integration behavior.
- UI panes → Permissions: prompts · Permission dialogs are surfaced in the terminal UI.
- Command tree → Session net: controls · Commands manage resume, bridge, remote, and SSH workflows.