strategy-bitrix-d7-incremental
Skill4 starsChanged 4 months agoMITView on GitHub
Modernize Bitrix from legacy CComponent-era code to D7 incrementally, one module or entity at a time, never as a big-bang rewrite; keep the old and new paths working side by side during the transition. Use when the task adds a new D7 ORM entity, event handler, or module class into a project that still contains legacy Bitrix code; the task is to modernize a legacy Bitrix codebase toward the D7 API — moving from CIBlockElement-style access to ORM entities, events, or the module structure; пользователь просит перевести старый код Битрикса на D7 постепенно, по одному модулю или сущности, не переписывая весь проект сразу. Keywords: strategy, bitrix, d7, incremental, migration, legacy, modernize, битрикс, постепенно, переписывай.
In this repository119 other files it gives its agents.
- strategy-explicit-over-magicSkill
- strategy-framework-conventionsSkill
- strategy-legacy-safe-editsSkill
- strategy-minimal-diffSkill
- strategy-no-untested-refactorSkill
- strategy-preserve-public-apiSkill
- strategy-readonly-immutabilitySkill
- strategy-security-firstSkill
- strategy-test-drivenSkill
- openapiSkill
- paginationSkill
- rest-designSkill
- versioningSkill
- cqrsSkill
- dependency-inversionSkill
- hexagonalSkill
- repository-patternSkill
- service-layerSkill
- bitrixSkill
- findings-reportSkill
- laravelSkill
- performanceSkill
- phpSkill
- project-analysisSkill
- refactoringSkill
- roi-prioritizationSkill
- securitySkill
- stack-detectionSkill
- cache-layersSkill
- component-engineSkill
- d7-eventsSkill
- d7-loaderSkill
- d7-orm-queriesSkill
- iblock-elementsSkill
- kernel-main-moduleSkill
- localizationSkill
- controllersSkill
- ormSkill
- validationSkill
- controllersSkill
- query-builderSkill
- routingSkill
- autoload-psr4Skill
- dependency-managementSkill
- scriptsSkill
- connection-poolingSkill
- mysql-indexingSkill
- redisSkill
- transactionsSkill
- ci-github-actionsSkill
- deployment-strategiesSkill
- docker-phpSkill
- env-configSkill
- associationsSkill
- entities-mappingSkill
- orm-basicsSkill
- entity-apiSkill
- module-developmentSkill
- routing-controllersSkill
- formsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 69
Do not apply the incremental-migration strategy to a brand-new Bitrix project written on D7 from the start, where there is no legacy code …
- Distinctive: line 71
Do not apply this strategy to a project that does not use Bitrix, since the D7 API and its migration concerns are Bitrix-specific.
- Distinctive: line 89
Never rewrite a whole Bitrix project from legacy to D7 in one sweep.
- Distinctive: line 94
Prefer migrating one entity or module to D7 at a time — introduce a D7 ORM entity or event handler beside the legacy code and cut consumers …
- Distinctive: line 99
Avoid interleaving legacy CIBlock-style calls and D7 ORM within the same function.
- Distinctive: line 113
Add a D7 ORM implementation behind the same seam, switch consumers to it one at a time verifying after each, and remove the legacy …
- Distinctive: line 148
Not applicable — no I/O, auth, or untrusted input.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- generated: do not edit — source: knowledge/atoms/ai-rules/strategy-bitrix-d7-incremental/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->Strategy — Incremental Bitrix D7 Migration
When to use
- The task adds a new D7 ORM entity, event handler, or module class into a project that still contains legacy Bitrix code.
- The task is to modernize a legacy Bitrix codebase toward the D7 API — moving from CIBlockElement-style access to ORM entities, events, or the module structure.
- Пользователь просит перевести старый код Битрикса на D7 постепенно, по одному модулю или сущности, не переписывая весь проект сразу.
When NOT to use
- Do not apply the incremental-migration strategy to a brand-new Bitrix project written on D7 from the start, where there is no legacy code to migrate.
- Do not apply this strategy to a project that does not use Bitrix, since the D7 API and its migration concerns are Bitrix-specific.
Core guidance
- Use the D7 ORM for newly migrated reads and writes — For the entity you are migrating, route new reads and writes through the D7 ORM DataManager while leaving untouched entities on their legacy access.
- Bridge behavior through D7 events, not core edits — When new behavior must react to legacy actions, hook it through the D7 event system rather than editing legacy core files in place.
- Keep the legacy path working during migration — Keep the legacy Bitrix code functioning until every consumer has moved to the D7 path, so the site never depends on an unfinished migration.
- Introduce a seam and strangle the legacy path — Wrap the legacy access behind a small interface, add a D7 implementation behind the same seam, and switch consumers over one at a time.
- Verify the portal after each migration step — After migrating each entity or consumer, verify the affected pages and admin functions still work before moving to the next step.
Never
- Never rewrite a whole Bitrix project from legacy to D7 in one sweep; a big-bang migration of a live portal risks breaking unrelated modules all at once.
Prefer
- Prefer migrating one entity or module to D7 at a time — introduce a D7 ORM entity or event handler beside the legacy code and cut consumers over gradually.
Avoid
- Avoid interleaving legacy CIBlock-style calls and D7 ORM within the same function; keep a clear seam so each unit is clearly on the old or the new path.
Escalate to user when
- Escalate to the user before migrating shared kernel or core module code that many components depend on, since the blast radius spans the whole portal.
Quick recipe
- Choose a single entity to migrate, wrap its current legacy access in a small interface, and route existing consumers through that seam without changing behavior yet. (verify: The chosen entity's consumers call the seam, and the portal still behaves exactly as before over the legacy implementation.)
- Add a D7 ORM implementation behind the same seam, switch consumers to it one at a time verifying after each, and remove the legacy implementation only once the last consumer has moved. (verify: Each consumer works on the D7 path after its cutover, the portal is verified at every step, and legacy is removed only after the final consumer migrates.)
Anti-patterns
| Anti-pattern | Why it fails | Do instead |
| Rewriting the whole portal to D7 at once | A big-bang cutover changes hundreds of interdependent paths at once, so any<br>regression is nearly impossible to isolate and the whole portal is at risk. | Migrate one entity or module at a time behind a seam, verifying the portal after<br>each step, and keep legacy running until the last consumer moves. |
| Deleting legacy code before consumers migrate | Removing legacy code that is still in use breaks the pages that depend on it and<br>makes the migration impossible to roll back. | Keep legacy in place until every consumer uses the D7 path, then remove it in a<br>later, isolated step. |
| Mixing legacy and D7 access inside one function | Mixing the two styles in one unit blurs the migration seam, duplicates caching and<br>filtering logic, and makes the code hard to reason about or finish migrating. | Keep each function on a single access style; put the D7 code behind the seam and<br>call the seam, not the legacy API, from migrated units. |
See references/anti-patterns.md.
Common mistakes
- Legacy and D7 writing the same data inconsistently — During coexistence, a legacy path and a D7 path writing the same records can drift if they apply different rules or caches. Fix: Route all writes for a migrated entity through a single path and treat the other as read-only until the cutover is complete.
- Editing Bitrix core files that updates overwrite — Modifying files under the Bitrix core during a migration means the next platform update silently reverts the changes. Fix: Put migration logic in your own module or in D7 event handlers, and never edit core files in place.
- Forgetting to include the module before D7 calls — Calling a D7 ORM entity without first including its module leaves the class unavailable and fails at runtime. Fix: Include the required module through the loader before using its D7 classes, and handle the case where inclusion fails.
Version notes
- Incremental-migration discipline is version-agnostic (PHP >=7.4) — Migrating Bitrix legacy code to D7 incrementally is a strategy that applies across PHP versions Bitrix supports; it constrains how the agent sequences the migration, not which language features it uses, so it holds from PHP 7.4 upward.
Security
- Not applicable — no I/O, auth, or untrusted input.
Testing
- Activation and decision behavior are verified in
eval/scenarios/ai-rules/strategy-bitrix-d7-incremental.yaml.
Additional resources
- references/anti-patterns.md
- references/examples.md
- references/pitfalls.md
- references/recipes.md
- references/version-differences.md
Knowledge graph
Related: ai-rules/strategy-legacy-safe-edits, ai-rules/strategy-minimal-diff, bitrix/d7-events, bitrix/d7-orm-queries
<!-- graph-fragment: graph/fragments/ai-rules/strategy-bitrix-d7-incremental.yaml -->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.

