cc-mirror
repository·main·Indexed 24 days ago
https://github.com/numman-ali/cc-mirrorAn opinionated provider-native coding distribution that creates isolated runtime instances for different AI providers such as Kimi, MiniMax, Z.ai, OpenRouter, Vercel, Ollama, NanoGPT, and GatewayZ. It automates the configuration of endpoints, model slots, and prompt packs to provide a plug-and-play coding environment. Version 2.2.3 supports custom providers, tweakcc theming, and version tracking (stable, latest, or pinned) for the native runtime.
What's inside cc-mirror
- CC-MIRROR is a tool designed to create multiple isolated coding variants using custom providers. It allows developers to switch between different LLM providers (such as Kimi, Minimax, Zai, OpenRouter, etc.) to create specialized coding environments with specific models, authentication modes, and prompt packs.
How CC-MIRROR works: System Overview
mainCC-MIRROR operates through a three-tier architecture:
- CLI / TUI: The user interface layer (Command Line Interface or Terminal User Interface) where users issue commands.
- Core Engine: The central logic that manages Providers (templates for different AI services) and Brands (visual theme presets).
- Variant Directory: The persistent storage layer located at
~/.cc-mirror/<name>/. This directory contains the configuration and files for a specific variant.
The engine generates a Shell Wrapper in a binary directory (defaulting to
~/.local/binon macOS/Linux or~/.cc-mirror/binon Windows) which points to the native Claude Code binary, allowing users to interact with their configured variant directly via the terminal.Understand the Variant Directory Structure
mainEach CC-MIRROR variant is stored in a dedicated directory under
~/.cc-mirror/<variant>/. This directory contains the native Claude Code installation, configuration files, and customization settings.Directory Layout:
native/: Contains theclaudebinary.config/: TheCLAUDE_CONFIG_DIR. Containssettings.json(environment variables like API keys and base URLs) and.claude.json(MCP servers, approvals, and onboarding).tweakcc/: Configuration for UI and theme customization viatweakcc. Includesconfig.jsonandsystem-prompts/for prompt pack overlays.variant.json: Metadata describing the specific variant.- Wrapper: A shell script located in your
<bin-dir>/that allows you to run the variant as a standalone command.
┌─────────────────────────────────────────────────────────────────────────────┐ │ │ │ ~/.cc-mirror/<variant>/ │ │ │ │ ├── native/ Claude Code native installation │ │ │ ├── claude Claude Code binary │ │ │ │ │ ├── config/ CLAUDE_CONFIG_DIR │ │ │ ├── settings.json Env vars (API keys, base URLs) │ │ │ ├── .claude.json MCP servers, approvals, onboarding │ │ │ │ │ ├── tweakcc/ tweakcc configuration │ │ │ ├── config.json Theme and UI customization │ │ │ ├── cli.js.backup tweakcc-managed backup │ │ │ └── system-prompts/ Prompt pack overlays │ │ │ │ │ └── variant.json Variant metadata │ │ │ │ Wrapper: <bin-dir>/<variant> Shell wrapper script │ │ │ └─────────────────────────────────────────────────────────────────────────────┘The Variant Lifecycle: Create and Update flows
mainCC-MIRROR manages the lifecycle of a 'variant' (a specific configuration of a provider and brand) through two primary automated flows:
Create Flow
When running
npx cc-mirror create, the engine performs the following steps:- Parse Args: Processes
--provider,--name, and--api-key. - Resolve Provider: Fetches the template from the provider registry.
- Build Steps:
PrepareDirectoriesStep: Creates~/.cc-mirror/<name>/.InstallNativeStep: Downloads and verifies the native Claude Code binary.WriteConfigStep: Writessettings.jsonand.claude.json.BrandThemeStep: Writestweakcc/config.json.TweakccStep: Applies customizations viatweakcc.WrapperStep: Creates the executable in the<bin-dir>/<name>.ShellEnvStep: (Optional) Updates shell profile environment variables.SkillInstallStep: (Optional) Installs dev-browser skills.FinalizeStep: Writesvariant.jsonmetadata.
Update Flow
When running
npx cc-mirror update <name>, the engine reads the existingvariant.jsonand executes these steps:- RebuildUpdateStep: Resets
claude/tweakccdirectories while preserving configuration. - InstallNativeUpdateStep: Re-verifies the native Claude Code binary.
- ModelOverridesStep: Updates model mappings.
- TweakccUpdateStep: Re-applies the chosen theme.
- WrapperUpdateStep: Regenerates the shell wrapper script.
- ConfigUpdateStep: Updates
settings.json. - ShellEnvUpdateStep: Updates shell environment integration.
- SkillInstallUpdateStep: Updates installed skills.
- FinalizeUpdateStep: Updates the
variant.jsonmetadata.
- Parse Args: Processes
How cc-mirror uses tweakcc for patching
maincc-mirror integrates
tweakccto customize Claude Code variants. It manages configuration and system prompts in specific directories for each variant and applies patches to the native Claude Code binary.Configuration Locations
- tweakcc config:
~/.cc-mirror/<variant>/tweakcc/config.json - system prompts:
~/.cc-mirror/<variant>/tweakcc/system-prompts/ - Claude settings:
~/.cc-mirror/<variant>/config/settings.json(used forpermissions.denyto enforce tool restrictions)
Patching Behavior
- cc-mirror applies
tweakccpatches automatically during creation or updates, unless the--no-tweakflag is used. - To re-apply patches to an existing variant without a full reinstallation, use:
npx cc-mirror apply <variant> - cc-mirror pins a specific
tweakccversion for reproducibility, but will retry withtweakcc@latestif it cannot extract a newer Claude Code native binary.
- tweakcc config:
How the cc-mirror Provider System works
maincc-mirror uses a template-based system to model each provider. A provider template defines the core connectivity and behavior for a specific service, including its base URL, auth mode, default model slots (Primary/Balanced/Fast), and UI elements like variant wrapper splash and labels.
This system ensures predictable provider wiring while allowing users to override any setting via
settings.json.Key architectural locations:
- Provider definitions:
src/providers/index.ts - Brand presets (tweakcc config):
src/brands/*.ts - Brand resolution:
src/brands/index.ts - Prompt-pack overlays:
src/core/prompt-pack/providers/
- Provider definitions:
Configure MCP Servers for a Variant
mainEach CC-MIRROR variant maintains its own isolated Claude Code configuration. To add MCP (Model Context Protocol) servers that apply specifically to one variant, you must edit the configuration file located at:
~/.cc-mirror/<variant>/config/.claude.jsonCC-MIRROR will preserve your manually added MCP servers during updates, while automatically managing provider-managed servers.
Understand Mirror Claude variant structure and environment
mainWhen you create a Mirror Claude variant,
cc-mirrorsets up an isolated directory structure to ensure configurations (like MCP servers and approvals) do not interfere with your main Claude Code installation.Directory Structure
Variants are stored in
~/.cc-mirror/<variant-name>/:native/: The Claude Code installation.config/: Containssettings.json(minimal env) and.claude.json(MCP servers, approvals).tweakcc/: Containsconfig.jsonfor the Mirror theme.variant.json: Metadata for the variant.- Wrapper: Located in your system's bin directory (e.g.,
~/.local/binon macOS/Linux or~/.cc-mirror/binon Windows).
Environment Variables Set by Mirror
Mirror Claude automatically injects the following environment variables:
CC_MIRROR_SPLASH:1CC_MIRROR_PROVIDER_LABEL:Mirror ClaudeCC_MIRROR_SPLASH_STYLE:mirrorDISABLE_AUTOUPDATER:1
How environment variables are built for variants
maincc-mirror constructs the environment for each variant and writes it to
~/.cc-mirror/<variant>/config/settings.json.The build process follows this precedence:
- Start with the provider's default
env. - Apply
authandbaseUrloverrides. - Apply model overrides (Primary/Balanced/Fast) if specified.
- Apply extra entries provided via
--env KEY=VALUE. - Append cc-mirror safety defaults (e.g.,
DISABLE_UPDATES=1,DISABLE_TELEMETRY=1,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1).
- Start with the provider's default
Understand the cc-mirror architecture and directory structure
maincc-mirror creates isolated Claude Code variants. Each variant resides in its own directory under
~/.cc-mirror/<variant>, ensuring that configurations, sessions, and binaries do not interfere with your global Claude Code installation.Variant Directory Structure:
native/: Contains the native Claude Code binary (claudeorclaude.exe).config/: Containssettings.json(environment overrides like API keys and model mappings) and.claude.json(API-key approvals and MCP server seeds).tweakcc/: Containsconfig.json(brand presets and themes) andsystem-prompts/(prompt fragment overlays/packs).variant.json: Metadata for the variant.
Wrappers are installed into a configurable
<bin-dir>. The default is~/.local/binon macOS/Linux and~/.cc-mirror/binon Windows.Checklist for adding a new provider
mainTo implement a new provider in cc-mirror, follow these steps:
- Define Provider: Add to
src/providers/index.ts(configureauthMode,requiresModelMapping, etc.). - Create Brand Preset: Add to
src/brands/<provider>.ts(set theme colors, thinking verbs, tool denies). - Register Brand: Add to
src/brands/index.ts. - UI/Splash: Add wrapper splash style and ASCII art in
src/core/wrapper.tsand test withscripts/preview-splash.mjs. - TUI Content: Add education content to
src/tui/content/providers.ts. - Documentation: Add help entries to
src/cli/help.ts, README tables, anddocs/README.md. - Testing:
- Provider matrix:
test/provider-matrix.test.ts - E2E creation:
test/e2e/creation.test.ts - E2E providers list:
test/e2e/providers.ts - E2E ASCII art:
test/e2e/ascii-art.test.ts
- Provider matrix:
- Define Provider: Add to
Manually apply tweakcc patches to a cc-mirror variant
mainIf you want to manually enable optional
tweakccfeatures (like swarm mode or session memory) for a specific variant, you can bypass the standard cc-mirror flow using one of these methods.Fast Path (Recommended)
Use the built-in cc-mirror command to trigger the tweak process:
npx cc-mirror tweak <variant>Direct Path (Explicit Target)
If you need to run
tweakccdirectly with specific environment variables to target a cc-mirror native installation:VARIANT=<variant> TWEAKCC_CONFIG_DIR="$HOME/.cc-mirror/$VARIANT/tweakcc" \ TWEAKCC_CC_INSTALLATION_PATH="$HOME/.cc-mirror/$VARIANT/native/claude" \ npx tweakcc@4.0.11Apply Specific Optional Patches
To apply a comma-separated list of specific patch IDs:
VARIANT=<variant> TWEAKCC_CONFIG_DIR="$HOME/.cc-mirror/$VARIANT/tweakcc" \ TWEAKCC_CC_INSTALLATION_PATH="$HOME/.cc-mirror/$VARIANT/native/claude" \ npx tweakcc@4.0.11 --apply --patches "<patch-a>,<patch-b>"Note: Patch names depend on your
tweakccversion. Runnpx tweakcc@4.0.11 --helpto see available IDs.