InkdownInkdown
Start writing

Claude-Code

62 filesยท4 subfolders

Shared Workspace

Claude-Code
codex

1000_non_obvious_patterns_gotchas_and_debugging_traps

Shared from "Claude-Code" on Inkdown

Non-Obvious Design Decisions, Traps, And Day-One Debugging Risks

  • Startup is intentionally front-loaded with safe parallel side effects. main.tsx starts MDM reads and keychain prefetch before most imports so later config and auth reads are faster.
  • Trust is a first-class boundary. Interactive startup applies only safe config environment variables before the trust dialog; riskier work such as git context prefetch, plugin LSP servers, and full environment injection waits until trust is granted. Headless --print mode treats trust as implicit.
  • This TypeScript source imports .js specifiers everywhere because the runtime build expects emitted .js paths. When reading imports, mentally map back to or .
0000_start_here_index_and_recommended_reading_order.md
0100_project_overview_tech_stack_runtime_modes_and_folder_map.md
0200_startup_flow_entry_points_and_cold_start_sequence.md
0300_codebase_modules_layers_state_models_and_schemas.md
0400_system_architecture_and_design_rationale.md
0500_interactive_repl_request_flow_end_to_end.md
0600_headless_sdk_and_print_mode_request_flow_end_to_end.md
0700_mcp_integration_connection_and_tool_call_flow.md
0800_external_services_sdks_storage_and_local_dependencies.md
0900_environment_variables_settings_feature_flags_and_failure_modes.md
1000_non_obvious_patterns_gotchas_and_debugging_traps.md
1100_full_codebase_file_inventory_grouped_by_directory.md
kimi
00-overview.md
01-entrypoints.md
02-state-management.md
03-query-system.md
04-tools-system.md
05-tasks-system.md
06-ui-components.md
07-bridge-remote.md
08-services.md
09-skills-plugins.md
10-commands.md
11-testing-architecture.md
12-permission-system.md
13-build-system.md
14-ink-internals.md
15-git-internals.md
16-context-compaction.md
17-vim-mode.md
18-mailbox-notifications.md
19-session-persistence.md
20-hooks-system.md
21-error-recovery.md
README.md
qwen
00-overview.md
01-entry-points.md
02-query-engine.md
03-tools-and-tasks.md
04-commands-and-skills.md
05-state-management.md
06-ink-rendering.md
07-bridge-remote.md
08-mcp-services.md
09-services-overview.md
10-multi-agent.md
11-system-prompt-constants.md
12-tool-interface.md
13-memory-system.md
14-buddy-companion.md
15-keybindings.md
16-stop-hooks.md
17-vim-mode.md
18-upstreamproxy.md
19-cost-tracking-history.md
20-contexts-styles-onboarding.md
21-hooks.md
22-screens.md
tweets-explain
claude-code-memory-analysis.md
compact
memory-system
agentic-architecture
foo.js
foo.ts
foo.tsx
  • There are two startup paths that share most core logic: interactive REPL and headless runHeadless. The shared core lives in query.ts, QueryEngine.ts, Tool.ts, tools.ts, and the tool execution services.
  • commands.ts is the human command registry. If a behavior feels global, check there before hunting through UI components.
  • tools.ts is the tool registry and uses feature flags plus lazy require() calls to keep dead-code elimination working. A missing tool can be a flag problem, environment problem, or permission and filtering problem.
  • Permission decisions are layered. Static rules, enterprise policy, auto-mode safety stripping, hooks, classifier checks, interactive dialogs, and remote permission bridges all participate. hasPermissionsToUseTool() is only one step.
  • The codebase distinguishes command availability from tool availability. Commands are human-triggered flows. Tools are model-callable units emitted in API schemas.
  • Settings are merged from multiple sources with precedence, validation, caching, and preservation of unknown fields. The effective value can come from user, project, local, flag, policy, managed, or remote managed settings.
  • Managed settings support both a base file and a drop-in directory. Alphabetical drop-in ordering matters because later files win.
  • Worktree mode changes cwd, originalCwd, and sometimes projectRoot. Bugs that only happen under --worktree usually come from reading one of those values at the wrong time.
  • Plugin loading differs between interactive and headless paths. Interactive startup does more background work; headless often awaits plugin work so the process does not exit before bookkeeping finishes.
  • MCP servers come from explicit flags, settings, .mcp.json, plugins, enterprise config, and Claude.ai connectors. Dedup happens by signature, not just by name.
  • The remote-control bridge and remote session viewer are related but different. bridge/* exposes the local machine or session outward. remote/* attaches to a hosted remote session.
  • The codebase has both React state and process-global bootstrap state. Session IDs, meters, counters, and certain flags live in bootstrap/state.ts; UI and session state lives in AppState and the store.
  • Background tasks, agents, and teammates are first-class. Many helpers under tasks/*, tools/AgentTool/*, utils/swarm/*, and components/tasks/* exist to keep those long-lived units visible and controllable.
  • A large share of performance work is about avoiding module-evaluation cost. Lazy imports, cache warming, and startup comments usually exist because someone measured a regression already.
  • Temp settings files use content-hash-based names instead of random UUIDs. That preserves prompt-cache stability because tool descriptions and sandbox prompts include those paths.
  • The giant utils/ directory is the platform layer. If a feature touches config, files, session logs, git, telemetry, hooks, plugins, or model plumbing, the implementation usually lands there.
  • Some apparent dependency cycles are type-only or UI-wrapper cycles. The clearly visible runtime cycle is main.tsx -> dialogLaunchers.tsx -> interactiveHelpers.tsx -> main.tsx.
  • There is no single database module. Persistent state is mostly file-backed plus OS keychain and remote services.
  • If something fails only in --print or SDK mode, check cli/print.ts first. If it fails only in the interactive REPL, check screens/REPL.tsx and the hooks it mounts.
  • If a feature exists in the UI but not in the API-facing session, confirm whether it is REPL-only, hidden behind USER_TYPE === "ant", or controlled by a bun:bundle feature gate.