carboncode CLAUDE.md

A repository instruction file for Carbon Code, a Chinese-first terminal coding agent. It records the project's governing rules, development workflow, architecture, and conventions.

In plain words
What is it for?
Use it when making non-trivial changes to Carbon Code, especially changes involving its project rules, Node setup, build process, CLI, dashboard, or source architecture.
Why use it?
It tells coding agents which project documents are authoritative and how the source tree, build commands, and compatibility rules fit together.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/yapie0/carboncode/claude-md
Clone the repo
git clone --depth 1 https://github.com/Yapie0/carboncode
Per session 2,028 This file is loaded in full into every session.
When invoked 2,028 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02028 $0.02028
Opus 5 $0.01014 $0.01014
Sonnet 5 $0.00406 $0.00406
Haiku 4.5 $0.00203 $0.00203

Measured 2d ago against content hash e6bcbf1e1603, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

carboncode CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 56 lines

How it starts

The opening of the file, as written. The whole thing — 56 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

Carbon Code is a Chinese-first, DeepSeek-native terminal coding agent (@carboncode/cli, bins carboncode / ccode), derived from DeepSeek-Reasonix and productized for personal developer workflows. Architecture is opinionated around three pillars: immutable prefix caching, tool-call repair, and tiered flash→pro cost control.

Canonical rules (authoritative — follow these)

  • AGENTS.md — project rules, PR merge principles, naming/scope, license/attribution. Read before any non-trivial change.
  • CARBON.md — working knowledge: stack, commands, product rules, watch points.
  • The agent itself loads project rules from AGENTS.md then CARBON.md (read priority order in src/memory/project.ts: AGENTS.mdCARBON.md → legacy REASONIX.mdAGENT.md; the legacy two are read-only fallbacks and are not present in this repo).

This file complements those two with an architecture map of src/. It does not restate their rules.

Dev workflow

Node 22+, ESM ("type": "module"). Scripts:

  • npm run build — tsup + scripts/copy-dashboard-vendor-css.mjs (library + CLI + dashboard bundles, then dashboard CSS copy)
  • npm run devtsx src/cli/index.ts (no subcommand); npm run chattsx src/cli/index.ts chat
  • npm run test / npm run test:watch / npm run test:coverage — Vitest
  • npm run test:mutation — Stryker on load-bearing modules (loop, context-manager, core, shell, plan, repair)
  • npm run lint / npm run lint:fix / npm run format — Biome over src tests
  • npm run typechecktsc --noEmit for src and tsc --noEmit -p dashboard
  • npm run verify — build + lint + typecheck + test in one shot

Run npm run verify before claiming work is done. Git hooks (simple-git-hooks): pre-commit lint, pre-push verify.

Architecture map (src/)

  • CLI & commandssrc/cli/index.ts (entry; imports cli/heap-limit-launch.ts FIRST for heap re-exec), Commander program, lazy-imported src/cli/commands/*. Top-level commands: setup, code, chat, run, acp, desktop (internal JSON-RPC for the desktop client), stats, doctor, commit, sessions, prune-sessions, events, replay, diff, mcp (list/search/install/browse/inspect), version, update, index. Interactive modes use Ink; src/cli/ui/App.tsx is the main TUI (~4.5k lines). src/cli/resolve.ts resolves precedence (per-setting flag > --preset > config.preset > auto).
  • Agent enginesrc/loop.ts CacheFirstLoop.step(input) is the turn loop (AsyncGenerator of LoopEvent); src/loop/* (types, escalation, healing, messages, force-summary, thinking, env), src/context-manager.ts (fold/force-summary/preflight thresholds 50/70/80/95% of ctxMax), src/memory/runtime.ts (ImmutablePrefix + AppendOnlyLog + VolatileScratch), src/frame/ (TUI grid primitives — fixed-width cell/row frames), src/core/ (events, inflight, pause-gate, pause-policy, reducers, event-redaction, eventize).
  • Repairsrc/repair/ (index.ts orchestrates scavenge → truncation → storm passes for malformed DeepSeek tool calls; flatten.ts schema flatten runs at loop construction).
  • Toolssrc/tools.ts (ToolRegistry register/dispatch, plan-mode enforcement, schema flatten/re-nest, result post-processing), src/tools/* (filesystem, shell, shell-chain, web, memory, plan/plan-core, subagent, skills, choice, todo, scaffold, jobs), src/tools/fs/ (edit with LCS diff, patch, glob, outline, search), src/tools/shell/parse.ts (allowlist) + exec.ts. Cross-cutting: src/hooks.ts, src/skills.ts, src/at-mentions.ts, src/at-mentions-url.ts.
  • Model client / netsrc/client.ts (DeepSeekClient: undici SSE streaming, ~11-min (660s) timeout, retry, cache-token usage), src/retry.ts, src/tokenizer.ts (encode-only V4 tokenizer, data/deepseek-tokenizer.json.gz), src/net/proxy.ts, src/adapters/ (JSONL event sink/source), src/ports/ (ModelClient/MemoryStore/CheckpointStore/EventSink/HookRunner/ToolHost interfaces).
  • Config / envsrc/config.ts (~/.carboncode/config.json, API key bridge, presets, project permissions, sensitive-path config, MCP), src/env.ts, src/workspaces.ts, src/frontmatter.ts, src/gitignore.ts.
  • Context / memory / transcriptsrc/memory/ (session JSONL persistence, user/project/subdir memory, runtime prefix), src/session-title.ts, src/transcript/ (log/replay/diff). Sessions/data live under ~/.carboncode/sessions/, ~/.carboncode/memory/{global,<projectHash>}/.
  • Semantic indexsrc/index/semantic/ (builder, store JSONL append-only + linear cosine scan, embedding via Ollama/OpenAI-compat, chunker, tool, ollama-launcher, preflight), src/index/config.ts. Complements lexical grep.
  • i18nsrc/i18n/ (index.ts t()/tObj(), types.ts schema, zh-CN.ts primary, EN.ts fallback). Chinese is first-class; English is fallback only.
  • Integration surfacessrc/mcp/ (client + stdio/SSE/streamable-http transports, registry, spec, catalog, reconnect, latency), src/acp/ (Agent Client Protocol over stdio: server/protocol/dispatch/gates), src/qq/ (QQ bot WebSocket channel + access control), src/server/ (loopback dashboard HTTP + api/* routes).
  • Telemetrysrc/telemetry/ (usage JSONL at ~/.carboncode/usage.jsonl, pricing/stats, subagent distillation). Local-only, no network calls.
  • Library barrelsrc/index.ts re-exports the public API.

Read the full file on GitHub · 56 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 56 lines · 2,028 tokens per session scan A e6bcbf1e1603

Subscribe to this mod's changes

carboncode CLAUDE.md is an instructions file published in the GitHub repository Yapie0/carboncode (195 stars, last pushed 23d ago), licensed MIT. It adds 2,028 tokens to every session, about $0.0101 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.