Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 58 additions & 26 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ bun install
# Dev mode (runs cli.tsx with MACRO defines injected via -d flags)
bun run dev

# Dev mode with debugger (set BUN_INSPECT=9229 to pick port)
bun run dev:inspect

# Pipe mode
echo "say hello" | bun run src/entrypoints/cli.tsx -p

Expand All @@ -30,6 +33,15 @@ bun test --coverage # with coverage report
bun run lint # check only
bun run lint:fix # auto-fix
bun run format # format all src/

# Health check
bun run health

# Check unused exports
bun run check:unused

# Docs dev server (Mintlify)
bun run docs:dev
```

详细的测试规范、覆盖状态和改进计划见 `docs/testing-spec.md`。
Expand All @@ -39,20 +51,27 @@ bun run format # format all src/
### Runtime & Build

- **Runtime**: Bun (not Node.js). All imports, builds, and execution use Bun APIs.
- **Build**: `build.ts` 执行 `Bun.build()` with `splitting: true`,入口 `src/entrypoints/cli.tsx`,输出 `dist/cli.js` + ~450 chunk files。构建后自动替换 `import.meta.require` 为 Node.js 兼容版本(产物 bun/node 都可运行)。
- **Dev mode**: `scripts/dev.ts` 通过 Bun `-d` flag 注入 `MACRO.*` defines,运行 `src/entrypoints/cli.tsx`。`scripts/defines.ts` 集中管理 define map。
- **Build**: `build.ts` 执行 `Bun.build()` with `splitting: true`,入口 `src/entrypoints/cli.tsx`,输出 `dist/cli.js` + chunk files。默认启用 `AGENT_TRIGGERS_REMOTE` feature。构建后自动替换 `import.meta.require` 为 Node.js 兼容版本(产物 bun/node 都可运行)。
- **Dev mode**: `scripts/dev.ts` 通过 Bun `-d` flag 注入 `MACRO.*` defines,运行 `src/entrypoints/cli.tsx`。默认启用 `BUDDY`、`TRANSCRIPT_CLASSIFIER`、`BRIDGE_MODE`、`AGENT_TRIGGERS_REMOTE` 四个 feature。
- **Module system**: ESM (`"type": "module"`), TSX with `react-jsx` transform.
- **Monorepo**: Bun workspaces — internal packages live in `packages/` resolved via `workspace:*`.
- **Lint/Format**: Biome (`biome.json`)。`bun run lint` / `bun run lint:fix` / `bun run format`。
- **Defines**: 集中管理在 `scripts/defines.ts`。当前版本 `2.1.888`。

### Entry & Bootstrap

1. **`src/entrypoints/cli.tsx`** — True entrypoint. Sets up runtime globals:
- `globalThis.MACRO` — build-time macro values (VERSION, BUILD_TIME, etc.),通过 `scripts/dev.ts` 的 `-d` flags 注入。
- `BUILD_TARGET`, `BUILD_ENV`, `INTERFACE_TYPE` globals。
- `feature()` 由 `bun:bundle` 内置模块提供,不需要在此 polyfill。
2. **`src/main.tsx`** — Commander.js CLI definition. Parses args, initializes services (auth, analytics, policy), then launches the REPL or runs in pipe mode.
3. **`src/entrypoints/init.ts`** — One-time initialization (telemetry, config, trust dialog).
1. **`src/entrypoints/cli.tsx`** — True entrypoint。`main()` 函数按优先级处理多条快速路径:
- `--version` / `-v` — 零模块加载
- `--dump-system-prompt` — feature-gated (DUMP_SYSTEM_PROMPT)
- `--claude-in-chrome-mcp` / `--chrome-native-host`
- `--daemon-worker=<kind>` — feature-gated (DAEMON)
- `remote-control` / `rc` / `bridge` — feature-gated (BRIDGE_MODE)
- `daemon` — feature-gated (DAEMON)
- `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS)
- `--tmux` + `--worktree` 组合
- 默认路径:加载 `main.tsx` 启动完整 CLI
2. **`src/main.tsx`** (~4680 行) — Commander.js CLI definition。注册大量 subcommands:`mcp` (serve/add/remove/list...)、`server`、`ssh`、`open`、`auth`、`plugin`、`agents`、`auto-mode`、`doctor`、`update` 等。主 `.action()` 处理器负责权限、MCP、会话恢复、REPL/Headless 模式分发。
Comment on lines +63 to +73

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incomplete documentation of cli.tsx fast paths.

