| name | nazgul:clean |
| description | Fully remove Nazgul from a project — deletes all runtime state, generated agents, MCP config, permissions, CLAUDE.md injections, and gitignore entries. Use when user says "remove nazgul", "uninstall nazgul", "clean nazgul", or wants to completely undo /nazgul:init. |
| allowed-tools | Read, Edit, Bash, Glob, Grep, ToolSearch |
| metadata | {"author":"Jose Mejia","version":"2.7.1"} |
Nazgul Clean
Examples
/nazgul:clean — Fully remove Nazgul from this project (with confirmation)
/nazgul:clean --force — Remove without confirmation prompt
Arguments
$ARGUMENTS
Current State
- Nazgul initialized: !
test -f nazgul/config.json && echo "YES" || echo "NO"
- Install mode: !
test -f nazgul/config.json && jq -r '.install_mode // "shared"' nazgul/config.json 2>/dev/null || echo "unknown"
- Tasks count: !
ls nazgul/tasks/TASK-*.md 2>/dev/null | wc -l | tr -d ' '
- Generated agents: !
ls .claude/agents/generated/*.md 2>/dev/null | wc -l | tr -d ' '
- CLAUDE.md has nazgul section: !
grep -q "Nazgul Framework" CLAUDE.md 2>/dev/null && echo "YES" || echo "NO"
- Gitignore has nazgul entries: !
grep -qE "# Nazgul Framework (\(local mode\)|— ephemeral runtime)" .gitignore 2>/dev/null && echo "YES" || echo "NO"
Instructions
Pre-load: Run ToolSearch with query select:AskUserQuestion to load the interactive prompt tool (deferred by default). Do this BEFORE any step that uses AskUserQuestion.
Fully remove Nazgul from this project. No archiving — permanent deletion.
Step 1: Check if Nazgul is Present
If none of the current state indicators show Nazgul presence (no config, no agents, no MCP entry, no CLAUDE.md section):
- Output: "Nazgul is not installed in this project. Nothing to clean."
- Stop here.
Step 2: Parse Arguments
Check $ARGUMENTS for --force flag. If present, skip confirmation.
Step 3: Confirm with User
Unless --force is present, show what will be removed, then use AskUserQuestion to confirm:
First, display a summary of what exists:
Nazgul Clean — Full Removal
═══════════════════════════════════════════════════════
The following will be PERMANENTLY DELETED:
nazgul/ [EXISTS | not found]
.claude/agents/generated/ [N file(s) | not found]
.claude/settings.json entries [EXISTS | not found]
CLAUDE.md nazgul section [EXISTS | not found]
.gitignore nazgul entries [EXISTS | not found]
Then use AskUserQuestion:
- header: "Confirm"
- question: "This cannot be undone. Remove all Nazgul files from this project?"
- options:
- "Remove everything" — "Permanently delete all Nazgul runtime state, agents, and config"
- "Abort" — "Cancel and keep everything as-is"
If Abort: stop immediately.
Step 4: Remove Runtime State
Delete the entire nazgul/ directory:
rm -rf nazgul/
Step 5: Remove Generated Agents
Delete the .claude/agents/generated/ directory (these are Nazgul-generated reviewer agents):
rm -rf .claude/agents/generated/
If .claude/agents/ is now empty, remove it too. Do NOT remove .claude/ itself as it may contain other settings.
Step 6: Clean .claude/settings.json
If .claude/settings.json exists:
- Read the file
- Remove
enableAgentTeams key if set to true
- Use jq:
jq 'del(.enableAgentTeams)' .claude/settings.json > .claude/settings.json.tmp && mv .claude/settings.json.tmp .claude/settings.json
- If the file is now effectively empty (
{} or only has empty arrays), delete it
- If
.claude/ directory is now empty, remove it too. But be careful — check first.
Step 7: Clean CLAUDE.md
If the project's CLAUDE.md contains a Nazgul-injected section:
- Read
CLAUDE.md
- Look for the Nazgul section — it starts with
# Nazgul Framework — Project Instructions (the content from templates/CLAUDE.md.template)
- Remove everything from that header to the end of the Nazgul section. The Nazgul section runs from
# Nazgul Framework — Project Instructions to the end of the file (it is always appended at the bottom by /nazgul:init).
- Trim any trailing blank lines left behind
- If CLAUDE.md is now empty (only whitespace), delete the file entirely
- If CLAUDE.md still has non-Nazgul content, write it back with the Nazgul section removed
Step 8: Clean .gitignore
/nazgul:init writes one of two blocks depending on install mode. Remove whichever is present (both, if somehow both exist):
- Read
.gitignore
- Remove the local-mode block if present: the marker
# Nazgul Framework (local mode) and its lines (nazgul/, .claude/agents/generated/, .mcp.json)
- Remove the shared-mode ephemeral block if present: the marker
# Nazgul Framework — ephemeral runtime and its lines (nazgul/checkpoints/, nazgul/logs/, nazgul/sessions/, nazgul/.session_id, nazgul/.compaction_count, nazgul/archive/, nazgul/reviews/*/test-failures.md, nazgul/reviews/*/simplify-report.md, nazgul/reviews/post-loop-simplify-report.md)
- Trim any extra blank lines left behind
- If
.gitignore is now empty, delete it
- Otherwise write it back
Step 9: Output Summary
Nazgul Clean Complete
═══════════════════════════════════════════════════════
Removed:
nazgul/ [DELETED | was not present]
.claude/agents/generated/ [DELETED (N files) | was not present]
.claude/settings.json entries [CLEANED | was not present]
CLAUDE.md nazgul section [REMOVED | was not present]
.gitignore nazgul entries [REMOVED | was not present]
Nazgul has been fully removed from this project.
To reinstall: /nazgul:init