Skip to content

feat(config): add preserveUnownedSkills to keep unmanaged skills under --delete - #4018

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-4015-preserve-unowned-skills
Nov 29, 2026
Merged

dyoshikawa merged 2 commits into
mainfrom
resolve-issue-4015-preserve-unowned-skills

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Adds an opt-in preserveUnownedSkills option (parallel to preserveUnownedHooks) so generate --delete can prune stale files inside the skill directories it generates without removing skills Rulesync does not manage — the common situation in global mode, where ~/.claude/skills/ and ~/.agents/skills/ are shared with other installers.

What changed

  • src/config/config.ts, src/config/config-resolver.ts: new preserveUnownedSkills key (default false, config-file only — no CLI flag, same as preserveUnownedHooks). The JSON schema is derived from the Zod schema, so it picks the key up automatically.
  • src/lib/generate.ts: with delete and the new key on, the skills sweep skips removeOrphanAiDirs (whole skill directories) and removeOrphanFlatFiles (Takt's flat skill files), and still runs removeOrphanFilesInAiDirs on the directories this run generates. generate --check therefore still reports a stale in-directory file, exactly as --check reports what --delete would remove.
  • src/lib/retire-targets.ts: retiring skills with the key on removes only the skill directories/files the current .rulesync/skills/ sources generate for the retired tool, so --retire-targets does not wipe unmanaged skills either.
  • Docs: docs/guide/configuration.md (option reference), docs/guide/global-mode.md (delete and shared user-scope directories), docs/reference/cli-commands.md (--delete skill-sweep note and retirement notes); src/generated/docs-content.ts regenerated.
  • Tests: config resolver default/file value, mocked generate unit test (whole-skill sweeps skipped, in-directory sweep run, diff reported), real-filesystem retirement test, and e2e tests for project and global mode (stale old.txt removed, unmanaged manual/ kept, --check fails while the stale file exists and passes afterwards). The e2e tests were confirmed to fail with the option off.

Design decision (made autonomously)

The issue offered two options. Option 2 (opt-in key) was chosen; option 1 (running the in-directory sweep with delete off) was not, because it would delete files while delete is off, changing behavior for every existing user.

Ownership record: Rulesync has no record of the skill outputs earlier runs generated (the only output lock is .rulesync-hooks-lock.json for hooks; rulesync.lock and friends track source installs, not generated outputs). So with the key on, a skill removed from .rulesync/skills/ cannot be told apart from an unmanaged one and is left behind too. This trade-off is documented; the user removes such a directory by hand. Adding a skills output lock could close that gap later but would be a larger change.

For retirement, the current sources are the only ownership evidence available, so retirement with the key on removes exactly the skills the sources would generate for the retired tool.

Skipped

  • No CLI flag: preserveUnownedHooks has none either (it is a property of the output root, not of a run).
  • No skills ownership lock (see above).

Closes #4015

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 2 commits November 29, 2026 15:32
…r --delete

With `delete` on and `preserveUnownedSkills: true`, the orphan sweep no
longer removes whole skill directories (or a flattening target's skill
files) that this run did not generate, while the in-directory sweep still
removes stale files inside the skill directories the run generates, and
`generate --check` still reports them. Retiring `skills` with the option on
removes only the skills the current sources generate for the retired tool.

Rulesync keeps no record of skills generated by earlier runs, so a skill
removed from `.rulesync/skills/` is left behind as well; the docs say so.
Off by default and config-file only, like `preserveUnownedHooks`.

Closes #4015

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ile filter

List the skills the sources own for a retired tool on a processor with a
silent logger, so its conversion warnings are not printed again, and add a
Takt retirement test for the flat-file ownership filter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
@dyoshikawa
dyoshikawa merged commit 7da2a34 into main Nov 29, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-4015-preserve-unowned-skills branch November 29, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prune stale files inside generated skill directories even when delete is off (keep unmanaged skills)

1 participant