The documented priority list is missing a fast path that exists in the actual code. According to the relevant code snippet from src/entrypoints/cli.tsx, there is a templates/environment-runner/self-hosted-runner fast path (lines 196-223) that executes between the ps/logs/attach/kill/--bg path and the --tmux + --worktree path, but it's not mentioned in this documentation.

📝 Suggested addition

Add the missing fast path to the list:

    - `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS)
+   - `templates` / `environment-runner` / `self-hosted-runner` — feature-gated paths
    - `--tmux` + `--worktree` 组合

Based on relevant code snippet from src/entrypoints/cli.tsx:196-223.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
1. **`src/entrypoints/cli.tsx`** — True entrypoint。`main()` 函数按优先级处理多条快速路径:
- `--version` / `-v` — 零模块加载
- `--dump-system-prompt` — feature-gated (DUMP_SYSTEM_PROMPT)
- `--claude-in-chrome-mcp` / `--chrome-native-host`
- `--daemon-worker=<kind>` — feature-gated (DAEMON)
- `remote-control` / `rc` / `bridge` — feature-gated (BRIDGE_MODE)
- `daemon` — feature-gated (DAEMON)
- `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS)
- `--tmux` + `--worktree` 组合
- 默认路径:加载 `main.tsx` 启动完整 CLI
2. **`src/main.tsx`** (~4680 行) — Commander.js CLI definition。注册大量 subcommands:`mcp` (serve/add/remove/list...)、`server`、`ssh`、`open`、`auth`、`plugin`、`agents`、`auto-mode`、`doctor`、`update` 等。主 `.action()` 处理器负责权限、MCP、会话恢复、REPL/Headless 模式分发。
1. **`src/entrypoints/cli.tsx`** — True entrypoint。`main()` 函数按优先级处理多条快速路径:
- `--version` / `-v` — 零模块加载
- `--dump-system-prompt` — feature-gated (DUMP_SYSTEM_PROMPT)
- `--claude-in-chrome-mcp` / `--chrome-native-host`
- `--daemon-worker=<kind>` — feature-gated (DAEMON)
- `remote-control` / `rc` / `bridge` — feature-gated (BRIDGE_MODE)
- `daemon` — feature-gated (DAEMON)
- `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS)
- `templates` / `environment-runner` / `self-hosted-runner` — feature-gated paths
- `--tmux` + `--worktree` 组合
- 默认路径:加载 `main.tsx` 启动完整 CLI
2. **`src/main.tsx`** (~4680 行) — Commander.js CLI definition。注册大量 subcommands:`mcp` (serve/add/remove/list...)、`server`、`ssh`、`open`、`auth`、`plugin`、`agents`、`auto-mode`、`doctor`、`update` 等。主 `.action()` 处理器负责权限、MCP、会话恢复、REPL/Headless 模式分发。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` around lines 63 - 73, Update the CLI fast-path list in CLAUDE.md
to include the missing templates/environment-runner/self-hosted-runner fast path
that exists in src/entrypoints/cli.tsx (the block around the
templates/environment-runner/self-hosted-runner check that runs after the
ps/logs/attach/kill/--bg feature-gated BG_SESSIONS branch and before the --tmux
+ --worktree branch); add a single bullet describing that fast path in the
priority order so the documentation matches the actual control flow.

3. **`src/entrypoints/init.ts`** — One-time initialization (telemetry, config, trust dialog)。

### Core Loop

Expand All @@ -70,25 +89,37 @@ bun run format # format all src/

