03 · Refactor — Rename Across Files
Renaming a function cleanly is the canonical multi-file refactor.
This case sets up a tiny project where load_config appears
in four files and asks DSCC to rename it to load_settings
everywhere, without touching unrelated code.
Capability demonstrated
grep_searchto enumerate call sites before editing.edit_filewithreplace_all(or targeted per-line edits) across multiple files.WorkspaceWritepermission mode.
Setup
In a fresh directory:
git init refactor-demo && cd refactor-demo
cargo init --lib
mkdir -p src/bin
cat > src/config.rs <<'RS'
pub fn load_config() -> String { "default".into() }
RS
cat > src/lib.rs <<'RS'
pub mod config;
pub use config::load_config;
pub fn describe() -> String {
format!("cfg={}", load_config())
}
RS
cat > src/bin/app.rs <<'RS'
use refactor_demo::load_config;
fn main() { println!("{}", load_config()); }
RS
cat > tests/smoke.rs <<'RS'
use refactor_demo::load_config;
#[test] fn it_loads() { assert_eq!(load_config(), "default"); }
RS
git add -A && git commit -m "initial"
Run command
dscc --model claude-sonnet-4-6 \
--permission-mode workspace-write \
prompt "$(cat ../dscc_cli/docs/cookbook/03-refactor-rename/PROMPT.md)"
A live run against doubao-seed-2.0-code is captured at
report_dscc.md; the exact
edit-set is in diff.patch.
Note: the model self-verifies with
git grep, so unattended runs should use--permission-mode danger-full-accessor an auto-approvePreToolUsehook forgit *.
Expected behavior
The model should typically:
grep_searchforload_configand list the four files.- Issue one
edit_fileper file (or a single call withreplace_all: trueper file). - Optionally
bashcargo checkto confirm the build still passes.
No unrelated edits.
Verification
git grep load_configreturns no matches.git grep load_settingsreturns four matches (definition + three callers).cargo buildpasses.git diff --statshows only the four files touched.
See also guides/permissions.md for why
workspace-write is the right floor here.