Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .agents/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
python .agents/install.py --target anthropic --scope user
python .agents/install.py --target openai google --scope project --project-dir ~/my_study
python .agents/install.py --list
python .agents/install.py --target openai --scope user --uninstall
python .agents/install.py --target openai --scope user --uninstall --dry-run

Destinations:
anthropic (Claude Code) skills: .claude/skills/ agents: .claude/agents/<name>.md
Expand Down Expand Up @@ -360,12 +360,16 @@ def main():
help='Agents to install (default: every agent whose skills are installed); give none to skip agents')
parser.add_argument('--model-map', default=None, help='JSON file with model-map entries overriding model_map.json')
parser.add_argument('--link', action='store_true', help='Symlink skills to this repository instead of copying them')
parser.add_argument('--force', action='store_true', help='Replace existing skills/agents with the same names')
parser.add_argument('--uninstall', action='store_true', help='Remove the selected skills/agents from the destination')
parser.add_argument('--force', action='store_true', help='Allow replacement or removal of existing skills/agents')
parser.add_argument('--uninstall', action='store_true',
help='Remove selected skills/agents. Use --dry-run to preview or --force to remove.')
parser.add_argument('--dry-run', action='store_true', help='Show what would be done without changing anything')
parser.add_argument('--list', action='store_true', help='List the available skills and agents, then exit')
args = parser.parse_args()

if args.uninstall and not (args.list or args.dry_run or args.force):
parser.error('--uninstall can delete existing user files. Use --dry-run to preview or --force to remove.')

agents = read_agents()
skills = available_skills()
if args.list:
Expand Down
38 changes: 38 additions & 0 deletions .agents/tests/test_install_safe_uninstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: LGPL-3.0-only
"""Exercise uninstall safety from the command line in an isolated project."""
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path


INSTALL = Path(__file__).resolve().parents[1] / 'install.py'


class UninstallSafetyTests(unittest.TestCase):
def setUp(self):
directory = tempfile.TemporaryDirectory()
self.addCleanup(directory.cleanup)
self.project = Path(directory.name)

def install(self, *args, expected_exit=0):
result = subprocess.run(
[sys.executable, str(INSTALL), '--scope', 'project', '--project-dir',
str(self.project), *args],
stdin=subprocess.DEVNULL, capture_output=True, text=True, check=False,
)
self.assertEqual(result.returncode, expected_exit, result.stdout + result.stderr)
return result.stdout + result.stderr

def test_uninstall_requires_force(self):
marker = self.project / '.claude/skills/thincurr-run/user-file'
marker.parent.mkdir(parents=True)
marker.write_text('user content')
target = ('--target', 'anthropic', '--skills', 'thincurr-run')
self.assertIn('exists', self.install(*target))
self.assertIn('--force', self.install(*target, '--uninstall', expected_exit=2))
self.assertIn(str(marker.parent), self.install(*target, '--uninstall', '--dry-run'))
self.assertEqual(marker.read_text(), 'user content')
self.install(*target, '--uninstall', '--force')
self.assertFalse(marker.exists())
9 changes: 6 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ python .agents/install.py --target anthropic openai --scope user

Skills are copied unchanged (`--link` symlinks them instead); agents are translated
from `.claude/agents/` to each tool's format. Hardcoded agent models are mapped
through `.agents/model_map.json` (edit it, or pass `--model-map FILE`). `--list`,
`--dry-run`, `--force`, and `--uninstall` do what they say. Keep skills and agents
free of paths into this repository (use `<skill-dir>/scripts/...`), and when adding
through `.agents/model_map.json` (edit it, or pass `--model-map FILE`).
Preview removal with `--uninstall --dry-run`. Actual removal requires
`--uninstall --force` because the installer can delete existing user files.

Keep skills and agents free of paths into this repository (use
`<skill-dir>/scripts/...`), and when adding
agent frontmatter fields, check that `install.py` translates or drops them: Codex
and Gemini CLI reject agent files with unknown keys.

Expand Down