- **`src/Tool.ts`** — Tool interface definition (`Tool` type) and utilities (`findToolByName`, `toolMatchesName`).
- **`src/tools.ts`** — Tool registry. Assembles the tool list; some tools are conditionally loaded via `feature()` flags or `process.env.USER_TYPE`.
- **`src/tools/<ToolName>/`** — Each tool in its own directory (e.g., `BashTool`, `FileEditTool`, `GrepTool`, `AgentTool`).
- Tools define: `name`, `description`, `inputSchema` (JSON Schema), `call()` (execution), and optionally a React component for rendering results.
- **`src/tools/<ToolName>/`** — 61 个 tool 目录(如 BashTool, FileEditTool, GrepTool, AgentTool, WebFetchTool, LSPTool, MCPTool 等)。每个 tool 包含 `name`、`description`、`inputSchema`、`call()` 及可选的 React 渲染组件。
- **`src/tools/shared/`** — Tool 共享工具函数。

### UI Layer (Ink)

- **`src/ink.ts`** — Ink render wrapper with ThemeProvider injection.
- **`src/ink/`** — Custom Ink framework (forked/internal): custom reconciler, hooks (`useInput`, `useTerminalSize`, `useSearchHighlight`), virtual list rendering.
- **`src/components/`** — React components rendered in terminal via Ink. Key ones:
- `App.tsx` — Root provider (AppState, Stats, FpsMetrics).
- `Messages.tsx` / `MessageRow.tsx` — Conversation message rendering.
- `PromptInput/` — User input handling.
- `permissions/` — Tool permission approval UI.
- **`src/components/`** — 大量 React 组件(170+ 项),渲染于终端 Ink 环境中。关键组件:
- `App.tsx` — Root provider (AppState, Stats, FpsMetrics)
- `Messages.tsx` / `MessageRow.tsx` — Conversation message rendering
- `PromptInput/` — User input handling
- `permissions/` — Tool permission approval UI
- `design-system/` — 复用 UI 组件(Dialog, FuzzyPicker, ProgressBar, ThemeProvider 等)
- Components use React Compiler runtime (`react/compiler-runtime`) — decompiled output has `_c()` memoization calls throughout.

### State Management

- **`src/state/AppState.tsx`** — Central app state type and context provider. Contains messages, tools, permissions, MCP connections, etc.
- **`src/state/store.ts`** — Zustand-style store for AppState.
- **`src/bootstrap/state.ts`** — Module-level singletons for session-global state (session ID, CWD, project root, token counts).
- **`src/state/AppStateStore.ts`** — Default state and store factory.
- **`src/state/store.ts`** — Zustand-style store for AppState (`createStore`).
- **`src/state/selectors.ts`** — State selectors.
- **`src/bootstrap/state.ts`** — Module-level singletons for session-global state (session ID, CWD, project root, token counts, model overrides, client type, permission mode).

### Bridge / Remote Control

- **`src/bridge/`** (~35 files) — Remote Control / Bridge 模式。feature-gated by `BRIDGE_MODE`。包含 bridge API、会话管理、JWT 认证、消息传输、权限回调等。Entry: `bridgeMain.ts`。
- CLI 快速路径: `claude remote-control` / `claude rc` / `claude bridge`。

### Daemon Mode

- **`src/daemon/`** — Daemon 模式(长驻 supervisor)。feature-gated by `DAEMON`。包含 `main.ts`(entry)和 `workerRegistry.ts`(worker 管理)。

### Context & System Prompt

Expand All @@ -97,17 +128,16 @@ bun run format # format all src/

### Feature Flag System

Feature flags control which functionality is enabled at runtime. The system works as follows:
Feature flags control which functionality is enabled at runtime:

- **在代码中使用**: 统一通过 `import { feature } from 'bun:bundle'` 导入,调用 `feature('FLAG_NAME')` 返回 `boolean`。**不要**在 `cli.tsx` 或其他文件里自己定义 `feature` 函数或覆盖这个 import。
- **启用方式**: 通过环境变量 `FEATURE_<FLAG_NAME>=1`。例如 `FEATURE_BUDDY=1 bun run dev` 启用 BUDDY 功能。
- **Dev 模式**: `scripts/dev.ts` 自动扫描所有 `FEATURE_*` 环境变量,转换为 Bun 的 `--feature` 参数传递给运行时。
- **Build 模式**: `build.ts` 同样读取 `FEATURE_*` 环境变量,传入 `Bun.build({ features })` 数组。
- **默认行为**: 不设置任何 `FEATURE_*` 环境变量时,所有 `feature()` 调用返回 `false`,即所有 feature-gated 代码不执行。
- **常见 flag 名称**: `BUDDY`、`FORK_SUBAGENT`、`PROACTIVE`、`KAIROS`、`VOICE_MODE`、`DAEMON` 等(见 `src/commands.ts` 中的使用)。
- **Dev 默认 features**: `BUDDY`、`TRANSCRIPT_CLASSIFIER`、`BRIDGE_MODE`、`AGENT_TRIGGERS_REMOTE`(见 `scripts/dev.ts`)。
- **Build 默认 features**: `AGENT_TRIGGERS_REMOTE`(见 `build.ts`)。
- **常见 flag**: `BUDDY`, `DAEMON`, `BRIDGE_MODE`, `BG_SESSIONS`, `PROACTIVE`, `KAIROS`, `VOICE_MODE`, `FORK_SUBAGENT`, `SSH_REMOTE`, `DIRECT_CONNECT`, `TEMPLATES`, `CHICAGO_MCP`, `BYOC_ENVIRONMENT_RUNNER`, `SELF_HOSTED_RUNNER`, `COORDINATOR_MODE`, `UDS_INBOX`, `LODESTONE`, `ABLATION_BASELINE` 等。
- **类型声明**: `src/types/internal-modules.d.ts` 中声明了 `bun:bundle` 模块的 `feature` 函数签名。

**新增功能的正确做法**: 如果要让某个 feature-gated 模块(如 buddy)永久启用,应保留代码中 `import { feature } from 'bun:bundle'` + `feature('FLAG_NAME')` 的标准模式,在运行时通过环境变量或配置控制,而不是绕过 feature flag 直接 import。
**新增功能的正确做法**: 保留 `import { feature } from 'bun:bundle'` + `feature('FLAG_NAME')` 的标准模式,在运行时通过环境变量或配置控制,不要绕过 feature flag 直接 import。

### Stubbed/Deleted Modules

Expand All @@ -131,17 +161,19 @@ Feature flags control which functionality is enabled at runtime. The system work

- **框架**: `bun:test`(内置断言 + mock)
- **单元测试**: 就近放置于 `src/**/__tests__/`,文件名 `<module>.test.ts`
- **集成测试**: `tests/integration/`,共享 mock/fixture 在 `tests/mocks/`
- **集成测试**: `tests/integration/` — 4 个文件(cli-arguments, context-build, message-pipeline, tool-chain)
- **共享 mock/fixture**: `tests/mocks/`(api-responses, file-system, fixtures/)
- **命名**: `describe("functionName")` + `test("behavior description")`,英文
- **Mock 模式**: 对重依赖模块使用 `mock.module()` + `await import()` 解锁(必须内联在测试文件中,不能从共享 helper 导入)
- **当前状态**: 1286 tests / 67 files / 0 fail(详见 `docs/testing-spec.md` 的覆盖状态表和评分)
- **当前状态**: ~1623 tests / 114 files (110 unit + 4 integration) / 0 fail(详见 `docs/testing-spec.md`)

## Working with This Codebase

- **Don't try to fix all tsc errors** — they're from decompilation and don't affect runtime.
- **Feature flags** — 默认全部关闭(`feature()` 返回 `false`)。启用方式见上方 Feature Flag System 章节。不要在 `cli.tsx` 中重定义 `feature` 函数。
- **Feature flags** — 默认全部关闭(`feature()` 返回 `false`)。Dev/build 各有自己的默认启用列表。不要在 `cli.tsx` 中重定义 `feature` 函数。
- **React Compiler output** — Components have decompiled memoization boilerplate (`const $ = _c(N)`). This is normal.
- **`bun:bundle` import** — `import { feature } from 'bun:bundle'` 是 Bun 内置模块,由运行时/构建器解析。不要用自定义函数替代它。
- **`src/` path alias** — tsconfig maps `src/*` to `./src/*`. Imports like `import { ... } from 'src/utils/...'` are valid.
- **MACRO defines** — 集中管理在 `scripts/defines.ts`。Dev mode 通过 `bun -d` 注入,build 通过 `Bun.build({ define })` 注入。修改版本号等常量只改这个文件。
- **构建产物兼容 Node.js** — `build.ts` 会自动后处理 `import.meta.require`,产物可直接用 `node dist/cli.js` 运行。
- **Biome 配置** — 大量 lint 规则被关闭(decompiled 代码不适合严格 lint)。`.tsx` 文件用 120 行宽 + 强制分号;其他文件 80 行宽 + 按需分号。
35 changes: 35 additions & 0 deletions docs/projects-collection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 社区项目 & Blog 合集

