# ghuntley/claude-code-source-code-deobfuscation architecture

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

- Interactive diagram: https://gitdiagram.com/ghuntley/claude-code-source-code-deobfuscation
- Repository: https://github.com/ghuntley/claude-code-source-code-deobfuscation

## Overview

#### Purpose and Runtime

This repository is a TypeScript cleanroom implementation of Claude Code: a terminal-resident agentic coding assistant. It accepts natural-language requests, inspects and changes a local repository, executes development commands, and delegates reasoning to Anthropic-backed AI services. The distributable package is rooted at `claude-code/package.json`; the TypeScript runtime is configured by `claude-code/tsconfig.json`.

#### Process Entry and CLI Surface

The executable application starts through `claude-code/src/index.ts`, with command-line orchestration in `claude-code/src/cli.ts`. Command registration and dispatch are centralized in `claude-code/src/commands/register.ts` and `claude-code/src/commands/index.ts`. This is the primary control boundary between shell invocation, interactive commands, and agent workflows.

#### Authentication and Service Access

Authentication is isolated under `claude-code/src/auth/`. `claude-code/src/auth/manager.ts` coordinates session state, `claude-code/src/auth/oauth.ts` handles the one-time OAuth flow, and `claude-code/src/auth/tokens.ts` persists or manages credentials. This layer gates access to Anthropic services and keeps identity/token concerns outside CLI and agent logic.

#### AI Agent Boundary

`claude-code/src/ai/client.ts` is the likely transport-facing AI client, while `claude-code/src/ai/prompts.ts` defines the context/instruction material provided to the model. `claude-code/src/ai/types.ts` establishes contracts between model interaction and the rest of the application. The key flow is: user request plus repository/terminal context → prompt/model client → structured agent response or requested actions.

#### Local Codebase and File Operations

Repository understanding is handled by `claude-code/src/codebase/analyzer.ts`, exposed through `claude-code/src/codebase/index.ts`. Local mutations and filesystem access are separated into `claude-code/src/fileops/index.ts` and `claude-code/src/fs/operations.ts`. This establishes an important boundary: AI planning may request inspection or edits, but local repository reads/writes pass through dedicated codebase and filesystem layers.

#### Execution and Terminal Interaction

`claude-code/src/execution/index.ts` represents command/process execution for tasks such as tests, linting, git operations, and other developer commands. Terminal-facing interaction is owned by `claude-code/src/terminal/prompt.ts`, `claude-code/src/terminal/formatting.ts`, and `claude-code/src/terminal/index.ts`. The operational loop is interactive prompt → command/AI orchestration → filesystem or shell action → formatted output and next prompt.

#### Cross-Cutting Policy, Failure, and Observability

Configuration defaults and validation schema reside in `claude-code/src/config/defaults.ts` and `claude-code/src/config/schema.ts`, providing application-wide behavior constraints. Errors are normalized and rendered through `claude-code/src/errors/formatter.ts` and `claude-code/src/errors/console.ts`, with external reporting indicated by `claude-code/src/errors/sentry.ts`. Telemetry is separately exposed through `claude-code/src/telemetry/index.ts`, reflecting the product’s feedback/usage collection boundary.

#### Supporting Contracts

Shared asynchronous, validation, logging, formatting, and type utilities live in `claude-code/src/utils/`. Product-level behavioral expectations and integration context are documented in `specs/architecture.md`, `specs/integration.md`, and `specs/features.md`; these are useful references for reconstructing intended interactions between the CLI, AI service, local execution, and feedback systems.

