data-migration
Skill6 starsChanged 28 days agoMITView on GitHub
Generate data patches, importer services, and transformation scripts. - Idempotent. Re-running setup:upgrade must NOT duplicate data. Check for existing state before inserting. - DataPatchInterface only. No legacy Setup/InstallData.php or UpgradeData.php. - Chunked for bulk. Imports of > 100 rows must process in batches of ≤ 500. - Transactional for transformations. SELECT → INSERT → DELETE wrapped in a single DB transaction (where possible). - Reversible when feasible. Patches that delete data must document the rollback path (or refuse to delete…
We split this skill into the rules it gives an agent
11 rules. 0 are common, 6 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
DataPatchInterface only: No legacy Setup/InstallData.php or UpgradeData.php.
- Distinctive: line 26
Test-first for the data effect: Write the failing integration test before the patch body (red → green → refactor) and watch it fail for the …
- Distinctive: line 57
Ask the user for:
- Very specific: line 65
2A — Write the failing test (RED): Before any patch code, add an integration test under Test/Integration/ that asserts the post-migration …
- Distinctive: line 72
unit: test of the importer's idempotency guard (lookup-then-insert) instead, and record the integration gap in the Phase 4 report.
- Distinctive: line 75
2B — Generate the patch (GREEN): Write the minimal patch needed to turn 2A green:
- Very specific: line 98
Run the Phase 2A test with {ctx.runner} vendor/bin/phpunit and confirm it now passes (it failed before 2B).
- Very specific: line 102
Apply the shared module-hygiene baseline (required): After generating or modifying PHP files, run …
- Distinctive: line 117
Test path + red→green evidence (or the recorded integration gap if a test DB was unavailable)
- Very specific: line 180
All generated patches implement DataPatchInterface and getDependencies().
- Distinctive: line 181
All patches are idempotent.
“Common” is measured: kept by at least 6 in 10 of the 8 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 Data Migration
Generate data patches, importer services, and transformation scripts.
Core Rules
- Idempotent. Re-running
setup:upgrademust NOT duplicate data. Check for existing state before inserting. - DataPatchInterface only. No legacy
Setup/InstallData.phporUpgradeData.php. - Chunked for bulk. Imports of > 100 rows must process in batches of ≤ 500.
- Transactional for transformations. SELECT → INSERT → DELETE wrapped in a single DB transaction (where possible).
- Reversible when feasible. Patches that delete data must document the rollback path
(or refuse to delete without
--allow-destructive). - Test-first for the data effect. Write the failing integration test before the patch body
(red → green → refactor) and watch it fail for the right reason. The test asserts the
post-migration state and, critically, idempotency (apply twice → identical state). The
patch exists only to turn that test green. See
context/references/tdd-discipline.md. A patch is exempt only when it is pure config with no data effect — document why. - Coding style. Generated PHP follows PER-CS 3.0 as the baseline, with the Magento 2 coding
standard taking precedence on any conflict;
--standard=Magento2PHPCS is the gate. 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.
Phase 1 — Plan
Determine migration class:
| Class | When |
| Fixed seed | Small, known data (< 100 rows hard-coded in PHP) |
| Bulk import | CSV/JSON, > 100 rows from an external source |
| Transformation | Move/rename existing data inside Magento |
Ask the user for:
- Data source (file path, API endpoint, M1 DB connection details)
- Target tables / entities
- Idempotency strategy (hash, unique constraint, lookup-then-insert)
- Whether rollback is required
Phase 2 — Test First, then Generate
2A — Write the failing test (RED). Before any patch code, add an integration test under
Test/Integration/ that asserts the post-migration state and idempotency (run the patch
twice → identical rows, no duplicates, no error). Start from
test-generate/templates/test-integration-data-patch.php and follow
context/references/tdd-discipline.md. Run it and confirm it fails for the right
reason (data absent / patch class missing) — not a setup or missing-class error. If no Magento
test DB is available, follow the tiered fallback in tdd-discipline.md: write a test-first
unit test of the importer's idempotency guard (lookup-then-insert) instead, and record the
integration gap in the Phase 4 report.
2B — Generate the patch (GREEN). Write the minimal patch needed to turn 2A green:
Fixed seed
Setup/Patch/Data/{Name}.phpwith the data inline.
Bulk import
Setup/Patch/Data/{Name}.phpinvoking…Service/Importer/{Name}Importer.php— chunked processing, idempotency checks- Optional
Console/Command/{Name}Command.php— CLI entry point (bin/magento {vendor}:{module}:import [--dry-run])
Transformation
Setup/Patch/Data/{Name}.phpwith SELECT → INSERT → DELETE inside a transaction.- Idempotency: check whether destination already has the migrated row before inserting.
2C — Refactor. With the test green, tidy only what you touched; keep it green.
Phase 3 — Verify
php -lon each file.- Run the Phase 2A test with
{ctx.runner} vendor/bin/phpunitand confirm it now passes (it failed before 2B). Run the affected module's suite to confirm nothing else broke. - Dry-run: optional
--dry-runflag on generated CLI command outputs what would be imported without writing. - 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.
Phase 4 — Report
Save to {output_root}/migrations/{name}-{date}.md:
- Source described
- Target tables / entities
- Idempotency strategy
- Test path + red→green evidence (or the recorded integration gap if a test DB was unavailable)
- Re-run safety statement
- Rollback statement (if feasible)
- Migration command for the user to run
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
/data-migration --type=seed|import|transform [source flags] [--docs-root=<path>]--docs-root=<path> — output-root override; see "Output root" below.
Outputs
{ctx.magento_root}/app/code/{Vendor}/{Module}/Setup/Patch/Data/{Name}.php
{ctx.magento_root}/app/code/{Vendor}/{Module}/Service/Importer/{Name}Importer.php # if import
{ctx.magento_root}/app/code/{Vendor}/{Module}/Console/Command/{Name}Command.php # if CLI
{ctx.magento_root}/app/code/{Vendor}/{Module}/Test/Integration/Setup/Patch/Data/{Name}Test.php # test-first (Phase 2A)
{output_root}/migrations/{name}-{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>/migrations/; otherwise default to
{ctx.docs_root}/migrations/. feature passes this so a feature run's
reports collect under its folder.
Reference Files
references/data-patch-rules.md— DataPatchInterface idempotency rules.references/importer-patterns.md— chunked import patterns.references/m1-to-m2-map.md— common Magento 1 → 2 transformations.references/idempotency-strategies.md— hash-based, unique-constraint, lookup-then-insert.references/rollback-strategies.md— when rollback is feasible; how to implement.context/references/tdd-discipline.md— shared test-first loop; the Phase 2A test reusestest-generate/templates/test-integration-data-patch.phpas its skeleton.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/data-patch-fixed-seed.phptemplates/data-patch-bulk-import.phptemplates/data-patch-transformation.phptemplates/importer-service.phptemplates/import-cli-command.php
Acceptance Criteria
- All generated patches implement
DataPatchInterfaceandgetDependencies(). - All patches are idempotent.
- A test asserting idempotency (apply twice → identical state) was written and watched to fail before the patch existed, and passes after (integration when a test DB is available; otherwise a test-first unit test of the idempotency guard, with the integration gap recorded).
- For bulk imports, processing is chunked (default 500 rows).
- For transformations, source data is preserved until destination is verified.
Related Skills
| Phase | Skill |
| 0 | context |
| (after Phase 2) | review for the affected module |
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- korchard333/claude-power-platform-community★ 46same name
- fmind/dot★ 11same name
- fmind/dotfiles★ 11same name
- Cure-Consulting-Group/ProductEngineeringSkills★ 3same name
- philtzjp/skills★ 2same name
- tejastn10/workbench★ 1same name
- Abdox-menara/guard-skills★ 0same name
- geoffsdesk/portage★ 0same name
- Jinbae10/skills★ 0same name
- shaheershoaib/data-migration★ 0same 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.
Used alongsideProjects with it also use incident-response.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
AnthropicSkillincident-response
Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.
Also in 4 projects that use this
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
- debugSkill
- deploySkill
- docsSkill
- eav-attributeSkill
- extension-pointSkill
- featureSkill
- fixSkill
- frontendSkill
- graphqlSkill
- i18nSkill
- indexerSkill
- lintSkill
- marketplaceSkill
- message-queueSkill
- module-createSkill
- perf-auditSkill
- releaseSkill
- remediateSkill
- reviewSkill
- securitySkill
- system-configSkill
- test-generateSkill
- triageSkill
- upgradeSkill
- webapiSkill
- widgetSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