> 每日更新,欢迎自荐!

## 工具 & 应用

| 项目 | 描述 | 作者 |
|------|------|------|
| [4qtask.vercel.app](https://4qtask.vercel.app/) | 免费四象限时间管理工具 | @kevinhuky |
| [kaying.studio](https://kaying.studio/) | 个人 AI 工具箱 | @kayingai |
| [supsub.ai](https://supsub.ai/) | 高效阅读工具 | @hidumou |
| [x-video-download.net](https://x-video-download.net/) | 视频下载工具 | @syakadou |
| [1openapi.com](https://1openapi.com/) | API 中转站 | @thinker007 |
| [claw-z.com](https://claw-z.com/) | 一键部署 OpenClaw AI Agent(场景驱动、全面管理) | @uhhc |
| [gemini-watermark-remover.net](https://gemini-watermark-remover.net/) | Gemini 水印移除工具 | @syakadou |

## GitHub 开源项目

| 项目 | 描述 | 作者 |
|------|------|------|
| [VersperClaw](https://github.com/versperai/VersperClaw) | 全自动科研流 | @versperai |
| [claude-reviews-claude](https://github.com/openedclaude/claude-reviews-claude) | 原汤化原食——Claude 如何看待眼中的老己 | @openedclaude |
| [agentica](https://github.com/shibing624/agentica) | 自研 Agent 框架,借鉴 claude-code 多 Agent 处理 | @shibing624 |
| [macman](https://github.com/tonngw/macman) | Mac 从 0 到 1 保姆级配置教程 | @tonngw |
| [SuperSpec](https://github.com/asasugar/SuperSpec) | SDD / Spec-Driven Development | @asasugar |
| [adnify](https://github.com/adnaan-worker/adnify) | 高颜值高定制化 AI 编辑器 | @adnaan-worker |
| [another-rule-engine](https://github.com/eatmoreduck/another-rule-engine) | 基于 Groovy 的开源多功能决策引擎 | @eatmoreduck |
| [creative_master](https://github.com/chatabc/creative_master) | AI 驱动的创意灵感管理工具 | @chatabc |
| [RapidDoc](https://github.com/RapidAI/RapidDoc) | Office 文件解析工具转 Markdown(支持 PDF/Image/Word/PPT/Excel) | @hzkitt |

## Blog

| 链接 | 作者 |
|------|------|
| [blog.xiaohuangyu.space](https://blog.xiaohuangyu.space/) | @eatmoreduck |
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "claude-code-best",
"version": "1.0.3",
"version": "2026.4.3-restored",
"private": true,
"description": "Reverse-engineered Anthropic Claude Code CLI — interactive AI coding assistant in the terminal",
"license": "SEE LICENSE IN LICENSE.md",
"type": "module",
"author": "claude-code-best <claude-code-best@proton.me>",
"repository": {
Expand Down Expand Up @@ -39,6 +41,7 @@
"scripts": {
"build": "bun run build.ts",
"dev": "bun run scripts/dev.ts",
"dev-debug": "FEATURE_BUDDY=1 bun run scripts/dev.ts --debug",
"dev:inspect": "bun run scripts/dev-debug.ts",
"prepublishOnly": "bun run build",
"lint": "biome lint src/",
Expand Down
28 changes: 28 additions & 0 deletions src/services/api/claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,27 @@ async function* queryModel(
const params = paramsFromContext(context)
captureAPIRequest(params, options.querySource) // Capture for bug reports

// Log the full API request to debug log file
logForDebugging(`[API_REQUEST] model=${params.model} max_tokens=${params.max_tokens}`)
// Set CLAUDE_CODE_LOG_FULL_PROMPT=1 to log full system prompt and messages
if (isEnvTruthy(process.env.CLAUDE_CODE_LOG_FULL_PROMPT)) {
logForDebugging(`[API_REQUEST_SYSTEM_FULL] ${jsonStringify(params.system)}`)
logForDebugging(`[API_REQUEST_MESSAGES_FULL] ${jsonStringify(params.messages)}`)
} else {
logForDebugging(`[API_REQUEST_SYSTEM] ${jsonStringify(params.system).slice(0, 5000)}...`)
logForDebugging(`[API_REQUEST_MESSAGES] count=${params.messages.length}`)
}
logForDebugging(`[API_REQUEST_TOOLS] count=${params.tools?.length ?? 0}`)
if (params.tools && params.tools.length > 0) {
for (const tool of params.tools) {
if ('name' in tool) {
logForDebugging(`[API_REQUEST_TOOL] name=${tool.name}`)
} else if ('type' in tool) {
logForDebugging(`[API_REQUEST_TOOL] type=${tool.type}`)
}
}
}

maxOutputTokens = params.max_tokens

// Fire immediately before the fetch is dispatched. .withResponse() below
Expand Down Expand Up @@ -1986,12 +2007,14 @@ async function* queryModel(
...part.content_block,
input: '',
}
logForDebugging(`[TOOL_USE] name=${part.content_block.name} id=${part.content_block.id}`)
break
case 'server_tool_use':
contentBlocks[part.index] = {
...part.content_block,
input: '' as unknown as { [key: string]: unknown },
}
logForDebugging(`[MCP_TOOL_USE] name=${part.content_block.name} id=${part.content_block.id}`)
if ((part.content_block.name as string) === 'advisor') {
isAdvisorInProgress = true
logForDebugging(`[AdvisorTool] Advisor tool called`)
Expand Down Expand Up @@ -2234,6 +2257,11 @@ async function* queryModel(
lastMsg.message.stop_reason = stopReason
}

// Log the API response summary
logForDebugging(`[API_RESPONSE] stop_reason=${stopReason} usage=${jsonStringify(usage)}`)
logForDebugging(`[API_RESPONSE_MESSAGES] count=${newMessages.length}`)
logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`)
Comment on lines +2260 to +2263

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Consider gating full response content logging with CLAUDE_CODE_LOG_FULL_PROMPT.

Line 2263 logs the entire newMessages array via jsonStringify, which contains assistant message content. This is inconsistent with the request logging (lines 1790-1796) where full content requires CLAUDE_CODE_LOG_FULL_PROMPT to be set.

From the context in src/utils/debug.ts:173-186, ant users always have debug logs written (for /share and bug reports), meaning this full response content would be logged unconditionally for internal users.

🛡️ Suggested fix to align with request logging pattern
             // Log the API response summary
             logForDebugging(`[API_RESPONSE] stop_reason=${stopReason} usage=${jsonStringify(usage)}`)
             logForDebugging(`[API_RESPONSE_MESSAGES] count=${newMessages.length}`)
-            logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`)
+            if (isEnvTruthy(process.env.CLAUDE_CODE_LOG_FULL_PROMPT)) {
+              logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`)
+            }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/services/api/claude.ts` around lines 2260 - 2263, The code
unconditionally logs full assistant response content by calling
logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`), which
bypasses the CLAUDE_CODE_LOG_FULL_PROMPT gating used for request logging; modify
the block that logs API response content so it only logs the full
jsonStringify(newMessages) when the CLAUDE_CODE_LOG_FULL_PROMPT flag (or
equivalent debug check used in src/utils/debug.ts) is set, otherwise log a
redacted/summary version (e.g., count or truncated text) — update the lines
around logForDebugging, newMessages and jsonStringify usage to mirror the
request-logging pattern.


// Update cost
const costUSDForPart = calculateUSDCost(resolvedModel, usage as unknown as BetaUsage)
costUSD += addToTotalSessionCost(
Expand Down
Loading