Main entry points: [`claude-code/src/cli.ts`](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/cli.ts) (CLI orchestration), [`claude-code/src/auth/manager.ts`](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/auth/manager.ts) (Authentication manager), [`claude-code/src/ai/client.ts`](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/ai/client.ts) (AI client), [`claude-code/src/terminal/index.ts`](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/terminal/index.ts) (Terminal interaction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI &amp; Interaction"]
  node_entry["Application entry<br/>TypeScript entrypoint<br/>[index.ts]"]
  node_cli["CLI orchestration<br/>CLI runtime<br/>[cli.ts]"]
  node_commands["Command dispatch<br/>command registry<br/>[register.ts]"]
  node_terminal["Terminal interaction<br/>interactive UI<br/>[index.ts]"]
end

subgraph group_agent["Agent Services"]
  node_auth["Authentication manager<br/>session coordinator<br/>[manager.ts]"]
  node_oauth["OAuth flow<br/>identity flow<br/>[oauth.ts]"]
  node_tokens["Credential storage<br/>token manager<br/>[tokens.ts]"]
  node_prompts["Prompt builder<br/>AI context<br/>[prompts.ts]"]
  node_ai_client["AI client<br/>model transport<br/>[client.ts]"]
  node_anthropic{{"Anthropic services<br/>external AI API"}}
end

subgraph group_local["Local Operations"]
  node_codebase["Codebase analyzer<br/>repository analysis<br/>[analyzer.ts]"]
  node_fileops["File operations<br/>mutation facade<br/>[index.ts]"]
  node_filesystem["Filesystem operations<br/>local I/O<br/>[operations.ts]"]
  node_execution["Command execution<br/>process runner<br/>[index.ts]"]
end

subgraph group_platform["Platform Services"]
  node_config["Configuration policy<br/>defaults and schema<br/>[schema.ts]"]
  node_errors["Error handling<br/>failure rendering<br/>[console.ts]"]
  node_telemetry["Telemetry<br/>usage reporting<br/>[index.ts]"]
  node_sentry{{"External error reporting<br/>observability sink<br/>[sentry.ts]"}}
end

node_entry -->|"starts"| node_cli
node_cli -->|"registers and dispatches"| node_commands
node_cli -->|"drives session"| node_terminal
node_terminal -->|"user requests"| node_cli
node_cli -->|"requires access"| node_auth
node_auth -->|"initiates login"| node_oauth
node_auth -->|"reads and persists"| node_tokens
node_cli -->|"inspects repository"| node_codebase
node_cli -->|"builds agent context"| node_prompts
node_codebase -->|"repository context"| node_prompts
node_prompts -->|"model request"| node_ai_client
node_auth -->|"authorizes"| node_ai_client
node_ai_client -->|"API calls"| node_anthropic
node_ai_client -->|"actions and responses"| node_cli
node_cli -->|"requested edits"| node_fileops
node_fileops -->|"local reads and writes"| node_filesystem
node_cli -->|"runs commands"| node_execution
node_cli -->|"formatted results"| node_terminal
node_config -.->|"runtime policy"| node_cli
node_cli -->|"normalized failures"| node_errors
node_errors -.->|"reports external failures"| node_sentry
node_cli -.->|"usage events"| node_telemetry

click node_entry "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/index.ts"
click node_cli "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/cli.ts"
click node_commands "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/commands/register.ts"
click node_terminal "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/terminal/index.ts"
click node_auth "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/auth/manager.ts"
click node_oauth "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/auth/oauth.ts"
click node_tokens "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/auth/tokens.ts"
click node_prompts "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/ai/prompts.ts"
click node_ai_client "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/ai/client.ts"
click node_codebase "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/codebase/analyzer.ts"
click node_fileops "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/fileops/index.ts"
click node_filesystem "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/fs/operations.ts"
click node_execution "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/execution/index.ts"
click node_config "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/config/schema.ts"
click node_errors "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/errors/console.ts"
click node_telemetry "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/telemetry/index.ts"
click node_sentry "https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/errors/sentry.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_entry,node_cli,node_commands,node_terminal toneBlue
class node_auth,node_oauth,node_tokens,node_prompts,node_ai_client,node_anthropic toneAmber
class node_codebase,node_fileops,node_filesystem,node_execution toneMint
class node_config,node_errors,node_telemetry,node_sentry toneRose
```

## Components

### CLI & Interaction

- [Application entry](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/index.ts): TypeScript entrypoint · `claude-code/src/index.ts`
- [CLI orchestration](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/cli.ts): CLI runtime · `claude-code/src/cli.ts`
- [Command dispatch](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/commands/register.ts): command registry · `claude-code/src/commands/register.ts`
- [Terminal interaction](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/terminal/index.ts): interactive UI · Prompts for input and renders agent results. · `claude-code/src/terminal/index.ts`

### Agent Services

- [Authentication manager](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/auth/manager.ts): session coordinator · `claude-code/src/auth/manager.ts`
- [OAuth flow](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/auth/oauth.ts): identity flow · `claude-code/src/auth/oauth.ts`
- [Credential storage](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/auth/tokens.ts): token manager · `claude-code/src/auth/tokens.ts`
- [Prompt builder](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/ai/prompts.ts): AI context · `claude-code/src/ai/prompts.ts`
- [AI client](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/ai/client.ts): model transport · Converts contextual requests into structured agent responses or actions. · `claude-code/src/ai/client.ts`
- **Anthropic services**: external AI API

### Local Operations

- [Codebase analyzer](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/codebase/analyzer.ts): repository analysis · `claude-code/src/codebase/analyzer.ts`
- [File operations](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/fileops/index.ts): mutation facade · `claude-code/src/fileops/index.ts`
- [Filesystem operations](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/fs/operations.ts): local I/O · `claude-code/src/fs/operations.ts`
- [Command execution](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/execution/index.ts): process runner · Runs development, test, and git commands in the local repository. · `claude-code/src/execution/index.ts`

### Platform Services

- [Configuration policy](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/config/schema.ts): defaults and schema · `claude-code/src/config/schema.ts`
- [Error handling](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/errors/console.ts): failure rendering · `claude-code/src/errors/console.ts`
- [Telemetry](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/telemetry/index.ts): usage reporting · `claude-code/src/telemetry/index.ts`
- [External error reporting](https://github.com/ghuntley/claude-code-source-code-deobfuscation/blob/main/claude-code/src/errors/sentry.ts): observability sink · `claude-code/src/errors/sentry.ts`

## Connections

- Application entry → CLI orchestration: starts
- CLI orchestration → Command dispatch: registers and dispatches
- CLI orchestration → Terminal interaction: drives session
- Terminal interaction → CLI orchestration: user requests
- CLI orchestration → Authentication manager: requires access
- Authentication manager → OAuth flow: initiates login
- Authentication manager → Credential storage: reads and persists
- CLI orchestration → Codebase analyzer: inspects repository
- CLI orchestration → Prompt builder: builds agent context
- Codebase analyzer → Prompt builder: repository context
- Prompt builder → AI client: model request
- Authentication manager → AI client: authorizes
- AI client → Anthropic services: API calls
- AI client → CLI orchestration: actions and responses
- CLI orchestration → File operations: requested edits
- File operations → Filesystem operations: local reads and writes
- CLI orchestration → Command execution: runs commands
- CLI orchestration → Terminal interaction: formatted results
- Configuration policy → CLI orchestration: runtime policy
- CLI orchestration → Error handling: normalized failures
- Error handling → External error reporting: reports external failures
- CLI orchestration → Telemetry: usage events
