返回 CodeWhale
CLAUDE_CODE_PARITY.md
根目录 / docs / design / CLAUDE_CODE_PARITY.md
1 # Claude Code — how its agents, workflows, plugins and skills actually work (parity reference)
2
3 Date: 2026-08-16. Author: the Claude Fable 5 session driving the v0.9.9
4 milestone, writing from direct operating knowledge of the Claude Code harness
5 (CLI/desktop/web, 2026-08). Companion to [`MODES.md`](../MODES.md). This is
6 a *mechanics* reference for builders on #5439 (orchestration trio visibility), #5311 (plugin system /
7 federated marketplaces), #5324/#5123 (agent tool surface), and the one-bash
8 consolidation. Where Codewhale already does the same thing, it says so; where
9 Claude Code is simply different (not better), it says that too.
10
11 ## 1. Sub-agents: the `Agent` tool
12
13 One tool, a handful of fields. What the model sees:
14
15 | field | meaning | notes |
16 |---|---|---|
17 | `prompt` | the task | required |
18 | `description` | 3–5 word label for the UI | required — the *only* per-spawn UX field |
19 | `subagent_type` | named agent definition (`Explore`, `Plan`, `general-purpose`, `code-reviewer`, `fork`, plus plugin-provided `plugin:agent`) | omit → general-purpose. `fork` inherits the parent's full context and always runs the parent model |
20 | `model` | optional override (`sonnet`/`opus`/`haiku`/…) | ignored for `fork`; agent-definition frontmatter normally decides |
21 | `isolation` | `worktree` (own git worktree, auto-cleaned if unchanged) or `remote` | no path knobs; the harness owns the worktree |
22
23 That is the whole spawn surface. There is **no** `max_steps`, `wall_time`,
24 `max_depth`, `thinking`, `write_roots`, `fork_context` bool,
25 `workspace_policy` or `write_authority` on the call. Budgets, tool
26 allow-lists, model tier and reasoning effort live in the **agent
27 definition** (`.claude/agents/<name>.md` frontmatter — `model`, `effort`,
28 `tools`, `description` "when to use") or in the harness. Everything the
29 parent needs after spawn is a lifecycle, not a knob:
30
31 - Agents run in the background; the parent gets a **completion
32 notification** and must not fabricate results before it arrives.
33 - `SendMessage(to: <agent>)` continues an existing agent with its context
34 intact; a new `Agent` call starts fresh. `ListAgents` enumerates them.
35 - The final report is *not* shown to the user — the parent relays what
36 matters. Sub-agent self-reports are treated as working sets, not facts.
37 - Fork semantics: `subagent_type: "fork"` = same model, same context,
38 tool output kept out of the parent context.
39
40 **Codewhale mapping.** The `agent` tool already has `action` (spawn/wait/
41 message/interrupt/…), `type` (8 roles), `profile`, `name`/`agent_id`/`message`,
42 `detached`, `worktree`, `resume_from`. That is the same shape as Claude Code's
43 Agent + SendMessage + ListAgents folded into one tool — fine. The delta is
44 that Codewhale *also* advertises ~20 budget/authority/model knobs per call.
45 Claude Code's answer, and the direction chosen for #5324/#5123: budgets and
46 authority belong to the role/profile definition, model to the operator's
47 session, and the per-call surface stays at ~12 fields (`action, prompt,
48 type, profile, name, agent_id, message, detached, worktree, write_roots,
49 resume_from, until`). Claude Code has no equivalent of `write_roots`; it is
50 kept because #5426 containment leans on it.
51
52 ## 2. Orchestration: the `Workflow` tool (scripts, not prose)
53
54 A workflow is a **JavaScript script the model writes inline**, executed by the
55 harness deterministically; it runs in the background and the model gets a
56 completion notification. The API surface the script sees:
57
58 - `export const meta = { name, description, whenToUse?, phases: [{title,
59 detail, model?}] }` — pure literal, required first statement.
60 - `agent(prompt, {label?, phase?, schema?, model?, effort?, isolation?,
61 agentType?}) → Promise<string | object>` — with `schema` (JSON Schema) the
62 sub-agent is *forced* to return validated structured output; returns
63 `null` if the user skipped it or it died.
64 - `pipeline(items, stage1, stage2, …)` — per-item stages, **no barrier**
65 between stages (default). `parallel([thunks])` — barrier. `phase(title)`,
66 `log(msg)`, `args`, `budget {total, spent(), remaining()}` (a hard
67 ceiling from a "+500k"-style user directive), `workflow(nameOrPath, args)`
68 (one level of nesting).
69 - Determinism rules: `Date.now()`, `Math.random()` throw (they would break
70 resume). Every run persists its script to a file; a run can be resumed by
71 `{scriptPath, resumeFromRunId}` and the **longest unchanged prefix of
72 agent() calls is replayed from a journal** (`journal.jsonl` records each
73 agent's return value) — edit the script, resume, only the changed tail
74 re-runs. Concurrency cap = min(16, CPUs−2); lifetime cap 1000 agents.
75 - Named/saved workflows: `.claude/workflows/<name>` resolve by name; the
76 script is the artifact. Opt-in is explicit: the user must say
77 "ultracode"/"use a workflow"/invoke a skill that calls it — the model may
78 not spawn dozens of agents on its own judgment.
79 - Documented quality patterns (all in the tool's own guidance): adversarial
80 verify (N refuters per finding), perspective-diverse verify, judge panel,
81 loop-until-dry, multi-modal sweep, completeness critic, no silent caps.
82
83 **Codewhale mapping.** Codewhale's `.codewhale/workflows/*.workflow.js` + Lane Runtime
84 is the same idea (Grok uses Rhai; Claude Code uses JS with the API above; dsh
85 uses YAML presets). What Claude Code does that #5439 asks for: the *user*
86 sees workflows as first-class objects — `/workflows` lists live runs with
87 phase groups and per-agent labels, scripts are files you can open, and the
88 model must announce/relay. The `journal.jsonl` replay-on-resume and the
89 `schema`-forced structured return are the two engine features worth
90 copying if they are missing (check `crates/tui/src/workflow*` before
91 building; do not assume). The "user opts in explicitly" rule is a product
92 decision Codewhale should keep too: goal/workflow/auto are chosen by the
93 user, visibly (#5439 acceptance list), never silently.
94
95 ## 3. Loops and schedules
96
97 - `/loop [interval] <prompt|/skill>` — recurring prompt on an interval; with
98 no interval the model self-paces via `ScheduleWakeup(delaySeconds, noop,
99 reason)`; quiet ticks are collapsed in the UI. Cron-style `CronCreate`
100 exists for autonomous loops.
101 - `/schedule` — cloud "routines" on a cron.
102
103 **Codewhale mapping.** Goal mode + dsh-style ralph loops cover the
104 "keep going until done" case; the interval loop with a *visible reason
105 string per wake* is the piece worth adopting for goal status
106 (`/goal status` should show *why* it is waiting and when it wakes).
107
108 ## 4. Plugins, skills, agents, hooks — the layout that makes them discoverable
109
110 - **Skills** = `SKILL.md` folders (frontmatter `name`, `description`
111 "use when…"). Loaded via a `Skill` tool by exact name; slash-invocable as
112 `/<name>`; scoped variants (`apps/web:deploy`) win by directory. The
113 session lists every available skill with its one-line description at
114 start — discoverability is a *listing*, not documentation.
115 - **Agents** = `.claude/agents/<name>.md` (frontmatter `model`, `effort`,
116 `tools`, description "when to use"). Same listing at session start.
117 - **Plugins** = a marketplace entry that bundles skills + agents + MCP
118 servers + hooks under a namespace (`plugin:skill`, `plugin:agent`, MCP
119 tools `mcp__plugin_<plugin>_<server>__<tool>`). `/plugin` manages
120 marketplaces (add/list/install/remove); plugin skills show up in the same
121 listing as local ones, namespaced. Plugin MCP tools are *deferred*: names
122 are visible, schemas load on demand via `ToolSearch` — the catalog stays
123 small in the prompt prefix.
124 - **Hooks** = `settings.json` (`SessionStart`, tool-call intercept, `Stop`
125 …); hook output is fed back to the model as user-level feedback.
126 - **CLAUDE.md / AGENTS.md** = per-repo contract, loaded verbatim; user-level
127 `~/.claude/CLAUDE.md` layers under it.
128
129 **Codewhale mapping.** Codewhale has all four primitives (docs/SKILLS.md,
130 docs/PLUGINS.md, docs/PLUGIN_BUNDLES.md, docs/HOOKS.md, `plugin.toml`,
131 `/plugin marketplace …`, `.claude/skills` compat per
132 docs/CLAUDE_PLUGIN_COMPAT.md). #5311's real gap versus Claude Code /
133 kimicode is (a) **one namespaced listing** that the model *and* the user see
134 at session start (skills + agents + plugin-provided ones), (b) parsing
135 Claude/Kimi marketplace manifests so a plugin can bring agents + hooks +
136 MCP servers, not only a skill folder, and (c) deferred tool schemas so a
137 large plugin surface does not bloat the pinned prefix (docs/CACHE.md
138 constraint). The `.claude-plugin/plugin.json` runtime semantics Codewhale
139 declines to emulate (docs/CLAUDE_PLUGIN_COMPAT.md) can stay declined; the
140 manifest *parse* and the namespaced listing are the parity items.
141
142 ## 5. Shell: one tool
143
144 Claude Code exposes exactly one shell tool, `Bash` (`command`,
145 `description`, `timeout` ms ≤ 600 000, `run_in_background`, an unsandbox
146 escape flag). Background jobs notify on exit; there is no separate
147 wait/interact/cancel tool family — a `Monitor` tool watches a condition,
148 `TaskStop` kills a background task. Interactive flags (`-i`) are refused up
149 front. Permission is a classifier + allow-rules over the *command string*,
150 not per-tool-name families.
151
152 **Codewhale mapping.** The one-bash consolidation planner already reached
153 the same conclusion (7 exec name families → `bash` + a small session
154 surface). Claude Code adds one detail worth copying: `run_in_background`
155 on the same tool with completion notifications, rather than a second tool
156 family for jobs.
157
158 ## 6. What Claude Code does *not* have (Codewhale is ahead)
159
160 - No fleet ledger, no role-based authority clamps (delegation-never-widens
161 is enforced by prompt + permission classifier, not by a typed envelope).
162 - No provider-portable model routing; the model column is one vendor.
163 - No `/goal` state machine with pause kinds; long-running autonomy is
164 `/loop` + judgment.
165 - No transcript-visible tool-lifecycle contract; retired tool names simply
166 vanish.
167
168 ## 7. Concrete asks this note supports
169
170 1. #5324/#5123 — 12-field agent tool; budgets to roles/profiles/config
171 (matches §1).
172 2. #5439 — `/workflow` no-arg catalog + live-run view; trio visible in the
173 mode picker with "when to use" copy (matches §2/§3 product rule:
174 user chooses, visibly).
175 3. #5311 — namespaced skill/agent/plugin listing at session start; parse
176 Claude + Kimi marketplace manifests; deferred tool schemas (matches §4).
177 4. One-bash — `bash` + `run_in_background` + completion notifications;
178 compat window for hidden legacy names ends at a version boundary
179 (matches §5).
180
180 lines MARKDOWN