From 6076041f19c0f05e300598500b9006634c339861 Mon Sep 17 00:00:00 2001 From: Yeachan-Heo Date: Tue, 31 Mar 2026 21:13:27 +0000 Subject: [PATCH] Make init output match the console-style command UX Reformat /init results into the same structured operator-console style used by the other polished commands so create and skip outcomes are easier to scan. This keeps the command behavior unchanged while making repo bootstrapping feedback feel more intentional. Constraint: /init must stay non-destructive and continue refusing to overwrite an existing CLAUDE.md Rejected: Expand /init to write more files in the same slice | broader scaffolding would be riskier than a focused UX polish commit Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep /init output explicit about whether the file was created or skipped so users can trust the command in existing repos Tested: cargo fmt --manifest-path ./rust/Cargo.toml --all; cargo clippy --manifest-path ./rust/Cargo.toml --workspace --all-targets -- -D warnings; cargo test --manifest-path ./rust/Cargo.toml --workspace Not-tested: Manual /init run in a repo that already has a heavily customized CLAUDE.md --- rust/crates/rusty-claude-cli/src/main.rs | 38 ++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 5c5d52c..4f9790d 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -338,6 +338,26 @@ fn format_resume_report(session_path: &str, message_count: usize, turns: u32) -> ) } +fn format_init_report(path: &Path, created: bool) -> String { + if created { + format!( + "Init + CLAUDE.md {} + Result created + Next step Review and tailor the generated guidance", + path.display() + ) + } else { + format!( + "Init + CLAUDE.md {} + Result skipped (already exists) + Next step Edit the existing file intentionally if workflows changed", + path.display() + ) + } +} + fn parse_git_status_metadata(status: Option<&str>) -> (Option, Option) { let Some(status) = status else { return (None, None); @@ -949,15 +969,12 @@ fn init_claude_md() -> Result> { let cwd = env::current_dir()?; let claude_md = cwd.join("CLAUDE.md"); if claude_md.exists() { - return Ok(format!( - "init: skipped because {} already exists", - claude_md.display() - )); + return Ok(format_init_report(&claude_md, false)); } let content = render_init_claude_md(&cwd); fs::write(&claude_md, content)?; - Ok(format!("init: created {}", claude_md.display())) + Ok(format_init_report(&claude_md, true)) } fn render_init_claude_md(cwd: &Path) -> String { @@ -1367,7 +1384,7 @@ fn print_help() { #[cfg(test)] mod tests { use super::{ - format_cost_report, format_model_report, format_model_switch_report, + format_cost_report, format_init_report, format_model_report, format_model_switch_report, format_permissions_report, format_permissions_switch_report, format_resume_report, format_status_report, normalize_permission_mode, parse_args, parse_git_status_metadata, render_config_report, render_init_claude_md, render_memory_report, render_repl_help, @@ -1537,6 +1554,15 @@ mod tests { assert!(report.contains("Current workspace-write")); } + #[test] + fn init_report_uses_structured_output() { + let created = format_init_report(Path::new("/tmp/CLAUDE.md"), true); + assert!(created.contains("Init")); + assert!(created.contains("Result created")); + let skipped = format_init_report(Path::new("/tmp/CLAUDE.md"), false); + assert!(skipped.contains("skipped (already exists)")); + } + #[test] fn model_report_uses_sectioned_layout() { let report = format_model_report("claude-sonnet", 12, 4);