indexer
Skill4 starsChanged 57 days agoMITView on GitHub
Scaffold a custom indexer and materialized view (mview) onto an existing Magento 2 module. Produces indexer.xml, mview.xml, an indexer class (implements both ActionInterface interfaces), and a dedicated action/builder class that owns all reindex logic. - Indexer id convention: {vendor_lower}_{module_lower}_{entity} (all lowercase, underscore-separated). See context/references/naming.md. - view_id matches the indexer id. The <view id> in mview.xml must equal the <indexer id> in indexer.xml — mismatch is the #1 mview wiring bug. - Two ActionInterfaces. The indexer class implements BOTH Magento\Framework\Indexer\ActionInterface (methods…
3 other projects use a version of this.
Adopted by
Most recently taken up by
- Kali-Decoder/Midnight-Skillstheir own version, first seen Sep 17, 2026
- abouchard11/midnight-seo-skillstheir own version, first seen Aug 31, 2026
- tusharpamnani/Midnight-Skillstheir own version, first seen May 2, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- Kali-Decoder/Midnight-Skills★ 16same name
- abouchard11/midnight-seo-skills★ 1same name
- tusharpamnani/Midnight-Skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository35 other files it gives its agents.
- a11y-auditSkill
- admin-formSkill
- admin-listingSkill
- auditSkill
- breeze-adaptSkill
- breeze-compatSkill
- breeze-themeSkill
- cli-commandSkill
- contextSkill
- data-migrationSkill
- debugSkill
- deploySkill
- docsSkill
- eav-attributeSkill
- extension-pointSkill
- featureSkill
- fixSkill
- frontendSkill
- graphqlSkill
- i18nSkill
- lintSkill
- marketplaceSkill
- message-queueSkill
- module-createSkill
- perf-auditSkill
- releaseSkill
- remediateSkill
- reviewSkill
- securitySkill
- system-configSkill
- test-generateSkill
- triageSkill
- upgradeSkill
- webapiSkill
- widgetSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 4 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 76
Hard stop if the target module does not exist: Check {ctx.magento_root}/app/code/{Vendor}/{Module}/registration.php.
- Distinctive: line 82
Ask for any missing values in one batch.
- Distinctive: line 113
3A — Write the failing tests (RED): Before generating implementation code, write the unit test asserting delegation behaviour.
- Very specific: line 131
Follow context/references/tdd-discipline.md.
- Distinctive: line 134
3B — Generate implementation (GREEN): Write the minimal code to make the 3A tests pass, using the templates:
- Very specific: line 151
Run the Phase 3A tests with {ctx.runner} vendor/bin/phpunit and confirm they now
- Very specific: line 153
Apply the shared module-hygiene baseline (required): After generating or modifying PHP files, run …
- Very specific: line 161
Run review --diff (gate: zero Critical/High findings).
- Very specific: line 166
Write a brief Markdown report to {output_root}/indexers/{Vendor}_{Module}-{indexer_id}-{date}.md listing:
- Distinctive: line 171
Test path + red→green evidence
- Very specific: line 242
All templates follow the placeholder registry in context/references/placeholder-schema.md.
- Very specific: line 248
All generated files pass php -l / xmllint --noout.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Magento 2 Indexer / Mview Scaffold
Scaffold a custom indexer and materialized view (mview) onto an existing Magento 2
module. Produces indexer.xml, mview.xml, an indexer class (implements both
ActionInterface interfaces), and a dedicated action/builder class that owns all reindex
logic.
Core Rules
- Indexer id convention:
{vendor_lower}_{module_lower}_{entity}(all lowercase, underscore-separated). Seecontext/references/naming.md. view_idmatches the indexer id. The<view id>inmview.xmlmust equal the<indexer id>inindexer.xml— mismatch is the #1 mview wiring bug.- Two ActionInterfaces. The indexer class implements BOTH
Magento\Framework\Indexer\ActionInterface(methodsexecuteFull,executeList,executeRow) ANDMagento\Framework\Mview\ActionInterface(methodexecute). Import them with distinct short names viause:
This avoids the fatal name clash without FQCNs in the class body.use Magento\Framework\Indexer\ActionInterface; use Magento\Framework\Mview\ActionInterface as MviewActionInterface; - Delegate all logic. The indexer class must do zero reindex work. It only
delegates to a constructor-injected action class (named
{IndexerName}Action). All SQL and batching logic lives in the action class. Tests mock the action, not the indexer. - Batching is mandatory.
executeList(array $ids)andexecute(array $ids)(Mview) must process ids in configurable-size chunks — never load all at once. Usearray_chunk($ids, self::BATCH_SIZE). - Idempotency. Full reindex (
executeFull) must rebuild from scratch such that running it twice produces identical index data. Partial reindex must be safe to re-run on the same id set. The action class achieves this via a delete-then-insert pattern per batch. - Mview subscriptions watch the SOURCE table(s). When a row changes in the source
table, Magento records the changed entity id in the mview changelog table; the scheduled
indexer mode picks those up and calls
execute([ids]). Choose the column that holds the entity primary key asentity_column. - Two indexer modes (set per-deployment via
bin/magento indexer:set-mode):realtime("Update on Save") — Magento callsexecuteRow($id)orexecuteList($ids)synchronously after a save.schedule("Update by Schedule") — saves write to the mview changelog; cron callsexecute($ids)on the batch.
- Dimensions / sharding (Adobe Commerce only, advanced surface) — the Indexer
framework supports
<fieldset>dimensions for sharding by store/customer-group. Do NOT scaffold dimensions by default; note the feature exists for Commerce deployments that need horizontal index sharding. - PHPCS / coding style. Generated PHP follows PER-CS 3.0 as the baseline with the
Magento 2 coding standard taking precedence;
--standard=Magento2is the gate.declare(strict_types=1)on every file; nofinalon any class. Seecontext/references/php-coding-style.md. - Source of truth. Generate from templates → shared references → baked-in Magento 2 knowledge
→ official Magento/Adobe docs (live-fetched only when uncertain). Do NOT read, grep, or "study"
other modules under
app/code/vendor/*/Magento core to infer conventions, entity shapes, naming, or wiring. Narrow exceptions: the target module/class of this operation, and the specific contract of a module this code explicitly depends on. Affirm sources in the final report. Seecontext/references/source-of-truth.md.
Workflow
Phase 0 — Context Resolution
Invoke context (or run
${CLAUDE_PLUGIN_ROOT}/skills/context/scripts/resolve-context.sh); capture the
JSON as {ctx}. Abort if {ctx.magento_root} is unresolved.
Hard stop if the target module does not exist. Check
{ctx.magento_root}/app/code/{Vendor}/{Module}/registration.php. If absent, offer
module-create and abort — do not scaffold into a non-existent module.
Phase 1 — Resolve Inputs
Ask for any missing values in one batch.
| Input | Default | Notes |
| Module | (ask) | Existing {Vendor}_{Module} |
| Indexer class name | (ask) | PascalCase, e.g. ProductStock; placed in Model/Indexer/ |
| Indexer id | (ask) | {vendor_lower}_{module_lower}_{entity}, e.g. acme_catalog_productstock |
| Indexer title | (ask) | Human-readable, shown in admin (e.g. Acme Product Stock) |
| Indexer description | (ask) | One-sentence description shown in admin |
| Entity being indexed | (ask) | Conceptual entity label, e.g. product_stock |
| Source table(s) | (ask) | DB table(s) to subscribe to in mview, e.g. cataloginventory_stock_item |
| Entity id column | (ask) | Column in the source table holding the entity PK, e.g. product_id |
| Target index table | (ask) | Destination table the action writes to, e.g. acme_catalog_productstock_index |
See ${CLAUDE_SKILL_DIR}/references/indexer-anatomy.md and
${CLAUDE_SKILL_DIR}/references/mview-subscriptions.md.
Phase 2 — Plan
Present every file to create or modify. Typical file set:
etc/indexer.xml(merge)etc/mview.xml(merge)Model/Indexer/{IndexerName}.phpModel/Indexer/{IndexerName}Action.phpTest/Unit/Model/Indexer/{IndexerName}Test.php
Wait for "proceed."
Phase 3 — Test First, then Generate
3A — Write the failing tests (RED). Before generating implementation code, write the unit test asserting delegation behaviour. Use mocks — no Magento bootstrap required.
The test (Test/Unit/Model/Indexer/{IndexerName}Test.php) must:
- Mock the
{IndexerName}Actionclass; configure withexpects(self::once())for each delegation method. - Assert
executeFull()delegates toaction->executeFull()— no ids. - Assert
executeList([1, 2, 3])delegates toaction->execute([1, 2, 3])with the exact id array. - Assert
executeRow(42)delegates toaction->execute([42])— wraps the single id. - Assert Mview
execute([1, 2])delegates toaction->execute([1, 2])with the exact id array. - Demonstrate idempotency-safety at the class level: instantiate a fresh indexer with a
fresh mock configured
expects(self::once()); callexecuteFull()twice on two different instances to show the class itself has no hidden state that breaks a repeat call — noself::assertTrue(true), nomarkTestIncomplete.
Follow context/references/tdd-discipline.md. Run the 3A tests and confirm they
fail for the right reason (class-not-found, not a PHPUnit setup error).
3B — Generate implementation (GREEN). Write the minimal code to make the 3A tests pass, using the templates:
${CLAUDE_SKILL_DIR}/templates/indexer.xml${CLAUDE_SKILL_DIR}/templates/mview.xml${CLAUDE_SKILL_DIR}/templates/indexer-class.php${CLAUDE_SKILL_DIR}/templates/indexer-action.php${CLAUDE_SKILL_DIR}/templates/test-indexer-unit.php
See ${CLAUDE_SKILL_DIR}/references/indexer-anatomy.md,
${CLAUDE_SKILL_DIR}/references/mview-subscriptions.md, and
${CLAUDE_SKILL_DIR}/references/pitfalls.md.
Phase 4 — Verify
php -lon every generated.phpfile.xmllint --noouton every generated.xmlfile.- Run the Phase 3A tests with
{ctx.runner} vendor/bin/phpunitand confirm they now pass (they failed before 3B); run the module suite to confirm nothing else broke. - Apply the shared module-hygiene baseline (required). After generating or modifying
PHP files, run
${CLAUDE_PLUGIN_ROOT}/skills/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). When adding acomposer.jsonrequireentry, resolve a bounded constraint via${CLAUDE_PLUGIN_ROOT}/skills/context/scripts/resolve-dep-constraint.sh <vendor/package>— never"*". Seecontext/references/module-hygiene.md. - Run
review --diff(gate: zero Critical/High findings). - Consult
${CLAUDE_SKILL_DIR}/references/pitfalls.mdbefore declaring Phase 4 done.
Phase 5 — Report
Write a brief Markdown report to
{output_root}/indexers/{Vendor}_{Module}-{indexer_id}-{date}.md listing:
- Indexer id and title
- Files generated
- Test path + red→green evidence
bin/magento setup:upgrade+bin/magento cache:flushcommands- How to trigger a full reindex:
bin/magento indexer:reindex {indexer_id} - How to check status:
bin/magento indexer:status - How to switch mode:
bin/magento indexer:set-mode [realtime|schedule] {indexer_id}
Docs may now be stale. This change modified module code. Run
docs --module={Vendor}_{Module}to refresh the module's README, CHANGELOG, anddocs/*.md(technical reference, guides, and API references as applicable).
Inputs
/indexer --module=Acme_Catalog --class=ProductStock \
--id=acme_catalog_productstock --title="Acme Product Stock" \
--source-table=cataloginventory_stock_item --id-column=product_id \
--target-table=acme_catalog_productstock_index [--docs-root=<path>]--docs-root=<path> — output-root override; see "Output root" below.
Outputs
{ctx.magento_root}/app/code/{Vendor}/{Module}/etc/indexer.xml (merge)
{ctx.magento_root}/app/code/{Vendor}/{Module}/etc/mview.xml (merge)
{ctx.magento_root}/app/code/{Vendor}/{Module}/Model/Indexer/{IndexerName}.php
{ctx.magento_root}/app/code/{Vendor}/{Module}/Model/Indexer/{IndexerName}Action.php
{ctx.magento_root}/app/code/{Vendor}/{Module}/Test/Unit/Model/Indexer/{IndexerName}Test.php
{output_root}/indexers/{Vendor}_{Module}-{indexer_id}-{date}.md{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
context/SKILL.md.
Output root (--docs-root)
This skill accepts --docs-root=<path> (see
context/references/artifact-layout.md). When set, write the run report (and any
report artifacts) under <path>/indexers/; otherwise default to
{ctx.docs_root}/indexers/. feature passes this so a feature run's
reports collect under its folder.
Reference Files
${CLAUDE_SKILL_DIR}/references/indexer-anatomy.md—indexer.xmlstructure, the two ActionInterfaces and their methods, the indexer→action delegation pattern,indexer:reindex/indexer:status/indexer:set-mode.${CLAUDE_SKILL_DIR}/references/mview-subscriptions.md—mview.xmlstructure, subscriptions, choosing the source table and entity_column, theindexermview group.${CLAUDE_SKILL_DIR}/references/pitfalls.md— full vs partial reindex, batching, idempotency,executeRowoverhead, realtime vs schedule mode, dimensions caveat, changelog table growth.context/references/naming.md— naming conventions.context/references/tdd-discipline.md— shared test-first RED/GREEN loop.context/references/php-coding-style.md— PER-CS + Magento coding style.context/references/placeholder-schema.md— token registry.context/references/source-of-truth.md— source-of-truth hierarchy + the no-unrelated-module-scanning rule (allowed reads, live-doc fetch protocol, report affirmation).
Templates
templates/indexer.xml→etc/indexer.xml(merge)templates/mview.xml→etc/mview.xml(merge)templates/indexer-class.php→Model/Indexer/{IndexerName}.phptemplates/indexer-action.php→Model/Indexer/{IndexerName}Action.phptemplates/test-indexer-unit.php→Test/Unit/Model/Indexer/{IndexerName}Test.php
All templates follow the placeholder registry in
context/references/placeholder-schema.md. Every token used must be in the
registry — tests/test-placeholder-tokens.sh enforces it.
Acceptance Criteria
- All generated files pass
php -l/xmllint --noout. - Indexer id follows
{vendor_lower}_{module_lower}_{entity}pattern. view_idinmview.xmlequalsidinindexer.xml.- The indexer class implements both ActionInterfaces; name clash resolved via
use ... as MviewActionInterface. - The indexer class contains zero reindex logic — all delegation to the action class.
- The action class batches id sets via
array_chunk; full reindex is idempotent (delete-then-insert). - Unit test uses
expects(self::once())for every delegation assertion; nomarkTestIncomplete, noself::assertTrue(true). review --diffreturns zero Critical/High findings.
Related Skills
| Phase | Skill |
| 0 | context |
| Before (if module absent) | module-create |
| After | review --diff |
| Diagnose existing indexer perf | perf-audit |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

