Reset — Remove optimus-generated files
Remove files installed by /optimus:init and /optimus:permissions. Does NOT uninstall the plugin itself — it only removes files from the project.
Safety Rules
Two boundaries the steps below cannot express, and that override anything else this skill does:
- NEVER touch test files, test directories, or test configuration — even if
/optimus:unit-testcreated them - NEVER touch anything outside
.claude/, subprojectCLAUDE.md, subprojectdocs/, workspace-rootCLAUDE.md, and theoptimus:pointerblocks in project- or workspace-rootAGENTS.md
.claude/settings.json is never deleted outright — Step 4 removes optimus entries surgically and keeps user content.
Step 1 — Detect and inventory
If the current directory has no .git/ directory, read $CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md and apply it; in a multi-repo workspace, process each child repo independently and also check for workspace-root CLAUDE.md and AGENTS.md files (local-only). Otherwise it is a single repo — possibly a monorepo whose subprojects have their own init-installed CLAUDE.md and docs/ files.
Inventory optimus-managed files, listing only what exists:
.claude/CLAUDE.md,.claude/.optimus-version,.claude/settings.json.claude/docs/{coding-guidelines,testing,styling,architecture,skill-writing-guidelines}.md.claude/hooks/format-*— the plugin's template hooks, any customformat-<language>.shfrom init's unsupported-stack fallback, and the legacyformat-python.pyinstalled by optimus <= 3.5.0.claude/hooks/restrict-paths.sh.claude/agents/{code-simplifier,test-guardian}.md(legacy — installed by older optimus versions)- Project- or workspace-root
AGENTS.mdwhen it contains the<!-- optimus:pointer -->block (init writes it for Codex) - Monorepo: subproject
CLAUDE.mdanddocs/{coding-guidelines,testing,styling,architecture}.md(subprojectcoding-guidelines.mdexists only when init found the subproject's conventions differ from root — classify it via the near-exact-pair rule below) - Multi-repo: the above per child repo, plus the workspace-root
CLAUDE.mdand pointer block in workspace-rootAGENTS.md
If no optimus files are found anywhere → say "Nothing to reset — no optimus files found" and stop. If .claude/.optimus-version is missing, warn that the project may not have been initialized by optimus, but proceed.
Step 2 — Classify each file
For each file, check git tracking with git ls-files --error-unmatch <file> (tracked → recoverable via git checkout).
Classify with shell comparison — do not read file bodies into context:
Verbatim templates. The template is the same-named file in the plugin: format-* hooks → $CLAUDE_PLUGIN_ROOT/skills/init/templates/hooks/, restrict-paths.sh → $CLAUDE_PLUGIN_ROOT/skills/permissions/templates/hooks/, legacy .claude/agents/*.md → $CLAUDE_PLUGIN_ROOT/agents/. Run cmp -s <file> <template>: identical → UNMODIFIED, else MODIFIED. A custom format-<language>.sh with no same-named template is LIKELY_GENERATED if it follows the shell-hook pattern (shebang, JSON stdin parsed into a file-path variable, file-extension guard, formatter invocation), else MODIFIED. Retired templates: format-python.py (replaced by format-python.sh in 3.5.1) has no template left to compare against — classify it LIKELY_GENERATED on the strength of its name alone, never MODIFIED. Reporting a retired plugin file as a user edit recommends keeping a hook that cannot run, and Step 4 then keeps its settings entry too, because the rule there only removes entries whose hook file is gone.
Near-exact pair — docs/coding-guidelines.md and docs/skill-writing-guidelines.md: line 1 carries init's [PROJECT NAME] substitution; the rest is verbatim from the same-named file under $CLAUDE_PLUGIN_ROOT/skills/init/templates/docs/. Run tail -n +2 <file> | diff -q - <(tail -n +2 <template>): identical → UNMODIFIED, else MODIFIED.
Generated docs — content is filled in by init, so compare structure against the plugin's own templates at runtime (all under $CLAUDE_PLUGIN_ROOT/skills/init/templates/):
- CLAUDE.md files: compare line 1 (
head -n 1) against the template's line-1 HTML comment. Root.claude/CLAUDE.mdmatchessingle-project-claude.mdormonorepo-claude.md; subprojectCLAUDE.md→subproject-claude.md; workspace-rootCLAUDE.md→multi-repo-claude.md. docs/testing.md,docs/styling.md,docs/architecture.md: compare##headings against the same-named template undertemplates/docs/. For testing.md and styling.md the headings must match in order:diff <(grep '^## ' <file>) <(grep '^## ' <template>). For architecture.md, init deletes the template's HTML-comment-marked conditional sections per project type, so require only that the file's##headings are an in-order subset of the template's headings. Pre-3.0 installs used three architecture.md template variants — also classify as LIKELY_GENERATED when the headings are an in-order subset of one of the 2.x sets: code-only (Overview,Directory Map,Data Flow,Key Patterns,Dependencies Between Modules), skill-authoring (Overview,Directory Map,Skill Organization,Agent Boundaries,Reference Hierarchy,Orchestration Patterns), or hybrid (Overview,Directory Map,Code Architecture,Skill Architecture).
Structure matches → LIKELY_GENERATED; otherwise → MODIFIED.
Always: .claude/.optimus-version → UNMODIFIED (pure tracking file). .claude/settings.json → COMPLEX (surgical handling in Step 4). Root AGENTS.md → UNMODIFIED when the file is exactly the pointer block, else COMPLEX (Step 4 strips the block and keeps the rest).
Summary: UNMODIFIED (exact template match), LIKELY_GENERATED (optimus structure, init-filled content), MODIFIED (user edits — or template drift from an older plugin version), COMPLEX (settings.json, a shared AGENTS.md).
Step 3 — Present plan and confirm
Show the file list grouped by classification (multi-repo: grouped by repo), each with its git-tracked status ("recoverable via git checkout"). If .optimus-version records an older plugin version, note it: MODIFIED files may reflect template drift since that install rather than user edits.
Then AskUserQuestion — header "Reset", question "Review the files above. Which should be removed?". Mark "Remove all" as "(Recommended)" only when every MODIFIED file is git-tracked; otherwise recommend "Keep modified" and name the untracked MODIFIED files in its option text:
- "Remove all" — all optimus files; irreversible for untracked MODIFIED files
- "Keep modified" — remove UNMODIFIED + LIKELY_GENERATED, keep MODIFIED
- "Unmodified only" — most conservative
- "Abort" — remove nothing
On Abort: confirm nothing was removed and stop.
Step 4 — Execute
- Delete the selected files. Monorepo: include selected subproject files; multi-repo: process each repo, plus the workspace-root
CLAUDE.mdif selected. - Clean
.claude/settings.jsonsurgically — for every non-Abort choice, since it preserves user content by construction. Read the project's settings.json and both templates ($CLAUDE_PLUGIN_ROOT/skills/init/templates/settings.json,$CLAUDE_PLUGIN_ROOT/skills/permissions/templates/settings.json), then:hooks.PostToolUse: remove entries whose commands reference.claude/hooks/format-— but only if the referenced hook file was deleted or is missing. If the user kept a hook file, keep its entry: removing it would silently disable a hook the user elected to preserve.hooks.PreToolUse: same rule for entries referencing.claude/hooks/restrict-paths.sh.permissions.allow/permissions.deny: remove entries matching the permissions template's lists. Also remove server-level entries of the exact formmcp__<server-name>only for servers declared in the relevant project root's.mcp.json(per child repo in multi-repo workspaces). Preserve tool-level entries (e.g.mcp__github__get_issue) and entries for undeclared servers — those are the user's. If no.mcp.jsonexists, leave allmcp__*entries untouched.- Prune arrays, keys, and objects that became empty. If the whole object is now
{}, delete the file; otherwise write it back with 2-space indentation.
- Each project- or workspace-root
AGENTS.md: delete it when it is exactly the pointer block; otherwise remove only both markers and the content between them, preserving all surrounding content and whitespace.
Step 5 — Clean up and report
Remove now-empty directories: .claude/hooks, .claude/agents, .claude/docs, and .claude/ itself only if completely empty — per repo in multi-repo workspaces, plus subproject docs/ in monorepos.
Report files removed, files kept (with reason), settings.json changes, and directories cleaned. If a kept hook file retained its settings entry, say so explicitly — that hook stays active.
Recommend reinstalling in a fresh conversation using the current host: Claude Code → /optimus:init (plus /optimus:permissions); Codex → $optimus:init only, since permissions is Claude-only. To remove the plugin itself, give the current host's command: Claude Code → /plugin uninstall optimus@optimus-claude; Codex CLI → codex plugin remove optimus@optimus-claude in the terminal. Do not run the uninstall command as part of reset.