use std::path::PathBuf;
fn main() {
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let canonical = manifest_dir.join("../.claude/skills/rustf/SKILL.md");
let template = manifest_dir
.join("templates/project/claude_skills/rustf/SKILL.md");
println!("cargo:rerun-if-changed={}", canonical.display());
if !canonical.exists() {
println!(
"cargo:warning=.claude/skills/rustf/SKILL.md not found at {} — \
template SKILL.md not refreshed",
canonical.display()
);
return;
}
if let Some(parent) = template.parent() {
std::fs::create_dir_all(parent).expect("create template parent dir");
}
let canonical_bytes = std::fs::read(&canonical).expect("read canonical SKILL.md");
let needs_write = match std::fs::read(&template) {
Ok(existing) => existing != canonical_bytes,
Err(_) => true,
};
if needs_write {
std::fs::write(&template, &canonical_bytes).expect("write template SKILL.md");
}
}