Repository navigation
Conversation
Native command registration wrote extension skills over any existing SKILL.md at the same path, even when the file was a user's own skill with no extension marker. The supplemental route already skipped such files, but it ran after native registration had already overwritten them. The overwritten file then carried the extension's marker, so extension remove deleted the user's skill as well. Registering a /SKILL.md output now checks whether the existing file was created by this extension (native, supplemental, or preset marker, or a dev-cache symlink) and skips it with a warning when it was not. A skipped skill is never added to the registry, so remove never targets it either. Adds a regression test: install with a pre-existing user skill leaves the skill and its notes file untouched, and remove leaves them in place. Fixes github#5380
There was a problem hiding this comment.
🟡 Changes recommended
The ownership guards can incorrectly accept another extension’s symlink and read non-regular targets, risking unintended skill replacement, blocked installation, or memory exhaustion.
6 open issues
Verify skill symlinks target the current extension's cache · New Reject non-regular SKILL.md symlink targets before reading · New Validate skill metadata is a dictionary before reading ownership · New Preserve preset overrides while tracking extension-owned skills · New Document native skill ownership checks and skipped-skill behavior · New Cover alias collisions and owned-alias refresh in regression tests · New
What changed in this PR
Adds collision protection for user-authored skills to Spec Kit’s shared command registrar, targeting the install/remove data-loss issue in #5380.
Changes:
- Checks ownership before replacing native
SKILL.mdcommand and alias files, warning when registration is skipped. - Adds an install/remove regression test verifying that an existing user skill and its notes survive.
Validation used isolated checks; project suites and the before/after regression comparison were not run.
AI-generated review by GitHub Copilot (model unknown; automated; requester identity not provided).
| File | Description |
|---|---|
tests/test_extension_skills.py |
Tests user-skill preservation and exclusion from registration across installation and removal. |
src/specify_cli/agents.py |
Adds ownership detection and collision guards for native command and alias skills. |
Review effort: Max (auto)
| if target is not None and ".specify-dev" in target.parts: | ||
| return True |
| try: | ||
| raw = path.read_text(encoding="utf-8") | ||
| except (OSError, UnicodeDecodeError): | ||
| return False |
| source = ( | ||
| fm.get("metadata", {}).get("source", "") if isinstance(fm, dict) else "" | ||
| ) |
| # Never overwrite a pre-existing user skill: the supplemental | ||
| # skills route already skips unowned directories, and native | ||
| # registration must do the same (#5380). The command is left | ||
| # unregistered so a later removal cannot delete it either. |
| if ( | ||
| agent_config["extension"] == "/SKILL.md" | ||
| and (alias_file.exists() or alias_file.is_symlink()) | ||
| and not self._skill_file_owned_by_source(alias_file, source_id) |
|
Please address Copilot feedback |
… routes The github#5380 ownership guard in CommandRegistrar treated any SKILL.md not created by the registering source as a user file and skipped it. That broke preset registration: the preset override of speckit.specify lands on a file init created (metadata.source templates/commands/specify.md), so the preset was never recorded and two integration tests failed. Judge ownership tooling-wide instead: a file is ours when its metadata.source matches a route the tooling itself writes (extension:, preset:, native <source_id>:<file>, or templates/commands/*.md). User-authored files (no recognized source) are still skipped, so the github#5380 protection is unchanged.
There was a problem hiding this comment.
🟡 Changes recommended
Overly permissive ownership checks can misidentify unrelated skills and symlinks as managed, causing user-owned content to be overwritten or deleted.
6 open issues
Validate ownership marker paths before overwriting skills · New Reject non-regular SKILL.md symlink targets before reading Verify skill symlinks target the current extension's cache Validate skill metadata is a dictionary before reading ownership Cover alias collisions and owned-alias refresh in regression tests Document native skill ownership checks and skipped-skill behavior
1 resolved since last review
Review effort: Balanced (auto)
| and tail | ||
| and ("/" in tail or tail.endswith(".md")) |
|
Please address Copilot feedback |



What broke
extension addoverwrote a user's own pre-existing skill when an extension command landed on the same path, andextension removethen deleted the user's skill. The supplemental route already skipped such files, but native command registration ran first and overwrote them, stamping the extension's marker on the file.What changed
CommandRegistrar.register_commandsnow checks whether an existingSKILL.mdwas created by the extension being installed (native, supplemental, or preset marker, or a dev-cache symlink) and skips it with a warning when it was not. A skipped skill is never registered, so remove never targets it.How verified
New regression test in
tests/test_extension_skills.py: install with a pre-existing user skill leaves the skill and its notes file untouched, and remove leaves them in place. The test fails on main and passes with the fix. Targeted suites pass: extension skills, registration, extensions, command-add, presets, bundles (1699 passed, 1 skipped).ruff checkclean.Fixes #5380