Skip to main content
Glama

scan_module_risk

Scan a Magento project's app/code and vendor modules for PHPCS, PHPStan, Rector, ObjectManager misuse, core overrides, and dangling XML references to surface upgrade blockers.

Instructions

Scans the given Magento project's custom code for coding-standard violations, static-analysis issues and dead-code/quality suggestions by shelling out to the project's own vendor/bin/phpcs, vendor/bin/phpstan and vendor/bin/rector. phpcs: if the project has its own phpcs.xml(.dist), that configuration is used as-is; otherwise falls back to the Magento2 standard on app/code. phpstan and rector: only run if the project has its own phpstan.neon(.dist)/rector.php — unlike phpcs there is no safe generic fallback (no paths/level/extensions/rule sets to guess), so they're skipped rather than guessing. rector's findings are reported as severity=warning (suggestions, not pass/fail violations). A fourth, separate check (vendor_phpcs) scans third-party vendor/ Magento modules (type magento2-module in composer.lock, excluding magento/* core) with the bare Magento2 standard — the scanned package list is in vendor_packages, and those issues carry scope='vendor' (vs 'app_code' for the rest) so callers can tell code they can fix from code they can't. A fifth check (object_manager_misuse) is a plain regex scan over app/code's own .php/.phtml files for ObjectManager::getInstance() — not a phpcs sniff: magento-coding-standard's only built-in check for this fires solely inside .phtml templates, not in Model/Block/Helper classes where bypassing constructor DI is arguably more harmful. A sixth check (core_overrides) flags app/code classes that redeclare a class already present in vendor/magento/* under the exact same fully qualified name (a copy-pasted core file, not a legitimate di.xml preference/plugin) — severity=error, so unlike the previous two it does become a build_upgrade_plan blocker, since that silently blocks safely updating the vendor copy it shadows. A seventh check (dangling_references) flags app/code's own di.xml (preference/plugin), events.xml (observer), crontab.xml (job), layout XML (block/uiComponent), indexer.xml and schema.graphqls (@resolver) naming a PHP class that doesn't resolve to any known class or virtualType — a stale reference left behind by a rename or removal, invisible to phpcs/phpstan/rector since none of them analyze XML. severity=warning, not a build_upgrade_plan blocker. Each tool reports scanned=false with a reason when it can't run, instead of staying silent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFilesystem path to the Magento project root (holds composer.json).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.4.0

TDQS

A4.2/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so richly: it discloses the shelling-out mechanism, the phpcs.xml fallback to Magento2 on app/code, the deliberate skipping of phpstan/rector when no config exists (and why no safe fallback), severity assignments per check, scope='vendor' vs 'app_code' tagging, and the scanned=false-with-reason contract.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The single dense paragraph is front-loaded with the overall purpose before enumerating the seven checks, and virtually every sentence carries distinct behavioral information with no filler. It is very long, but for a tool with seven heterogeneous checks the length is largely earned rather than padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity, an output schema exists so return shape needn't be explained, yet the description still covers scanned=false handling, severity semantics, and scope tagging. Nothing an agent needs to invoke and interpret this tool correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

A single parameter with 100% schema description coverage: the schema already documents 'path' as the project root holding composer.json. The description adds no syntax or format detail beyond that, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a precise verb+resource: scans a Magento project's custom code for phpcs/phpstan/rector violations plus four additional non-obvious checks (vendor_phpcs, object_manager_misuse, core_overrides, dangling_references). It enumerates each check and its scope, so an agent can distinguish this from sibling tools like audit_security or build_upgrade_plan.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied through the severity/blocker semantics (core_overrides errors feed build_upgrade_plan; warnings do not) and the vendor vs app_code scope split, which tells the caller which findings are actionable. However, it never explicitly states when to run this versus audit_security or the other sibling tools, nor any prerequisites beyond a project path.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.