From magento2-tools
Surgical defect remediation. The user describes a bug; this skill drives reproduction,
How this skill is triggered — by the user, by Claude, or both
Slash command
/magento2-tools:magento2-bug-fixThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Surgical defect remediation. The user describes a bug; this skill drives reproduction,
references/commit-format.mdreferences/deferred-bugs.mdreferences/log-targets.mdreferences/rca-format.mdreferences/regression-test-patterns.mdreferences/reproduction-patterns.mdreferences/stack-trace-reading.mdtemplates/rca.mdtemplates/regression-test-controller.phptemplates/regression-test-integration.phptemplates/regression-test-unit.phptemplates/report.mdSurgical defect remediation. The user describes a bug; this skill drives reproduction, root-cause analysis, the minimal fix, a regression test, and review across eight phases (Phase 0 setup, then Phases 1–7).
magento2-context/references/tdd-discipline.md — this skill applies it to defect remediation.vendor/magento/ or any third-party module is forbidden.[bug-fix] prefix. See references/commit-format.md.--standard=Magento2 PHPCS is the gate.
See magento2-context/references/php-coding-style.md. (Stay within the minimal-change rule —
do not restyle surrounding code.)superpowers:systematic-debugging,
superpowers:test-driven-development) and do not replace the Phase 5 review with a generic
one — each duplicates owned work and lacks the Magento specifics (log paths, stack-trace
frames, ACL/escaping/EQP). Unlike magento2-feature-implement, bug-fix has no sanctioned
defer-if-present hand-wave — it is surgical and single-threaded, so there is nothing to defer.
The governing policy and the reasons are in magento2-context/references/process-skills.md.Invoke magento2-context. Capture {ctx.vendor}, {ctx.runner}, {ctx.magento_cli},
{ctx.magento_root}, {ctx.tools}. If magento_cli is null, reproduction Phase 2 will
be limited to static log analysis — note this up-front.
Then ensure work happens on a dedicated branch. If the current branch is the default
(main) or a detached HEAD, create bugfix/{slug} before any commit. All per-phase
commits land on that branch; the skill never pushes (see references/commit-format.md).
Goal: have enough information to attempt reproduction.
{ctx.magento_root}):
var/log/system.logvar/log/exception.logvar/log/debug.logSave the initial collection notes to {output_root}/bug-fixes/{slug}/collect.md.
Goal: make the failure happen deterministically.
references/reproduction-patterns.md.references/regression-test-patterns.md).
A failing test is itself a valid reproduction. Only report "cannot reproduce" when
neither a live recipe nor a failing test can be produced.The runtime recipe is scaffolding to find the failing assertion; the regression test
written in Phase 4 is the durable reproduction artifact. Save the recipe to
{output_root}/bug-fixes/{slug}/reproduction.md.
Goal: locate the exact code line(s) responsible.
references/stack-trace-reading.md for tips on plugin/observer/preference frames.git blame, and recent commits.references/rca-format.md:
file:line{output_root}/bug-fixes/{slug}/rca.md.Goal: minimal patch + a test that fails before, passes after. Follow red → green → refactor.
{ctx.magento_root}/app/code/{Vendor}/{Module}/Test/Unit/... (or Test/Integration/...
if the bug requires DB state). Prefer appending a testRegression{Behaviour}() method
to the module's existing test class for that subject; create a new file only when none
exists. Follow the location and naming convention in
references/regression-test-patterns.md and start from the matching
templates/regression-test-*.php skeleton.{ctx.tools} — PHPCS/PHPStan). Confirm no other tests broke and the patch is clean
(REFACTOR: tidy only the lines you touched, keeping the test green).${CLAUDE_PLUGIN_ROOT}/skills/magento2-context/scripts/add-license-headers.sh {ctx.magento_root}/app/code/{Vendor}/{Module} {Vendor}
to stamp the standard copyright header onto every new .php (idempotent — it skips files
that already carry it, so existing patched files are left as-is). On the rare occasion the
fix adds a composer.json require entry, resolve a bounded constraint via
${CLAUDE_PLUGIN_ROOT}/skills/magento2-context/scripts/resolve-dep-constraint.sh <vendor/package>
— never "*". See magento2-context/references/module-hygiene.md.references/commit-format.md:
[bug-fix] {Module}: {symptom}
RCA: {output_root}/bug-fixes/{slug}/rca.md
Files: {list}
magento2-module-review --diff on each modified module.[bug-fix] {Module}: review fix - {finding}.magento2-deploy --env={target}.magento2-deploy's rollback recipe and report.Save report per templates/report.md to {output_root}/bug-fixes/{slug}/report.md:
Optional: open a PR. Same shape as magento2-feature-implement PR step.
Classify at the start of Phase 7 (do not let classification gate Phase 6 — the fix is already in):
| Class | Definition | Default deploy timing |
|---|---|---|
| Critical | Production down, data loss, security breach | Immediate |
| High | Major functional break on common path | Next deploy window |
| Medium | Edge case with workaround | Bundled with next feature deploy |
| Low | Cosmetic / minor inconvenience | Discretionary |
| Case | Behaviour |
|---|---|
| Bug in vendor/ third-party module | RCA proceeds; fix proposed as a plugin/observer in a project module, not as a vendor edit. |
| Bug in Magento core | Same: plugin/observer in a project module. Never edit vendor/magento/. |
| Bug spans ≥ 2 modules | Per-task commits; RCA covers each module separately; one report. |
| Bug can't be reproduced | Phase 2 fails after 2 attempts; report "cannot reproduce" with all evidence collected. |
Fix requires a schema change (db_schema.xml) | Stop; redirect to magento2-feature-implement --mode=extend. Bug-fix is for code-only changes. |
| Fix requires a data repair (correct corrupted rows, backfill) | Stays in-skill: write an idempotent data patch via magento2-data-migration; the regression test asserts the corrected state. |
| Bug is in a config file only | Config/XSD-validation waiver applies (see Core Rules); document why no PHPUnit test in the RCA. |
/magento2-bug-fix "<bug description>"
Optional flags:
--module=<Vendor>_<Module> — constrain RCA to a single module.--log=<path> — additional log file beyond the defaults.--no-deploy — skip Phase 6.--severity=critical|high|medium|low — pre-classify.--docs-root=<path> — output-root override; see "Output root" below.{output_root}/bug-fixes/{slug}/
├── collect.md # Phase 1 evidence
├── reproduction.md # Phase 2 recipe
├── rca.md # Phase 3 RCA
└── report.md # Phase 7 final report
{output_root} defaults to .docs ({ctx.docs_root}), anchored at the project root, never
under {ctx.magento_root}, app/code, or a module dir. See the Artifact location rule in
magento2-context/SKILL.md.
--docs-root)This skill accepts --docs-root=<path> (see
magento2-context/references/artifact-layout.md). When set, write the run report (and any
report artifacts) under <path>/bug-fixes/; otherwise default to
{ctx.docs_root}/bug-fixes/. magento2-feature-implement passes this so a feature run's
reports collect under its folder. The dossier root for a given fix is
{output_root}/bug-fixes/{slug}/.
Plus per-task git commits per references/commit-format.md.
references/log-targets.md — bug-fix log-collection specifics; defers to the shared
magento2-debug/references/log-locations.md for the canonical log-path catalogue.references/reproduction-patterns.md — HTTP / CLI / cron / queue / GraphQL recipes.references/stack-trace-reading.md — how to follow a Magento stack trace through plugins.references/rca-format.md — RCA document structure and required sections.references/regression-test-patterns.md — patterns by bug class (DI, plugin, observer, query, controller).references/deferred-bugs.md — when to file a new bug vs expand current scope.references/commit-format.md — [bug-fix] commit message format.templates/rca.mdtemplates/report.mdtemplates/regression-test-unit.phptemplates/regression-test-integration.phptemplates/regression-test-controller.php| Phase | Skill |
|---|---|
| 0 | magento2-context |
| 4 | magento2-data-migration (only when the fix is a data repair) |
| 5 | magento2-module-review (with --diff) |
| 6 | magento2-deploy (if user authorizes) |
| (alternative) | magento2-debug — when reproduction fails and you need to investigate logs/DI graph |
This skill does not invoke magento2-module-create (no new modules) or
magento2-feature-implement (different shape).
npx claudepluginhub 5mehulhelp5/magento2-tools-muon-m2Guides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
2plugins reuse this skill
First indexed Jul 5, 2026