Claude Extension Logging
[Created by Codex: 019bdeae-0f44-7413-a3f8-47b58a9b4e30 2026-01-21]
Overview
Outline how to instrument the Claude extension and shim so the four canonical streams (claude_extension_to_webview, webview_to_claude_extension, claude_extension_to_cli, and cli_to_claude_extension for the extension, plus the shim variants prefixed with claude_shim_) are always emitted. These logs are the observable record that the shim needs before we compare behavior with Codex.
When to use this skill
Use this skill whenever you work on observability, debugging, or logging improvements in the Claude ecosystem so that each message path is captured consistently and the new filenames avoid confusion between shim vs. extension traffic.
Claude extension instrumentation
- •Ensure log directories exist. Create
~/centralized-logs/claude-extension/for the extension and~/centralized-logs/claude-vscode-shim/for the shim (or whichever directory the environment requires), and grant write permissions. - •Hook the router. Identify each place in
extension.jswhere the extension sends data to the webview or CLI. Before dispatching, append a JSON line to the appropriate file (claude_extension_to_webview.jsonlwhen talking to the UI,claude_extension_to_cli.jsonlwhen talking to the CLI, and the reverse for the other two files). - •Share a logger helper. The helper can look like:
const logMessage = (file, payload) => {
const line = JSON.stringify({
ts: Date.now(),
channelId: payload.channelId ?? payload.message?.channelId,
message: payload
});
fs.appendFileSync(path.join(logDir, `${file}.jsonl`), line + "\n");
};
Call this helper for every message to ensure the same schema is appended regardless of direction. 4. Rotate files gracefully. Trim or archive logs once they hit a few megabytes to keep the observer terminals responsive.
Claude shim instrumentation
- •Adopt the
claude_shim_naming. Log toclaude_shim_to_webview,web_view_to_claude_shim,claude_shim_to_cli, andcli_to_claude_shimso the shim’s traffic is instantly distinguishable. - •Wrap CLI responses. Mirror the extension envelope
{"type":"from-extension","message":...}for every CLI response before logging toclaude_shim_to_webview.jsonl. - •Log inbound UI events. As soon as messages arrive from the UI, record them to
web_view_to_claude_shim.jsonlbefore sending them to the CLI and logging toclaude_shim_to_cli.jsonl.
Verification checklist
- •Confirm that the eight Claude files exist and append lines when interacting with the UI.
- •Use
tail -f ... | jqto ensure new requests and streaming events appear as expected. - •Run
rg -c '"type":"control_request"'on the extension and shim logs to verify nothing is missing. - •Rotate logs or truncate them if they grow too large so the observers stay responsive.
Porting guidance for Codex
When porting this skill to Codex, swap each claude_ prefix for codex_ (the files become codex_extension_to_webview, webview_to_codex_extension, etc.). The same helper, directories, and verification steps apply so the observability story remains mirrored across both ecosystems.