@@ -35,7 +35,7 @@ pub fn build_claude_code_output_plan(
3535 Ok ( BaseOutputPluginPlanDto {
3636 plugin_name : CLAUDE_CODE_PLUGIN_NAME . to_string ( ) ,
3737 output_files : build_output_files ( workspace, context) ,
38- cleanup : build_cleanup ( workspace) ,
38+ cleanup : build_cleanup ( workspace, context ) ,
3939 } )
4040}
4141
@@ -758,8 +758,9 @@ mod tests {
758758 }
759759}
760760
761- fn build_cleanup ( workspace : & Workspace ) -> CleanupDeclarationsDto {
761+ fn build_cleanup ( workspace : & Workspace , _context : & OutputContext ) -> CleanupDeclarationsDto {
762762 let mut delete = Vec :: new ( ) ;
763+ let prompt_projects = get_project_prompt_output_projects ( workspace) ;
763764
764765 for project in get_project_output_projects ( workspace) {
765766 let Some ( project_root_dir) = resolve_project_root_dir ( workspace, project) else {
@@ -778,6 +779,28 @@ fn build_cleanup(workspace: &Workspace) -> CleanupDeclarationsDto {
778779 label : Some ( "delete.project" . to_string ( ) ) ,
779780 } ) ;
780781
782+ // #385: clean must keep deleting generated child CLAUDE.md files even when
783+ // claudeCode is later disabled, so cleanup needs explicit child targets too.
784+ if let Some ( prompt_project) = prompt_projects. iter ( ) . copied ( ) . find ( |candidate| {
785+ resolve_project_root_dir ( workspace, candidate)
786+ . as_ref ( )
787+ . is_some_and ( |candidate_root_dir| candidate_root_dir == & project_root_dir)
788+ } ) && let Some ( child_prompts) = prompt_project. child_memory_prompts . as_ref ( ) {
789+ for child_prompt in child_prompts {
790+ delete. push ( CleanupTargetDto {
791+ path : resolve_relative_path ( & child_prompt. dir )
792+ . join ( CLAUDE_CODE_MEMORY_FILE )
793+ . to_string_lossy ( )
794+ . into_owned ( ) ,
795+ kind : CleanupTargetKindDto :: File ,
796+ exclude_basenames : Vec :: new ( ) ,
797+ protection_mode : None ,
798+ scope : Some ( PROJECT_SCOPE . to_string ( ) ) ,
799+ label : Some ( "delete.project.child" . to_string ( ) ) ,
800+ } ) ;
801+ }
802+ }
803+
781804 let settings_dir = project_root_dir. join ( ".claude" ) ;
782805 delete. push ( CleanupTargetDto {
783806 path : settings_dir
0 commit comments