Claude Code
Anthropic Claude Code: TypeScript, a skill engine, and multi-channel IDE integration
One loop behind four entry points
Section titled “One loop behind four entry points”Anthropic’s agentic coding tool, shipped as the npm package @anthropic-ai/claude-code. The same TypeScript codebase supports four entry types: terminal, IDE plugin, Web, and Mobile.
Directories organized around developer actions
Section titled “Directories organized around developer actions”| 维度 | Codex | Claude Code | OpenClaw | Hermes |
|---|---|---|---|---|
| Entry | `cli/` terminal entry | `server/` IDE backend | `remote/` Web/Mobile client protocol | `entrypoints/` sub-command dispatch |
| Commands & handlers | `commands/` explicit slash commands (`/memory`, `/insights`, `/security-review`, `/cron`) | `cli/handlers/` autoMode / classifier / skillify loops | `commands.ts` registry | `schemas/` command argument schemas |
| Skill engine | `skills/bundled/` 17 bundled skills | `skills/skillify.ts` 4-round AskUserQuestion to distill a skill | `SkillTool` runs a skill | 5 frontmatter fields (name / description / allowed-tools / when_to_use / context: inline\|fork) |
| Memory | `memdir/` 4 MemoryTypes (user / feedback / project / reference) | COMBINED vs INDIVIDUAL prompt modes | MEMORY_DRIFT_CAVEAT warns model about staleness | "Before recommending from memory" forces a grep verify |
| Hooks & coordination | `hooks/` lifecycle hooks | `buddy/` collaboration mode | `coordinator/` multi-agent dispatch | `outputStyles/` output format injection |
| Observability & cost | `cost-tracker.ts` + `costHook.ts` live cost tracking | `commands/insights.ts` Opus over jsonl produces narrative | `logEvent("tengu_*")` event stream | `modelCost.ts` hardcoded price table |
Skills, self-audit, and memory checks
Section titled “Skills, self-audit, and memory checks”- The skill engine has explicit boundaries. 17 bundled skills sit beside
skillify, a meta-skill that uses four AskUserQuestion rounds to turn a session into SKILL.md. Its prompts and exit conditions are concrete enough to study directly. - Four entries share one codebase. All four entries run the same turn loop. Protocol adapters live only in
entrypoints/. - autoMode classifier. An LLM reviews the user-written auto allow, soft_deny, and env classifier rules for clarity, completeness, and conflicts.
/security-reviewacts as senior security engineer. The LLM scans a PR diff against 5 vulnerability classes, with an 80% confidence floor. Actively excludes DOS and disk-secret findings.- MEMORY_DRIFT_CAVEAT admits staleness up front. The prompt tells the model memories may be stale and forces a grep verification before acting.
Closed-source and isolation limits
Section titled “Closed-source and isolation limits”- Closed source. All conclusions come from sourcemap reverse-engineering. Some behavior is inferred.
- No native cross-OS sandbox. Relies on the host IDE for execution isolation. Sandbox is weak in pure-CLI mode.
- Memory drift is prompt-mitigated, not mechanism-mitigated. Compared to OpenClaw’s temporal decay plus retrieval, the mechanism layer is thin.
- Trace is weaker. No Codex-style full-session rollout-trace.jsonl.
Five designs worth carrying over
Section titled “Five designs worth carrying over”skillify4-round AskUserQuestion flow (src/skills/bundled/skillify.ts). R1 captures name and description, R2 captures step and arg, R3 decomposes, R4 extracts triggers. Splits “agent produces its own skill” into four bounded questions./security-reviewprompt design (src/commands/security-review.ts). Senior security engineer persona, 5 vulnerability classes, and an explicit exclusion list.- MemoryType × 2 prompt mode matrix (
src/memdir/). 4 types ×{COMBINED, INDIVIDUAL}= 8 combinations. - autoMode classifier reviewing user rules (
src/cli/handlers/autoMode.ts). Rule audit is itself an LLM task. - The boundaries of the 17 bundled skills.
loop,stuck,remember, andverifyeach have explicit exit conditions you can lift as design patterns.
Where the unpacked evidence begins
Section titled “Where the unpacked evidence begins”Closed-source disclosure: paths above come from community reverse-engineering of
@anthropic-ai/claude-code@2.1.88sourcemaps. Every “behavioural inference” claim defers to official docs when in conflict.