返回 CodeWhale
GUIDE.md
根目录 / docs / GUIDE.md
1 # Codewhale User Guide
2
3 This guide is for your first hour with Codewhale. It explains the main
4 workflow, the important safety controls, and where to go next when you need a
5 complete reference.
6
7 Codewhale has deeper reference documents for installation, configuration,
8 providers, modes, keybindings, tools, and operations. Use this page as a guided
9 walkthrough, then follow the "Next" links when you need every option.
10
11 ## 1. Welcome to Codewhale
12
13 Codewhale is a terminal coding agent. You run it from a workspace, give it a
14 task, and it can use structured tools to inspect files, run commands, edit
15 code, and report back with evidence.
16
17 The important difference from a normal chat model is that Codewhale is built
18 around a harness:
19
20 - It keeps the active workspace and session visible.
21 - It routes each turn through explicit modes and approval rules.
22 - It shows tool calls in the transcript instead of hiding the work.
23 - It can preserve sessions, fork conversations, and continue later.
24 - It can run sub-agents for focused background work.
25
26 You can use Codewhale for small questions:
27
28 ```text
29 Explain the authentication flow in this repository.
30 ```
31
32 You can also use it for multi-step work:
33
34 ```text
35 Find the failing validation path, propose a fix, and wait for my approval
36 before editing files.
37 ```
38
39 For a new repository, start conservatively. Ask Codewhale to explore and plan
40 before asking it to change files. That gives you a reviewable path and makes it
41 easier to catch wrong assumptions early.
42
43 Next: [ARCHITECTURE.md](ARCHITECTURE.md) explains the internal harness and
44 runtime model.
45
46 ## 2. First Launch
47
48 For a new macOS or Linux installation, use the official GitHub release.
49 The installer verifies the release checksums and provides the same runtime
50 under the `codewhale` and `codew` command names:
51
52 ```bash
53 curl -fsSL https://codewhale.net/install.sh | sh
54 ```
55
56 Windows users should choose the matching installer or archive from
57 [GitHub Releases](https://github.com/codewhale-hq/CodeWhale/releases/latest).
58 For an existing direct install, use `codewhale update --check`, then
59 `codewhale update`. npm and Cargo remain secondary packaging routes; Cargo
60 also supports source builds where a compatible prebuilt is unavailable.
61 For occupied directories, package-managed installs, and PATH setup, follow
62 [the installation and migration guide](INSTALL.md#recommended-official-github-releases).
63 Android/Termux uses its own [preview archive or source-build path](INSTALL.md#android--termux-arm64).
64
65 Docker is also available when you want an isolated runtime. Pull
66 `ghcr.io/hmbown/codewhale:latest` or [build it from source](DOCKER.md#building-locally).
67
68 ```bash
69 docker volume create codewhale-home
70 docker run --rm -it \
71 -e DEEPSEEK_API_KEY="$DEEPSEEK_API_KEY" \
72 -v codewhale-home:/home/codewhale/.codewhale \
73 -v "$PWD:/workspace" \
74 -w /workspace \
75 ghcr.io/hmbown/codewhale:latest
76 ```
77
78 Once the install directory is on PATH, launch Codewhale from the repository or
79 directory you want it to work in:
80
81 ```bash
82 codewhale
83 ```
84
85 For the default GitHub installer destination, you can use
86 `"$HOME/.local/bin/codewhale"` until that directory is on PATH.
87
88 On first launch, Codewhale opens the composer, even with no key or route.
89 With no key or route, workspace trust is asked once a provider is connected;
90 otherwise only when the folder requires a decision. A provider is asked for
91 when you send your first message: the message stays in the box while you sign
92 in or use your own key, and a local model is offered only when a local Ollama
93 server answers. The provider step also has an explicit offline route.
94
95 Everything optional stays available after that. Use `/setup` for the
96 progressive setup and repair guide, `/settings` for the full typed editor, and
97 `/constitution` when you want your own constitution on top of the bundled one.
98 The localized telemetry choice appears only after the workspace is ready and
99 does not block the composer.
100
101 DeepSeek is the default provider. If you want to configure its key before or
102 after the first launch, the most direct setup path is:
103
104 ```bash
105 codewhale auth set --provider deepseek
106 ```
107
108 You can also provide a key through the environment:
109
110 ```bash
111 export DEEPSEEK_API_KEY="your-key"
112 codewhale
113 ```
114
115 New Codewhale config is stored under `~/.codewhale/config.toml`. Legacy
116 `~/.deepseek/config.toml` files are still supported for users migrating from
117 the old name.
118
119 Use `/constitution` to review or change standing guidance. After setup, run a
120 doctor check:
121
122 ```bash
123 codewhale doctor
124 ```
125
126 It prints a short verdict: whether Codewhale is ready, what works, what needs
127 attention and the next step. `codewhale doctor --full` prints every check.
128
129 Use the JSON form when you need a machine-readable report for an issue:
130
131 ```bash
132 codewhale doctor --json
133 ```
134
135 Both forms are offline by default. They report structural configuration and
136 literal unknown/not-probed credential states without loading workspace `.env`
137 credentials, opening secret/OAuth files, probing a keyring, contacting a
138 provider, or starting MCP servers. Use `--check-updates`, `--probe-api`,
139 `--probe-local`, or `--probe-mcp` only when you intentionally want that live
140 boundary. JSON remains offline and does not accept live flags.
141
142 JSON reports credential `source` separately from literal `availability`.
143 Configured environment, external-auth, OAuth, consent, and secret-store sources
144 remain `not_probed`; their declaration alone does not make Setup or fleet ready.
145 Only a structurally present literal config value, or a route where credentials
146 are not required, certifies offline readiness. A legacy secret-store sentinel on
147 a route that cannot use the shared store is reported separately as
148 `secret_store_unavailable`/`unavailable`, not as eligible or merely unknown.
149
150 Both `doctor` and `doctor --json` also include a session-recovery diagnostic
151 that compares legacy session filenames against the current store and reports
152 one of `isolated`, `no_legacy_sessions`, `migration_pending`,
153 `migration_incomplete`, `migration_complete`, or `scan_failed`; it never reads
154 session contents. Use `migration_pending` or `migration_incomplete` as your
155 cue to finish moving sessions from `~/.deepseek` to `~/.codewhale`, the same
156 legacy-path migration described above. Setting an explicit `CODEWHALE_HOME`
157 suppresses this ambient inspection.
158
159 Next: [INSTALL.md](INSTALL.md) covers platform-specific install paths,
160 [CONFIGURATION.md](CONFIGURATION.md) covers config resolution, and
161 [PROVIDERS.md](PROVIDERS.md) covers provider IDs and credentials.
162
163 ## 3. Your First Task
164
165 For a bounded first task, open an existing project folder and launch Codewhale:
166
167 ```bash
168 cd /path/to/your/project
169 codewhale
170 ```
171
172 Replace `/path/to/your/project` with your folder. Choose Plan, then paste this
173 into the message box:
174
175 ```text
176 Read one source file in this project and explain what it does. Cite its file
177 path and the lines that support your explanation. Do not edit files or run
178 commands.
179 ```
180
181 The model receives the file content it needs to answer. Open the cited file
182 yourself and compare the cited lines with the explanation. This task is
183 complete when you can confirm what the file does and the cited evidence
184 supports the answer. Ask about any mismatch. If setup fails or no reply
185 arrives, follow [the troubleshooting steps](INSTALL.md#13-troubleshooting).
186 You can configure a Fleet after this; it is not required for your first task.
187
188
189 Start with a read-only task in a real workspace:
190
191 ```text
192 Map the repository structure and tell me where the CLI entrypoint lives.
193 ```
194
195 Then ask for a focused plan:
196
197 ```text
198 I want to add a small validation for empty config values. Inspect the relevant
199 code and propose the smallest safe change before editing anything.
200 ```
201
202 When you are ready for edits, be specific about the acceptance criteria:
203
204 ```text
205 Implement the validation you proposed. Keep the change scoped to config
206 parsing, add or update the narrowest test, and run the relevant check.
207 ```
208
209 Good first prompts include four details:
210
211 - The outcome you want.
212 - The files, feature, or behavior you care about.
213 - What is out of scope.
214 - What verification should count as done.
215
216 For example:
217
218 ```text
219 Fix the broken provider error message in the config loader. Do not change the
220 provider registry. Add a regression test and run only the config crate tests.
221 ```
222
223 If you are not sure where the bug is, say that:
224
225 ```text
226 Investigate why `codewhale doctor` reports the wrong provider. Do not edit
227 files yet. Return the likely cause, evidence, and a proposed patch plan.
228 ```
229
230 Codewhale works best when you let investigation and implementation happen in
231 separate steps for unfamiliar code. For small, well-understood changes, a
232 single implementation request is fine.
233
234 Next: [MODES.md](MODES.md) explains when to use Plan and Work.
235
236 ## 4. Understanding the Interface
237
238 The interactive TUI has a few stable regions:
239
240 - Header: current session, active model, mode, and high-level status.
241 - Transcript: the conversation, tool calls, command output summaries, and
242 model responses.
243 - Composer: where you type prompts, slash commands, and file mentions.
244 - Workbar: the strip under the composer (or an optional side workbar) that
245 holds the active goal, the to-do list, and sub-agents. Rows stay for the
246 whole session — finished work reads as done rather than disappearing — and
247 clicking a row (or pressing `Enter` on it) opens its detail.
248 - Status and footer areas: live activity, queued follow-ups, and short command
249 hints.
250
251 When the model asks a question (`request_user_input`), a bottom sheet opens
252 over the transcript rather than a centered overlay. The conversation stays
253 visible above it. Use `PageUp`/`PageDown`, `Home`/`End`, or modified `↑`/`↓`
254 (`Ctrl`, `Alt`, or `Shift`) to review the transcript while the sheet stays open.
255 The mouse wheel scrolls the transcript above the sheet and the question content
256 over the sheet itself. Moving the highlight or typing brings that content back
257 into view after wheel browsing. Use `↑`/`↓` to move, `Enter` to confirm, `←`/`h`
258 to go back to a previous question, and `Esc` to cancel the whole request.
259 Every question offers an "Other" row for a custom response; that text stays on
260 screen while you type. Keys for the sheet are in [KEYBINDINGS.md](KEYBINDINGS.md).
261
262 The bottom chrome is configurable. Run `/statusline` to choose what is
263 visible, or set `[tui].status_items` in `config.toml`. Each key owns exactly
264 one thing on screen: `mode` is the posture bar's plan/work chip, and
265 `model`, `context_percent`, `cost`, `balance` (prepaid providers only:
266 DeepSeek, DeepSeekCN, OpenRouter, SiliconFlow), `cache`, `tokens` and
267 `ttft`, `output_rate`, `workspace` and `git_branch` are segments of the metrics line below it. Omit
268 `status_items` to keep the built-in default; set it to `[]` to strip the
269 metrics line down to the help hint.
270
271 `workspace` and `git_branch` are opt-in. The workspace chip shows the folder
272 name; linked worktrees include its parent to distinguish repeated names. The
273 branch chip shows the current branch or a short detached HEAD SHA, with `(wt)`
274 for linked worktrees. Both keep the last 24 display columns when long. Git
275 metadata refreshes in the background on the existing 15-second cadence and
276 when a refresh is requested; unavailable Git data removes the branch chip.
277 These identify the active session workspace. The full path remains in `/status`.
278
279 `context_percent` is on by default and shows `ctx NN%` at every fullness —
280 0.9.12 went silent below 50% and left most of a session with no context
281 signal at all. The reading keeps its warning colour from 80% up.
282
283 The keys `status`, `agents`, `reasoning_replay`, `prefix_stability`,
284 `last_tool_elapsed` and `rate_limit` were retired in 0.9.13:
285 they drove nothing. Old configuration files still load — the retired keys are
286 ignored with a warning in the log.
287
288 `status_items` composes the rows; two size presets decide how much of each
289 row paints. `[tui].posture_bar` and `[tui].metrics_line` each take `full`,
290 `compact`, or `hidden`. The posture bar defaults to `full` so active controls
291 stay visible; the metrics line defaults to `compact` to keep selected performance
292 readings while removing secondary counts and help. These are also settable at runtime with
293 `/config posture_bar compact`. TOML values must be lowercase; `/config`
294 accepts either case. `compact` is the row after its first shed
295 rungs: the posture bar keeps its permission and mode chips — and the cap
296 warning, which is advice, not decoration — and drops the clocks, counts and
297 hint; the metrics line keeps the route, the context reading, the cost and
298 the balance, plus selected TTFT and output rate when space allows, and drops
299 secondary counts and the help hint. `hidden` gives the
300 row back to the transcript. A small tmux pane can hide both rows without
301 touching what `/statusline` composes.
302
303 Both `ttft` and `output_rate` are on by default and work in full or compact
304 rows. `/statusline` lets you toggle them separately; Space previews, Enter saves,
305 and Esc restores your previous settings. Legacy `session_metrics` still enables
306 both readings. The pair shows: `ttft 1.5s` — the mean time to first streamed token — and `120 avg tok/s`,
307 the session's provider-reported output tokens divided by the measured request
308 seconds for those same calls. The rate includes connection setup, time to first
309 token and pauses within a response, and excludes tools and idle time between
310 calls. It measures effective request throughput, not decoder speed. Streaming
311 and non-streaming calls follow the same rule; receipts without individual
312 request timing are excluded from both tokens and time. While a request runs,
313 the last measured average stays visible. Both readings use the same
314 accumulators `/status` prints in full. Missing evidence is omitted rather than
315 estimated. On narrow rows the pair sheds before cost and context.
316
317 Every file read, command, and edit appears in the transcript as it happens.
318 `/receipts` lists what the session did, one line per action; see
319 [What Codewhale records](#what-codewhale-records). If a command fails, use the
320 visible failure output as part of your next instruction instead of starting
321 over.
322
323 The composer accepts normal prompts and slash commands. Type `/` to discover
324 available commands. Use file mentions when you want the model to focus on a
325 specific file or directory instead of searching broadly.
326
327 The workbar is useful when a turn spans multiple steps. It keeps the goal,
328 the to-do list, and agent state visible while the transcript continues to
329 grow — including after the work settles, so you can still open what happened.
330
331 Keyboard shortcuts vary by context, terminal, and platform. This guide avoids
332 duplicating the full shortcut catalog so it does not drift from the TUI.
333
334 Next: [KEYBINDINGS.md](KEYBINDINGS.md) is the complete shortcut reference.
335
336 ## 5. Modes
337
338 Codewhale has two visible TUI modes:
339
340 | Mode | Use it for | Default posture |
341 | --- | --- | --- |
342 | Plan | Exploration, design, and review before changes | Read-only investigation |
343 | Work | Normal multi-step coding work | Tool use with approval gates |
344
345 Switch modes from the TUI with the mode picker:
346
347 ```text
348 /mode
349 ```
350
351 Or switch directly:
352
353 ```text
354 /mode plan
355 /mode work
356 ```
357
358 `operate` still parses, as Work, so an older setting or script keeps working.
359
360 Plan mode is the safest place to start in an unfamiliar repository. It is for
361 inspection and decision-making, not file edits.
362 When a Plan turn successfully finishes a nonempty response, Codewhale asks
363 how to continue, including when the plan is plain text. **Work (Ask)**,
364 **Work (Accept Edits)** and **Work (Auto-Review)** switch to Work with that
365 permission and send the exact approved response as the next message. Existing To-dos from that turn are
366 preserved; a prose-only plan adds one pending item without replacing unrelated
367 work. If Codewhale cannot prepare the work state, it stays in Plan without
368 starting the task. **Keep planning**, or `Esc`, stays in Plan. You can also
369 type feedback there to have the plan revised. The question appears only when
370 the composer is empty and no other view is open; `/mode work` always works.
371
372 Work mode is the default for most contribution work. It lets Codewhale read,
373 run checks, and edit files while keeping risky actions behind approval gates.
374
375 Work keeps that direct tool surface and its approval, sandbox, shell,
376 ask-rule, and repository protections. Small or tightly coupled work stays
377 direct. Multi-step delegation uses a compact Workflow plan with dependencies,
378 bounded scopes, and completion evidence passed between steps. Fleet configures
379 and manages those same sub-agents and their roles. One bounded, independent
380 task can use a direct agent; continued work reuses it through `followup`.
381 `codewhale dispatch "<task>"` runs work on a Codewhale cloud computer when
382 your account has access. Cloud availability and admission come from the account
383 service.
384
385 Local work needs no Codewhale account. In 0.10.5 starting a new account
386 sign-in is closed until accounts open (see [Account](ACCOUNT.md)); a profile
387 that is already signed in keeps working, and `codewhale account status` shows
388 its state. When accounts are open, `/login` opens account sign-in inside the
389 TUI, with a browser link and code, Copy, and Cancel. `/connect` connects a model provider or local model. Signing in
390 preserves your selected model and unsent message. An account connection is
391 separate from usable model access.
392
393 `/logout`, `codewhale logout` and `codewhale account logout` sign out of
394 Codewhale while keeping local model connections and conversations. To remove
395 all saved provider credentials as well, use `codewhale logout --all`; that
396 operation asks for confirmation (`--all --yes` confirms non-interactively).
397
398 For trusted workspaces where you intentionally want actions to proceed without
399 approval prompts, select the Full Access permission posture with `Shift+Tab`.
400 Do not use Full Access in a repository you do not trust.
401
402 Modes are separate from model routing. The `Shift+Tab` permission dial steps
403 Ask → Accept Edits → Plan → Auto-Review → Full Access, while `/model auto`
404 controls model and thinking selection for turns.
405
406 You can also change approval behavior from `/config` by editing the approval
407 mode. Use this only when you understand how it changes tool execution.
408
409 Next: [MODES.md](MODES.md) has the full mode, approval, and trust-mode
410 reference.
411
412 ## 6. Slash Commands
413
414 Slash commands are typed into the composer. They are useful when you want to
415 change Codewhale state directly instead of asking the model in natural
416 language.
417
418 Common commands for first-time users:
419
420 | Command | Use |
421 | --- | --- |
422 | `/mode` | Open the mode picker or switch with `/mode agent` |
423 | `/model` | Select a model or use `/model auto` |
424 | `/provider` | Pick the active API provider |
425 | `/fleet` | Open the selected fleet's member roster |
426 | `/fleet saved` | Pick or switch among named saved fleets |
427 | `/fleet context` | List shared project notes or read one with `/fleet context read <name>` |
428 | `/fleet board` | List shared tasks or use `add`, `claim`, and `done` to update them |
429 | `/view-plan` | Open the session plan. Use `save`, `edit`, or `build` for that plan |
430 | `/worktree` | Open the Git worktree manager. `/workspace worktrees` opens the same view |
431 | `/context limit <tokens>` | Set the model’s context window. `/context limit reset` restores automatic sizing |
432 | `/goal` | Set a persistent objective the agent works toward across turns; bare `/goal` shows progress |
433 | `/workflow` | Orchestrate the current work as a Workflow; `status`, `cancel`, `settings` answer without a model turn |
434 | `/workflows` | Open the live Workflow run dashboard: every run this workspace's journal keeps, with phases, children, progress, and host-side cancel |
435 | `/config` | Edit runtime and provider settings |
436 | `/settings` | Open the typed settings editor; `/settings text` prints the resolved values |
437 | `/statusline` | Choose which footer status chips are visible |
438 | `/anchor` | Pin a fact that stays when Codewhale makes room; `/anchor list` and `/anchor remove <n>` manage pins |
439 | `/structcopy` | Copy one session object (`turn <n>`, `tool <call-id>`, `plan`, `workflow <run-id>`) as redacted JSON |
440 | `/remote-env` | Show hosted Work options; `/remote-env open` opens new hosted Work from a GitHub or CNB branch tip |
441 | `/color` | Give this chat's composer box its own color: bare `/color` cycles red, orange, amber, green, cyan, blue, purple and pink, `/color blue` picks one, `/color off` returns to the theme |
442 | `/receipts` | List what this session did: files changed, commands run, web and MCP calls, agents, approvals and who gave them, failures |
443 | `/compact` | Summarize long context to recover token budget |
444 | `/copy` | Copy the last completed assistant response to the clipboard |
445 | `/export` | Copy the conversation, or save it as Markdown, HTML or JSON; see [Exporting a conversation](#exporting-a-conversation) |
446 | `/review` | Ask for a structured review workflow |
447 | `/memory` | Inspect or manage memory when enabled |
448 | `/mcp` | Configure or inspect MCP server integration |
449 | `/plugin` | Review and manage disabled-by-default local plugin bundles |
450 | `/rc` | Hand this exact session to the signed-in Codewhale web app |
451
452 Toolbox commands stay searchable when you type them directly: `/models`
453 fetches live endpoint IDs, `/modeldb` opens the bundled model reference, and
454 `/rlm` loads a file or block of text into a working context that stays
455 available for the rest of the session.
456
457 Use `/provider` when you want to switch away from the default DeepSeek route.
458 Provider IDs, environment variables, model defaults, and capability notes are
459 kept in the provider registry document.
460
461 Soft-auto multi-agent work: [AUTOMATIC_WORKFLOWS.md](AUTOMATIC_WORKFLOWS.md).
462
463 Posting Codewhale PR reviews as a bot identity:
464 [GITHUB_APP.md](GITHUB_APP.md).
465
466 Next for durable multi-worker work: [FLEET_WORKFLOW_TUTORIAL.md](FLEET_WORKFLOW_TUTORIAL.md)
467 walks through fleet task specs, monitoring, and Workflow authoring.
468
469 Fleet is the public noun for the durable roster. `codewhale fleet …` is
470 the command and `/fleet` the slash command. The Fleet name is
471 shared by what has to stay stable across versions: the durable ledger
472 `.codewhale/fleet.jsonl`, saved rosters `fleets/<name>.toml`, the `[fleet]`
473 config table, and the `codewhale workflow run --fleet` flag.
474
475 Use `/model auto` when you want Codewhale to choose the model and thinking
476 level per turn. When the DeepSeek routing model is available, Auto may select
477 any runnable provider/model pair in the redacted inventory. That classification
478 sends the latest request (capped at 4,000 characters) plus a bounded summary of
479 up to six recent context rows (900 characters each) to
480 `DeepSeek / deepseek-flash`. Credentials, endpoints, and provider error text
481 are not included in the inventory. Without that router, Auto uses a local,
482 provider-aware heuristic and sends no routing request. If a classifier attempt
483 fails validation or errors, Auto falls back to that heuristic while retaining
484 the attempted classifier data path in the turn receipt.
485
486 The `/model` picker states which data path is available and shows the last
487 resolved route. `Ctrl+O` opens the reasoning detail for the selected or current
488 turn; `Ctrl+Alt+O` (or `/turn inspect`) opens the whole-turn Turn Inspector,
489 whose model-route section records the concrete provider/model, strong/fast pair,
490 selected tier, selection scope, route reason, and whether the classifier received
491 routing context. Use a
492 fixed model when you need repeatable comparisons, a strict provider boundary,
493 or no classification request.
494
495 Use `/compact` when a session gets long and the model starts carrying too much
496 history. Compaction trades raw transcript detail for a concise working summary.
497
498 ### Viewing the live transcript
499
500 Run `/transcript` to open a view of the current conversation that follows new
501 output. Use `PageUp` and `PageDown` to scroll. Scrolling up pauses automatic
502 following. Press `End` to return to the latest output and resume following, or
503 `Esc` to return to the composer.
504
505 ### Exporting a conversation
506
507 `/export` copies a redacted transcript to the clipboard. `/export file` saves
508 it instead, and the file format follows the extension:
509
510 ```text
511 /export file auto-named Markdown under the Codewhale exports folder
512 /export file notes.html a self-contained HTML page (light and dark, no scripts)
513 /export file notes.json structured JSON with typed message blocks
514 /export file notes.md --no-tools Markdown without tool calls and results
515 /export file notes.md --force replace an existing file
516 /export turn the latest turn as a handoff note
517 ```
518
519 `--format md|html|json` overrides the extension, and `--format html` or
520 `--format json` on its own writes an auto-named file. HTML and JSON are
521 file-only because a clipboard paste would lose their structure. Auto-named
522 files are `codewhale-<title>-<timestamp>.<ext>` in `<codewhale home>/exports`.
523 `~` is expanded, quotes keep a path with spaces together, and an existing file
524 is never replaced without `--force`.
525
526 Every format omits the system prompt and internal reasoning, redacts
527 secret-like values and credential-bearing URLs, and fences tool output so it
528 cannot forge a heading or a message. `/share` publishes the same HTML page as a
529 secret gist after a confirmation.
530
531 This guide intentionally does not list every command. The command surface
532 changes more often than the onboarding flow, and the TUI command palette is the
533 source of truth while you are inside a session.
534
535 Next: [CONFIGURATION.md](CONFIGURATION.md) covers runtime settings and
536 [MCP.md](MCP.md) covers Model Context Protocol integration.
537 [PLUGIN_BUNDLES.md](PLUGIN_BUNDLES.md) covers the disabled-by-default bundle
538 inventory, capability review, and namespaced Skill/MCP activation boundary.
539
540 ## 7. Working with Tools
541
542 Codewhale tools are structured actions. Instead of only producing prose, the
543 model can call tools to inspect and change the workspace.
544
545 Examples of tool-backed work include:
546
547 - Reading a file before explaining it.
548 - Searching for call sites before proposing a refactor.
549 - Running a focused test command.
550 - Applying a small patch.
551 - Opening a sub-agent for parallel investigation.
552
553 Tool use is governed by mode, approvals, and sandbox policy. The exact behavior
554 depends on the current mode and config, but the basic rule is simple: start in
555 Plan for read-only exploration, use Work for normal changes, and reserve Full
556 Access for trusted automation.
557
558 The workspace boundary matters. Codewhale is expected to work in the directory
559 you launched it from or the workspace you configured. Be explicit when a task
560 should stay inside a repo:
561
562 ```text
563 Only inspect and edit files under this repository. Do not touch parent
564 directories or global config.
565 ```
566
567 When a command needs network, writes outside the workspace, or a risky shell
568 operation, expect an approval prompt unless you have configured more permissive
569 behavior.
570
571 Good tool instructions are concrete:
572
573 ```text
574 Run the narrowest test that covers this parser change. If it fails, report the
575 failure and stop before broadening the test scope.
576 ```
577
578 Avoid asking for broad cleanup during a focused fix. Smaller tool scopes make
579 the transcript easier to review and the final diff easier to merge.
580
581 Next: [TOOL_SURFACE.md](TOOL_SURFACE.md) lists the tool surface and
582 [SANDBOX.md](SANDBOX.md) explains sandbox behavior.
583
584 ### What Codewhale records
585
586 Codewhale keeps these records on your machine, under `~/.codewhale/`:
587
588 - **The session.** `sessions/<id>.json` holds the full conversation,
589 including every tool call and its result text. App and `codewhale serve`
590 threads keep each call as a turn item under `tasks/runtime/`, with its
591 input, status, start and end time, and structured result.
592 - **Approvals.** `sessions/<id>/approval_receipts.jsonl` records every
593 approval Codewhale asked for, the decision, and who made it: you, a
594 session rule, or the active posture. App threads also record each decision
595 in their event log. A call that ran without asking (Full Access, an allow
596 rule, a remembered grant) has no approval record; the posture each turn
597 ran under is saved with the turn.
598 - **Undo points.** `/undo` takes back your last request and its proven file
599 changes. `/undo select` lets you choose the first request to undo along with
600 all later requests, with visible checking, restoring and saving progress.
601 Neither command changes your access mode. File reversal requires the
602 request's own recorded tool executions, complete restore points and files
603 that still match what those executions left. Missing or incomplete records,
604 including older sessions or turns run with snapshots disabled, cause a
605 refusal that preserves the files and conversation. `/undo force` cannot
606 bypass these checks. A request with no file-writing work can rewind only its
607 conversation. Esc Esc also rewinds the conversation only. `/restore` selects
608 an explicit workspace snapshot and can overwrite later edits; it requires
609 `/trust on` or Full Access.
610 - **Security events.** `audit.log` records credential changes, hook
611 environment key names, compaction passes, the terminal's approval
612 routing, and Auto-Review verdicts. It is not a list of what a session did.
613
614 To see what a session did, run `/receipts`, or from a shell:
615
616 ```bash
617 codewhale receipts --last
618 codewhale receipts <session-id> --format json
619 ```
620
621 A receipt says what it cannot show. A terminal session's receipt lists the
622 files a command changed from each turn's workspace snapshots; a Runtime
623 thread's lists only file tools. Terminal sessions do not save a passing
624 command's exit code or how long each call took. A call Codewhale blocked
625 before it started (Auto-Review, a policy, invalid input) is listed as
626 blocked, with the reason, and is not counted as run. [RECEIPTS.md](RECEIPTS.md) has the full contract.
627
628 ## 8. Sub-agents and Parallel Work
629
630 Sub-agents are background child agents. The parent session gives a child a
631 focused task, receives an agent id, and can continue working while the child
632 runs.
633
634 The main orchestration tool is:
635
636 - `agent`: start a focused child with a task and role. The child runs in the
637 background and returns a compact receipt plus transcript handle.
638
639 You normally do not need to call these tools directly. Ask for parallel work in
640 plain language:
641
642 ```text
643 Open one read-only explorer for the config crate and another for the TUI
644 provider picker. Have both return file references and risks before we plan the
645 fix.
646 ```
647
648 Useful roles include:
649
650 | Role | Good for |
651 | --- | --- |
652 | `general` | Multi-step tasks; the default when no role is specified |
653 | `explore` | Read-only code mapping |
654 | `plan` | Design and migration planning |
655 | `review` | Bug-focused review of an existing change |
656 | `implementer` | A tightly specified edit |
657 | `verifier` | Running checks and reporting pass/fail evidence |
658
659 Sub-agents are most useful when work can be separated cleanly. Do not use them
660 for tiny edits, and do not ask multiple agents to write the same files at the
661 same time.
662
663 ### How long work stays coherent
664
665 Work that spans many turns does not rely on an ever-growing chat transcript.
666 This is ordinary Agent behavior — there is nothing to turn on and no separate
667 workflow to learn:
668
669 - A working context stays loaded for the session. Large source material and the
670 durable transcript are held as data the agent can search and slice, and useful
671 variables and imports survive across turns.
672 - Workflow composes independent `task(...)` calls and parallel fan-out.
673 - `agent` messages and follow-ups coordinate active children directly.
674 - Goals retain the durable objective across the work.
675
676 `/rlm <file-or-text>` points that working context at a specific file or block
677 of text. The historic action-shaped `rlm` tool remains registered only so older
678 sessions replay, and is deliberately not taught to new model turns.
679
680 Next: [SUBAGENTS.md](SUBAGENTS.md) covers roles, lifecycle, concurrency, and
681 output contracts.
682
683 ## 9. Skills
684
685 Skills are reusable instruction packs. A skill is usually a `SKILL.md` file
686 that teaches Codewhale how to perform a recurring workflow, use a tool family,
687 or follow a project convention.
688
689 Use skills when a task has a repeatable process:
690
691 - Reviewing a specific kind of PR.
692 - Working with a document or spreadsheet format.
693 - Following a team release checklist.
694 - Using a project-specific memory or wiki workflow.
695
696 Inside the TUI, `/skill <name>` activates a skill when one is available, and
697 bare `/skills` opens Plugins → Skills (owned-only inventory, no network).
698 Use `/skills manage` for the manager and
699 `/skills <prefix>`, `/skills inspect`, `/skills --remote`, `/skills suggest <task>`,
700 or `/skills sync` for the text/registry paths. Suggestions rank the remote
701 catalog but never install or activate anything. The command palette can also
702 surface skill entries alongside normal slash commands.
703
704 Good skills are narrow. They should tell the model what workflow to follow,
705 what evidence to collect, and what to avoid. They should not hide credentials
706 or replace normal repository documentation.
707
708 If a repository has its own instructions, treat them as part of the active
709 work. Read the local guidance before editing, and keep any contribution within
710 the repository's conventions.
711
712 Next: see [SKILLS.md](SKILLS.md) for the manager, ownership, and provenance
713 rules; [CLAUDE_PLUGIN_COMPAT.md](CLAUDE_PLUGIN_COMPAT.md) for Claude Code
714 skill/plugin compatibility; and [CONFIGURATION.md](CONFIGURATION.md) for config
715 paths and project authority.
716
717 ## 10. Getting Help
718
719 Start with doctor output:
720
721 ```bash
722 codewhale doctor
723 ```
724
725 Add `--full` for every check. Use JSON when filing a detailed issue:
726
727 ```bash
728 codewhale doctor --json
729 ```
730
731 For authentication problems, use the structural source state in
732 `codewhale doctor --full` to identify what is declared. Doctor deliberately does not inspect environment, secret-store,
733 keyring, or OAuth token values. When a live check is appropriate, opt in with
734 `codewhale doctor --probe-api` (or `--probe-local` for a local endpoint).
735
736 For provider problems, confirm the active provider and model:
737
738 ```text
739 /provider
740 /model
741 ```
742
743 For long or confusing sessions, use `/compact` to reduce context pressure, or
744 start a fresh session in the same workspace and summarize what you need.
745
746 When reporting an issue, include:
747
748 - Codewhale version.
749 - Install method.
750 - Operating system and terminal.
751 - Provider and model.
752 - The exact command or prompt.
753 - Relevant doctor output.
754 - Whether the problem happens in a fresh workspace.
755
756 Do not paste API keys, private source code, or secrets into a public issue.
757
758 Next: [OPERATIONS_RUNBOOK.md](OPERATIONS_RUNBOOK.md) has operational triage and
759 recovery steps.
760
761 ## FAQ
762
763 ### Is Codewhale only for DeepSeek?
764
765 DeepSeek is the default and first-class route, but Codewhale also supports
766 other hosted and local OpenAI-compatible providers. Use `/provider` or
767 `codewhale --provider <id>` to choose a provider. Keep the provider registry
768 open when configuring a non-default route.
769
770 ### Which mode should I use first?
771
772 Use Plan for unfamiliar code, Work for normal implementation, and Full Access
773 only for trusted repositories where automatic execution is acceptable.
774
775 ### Why does Codewhale ask before running commands?
776
777 Approvals are part of the safety model. Shell commands, paid tools, writes, and
778 actions outside the expected workspace can have side effects. Approval prompts
779 let you keep control while still letting the model do useful work.
780
781 ### How do I run a Python file on macOS?
782
783 Open Terminal in the folder that contains the file and run:
784
785 ```bash
786 python3 your_file.py
787 ```
788
789 If macOS says `python3` is missing, install Python from
790 [python.org](https://www.python.org/downloads/macos/) or with Homebrew:
791
792 ```bash
793 brew install python
794 ```
795
796 Inside Codewhale, ask the agent to inspect the file and run it with
797 `python3 your_file.py`. If the script needs packages, install them in a virtual
798 environment first:
799
800 ```bash
801 python3 -m venv .venv
802 source .venv/bin/activate
803 python3 -m pip install -r requirements.txt
804 python3 your_file.py
805 ```
806
807 ### Where is my config stored?
808
809 New Codewhale config uses `~/.codewhale/config.toml`. Legacy
810 `~/.deepseek/config.toml` remains supported for compatibility. Project overlays
811 can also affect behavior when a workspace config exists.
812
813 ### How do I keep costs predictable?
814
815 Use `/model auto` for routing, choose a fixed model when you need a strict
816 profile, and compact long sessions. For larger tasks, ask Codewhale to plan
817 before implementing so you do not spend tokens on the wrong path.
818
819 ### How do I continue previous work?
820
821 Codewhale saves sessions. Use the session picker or resume/continue CLI paths
822 documented in the README and modes guide. For a risky experiment, fork the
823 session before changing direction.
824
825 The `/sessions` picker starts scoped to the current workspace so resumes stay
826 attached to the project you opened. Press `a` in the picker to show sessions
827 from every workspace, or run `codewhale sessions` to list all saved sessions
828 with last-updated timestamps before resuming a specific id.
829
830 Use `/rename <name>` to change the saved session name shown in the picker.
831 Use `/title <name>` to set the terminal tab title for the current session.
832 Run `/title` to see the effective title or `/title off` to clear the session
833 setting. The configured default applies again if one exists.
834
835 If you move or rename a project folder, update saved sessions, recovery
836 checkpoints, and Runtime thread bindings together before resuming:
837
838 ```sh
839 codewhale sessions migrate --old-path /path/to/old-project --new-path /path/to/new-project
840 ```
841
842 Pass `--dry-run` to preview affected records, or `--session <id>` to migrate
843 one session.
844
845 To archive the durable record and its artifacts, run:
846
847 ```sh
848 codewhale sessions export <id-or-unique-prefix> --output session.tar.xz
849 ```
850
851 The archive contains `session.json`, a portable `container.json`, a manifest,
852 and regular files under `artifacts/`. Use `--skip-artifacts` for the record
853 only, `--compression 0` through `9` to choose the xz preset (default `6`),
854 and `--force` to replace an existing output. Store the archive outside the
855 session store. Symlinks are skipped; linked artifact roots, hard links,
856 nonportable filenames, and trees exceeding 64 directory levels or 100,000
857 entries fail the export without replacing the destination.
858
859 Unlike the sanitized `/export`, these archives retain unredacted
860 session content, including system prompts, thinking, tool calls and results,
861 journal branches, and approval receipts. Extract `session.json` and open it
862 with `/load` in the TUI; `/resume` imports the conversation only. Extracted
863 artifacts remain separate files and are not installed into the artifact store
864 by `/load`. Pause writes before archiving if every artifact must reflect the
865 same instant; growing files are bounded to their recorded size and shrinking
866 files abort the export.
867
868 If a long linear session exceeds the 8 MiB full-history transport limit and
869 cannot be resumed directly, preview or apply an archive-backed trim that moves
870 the oldest journal entries into `.journal-archive/<id>.jsonl` while keeping the
871 recent working tail:
872
873 ```sh
874 codewhale sessions trim <id-or-unique-prefix> # dry run
875 codewhale sessions trim <id-or-unique-prefix> --apply # trim to 7.0 MiB
876 codewhale sessions trim <id-or-unique-prefix> --keep-mib 6 --apply
877 ```
878
879 Close any open session before running `--apply`. Export first with
880 `codewhale sessions export <id>` if you also want a standalone `.tar.xz`
881 backup.
882
883 To continue the exact running session from the web app, type `/rc` or launch
884 with `codewhale rc`. Approve the one-time code in the system browser. While the
885 lease is active, the browser owns new prompts and approvals and the terminal is
886 a readable safety surface. Once connected, the banner and a transcript note
887 show the live session link; `/rc open` opens it in your browser and `/rc link`
888 prints it. The hosted browser app at app.codewhale.net is not open yet. `/rc status`
889 shows ownership, `/rc stop` returns it to the terminal, and interrupt remains
890 available. A dropped connection keeps local input locked until the last web
891 lease expires so two controllers never race. Every folder you enroll from one
892 terminal shares a single stable device id, so the web app lists one computer
893 per machine rather than one per session.
894
895 If remote control fails, the reason remains in the current terminal transcript
896 and TUI log after the error toast expires. The footer then shows `/rc status`;
897 run it to inspect the failure and whether retrying must wait for a prior lease.
898
899 > Note: the hosted browser app at app.codewhale.net is not open yet. The
900 > desktop app (Electron and React, a development build) is the client being
901 > built. The local browser client, `codewhale web`, is released and needs no
902 > account.
903
904 ### What should I do when the model gets confused?
905
906 Stop and restate the goal, constraints, and current evidence. If the transcript
907 is long, use `/compact` or start a fresh session with a short handoff. If the
908 problem is operational, run `codewhale doctor` and inspect the reported config
909 and provider state.
910
911 ### Should I put project rules in prompts or files?
912
913 Use repository files for durable project rules and prompts for turn-specific
914 intent. If a workflow repeats across projects, consider turning it into a
915 skill.
916
917 ### Can Codewhale edit files outside the current repository?
918
919 That depends on workspace boundaries, sandbox settings, trust mode, and
920 approval policy. For contribution work, keep instructions scoped to the current
921 repository unless you intentionally need something else.
922
923 ### Where should I go after this guide?
924
925 Read the focused reference for the thing you are changing. For most users, the
926 next pages are install, configuration, providers, modes, keybindings, tools,
927 and sub-agents.
928
929 Next: [INSTALL.md](INSTALL.md), [CONFIGURATION.md](CONFIGURATION.md),
930 [PROVIDERS.md](PROVIDERS.md), [MODES.md](MODES.md), and
931 [TOOL_SURFACE.md](TOOL_SURFACE.md).
932
933 ## Live Terminal dock
934
935 Open `/workbar terminal` to watch the same workspace PTY sessions the model
936 uses. Click the dock or press `Alt+W` to give it input focus. While focused,
937 typing, Enter, Tab and Ctrl+C reach the selected shell. Esc returns focus to
938 the composer; the output remains visible. Click a session or use `Alt+Down` /
939 `Alt+Up` to switch. `Ctrl+N` starts your own fresh shell without replacing the
940 model’s session. Mouse-wheel and PageUp/PageDown review the retained output.
941 The active permission posture and filesystem scope govern fresh shells and
942 refuse reuse of an unsandboxed shell after the scope narrows.
943
944 On macOS and Linux, interactive tabs render terminal cells. Progress updates
945 overwrite their line, and alternate-screen programs restore the shell when they
946 exit. The dock fits the PTY to its pane up to 512 columns by 256 rows,
947 keeps 256 rows of scrollback and caches the four most recently viewed screens. It reads the Engine’s
948 retained output in 64 KiB chunks with its own cursor. A gap starts a fresh
949 screen and shows how many bytes were missed. Background command tabs show
950 their stdout and stderr logs. A reset or lost session requires explicit
951 selection before input reaches its replacement. Process restart ends the PTY.
952
953 Paste
954 is direct terminal input and may execute commands containing newlines; control
955 characters and pastes over 64 KiB are refused. While a process uses canonical
956 line input, batches of 1 KiB or more are refused before any bytes are sent:
957 the terminal can discard oversized input. Transfer long content through a file.
958
958 lines MARKDOWN