name: resharper-safe-cleanup
description: Run JetBrains ReSharper CLI jb cleanupcode with the repository's narrow, versioned cleanup profile to apply safe automated cleanup edits such as removing unused using directives, shortening redundant qualified references, and removing redundant XAML namespace aliases. Use when the user wants ReSharper-driven cleanup changes rather than a dead-code report or a broad style rewrite.
ReSharper Safe Cleanup
Use this skill to run the repository's committed cleanupcode profile while keeping the edit scope intentionally narrow.
Preconditions
- Require
jbonPATH; verify it with a command lookup, notjb --version. On PowerShell useGet-Command jb -ErrorAction SilentlyContinue; on other shells usewhere jborcommand -v jb. - Do not install ReSharper CLI tools yourself unless the user explicitly asks.
- If
jbis missing, stop and tell the user that JetBrains ReSharper Command Line Tools are required. Suggest:dotnet tool install -g JetBrains.ReSharper.GlobalTools- or repo-local install with
dotnet new tool-manifest,dotnet tool install JetBrains.ReSharper.GlobalTools,dotnet tool restore - docs: https://www.jetbrains.com/help/resharper/ReSharper_Command_Line_Tools.html
- cleanup docs: https://www.jetbrains.com/help/resharper/CleanupCode.html
- Require a solution-shared
.DotSettingsfile next to the target.sln. This skill assumes the cleanup profile is versioned in VCS, not stored only in Rider user settings. - Build the target solution before cleanup so
cleanupcodecan resolve symbols. For this repo, rundotnet build Clever.TokenMap.sln. - Do not use this skill for broad style normalization, dead-code triage, or semantic refactors. Use
resharper-unused-codeforinspectcodedead-code reporting.
Execution
- Run
python .codex/skills/resharper-safe-cleanup/scripts/run_safe_cleanup.pyfrom the repository root. - Pass
--solution <path>when the repo has multiple.slnfiles. - Pass
--profile <name>only when the committed profile is not namedSafe Cleanup. - Use
--include/--excludeto scope cleanup when the user wants only part of the tree. - Use
--dry-runto validate the resolved solution, settings, profile, and command without editing files. - Read
.artifacts/resharper-safe-cleanup/cleanup-summary.mdfirst. - Review
git diff, then run the repo's normal verification and commit only after the cleanup result is acceptable.
Profile Contract
The orchestrator script intentionally rejects cleanup profiles that enable tasks outside this narrow allowlist:
CSOptimizeUsingsCSShortenReferencesXaml.RemoveRedundantNamespaceAlias
This keeps the skill aligned with "unused usings + redundant qualifiers" cleanup and prevents accidental full-style rewrites through a broader profile.
Keep the Rider option Embrace 'using' directives in region turned off inside that profile. Configure that in the profile itself rather than expecting the script to compensate for it.
Output Files
The orchestrator writes:
.artifacts/resharper-safe-cleanup/cleanup-summary.md.artifacts/resharper-safe-cleanup/cleanup-summary.json.artifacts/resharper-safe-cleanup/cleanup-command.txt
Response Shape
When reporting results:
- State the exact solution, settings file, and profile used.
- Link the summary path.
- Summarize the cleanup scope and mention whether the profile stayed within the safe allowlist.
- Tell the user to review
git diffand run verification before committing.
Manual Fallback
If the orchestrator script is unsuitable, run:
jb cleanupcode --settings="<solution>.sln.DotSettings" --profile="Safe Cleanup" "<solution>.sln"
Build the solution first, and keep the profile narrow.