B2C Doctor finds what nothing in your linked cartridges uses: files, functions, variables, requires, exports, commented-out code, routes, resource keys, custom hooks and tags, custom attributes and object types. It says why each one is dead and whether it is safe to remove, removes a selection at once with Undo to put it back, and lists the errors the scan, your editors and Log Center find
Why use it
- Old code stays forever. Overrides, retired integrations and copied cartridges leave files nobody dares to delete. B2C Doctor proves what is unused
- It tells safe from risky. Ready to remove means nothing uses it. Check first means something might: a name built at run time, a route a payment provider calls, a file the server logs show running
- It explains every finding. Each one says why it counts as dead and what to do, next to its code
- Removal is one step back. Everything you remove goes at once, and Undo puts it all back
- It stays current. It scans again as you edit while its tab is open, and script editors fade what it finds
- Same answer for every site. It reads every linked cartridge, never one site's cartridge path
Open it
Click Open B2C Doctor in the title bar of the Cartridges view, or run Intellij SFCC: Open B2C Doctor from the Command Palette. It opens as an editor tab. The first scan shows its steps, and you keep working meanwhile
Overview
The Overview sums up the last scan in four numbers: the findings, what is ready to remove, what to check first and the errors. Under them, how many files it read and how long it took
| Part | What it shows |
|---|---|
| Ready to remove | Nothing in the linked cartridges uses them |
| Check first | Code may build their names, links may call the routes, the server logs show them running, or removing them does more |
| By type | The types with findings, in four groups: Files nothing uses, Inside live files, Hooks, tags and resource keys and Site metadata, with each one's share of what the scan read, such as 1% of 412. The types with none share one line under them |
| Errors | The errors per source, then the errors from the server logs |
| By cartridge | The findings per cartridge, then Site metadata |
| Live files with the most unused code | Where cleaning up pays most |
Click a line to open Findings on that type, cartridge or file, or Errors on that source. The findings and errors numbers open their pages
Findings
The Findings page lists every finding in a tree, and the details of the selected one beside it: why it counts as dead, what to do, and its code
| Section | What it lists |
|---|---|
| Server scripts | Scripts no controller, hook, job step, pipeline or live script requires, imports or names |
| ISML templates | Templates nothing renders, includes or names |
| Form definitions | Forms no code names, whatever locale folder their copies are in |
| JSON files | JSON no live script requires and no code or site data names |
| Unused code | Functions, variables, requires and exports nothing reads, inside live scripts |
| Commented-out code | Comments that hold code, not words |
| Unused routes | Controller routes nothing links to |
| Resource keys | Keys no live script, template or form reads. A key counts in every locale file of its bundle |
| Custom hooks | Hooks no live code calls by name, so their scripts never run |
| Custom tags | <ismodule> tags no live template uses |
| Custom attributes | Attributes no script, template or form reads |
| Custom object types | Types no script or template names |
A file only other dead files use is dead too. Removing an unused function also lists what only it uses. Previous and Next step through the findings, Open in Editor opens the code, and Ignore keeps a finding out of the list. Right-click a row for Open, Remove..., Ignore, Reveal in Explorer View and Copy Path
Group, filter and search
- View Options groups the tree by type or by cartridge
- Show hides dead files or metadata, or shows the findings you ignored
- Search dead code narrows the tree by name or path, and the status line counts what it shows
Remove dead code
Select findings, a file or a whole section and click Remove.... The dialog lists what goes, and a file the server logs show running starts unticked
- Everything goes at once. Undo in the notification or the toolbar puts it all back, and files you had not changed are saved
- A resource key goes from every locale file of its bundle, in every cartridge
- Custom attributes and object types change in your metadata files only. Business Manager keeps them until you import the files
- A file that changed since the scan, or is read only, is kept
Errors
The Errors page lists the error-level problems in the files B2C Doctor reads: its own syntax check, then what your editors report for those files. Click one to open its line in an editor beside the tab
Seen in server logs adds the errors Log Center found on your instance, at the lines they name in your cartridges. It reads what Log Center already has, so it costs no extra requests
In the editor
Script editors fade unused requires, functions, variables and exports, and a lens above the first line counts them, with Show in B2C Doctor, Remove All in This File... and Ignore All in This File. Hover a faded name to see why it is dead
- The light bulb, or Quick Fix... (⌘ . on macOS, Ctrl . on Windows and Linux), offers Remove with B2C Doctor..., which opens the Remove dialog on that finding, and Ignore in B2C Doctor
- A dead file shows its reason in the lens, with Show in B2C Doctor, Remove... and Ignore
- Commented-out code, unread resource keys, unused hooks and tags, and unused custom object types fade in their files too
- The marks are faint hints, never problems. They show a few seconds after VS Code starts, even before you open the tab, and follow the report as it changes
Share the Overview
Share… in the Overview toolbar opens a preview of the Overview as an image: a dark card with your project name as its title, the four numbers, the top types and cartridges, and the Intellij SFCC and B2C Doctor marks. Type the name you want on it, since the workspace name is often a folder name; the name is kept for the project. Then Copy Image or Save as PNG…, ready for a ticket or a team chat
With agents
B2C MCP gives AI agents the same scan in two tools. Agents read the counts first and fetch only the findings they need, so a cleanup costs few tokens
| Tool | What it does |
|---|---|
sfcc_dead_code | Counts first: what is ready to remove and what to check first, by type and cartridge. groupBy counts per type, cartridge, folder or file, as View Options groups the tab. Then short pages of findings by type, cartridge, path or a search, each with an ID the remove plan takes. detail: full adds why each one is dead and its code. It also lists the error-level problems |
sfcc_dead_code_remove_plan | Plans removing the findings an agent names, or every ready one that matches. sfcc_mutation_execute removes them at once after you confirm in VS Code, and Undo in B2C Doctor puts it all back |
Ask "Which cartridge has the most dead code?", "Find dead code in app_custom/cartridge/scripts" or "Remove the unused scripts". The agent leaves findings to check first alone unless you name them, and ignored findings stay out. Agents plan removals under the Plan profile and run them under Full. See Tools & Access
What it leaves alone
- Custom APIs under a cartridge's
rest-apisfolder: storefront apps call them from outside the cartridges - Platform routes the server calls by itself
- Nothing changes when you switch sites: decisions use every linked cartridge
License
B2C Doctor needs an active license or trial. See Purchase