Repository navigation
fix(sync): safely clean unreferenced attachments - #843
Merged
Merged
Conversation
ctawiah
added this pull request to stack #844
October 2, 2026 20:40
ctawiah
force-pushed
the
ctawiah/sync-attachment-cleanup-safety
branch
from
October 2, 2026 20:43
a25bfdc to
055ffba
Compare
This was referenced Oct 2, 2026
ctawiah
marked this pull request as ready for review
October 7, 2026 14:56
ld-ahartmann
approved these changes
Oct 7, 2026
ctawiah
force-pushed
the
ctawiah/sync-attachment-cleanup-safety
branch
2 times, most recently
from
October 7, 2026 15:44
0f4b180 to
f183b15
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f183b15. Configure here.
ctawiah
force-pushed
the
ctawiah/sync-attachment-cleanup-safety
branch
from
October 8, 2026 00:38
f183b15 to
69d7fbf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Context
A local tool or skill file is no longer needed after the final synchronized variation stops referencing it. This layer completes the attachment lifecycle by finding those files and asking before removing them. It applies the same behavior to normal syncs and watch mode.
What changes
--yesas confirmation for attachment cleanup along with the rest of the sync.This cleanup only removes local files. It does not delete tools or skills from LaunchDarkly.
Review focus
--yeshandled consistently?Verification
go test ./internal/sync/local ./internal/sync/prompt ./internal/sync/detachgo test ./...go vet ./internal/sync/... ./cmd/syncgit diff --checkRelated changes
Review the stack in this order:
Note
Overview
Adds orphaned local attachment cleanup to the sync prompt flow: after a successful sync (or when the plan has no changes and the user declines apply), the CLI finds managed
tools/*.jsonandskills/*.mdfiles that no variation still references, lists them, and deletes only after interactive confirmation or--yes(with a second reference check right before delete).The local store gains
OrphanedAttachmentsandDeleteAttachments, using staged renames plus path/symlink/regular-file validation.commitDeletionsnow treats the staged rename as the commit point and cleans up backups best-effort (no partial rollback on backup removal failure).Watch mode passes the file watcher into each sync explicitly, and
SourceFilesincludes all files under project subtrees in.launchdarkly(not just variation wrappers) so attachment edits trigger sync.Store.ProjectKeysis removed.Reviewed by Cursor Bugbot for commit 69d7fbf. Bugbot is set up for automated code reviews on this repo. Configure here.