context
/context
Resolve Magento 2 project context — vendor prefix, edition, Magento version, PHP version, shell runner (Docker vs bare PHP), Magento CLI, active theme, and available quality tools. Use this skill from every other magento2-* skill to capture a single source of truth for project context. Emits a JSON document; caches to .claude/.cache/context.json keyed by composer.lock hash. Library skill — consumed by other skills, rarely invoked directly by humans.
- Author
- muon-m2 ↗
- Repository
- magento2-tools ↗
- Licence
- MIT
- Last repository change
- 04.10.2026
Assessment and security
- Files in this package
- 35
- Scripts
- 13
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 04.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 13 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/add-license-headers.sh, scripts/emit-findings.sh, scripts/emit-json.sh, scripts/emit-sarif.sh, scripts/findings-lib.sh, scripts/gen-routing.sh, scripts/gen-versions.sh, scripts/probe-tools.sh, scripts/resolve-basename.sh, scripts/resolve-context.sh, scripts/resolve-dep-constraint.sh, scripts/route-finding.sh, scripts/waivers-lib.sh
What it does and when to use it
Resolve Magento 2 project context — vendor prefix, edition, Magento version, PHP version, shell runner (Docker vs bare PHP), Magento CLI, active theme, and available quality tools. Use this skill from every other magento2-* skill to capture a single source of truth for project context. Emits a JSON document; caches to .claude/.cache/context.json keyed by composer.lock hash. Library skill — consumed by other skills, rarely invoked directly by humans.
Original author description
Resolve Magento 2 project context — vendor prefix, edition, Magento version, PHP version, shell runner (Docker vs bare PHP), Magento CLI, active theme, and available quality tools. Use this skill from every other magento2-* skill to capture a single source of truth for project context. Emits a JSON document; caches to .claude/.cache/context.json keyed by composer.lock hash. Library skill — consumed by other skills, rarely invoked directly by humans.
How it works
- Core Rules
- Workflow
- Output JSON Schema
- Consumption Pattern (for caller skills)
- Cache Invalidation
- Reference Files
- Scripts
SKILL.md preview
---
name: context
version: 1.16.0
description:
Resolve Magento 2 project context — vendor prefix, edition, Magento version, PHP version,
shell runner (Docker vs bare PHP), Magento CLI, active theme, and available quality tools.
Use this skill from every other magento2-* skill to capture a single source of truth for
project context. Emits a JSON document; caches to .claude/.cache/context.json
keyed by composer.lock hash. Library skill — consumed by other skills, rarely invoked
directly by humans.
---
# Magento 2 Context Resolver
Library skill consumed by every skill in this pack. Produces a JSON document describing
the project's Magento 2 context. Always emit the JSON to the conversation; also persist it
to `.claude/.cache/context.json`.
## Core Rules
- **Resolution priority order**: explicit `CLAUDE.md` hint → file/composer probe → tool probe
→ ask the user. Never guess silently.
- **Honest gaps.** If a tool is missing, the field is `null` — never invent a path.
- **Cache by `composer.lock` mtime+sha256.** If the cache exists and `composer.lock` hasn't
changed since the cached value (and `<24h` old), return the cache.
- **Document the source.** Every resolved value records *where it came from* in
`resolution_source` so future skills can dispute a wrong value with evidence.
- **One JSON object out.** Output a single JSON document — no prose around it (other than
a one-line preamble saying "Context resolved.").
- **Artifact location is the project root.** All `.docs/` artifacts produced by any
skill in this pack (reviews, audits, blueprints, plans, reports, i18n, deploy logs)
are written under `{project_root}/.docs/`, where `{project_root}` is the working
directory the session runs from — the directory that contains `{magento_root}`.
Never write `.docs/` under `{magento_root}`, `app/code`, or any module directory,
even if a step changes the shell's cwd. When `magento_root` is `"src"`, `.docs/`
is a sibling of `src/`, not `src/.docs/`.
The output root is overridable per run via the `--docs-root=<path>` argument
(scripts read it as the `DOCS_ROOT` env var); orchestrators such as
`feature` use it to collect a whole run's artifacts under one
folder. The category layout, filename scheme, and `--docs-root` recipe are defined
once in `references/artifact-layout.md`.
## Workflow
1. Check cache (`.claude/.cache/context.json`).
- If present, age < 24h, and `composer.lock` sha256 matches: return cached JSON.
- Else: continue.
2. Resolve each context field per `references/`:
- `vendor` — see `references/vendor-resolution.md`
- `runner`, `magento_cli`, `composer` — see `references/runner-detection.md`
- `edition`, `magento_version`, `php_constraint`, `php_version`,
`framework_constraint` — see `references/version-resolution.md`
- `theme.frontend`, `theme.adminhtml` — see `references/theme-detection.md`
- `tools.*` — see `references/tool-probe.md`
3. Assemble JSON per the schema below.
4. Save to cache.
5. Emit JSON.
## Output JSON Schema
```json
{
"schemaVersion": "1.0",
"skill": "context",
"skillVersion": "1.13.0",
"resolvedAt": "2026-05-26T14:30:00Z",
"cacheKey": "lock:sha256-...;json:sha256-...;claude:sha256-...;m2:sha256-...;env:<M2_MAGENTO_ROOT>|<M2_PHP_CONTAINER>",
"vendor": "Acme",
"vendor_lower": "acme",
"project_root": ".",
"magento_root": "src",
"module_dir": "src/app/code",
"docs_root": ".docs",
"edition": "open-source",
"magento_version": "2.4.7-p1",
"distribution_version": "2.4.7-p1",
"b2b_version": null,
"php_version": "8.2.15",
"php_constraint": "~8.2.0",
"framework_constraint": "103.0.7-p1",
"runner": "docker compose exec -T -u magento php",
"runner_kind": "docker-compose",
"magento_cli": "docker compose exec -T -u magento php bin/magento",
"composer": "docker compose exec -T -u magento php composer",
"theme": {
"frontend": "hyva",
"frontend_source": "src/composer.json:hyva-themes/* dependency (installed, active-theme unverified)",
"adminhtml": "Magento/backend",
"adminhtml_source": "src/app/etc/config.php:themes[].area=adminhtml",
"breeze": {
"installed": false,
"active": false,
"parent": null,
"packages": [],
"source": null
}
},
"tools": {
"phpcs": "vendor/bin/phpcs",
"phpstan": "vendor/bin/phpstan",
"phpunit": "vendor/bin/phpunit",
"phpmd": "vendor/bin/phpmd",
"rector": null,
"psalm": null,
"php-cs-fixer": "vendor/bin/php-cs-fixer",
"xmllint": "xmllint",
"composer": "composer",
"semgrep": null,
"gitleaks": null,
"trufflehog": null,
"node": "node",
"pa11y": null,
"gh": "gh",
"curl": "curl",
"headless_browser": null
},
"resolution_source": {
"vendor": "CLAUDE.md:Vendor prefix",
"runner": "docker compose ps probe (php running)",
"magento_cli": "{runner} + bin/magento exists",
"composer": "{runner} + composer",
"edition": "src/composer.json:magento/product-community-edition",
"magento_version": "src/composer.json:magento/product-community-edition",
"distribution_version": "src/composer.json:magento/product-community-edition (mirrors magento_version)",
"b2b_version": null,
"php_version": "docker-compose:php -r",
"theme.frontend": "src/composer.json:hyva-themes/* dependency",
"theme.adminhtml": "src/app/etc/config.php:themes[].area=adminhtml"
}
}
```
### Field reference
- `project_root` — the working directory the session runs from, expressed relative to
itself (`.`). All `.docs/` artifacts are anchored here. It is the parent of
`{magento_root}`; when Magento is installed at the repo root, `project_root` and
`magento_root` coincide but `.docs/` still sits beside `app/code`, never inside it.
- `magento_root` — directory holding the Magento installation relative to
`{project_root}` (e.g. `"src"` or `"."`). Used to locate `app/code`, `app/etc`, etc.
Never use it to anchor `.docs/`.
- `docs_root` — resolved path to the artifact directory, `{project_root}/.docs`. Skills
and scripts write under this path; they must not join it with `{magento_root}`.
- `runner` — command prefix that places subsequent argv inside a PHP-capable
environment. Empty string for bare host PHP; non-empty (e.g. `docker compose exec ...`)
for containerized projects. Downstream `${RUNNER} php -r '...'` works in both cases.
- `runner_kind` — one of `null`, `bare`, `docker-compose`, `docker-exec`, `custom`.
Use this when you need to branch on the runner *mode* rather than its string form.
Treat `null` as "no PHP environment detected"; `bare` is valid even though `runner`
is empty.
- `magento_version` / `distribution_version` — two different questions. `magento_version`
is the **Magento base**: which Magento APIs exist, and what version ranges (CVE
advisories, the BC-break matrix) compare against. `distribution_version` is **what you
actually installed**. On the `magento/*` editions they are identical, because those
product metapackages version in lockstep with Magento. On Mage-OS they diverge —
Mage-OS `3.2.0` is based on Magento `2.4.9` — and the distribution version is the only
patch-level signal, since `3.0.0`, `3.1.0` and `3.2.0` all report base `2.4.9`.
Read `distribution_version` to answer "which release is deployed?" and `magento_version`
to answer "which Magento is this?". Mage-OS mirrors this same split in its own API
(`ProductMetadata::getVersion()` vs `getDistributionVersion()`). See
`references/version-resolution.md`.
- `b2b_version` — installed Adobe Commerce B2B module version (`magento/extension-b2b`
from `composer.lock`). `null` unless `edition` is `commerce` or `commerce-cloud` with the
B2B metapackage installed.
- `theme.frontend` / `theme.adminhtml` — active theme as resolved from
`app/etc/config.php`. `null` when no active theme can be confirmed; never silently
defaulted to `custom`. Always read alongside `theme.frontend_source` /
`theme.adminhtml_source` to know how the value was derived.
- `theme.breeze` — Swissup Breezefront detection. `installed` is `true` when any
`swissup/breeze-*` (or `swissup/module-breeze`) package is required in composer.
`active` is `true` only when `theme.frontend` (or a `<parent>` in its app/design chain)
resolves to a Breeze theme; `parent` is that Breeze theme code (e.g.
`Swissup/breeze-evolution`), else `null`. `packages` lists the matched composer
packages; `source` records how the verdict was reached. The `breeze-*` skills
refuse to run when `installed` is `false` and print the install command instead. See
`references/theme-detection.md`.
## Consumption Pattern (for caller skills)
```
1. Invoke this skill (or read the cache file directly if you're an inline script).
2. Capture the JSON as `{ctx}`.
3. Use `{ctx.vendor}`, `{ctx.runner}`, `{ctx.magento_cli}`, `{ctx.tools.phpcs}` etc.
4. Do not re-resolve any of these values independently.
5. If a required value is null (e.g. magento_cli for a deploy skill), abort with a
clear error explaining what's missing.
```
## Cache Invalidation
The cache becomes stale when any of:
- `composer.lock` sha256 changes
- `composer.json` sha256 changes
- `CLAUDE.md` sha256 changes
- `.claude/m2.json` sha256 changes (the optional layout/container override file)
- the `M2_MAGENTO_ROOT` or `M2_PHP_CONTAINER` env override changes
- `--no-cache` argument supplied
The cache key is composed as
`lock:<sha>;json:<sha>;claude:<sha>;m2:<sha>;env:<M2_MAGENTO_ROOT>|<M2_PHP_CONTAINER>` and
stored on the cached JSON; the resolver short-circuits only when the recomputed key is
byte-identical. Separately, a TTL (default 24h; `M2_CACHE_TTL` seconds, `0` disables) bounds
how long a key-match can serve a possibly-stale *runner* state, since runner availability is
not part of the key.
Force a refresh by deleting `.claude/.cache/context.json` or passing `--no-cache`.
## Reference Files
- `references/vendor-resolution.md` — algorithm + edge cases for `{vendor}`.
- `references/runner-detection.md` — Docker vs bare PHP resolution.
- `references/version-resolution.md` — Magento + PHP + framework constraint resolution.
- `references/theme-detection.md` — Luma / Hyva / custom theme detection.
- `references/tool-probe.md` — opt-in tool detection rules.
- `references/naming.md` — authoritative naming conventions (consumed by all builder skills).
- `references/php-coding-style.md` — PER-CS 3.0 baseline + Magento-2-precedence rule for all
generated/modified PHP (consumed by every builder skill and by `review`).
- `references/tdd-discipline.md` — shared test-first (red → green → refactor) discipline + the
behaviour/boilerplate line (consumed by `fix`, `feature`,
`data-migration`, `eav-attribute`).
- `references/severity.md` — shared severity scale (consumed by all findings-producing skills).
- `references/skill-versioning.md` — current skill versions + bump rules; consumed by every artefact-producing skill.
- `references/findings-schema.md` — shared JSON + SARIF schema for finding-producing skills (review, security,
performance-audit, module-upgrade).
- `references/artifact-layout.md` — category registry, filename scheme, and the
`--docs-root`/`DOCS_ROOT` output-root recipe; consumed by every artifact-producing skill.
## Scripts
- `${CLAUDE_SKILL_DIR}/scripts/resolve-context.sh` — emits the JSON to stdout. Use when an automated path
needs the JSON without spawning an LLM-driven resolver pass.
- `${CLAUDE_SKILL_DIR}/scripts/probe-tools.sh` — reusable tool-probe helper.
Files in this package (35)
- SKILL.md 11 KB
- references/artifact-layout.md 5 KB
- references/changelog-format.md 2 KB
- references/execution-modes.md 6 KB
- references/findings-schema.md 17 KB
- references/fix-routing.md 10 KB
- references/module-hygiene.md 3 KB
- references/naming.md 11 KB
- references/output-budget.md 2 KB
- references/php-coding-style.md 5 KB
- references/placeholder-schema.md 17 KB
- references/process-skills.md 4 KB
- references/runner-detection.md 5 KB
- references/runtime-test-tooling.md 6 KB
- references/severity.md 5 KB
- references/skill-versioning.md 3 KB
- references/source-of-truth.md 3 KB
- references/tdd-discipline.md 5 KB
- references/theme-detection.md 8 KB
- references/tool-probe.md 6 KB
- references/vendor-resolution.md 2 KB
- references/version-resolution.md 10 KB
- scripts/add-license-headers.sh 2 KB
- scripts/emit-findings.sh 5 KB
- scripts/emit-json.sh 10 KB
- scripts/emit-sarif.sh 5 KB
- scripts/findings-lib.sh 8 KB
- scripts/gen-routing.sh 4 KB
- scripts/gen-versions.sh 2 KB
- scripts/probe-tools.sh 2 KB
- scripts/resolve-basename.sh 1 KB
- scripts/resolve-context.sh 45 KB
- scripts/resolve-dep-constraint.sh 4 KB
- scripts/route-finding.sh 3 KB
- scripts/waivers-lib.sh 4 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · muon-m2/magento2-tools | 100 | MIT |
| ADWilkinson/astack | 100 | MIT |
| rubycatco/herdr-fleet | 100 | MIT |
| rvdbreemen/adr-kit | 100 | MIT |
| pawangai/pawang-agents | 100 | MIT |
| nocodework/growth-os | 100 | MIT |
| k1p1l0/claude-telegram-supercharged | 100 | Apache-2.0 |
| e-reitbauer/habits | 90 | MIT |
| nicknisi/sessions | 90 | MIT |
Database snapshot: 13.11.2026 · package version 0f3d73e2d11b (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100upgrade
Upgrade an existing Magento 2 module to a newer Magento version, newer PHP version, or newer framework dependency. Use when the user wants to bump Magento support, update PHP constraints, replace deprecated API usage, or scan for and remediate BC breaks. Drives: deprecation scan… - 100magento-setup
Set up a Magento 2 Open Source project — installation, Composer setup, system requirements verification, and initial configuration. Use when starting a new Magento project or setting up a development environment. - 100php-guide
PHP language guardrails, patterns, and best practices for AI-assisted development. Use when working with PHP files (.php), composer.json, or when the user mentions PHP. Provides type declaration patterns, Composer conventions, PSR standards, and testing guidelines specific to… - 100php-testing
Write PHP tests with PHPUnit — unit tests, mocking, data providers, test doubles, assertions, and TDD practices. Use when writing tests for PHP code, whether in Magento or standalone PHP applications. - 100composer-tooling
Composer conventions for any PHP project: dependency management, version constraints, PSR-4 autoloading, scripts, platform requirements, and the composer.json vs composer.lock contract. Stack-agnostic — referenced by every PHP plugin in the marketplace. Use this skill to: - Read… - 100programming-php
PHP 8 practices: typed concise code, features through PHP 8.5, input validation, quality checks. Use when writing or reviewing PHP in Composer projects.