# 0chencc/clawgod architecture

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

- Interactive diagram: https://gitdiagram.com/0chencc/clawgod
- Repository: https://github.com/0chencc/clawgod

## Overview

ClawGod patches the official Claude Code runtime and launches the patched CLI rather than providing a replacement client. The main workflow is: the user launches Claude Code, the ClawGod wrapper loads provider settings and runtime controls, then starts the patched bundle; optional OpenAI-compatible configuration routes API traffic through a translation proxy. The patcher, native-binary extraction, and re-patching support version updates. README capabilities such as feature unlocks, restriction removals, reliability fixes, and Lean Settings are represented at subsystem level. Some update and patcher connections rely on README statements because their source was not fully sampled.

Main entry points: [`src/shared/cli.cjs`](https://github.com/0chencc/clawgod/blob/main/src/shared/cli.cjs) (ClawGod launcher), [`src/shared/patch.mjs`](https://github.com/0chencc/clawgod/blob/main/src/shared/patch.mjs) (Bundle patcher), [`src/shared/extract-natives.mjs`](https://github.com/0chencc/clawgod/blob/main/src/shared/extract-natives.mjs) (Native extraction), [`src/shared/repatch.mjs`](https://github.com/0chencc/clawgod/blob/main/src/shared/repatch.mjs) (Upgrade re-patching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launch["Launch and configuration"]
  node_launcher["ClawGod launcher<br/>[cli.cjs]"]
  node_provider_config["Provider settings<br/>[main.rs]"]
  node_feature_gates["Feature gates<br/>[feature-gates.cjs]"]
  node_runtime_helpers["Runtime helpers"]
end

subgraph group_patching["Runtime patching"]
  node_patch_engine["Bundle patcher<br/>[patch.mjs]"]
  node_native_extract["Native extraction"]
  node_repatch["Upgrade re-patching<br/>[repatch.mjs]"]
  node_post_process["Patch post-processing<br/>[post-process.mjs]"]
  node_patched_bundle["Patched Claude bundle"]
end

subgraph group_features["Runtime features"]
  node_feature_unlocks["Feature and restriction patches<br/>[patch.mjs]"]
  node_lean_settings["Lean Settings<br/>[cli.cjs]"]
  node_renderer_shim["Bun renderer shim<br/>[bun-ant-shim.cjs]"]
end

subgraph group_provider["Provider integration"]
  node_proxy["API translation proxy<br/>[openai-proxy.cjs]"]
  node_provider_tool["Provider setup CLI<br/>[main.rs]"]
end

node_user(("Claude Code user"))
node_official["Official Claude Code"]
node_compatible_api["OpenAI-compatible API"]

node_user -->|"launches"| node_launcher
node_launcher -->|"replaces launcher"| node_official
node_launcher -->|"reads settings"| node_provider_config
node_provider_tool -->|"writes settings"| node_provider_config
node_provider_tool -->|"queries models"| node_compatible_api
node_launcher -->|"loads gates"| node_feature_gates
node_launcher -->|"loads helpers"| node_runtime_helpers
node_launcher -->|"loads shim"| node_renderer_shim
node_launcher -->|"starts proxy"| node_proxy
node_launcher -->|"applies toggles"| node_lean_settings
node_official -->|"provides binary"| node_native_extract
node_native_extract -.->|"supplies bundle"| node_patch_engine
node_patch_engine -->|"patches bundle"| node_patched_bundle
node_patched_bundle -->|"runs as CLI"| node_official
node_repatch -->|"re-extracts on update"| node_native_extract
node_repatch -->|"re-patches on update"| node_patch_engine
node_post_process -.->|"processes output"| node_patched_bundle
node_patched_bundle -->|"enables patched features"| node_feature_unlocks
node_proxy -->|"translates requests"| node_compatible_api

click node_launcher "https://github.com/0chencc/clawgod/blob/main/src/shared/cli.cjs"
click node_provider_config "https://github.com/0chencc/clawgod/blob/main/tools/provider-import/src/main.rs"
click node_feature_gates "https://github.com/0chencc/clawgod/blob/main/src/shared/feature-gates.cjs"
click node_runtime_helpers "https://github.com/0chencc/clawgod/blob/main/src/shared/runtime-helpers.cjs"
click node_patch_engine "https://github.com/0chencc/clawgod/blob/main/src/shared/patch.mjs"
click node_native_extract "https://github.com/0chencc/clawgod/blob/main/src/shared/extract-natives.mjs"
click node_repatch "https://github.com/0chencc/clawgod/blob/main/src/shared/repatch.mjs"
click node_post_process "https://github.com/0chencc/clawgod/blob/main/src/shared/post-process.mjs"
click node_feature_unlocks "https://github.com/0chencc/clawgod/blob/main/src/shared/patch.mjs"
click node_lean_settings "https://github.com/0chencc/clawgod/blob/main/src/shared/cli.cjs"
click node_renderer_shim "https://github.com/0chencc/clawgod/blob/main/src/shared/bun-ant-shim.cjs"
click node_proxy "https://github.com/0chencc/clawgod/blob/main/src/shared/openai-proxy.cjs"
click node_provider_tool "https://github.com/0chencc/clawgod/blob/main/tools/provider-import/src/main.rs"

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_launcher,node_provider_config,node_feature_gates,node_runtime_helpers,node_user toneBlue
class node_patch_engine,node_native_extract,node_repatch,node_post_process,node_patched_bundle toneAmber
class node_feature_unlocks,node_lean_settings,node_renderer_shim,node_compatible_api toneMint
class node_proxy,node_provider_tool toneRose
class node_official toneIndigo
```

## Components

### Launch and configuration

- [ClawGod launcher](https://github.com/0chencc/clawgod/blob/main/src/shared/cli.cjs): `src/shared/cli.cjs`
- [Provider settings](https://github.com/0chencc/clawgod/blob/main/tools/provider-import/src/main.rs): `tools/provider-import/src/main.rs`
- [Feature gates](https://github.com/0chencc/clawgod/blob/main/src/shared/feature-gates.cjs): `src/shared/feature-gates.cjs`
- [Runtime helpers](https://github.com/0chencc/clawgod/blob/main/src/shared/runtime-helpers.cjs): `src/shared/runtime-helpers.cjs`

### Runtime patching

- [Bundle patcher](https://github.com/0chencc/clawgod/blob/main/src/shared/patch.mjs): `src/shared/patch.mjs`
- [Native extraction](https://github.com/0chencc/clawgod/blob/main/src/shared/extract-natives.mjs): `src/shared/extract-natives.mjs`
- [Upgrade re-patching](https://github.com/0chencc/clawgod/blob/main/src/shared/repatch.mjs): `src/shared/repatch.mjs`
- [Patch post-processing](https://github.com/0chencc/clawgod/blob/main/src/shared/post-process.mjs): `src/shared/post-process.mjs`
- **Patched Claude bundle**

### Runtime features

- [Feature and restriction patches](https://github.com/0chencc/clawgod/blob/main/src/shared/patch.mjs): `src/shared/patch.mjs`
- [Lean Settings](https://github.com/0chencc/clawgod/blob/main/src/shared/cli.cjs): `src/shared/cli.cjs`
- [Bun renderer shim](https://github.com/0chencc/clawgod/blob/main/src/shared/bun-ant-shim.cjs): `src/shared/bun-ant-shim.cjs`

### Provider integration

- [API translation proxy](https://github.com/0chencc/clawgod/blob/main/src/shared/openai-proxy.cjs): `src/shared/openai-proxy.cjs`
- [Provider setup CLI](https://github.com/0chencc/clawgod/blob/main/tools/provider-import/src/main.rs): `tools/provider-import/src/main.rs`

### Other components

- **Claude Code user**
- **Official Claude Code**
- **OpenAI-compatible API**

## Connections

- Claude Code user → ClawGod launcher: launches (evidence: `README.md`)
- ClawGod launcher → Official Claude Code: replaces launcher (evidence: `README.md`)
- ClawGod launcher → Provider settings: reads settings (evidence: `src/shared/cli.cjs`)
- Provider setup CLI → Provider settings: writes settings (evidence: `tools/provider-import/src/main.rs`)
- Provider setup CLI → OpenAI-compatible API: queries models (evidence: `tools/provider-import/src/main.rs`)
- ClawGod launcher → Feature gates: loads gates (evidence: `src/shared/cli.cjs`)
- ClawGod launcher → Runtime helpers: loads helpers (evidence: `src/shared/cli.cjs`)
- ClawGod launcher → Bun renderer shim: loads shim (evidence: `src/shared/cli.cjs`)
- ClawGod launcher → API translation proxy: starts proxy (evidence: `src/shared/cli.cjs`)
- ClawGod launcher → Lean Settings: applies toggles (evidence: `src/shared/cli.cjs`)
- Official Claude Code → Native extraction: provides binary (evidence: `README.md`)
- Native extraction → Bundle patcher: supplies bundle
- Bundle patcher → Patched Claude bundle: patches bundle (evidence: `README.md`)
- Patched Claude bundle → Official Claude Code: runs as CLI (evidence: `README.md`)
- Upgrade re-patching → Native extraction: re-extracts on update (evidence: `README.md`)
- Upgrade re-patching → Bundle patcher: re-patches on update (evidence: `README.md`)
- Patch post-processing → Patched Claude bundle: processes output
- Patched Claude bundle → Feature and restriction patches: enables patched features (evidence: `README.md`)
- API translation proxy → OpenAI-compatible API: translates requests (evidence: `src/shared/openai-proxy.cjs`)
