How ghuntley/claude-code-source-code-deobfuscation works
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: cli.ts CLI orchestration · manager.ts Authentication manager · client.ts AI client · index.ts Terminal interaction
Components 18
CLI & Interaction
- Application entry
claude-code/src/index.ts - CLI orchestration
claude-code/src/cli.ts - Command dispatch
claude-code/src/commands/register.ts - Terminal interaction · Prompts for input and renders agent results.
claude-code/src/terminal/index.ts
Agent Services
- Authentication manager
claude-code/src/auth/manager.ts - OAuth flow
claude-code/src/auth/oauth.ts - Credential storage
claude-code/src/auth/tokens.ts - Prompt builder
claude-code/src/ai/prompts.ts - AI client · Converts contextual requests into structured agent responses or actions.
claude-code/src/ai/client.ts - Anthropic services
Local Operations
- Codebase analyzer
claude-code/src/codebase/analyzer.ts - File operations
claude-code/src/fileops/index.ts - Filesystem operations
claude-code/src/fs/operations.ts - Command execution · Runs development, test, and git commands in the local repository.
claude-code/src/execution/index.ts
Platform Services
- Configuration policy
claude-code/src/config/schema.ts - Error handling
claude-code/src/errors/console.ts - Telemetry
claude-code/src/telemetry/index.ts - External error reporting
claude-code/src/errors/sentry.ts
Connections 22
- 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