Use before writing code for any Codewhale feature, upgrade, or refactor: find the existing owner of the behavior, bound the change to one reviewable slice, and
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-cw-slice-61faebbaaea1 ,按照其中的说明把「cw-slice」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
The expensive mistake in this repo is not a bad implementation — it is a second
implementation. A new model_*, *_config, provider_*, or "bridge" module
beside the one that already does the job ships two systems and a comment that is
no longer true. This skill is the ponytail ladder's rung 2 with commands
attached: find the thing that already exists, then edit it.
Stage 2 of the loop: cw-orient → slice → cw-gates → cw-dogfood → cw-land → cw-handoff.
Walk the ladder before opening an editor (AGENTS.md, "The ponytail
method" — not restated here, since a second copy is what rung 2 forbids).
Stop at the first rung that answers. The ladder runs after reading the
code, never instead of it: a short diff written without reading the call
sites is a guess, not a small change. State the rung only when the choice
isn't obvious from the diff itself.
Grep for the predecessor. This is the step that gets skipped and the one that costs the most:
grep -rn "<the concept, in the words the code would use>" crates --include='*.rs' | head -40
ls crates
grep -rln 'model_\|_config\|provider_' crates/*/src --include='*.rs' | head -30
Search behavior and symbols, not just filenames. If you find an owner, edit it. If you are still adding a new layer, its module doc must name the predecessor it replaces — otherwise you are editing the wrong file.
Check the contracts you are about to walk into. One of these is guard-tested, the rest are convention — either way, move them with their code, not around it:
crates/tui/src/core/engine/turn_loop.rs, guarded by
crates/core/tests/single_turn_loop.rs. A second loop fails the guard;
changing the shape means changing the guard with it.BASE_PROMPT in crates/tui/src/prompts/text.rs.agent; agent_open / agent_eval /
agent_close / delegate_to_agent are removed surfaces. If the shape
must move, move the code and add the guard test that judges the new
shape — the convention is not a fence around the area.docs/CACHE.md). Any new session-context contributor must state its cache
effect — frozen prefix vs. append-only history. Never splice a volatile
fact into the prefix.crates/tui/src/core/ is a module inside the TUI crate. crates/core is a
different crate that runs no turns. Do not confuse them.runtime/src/context_budget.rs, tui/src/model_registry.rs,
runtime/src/prompt_zones.rs, tui/src/tools/remember.rs, config/src/route/.Read the scoped guidance for the files you will touch. crates/tui/AGENTS.md
owns the UI contracts (one owner per fact, codewhale_palette::grammar semantics, typed
state enums, toast routing, tr(locale, MessageId::...) for user prose).
crates/tui/locales/AGENTS.md owns string changes. web/AGENTS.md owns the
site. docs/MOTION_CONTRACT.md owns motion. Design law lives in
docs/design/, not in a prototype file someone left in a sibling directory.
Bound the slice. One coherent change, reviewable in one sitting, that
leaves the tree building and green. AGENTS.md's two corollaries keep
slices honest: an abstraction must delete caller code, and a migration
ships its last consumer or does not start.
Fix the evidence bar now, not after. Decide before writing code what will prove this works, and write it into your plan:
scripts/dev-test.sh --list maps an area to its fastest invocation);Write the implementation first. Code first, then tests (see AGENTS.md
— this repo does not practice TDD). Build it, prove it runs, then add or
adjust tests to cover what you actually built.
#[allow(dead_code)] behind as the cost of an incomplete
migration — scripts/check-dead-code-budget.py is the running receipt.Default shape before the first edit — compress when trivial (a one-line change gets a one-line note, not four bullets):
path/to/file.rs:line), or the predecessor
your new module names;