DSCC
home / cookbook / 03-refactor-rename

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

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-access or an auto-approve PreToolUse hook for git *.

Expected behavior

The model should typically:

  1. grep_search for load_config and list the four files.
  2. Issue one edit_file per file (or a single call with replace_all: true per file).
  3. Optionally bash cargo check to confirm the build still passes.

No unrelated edits.

Verification

See also guides/permissions.md for why workspace-write is the right floor here.