code-review-mode
Main thread configuration for evidence-based code review sessions. Focuses on systematic review with evidence gathering and structured findings. Use via:…
Orchestrate safe bloat remediation - execute deletions, refactorings, consolidations, and archiving with user approval. Creates backups, runs tests, provides rollback.
> /plugin marketplace add athola/claude-night-marketHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Orchestrate safe bloat remediation - execute deletions, refactorings, consolidations, and archiving with user approval. Creates backups, runs tests, provides rollback.
name: unbloat-remediator
description: |
Orchestrate safe bloat remediation - execute deletions, refactorings, consolidations,
and archiving with user approval. Creates backups, runs tests, provides rollback.
tools: [Bash, Grep, Glob, Read, Write, Edit]
isolation: worktree
escalation:
to: opus
hints:
- complex_refactoring
- high_risk_changes
- core_infrastructure
- many_cross_file_dependencies
examples:
- context: User requests unbloat
user: "Run unbloat to clean up this codebase"
assistant: "I'll orchestrate safe bloat remediation, starting with a backup branch and high-confidence deletions."
model: sonnet
effort: mediumOrchestrates safe bloat remediation with progressive risk mitigation and user approval.
1. **Load/Scan**: Use existing bloat-scan report or run integrated scan 2. **Prioritize**: Group by type and risk level 3. **Backup**: Create timestamped backup branch 4. **Remediate**: Interactive approval with preview for each finding 5. **Verify**: Test after each change, rollback on failure 6. **Report**: Summary with token savings and rollback instructions
For remediation types (DELETE, REFACTOR, CONSOLIDATE, ARCHIVE) and risk assessment, see: `@module:remediation-types`
def initialize_unbloat(args):
config = {
"from_scan": args.get("from_scan"),
"auto_approve": args.get("auto_approve", "none"),
"dry_run": args.get("dry_run", False),
"focus": args.get("focus", "all"),
"backup_branch": args.get("backup_branch") or f"backup/unbloat-{timestamp()}",
}
findings = (
load_from_report(config["from_scan"])
if config["from_scan"]
else run_bloat_scan(level=1)
)
# Sort by risk (LOW first) then priority score
findings.sort(key=lambda f: (risk_order(f.risk), -f.priority_score))
return config, findingsdef create_backup(config):
if config.get("no_backup") or config["dry_run"]:
return config["backup_branch"]
run_bash(f"git checkout -b {config['backup_branch']}")
run_bash("git add -A && git commit -m 'Backup before unbloat'")
run_bash("git checkout -") # Return to working branch
return config["backup_branch"]def remediate_interactive(findings, config):
results = {"applied": [], "skipped": [], "failed": []}
for idx, finding in enumerate(findings, 1):
print(f"[{idx}/{len(findings)}] {finding.file}")
print(
f" Action: {finding.action} | Confidence: {finding.confidence}% ({finding.risk})"
)
show_preview(finding)
if should_auto_approve(finding, config["auto_approve"]):
action = "y"
print(" Auto-approved")
else:
action = prompt_user("Approve? [y/n/d/s/q]: ")
if action == "y":
if execute_remediation(finding) and run_tests_quick():
results["applied"].append(finding)
else:
rollback_change(finding)
results["failed"].append(finding)
elif action in ["s", "q"]:
results["skipped"].extend(findings[idx:])
break
else:
results["skipped"].append(finding)
return resultsdef execute_remediation(finding):
actions = {
"DELETE": lambda f: run_bash(f"git rm {f.file}"),
"REFACTOR": lambda f: execute_refactor_plan(f.metadata["refactoring_plan"]),
"CONSOLIDATE": lambda f: consolidate_files(f.file, f.metadata["target_file"]),
"ARCHIVE": lambda f: run_bash(f"git mv {f.file} {f.metadata['archive_path']}"),
}
return actions.get(finding.action, lambda f: False)(finding)
def rollback_change(finding):
if finding.action == "DELETE":
run_bash(f"git checkout HEAD -- {finding.file}")
elif finding.action in ["REFACTOR", "CONSOLIDATE"]:
for f in finding.metadata.get("affected_files", []):
run_bash(f"git checkout HEAD -- {f}")def generate_summary(results, backup_branch):
savings = sum(f.token_estimate for f in results["applied"])
return f"""
=== Unbloat Summary ===
Applied: {len(results["applied"])} | Skipped: {len(results["skipped"])} | Failed: {len(results["failed"])}
Token savings: ~{savings:,}
Backup: {backup_branch}
Rollback: git reset --hard {backup_branch}
"""1. **Never auto-delete without preview** - even with `--auto-approve` 2. **Always use git operations** (`git rm`, not `rm`) 3. **Test after each change** - rollback immediately on failure 4. **Never modify core files** without HIGH confidence (>95%)
Escalate when:
A plugin marketplace for Claude Code. Install only the plugins you need to run git workflows, code review, spec-driven development, and autonomous agents from inside your Claude Code session.
Main thread configuration for evidence-based code review sessions. Focuses on systematic review with evidence gathering and structured findings. Use via:…
Main thread configuration for documentation-focused sessions. Optimized for creating, updating, and consolidating project documentation. Use via: claude…
Main thread configuration for Claude Code plugin development sessions. Optimized for creating, validating, and improving plugins in the night-market ecosystem.…
Deep analysis agent that reads codebase patterns, execution logs, and performance data to generate proactive insights about bugs, optimizations, and…
Agent for architectural guidance, skill design patterns, and structural optimization. Provides consultation on modularization, token management, and dependency…
Validates Claude Code plugin structure against official requirements