salesforce-claude-code: Agent for Claude Code

.cursor/agents/refactor-cleaner.md

refactor-cleaner is an agent for Claude Code, Cursor from jiten-singh-shahi/salesforce-claude-code. It costs 46 tokens per session (1,030 once invoked), scanned A, original, MIT.

A Salesforce refactoring agent for finding and safely removing unused Apex code, unused metadata, and duplicate logic. Apex is Salesforce's programming language, and metadata describes parts of a Salesforce application.

In plain words
What is it for?
Use it after a sprint, after static-analysis findings, during larger refactors, or before a managed-package audit. It is not intended for active feature work or immediately before production deployment.
Why use it?
It reduces clutter and duplication while checking references that ordinary searches may miss, including flows, pages, and dynamic calls. Safety rules help avoid removing code that is still needed.

Agent for Claude CodeCursor

Written for Claude Code and Cursor: shipped in a Claude Code plugin, but also installed under .cursor/. Also seen: model in frontmatter.

This is jiten-singh-shahi/salesforce-claude-code's own configuration. It tells Claude Code and Cursor how to work on salesforce-claude-code itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything salesforce-claude-code configures →

Part of the salesforce-claude-code plugin — 41 skills, 17 agents shipped together

Reuse

Borrowing it

Nothing to install: this file belongs to jiten-singh-shahi/salesforce-claude-code. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/jiten-singh-shahi/salesforce-claude-code/main/.cursor/agents/refactor-cleaner.md
Clone the repo
git clone --depth 1 https://github.com/jiten-singh-shahi/salesforce-claude-code

Made for: Claude Code, Cursor.

Or install salesforce-claude-code, the plugin that ships this one along with the rest of its 41 skills, 17 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refactor-cleaner

README.md
[![agentmods](https://agentmods.dev/badge/agents/jiten-singh-shahi/salesforce-claude-code/refactor-cleaner.svg)](https://agentmods.dev/agents/jiten-singh-shahi/salesforce-claude-code/refactor-cleaner)
Your own site
<a href="https://agentmods.dev/agents/jiten-singh-shahi/salesforce-claude-code/refactor-cleaner"><img src="https://agentmods.dev/badge/agents/jiten-singh-shahi/salesforce-claude-code/refactor-cleaner.svg" alt="Measured on agentmods" height="20"></a>
Per session 46 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,030 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00046 $0.01030
Opus 5 $0.00023 $0.00515
Sonnet 5 $0.00009 $0.00206
Haiku 4.5 $0.00005 $0.00103

Measured 6d ago against content hash 7b7fdb34ae26, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

refactor-cleaner scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/agents/refactor-cleaner.md · 120 lines

How it starts

The opening of the file, as written. The whole thing — 120 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a refactoring specialist that removes dead code and consolidates duplicates safely in Salesforce projects.

When to Use

  • After a sprint to clean unused Apex classes, methods, and custom fields
  • When PMD or sfdx-scanner has flagged dead code or anti-patterns
  • When consolidating duplicate utility logic spread across service classes
  • When preparing a codebase for a major refactor or managed package audit

Do NOT use during active feature development, right before production deploys, with < 75% test coverage, or on code you don't fully understand.

Workflow

Step 1: Analyze

Run detection tools and categorize findings by safety tier:

sf scanner run --target force-app --format json --engine pmd
sf scanner run --target force-app --format json --engine eslint-lwc

For reference lookups:

grep -rn "ClassName" force-app/ --include="*.cls" --include="*.trigger" \
  --include="*.flow-meta.xml" --include="*.js" --include="*.html" -l

Step 2: Verify

For each candidate removal:

  • Grep for all references including dynamic invocations (Type.forName(), @InvocableMethod)
  • Check Flow metadata, Process Builder, and Lightning Page references
  • Check if part of a managed package or used by external integrations
  • Review git history for context

Step 3: Remove Safely

  • Start with SAFE items only — one item at a time
  • After each removal: sf apex run test --test-level RunLocalTests
  • Validate: sf project deploy validate --source-dir force-app/
  • Commit after each successful batch

Step 4: Consolidate Duplicates

  • Find classes with similar logic
  • Choose the best implementation (most complete, best tested)
  • Update all references, delete duplicates
  • Verify tests pass after consolidation

Safety Classification

Tier Risk Examples Action
SAFE Low Commented-out code, truly orphaned test helpers Remove directly
CAREFUL Medium Classes in Flows/Process Builder, dynamic Apex (Type.forName) Verify all metadata refs first
RISKY High @AuraEnabled, @InvocableMethod, @RestResource, managed package APIs Never remove without confirming zero external usage

Read the full file on GitHub · 120 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 120 lines · 46 tokens per session scan A 7b7fdb34ae26

Subscribe to this mod's changes

refactor-cleaner is an agent published in the GitHub repository jiten-singh-shahi/salesforce-claude-code (15 stars, last pushed 2mo ago), licensed MIT. It adds 46 tokens to every session and 1,030 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

atomic-reviewer

Diff / branch / file reviewer with two modes. Code-mode (default): reviews a diff against a spec, verifies TDD signals were actually run. Spec-mode: reviews a draft spec for alignment with its design doc, coverage, voice, and over-prescription. One line per finding, severity-tagged, no praise, no scope creep. Output…

damusix/atomic-claude · 127 tokens

architecture-analyst

Analyzes system architecture, identifies patterns/anti-patterns, and provides strategic recommendations. Use for architectural reviews, refactoring planning, or system design decisions.

travisjneuman/.claude · 36 tokens

deep-code-reviewer

Thorough 6-aspect code review covering correctness, security, performance, maintainability, testing, and documentation. Use for comprehensive PR reviews or code quality audits.

travisjneuman/.claude · 38 tokens

architect-reviewer

Use this agent for read-only architectural audits between waves. Reviews changed files for module depth, seams, dependency layering, ADR compliance per LANGUAGE.md vocabulary. Context: After Impl-Core wave shipped 8 files. user: "Audit the W2 architecture before proceeding." assistant: "I'll dispatch…

Kanevry/session-orchestrator · 117 tokens

security-auditor

Use when reviewing security-sensitive code paths or running OWASP / supply-chain checks. Dispatched by code-review-loop on sensitive paths (auth, payments, crypto, users, sessions, tokens). Returns findings with severity (Critical / High / Medium / Low) and OWASP category. Context: A diff touches the auth middleware.…

duthaho/claudekit · 164 tokens

changes-review

Changes review agent that verifies plan compliance, code quality, and goal achievement in a single pass. Returns structured JSON findings.

maxritter/pilot-shell · 27 tokens