Repository navigation
Conversation
Removing a preset that is the base, or a middle layer, of another preset's prepend/append/wrap command left the removed preset's text in the active agent's SKILL.md (Claude, Codex, Copilot with --skills). Command-file agents were recomposed onto the new stack, so `specify preset resolve` disagreed with what the skill agent ran. The composed skill is owned by the surviving preset at the top of the chain. _unregister_skills() restores nothing for the removed preset, and _reconcile_skills() only revisited the active skills directory when that restore had touched it, so the recomposed .composed/<cmd>.md was never rendered into the skill. After a removal: - Recompose the active directory's skill for a command whose winning layer composes, while the skill still carries the winning preset's source marker. A hand-edited skill is left alone. - Write only the skill names the directory manages, so a user-owned legacy (speckit.<cmd>) sibling is not overwritten. - When no base is left to compose onto, remove the survivor's stale .composed cache and the SKILL.md that still carries its marker, as command-file agents unregister the command. Other files in the skill directory stay. New file reads and removals go through FileHelper and unlink_in_directory. Assisted-by: Claude Code (model: Claude Mythos 5.2, autonomous)
There was a problem hiding this comment.
🟡 Changes recommended
An active issue allows preset removal to delete a surviving preset’s cache and owned SKILL.md when its remaining content cannot be read or decoded, requiring preservation logic and a regression test.
1 open issue
What changed in this PR
This PR fixes stale composed skills after preset removal. It refreshes surviving skills in the active agent directory or retires generated output when no base remains, while preserving user-owned content.
Changes:
- Track resolved and unresolved composition winners during reconciliation.
- Restrict rewrites and deletions using preset ownership markers and allowed skill names.
- Add six regression and preservation tests covering base removal, middle-layer removal, and user-owned skills.
Review and suggested fix generated by GitHub Copilot (model: unknown, autonomous) for the requesting reviewer. Tests were not rerun; regression results are supplied in the PR description.
| File | Description |
|---|---|
tests/specify_cli/presets/test_manager_skills.py |
Adds composition-removal regressions and user-content preservation checks. |
src/specify_cli/presets/_manager_skills.py |
Recomposes or retires surviving owned skills and limits rewrite targets. |
Review effort: Balanced (adaptive)
…able When PresetResolver.resolve_content() returns None for a composing command during _reconcile_skills(), distinguish a genuinely missing replace base from an unreadable or undecodable surviving layer: - Retire the survivor's .composed cache and owned SKILL.md only when no replace layer remains in the stack. - When a replace base still exists, skip reconciliation cleanly without deleting the survivor's cache or owned SKILL.md and without adding the command to preset_cmds. - Add regression tests in test_manager_skills.py covering undecodable base and composing layers, OSError base reads, and removing a higher-priority replace preset over an unreadable composing stack. Assisted-by: Antigravity (model: Gemini 4 Neon (XHigh), autonomous)
|
Addressed Copilot's review comment in dcba729:
Posted on behalf of |
There was a problem hiding this comment.
🔵 Needs a closer look
Preset removal couples composition resolution, shared-cache invalidation, and ownership-gated skill rewrites or deletions, requiring human review of the interacting lifecycle and filesystem effects.
No open issues 🎉
1 resolved since last review
Review effort: Balanced (adaptive)

Summary
Minimal replacement for #5013 as discussed with @mnriem.
Removing a preset that serves as the base or a middle layer of another preset's
prepend,append, orwrapcommand leaves the removed preset's instructions in the active agent'sSKILL.md(Claude, Codex, Copilot with--skills), while command-file agents are recomposed onto the remaining stack. Because the composed skill is owned by the surviving preset at the top of the chain,_unregister_skills()restores nothing for the removed preset and_reconcile_skills()previously skipped revisiting the active skills directory.Changes (
src/specify_cli/presets/_manager_skills.py)composed_winners) and composing winners whose stacks no longer have a base layer (unresolved_winners).extra_skills_dirs is not None), identify active-directory skills that still carry the winning preset'smetadata.source: preset:<pack_id>marker via_skills_owned_by_preset()(reading throughFileHelper).only_skill_namesin_register_skills()so hand-edited skills and user-owned legacy (speckit.<cmd>) siblings are left untouched..composed/<cmd>.mdcache and the generatedSKILL.mdthat still carries the survivor's marker viaunlink_in_directory(), leaving any other files in the skill directory intact.Deliberately left out of this minimal PR (can be follow-up PRs if desired): native-skill aliases of composed commands, historical (inactive) agent directories, file-mode preservation on rewrite, and partial-registration edge cases.
Tests (
tests/specify_cli/presets/test_manager_skills.py)Added 6 positive and negative tests:
test_remove_base_preset_recomposes_surviving_composed_skill(removing base layer recomposes surviving skill onto core)test_remove_middle_preset_drops_its_layer_from_composed_skill(removing middle layer drops its fragment from surviving skill)test_remove_sole_base_preset_retires_stale_composed_skill(removing sole base with no fallback removes stale.composedcache andSKILL.md)test_remove_base_preset_preserves_hand_edited_composed_skill(hand-edited skill without preset marker is not overwritten)test_remove_sole_base_preset_keeps_hand_edited_skill(hand-edited unbacked skill is not deleted)test_remove_base_preset_preserves_user_owned_legacy_skill(modern skill recomposes while user-owned legacyspeckit.specify/SKILL.mdsibling is untouched)Verification
Before/after regression check on macOS arm64, Python 3.14.6:
f61648db, base commit): 4 failed, 2 passed on the 6 new tests (the 4 behavioral regressions fail; the 2 hand-edited preservation guards pass).a8a92291): 6 passed on the 6 new tests.PATH="$PWD/.venv/bin:$PATH" LC_ALL=en_US.UTF-8 COLUMNS=1000 .venv/bin/python -m pytest -n auto tests/specify_cli/presets tests/test_presets.py tests/integrations tests/specify_cli/integrations tests/specify_cli/extensions tests/specify_cli/bundles tests/test_extension_skills.py -q: 7,627 passed, 9 skippeduvx ruff@0.15.0 check src tests: passed.venv/bin/python .github/scripts/check_file_helper_migration.py --base f61648db --head HEAD: passed.venv/bin/specify --helpandgit diff --check: passedAI Disclosure
a8a92291was authored on behalf of @yxshee by Claude Code (model: Claude Mythos 5.2, autonomous mode), covering the implementation and tests.