Agent skill

Polylith Migrate Split Big Component

by DavidVujic in DavidVujic/python-polylith

[Internal sub-skill of polylith-migrate-orchestrator. An agent skill from DavidVujic/python-polylith.

MITAuto-check passedDevelopment

Install Polylith Migrate Split Big Component

skills CLI
$ npx skills add DavidVujic/python-polylith --skill polylith-migrate-split-big-component -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install DavidVujic/python-polylith polylith-migrate-split-big-component --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/DavidVujic/python-polylith.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/polylith/migrate-project/polylith-migrate-split-big-component .claude/skills/polylith-migrate-split-big-component && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
polylith-migrate-split-big-component
GitHub stars
553
Token cost
~3.2k tokens
SKILL.md length
1,446 words
Files
1
Skills in repo
37
Repo updated
First seen
Licence
MIT

At a glance

[Internal sub-skill of polylith-migrate-orchestrator. An agent skill from DavidVujic/python-polylith.

  • Works in 2 steps: Plan the Split → Execute the Split
  • Development work in your project
  • SKILL.md covers Goal, Inputs, Steps and Verify, plus 2 more sections
  • Calls git

What it does

Polylith Migrate Split Big Component is an agent skill from DavidVujic/python-polylith. [Internal sub-skill of polylith-migrate-orchestrator. Do not load directly — load polylith-migrate-orchestrator first, which drives all phases.] Split the big component (components/<topns/<INITIALBASENAME/) into multiple focused components.

Its SKILL.md is about 3.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development. The repository describes itself as: Tooling support for the Polylith Architecture in Python. The licence is MIT.

When your agent uses it

  • Development work in your project

Example prompts

  • “/polylith-migrate-split-big-component”

Requirements

  • Python 3

Workflow steps

2 steps, taken from the step headings in SKILL.md.

  1. Plan the Split
  2. Execute the Split

What it can do on your machine

Read from SKILL.md and the folder at commit a7a80f2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Polylith Migrate Split Big Component loads about 3.2k tokens when it runs. Until then it costs about 72 tokens; SKILL.md has 1,446 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~72
When it runs · the whole SKILL.md, loaded when a task matches
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from DavidVujic/python-polylith at commit a7a80f2, republished under its MIT licence (© DavidVujic). 1,446 words, ~3,241 tokens.

Download SKILL.mdSave it as .claude/skills/polylith-migrate-split-big-component/SKILL.md (or your agent's skills folder).
name
polylith-migrate-split-big-component
description
[Internal sub-skill of `polylith-migrate-orchestrator`. Do not load directly — load `polylith-migrate-orchestrator` first, which drives all phases.] Split the big component (`components/<top_ns>/<INITIAL_BASE_NAME>/`) into multiple focused components.

Skill: polylith-migrate-split-big-component

📐 Scope vs sibling skills. This skill operates within one project and turns one component into many components. Don't confuse with:

  • polylith-migrate-extract-standalone-modules — same scope (one project) but pulls foundational modules (consts.py, exceptions.py) out of the residual big component into their own standalone components.
  • polylith-migrate-split-component-internals — operates inside one already-extracted component, splitting its core.py into multiple files. No new components are created.
  • polylith-migrate-isolate-shared-and-project-logic — cross-project scope; identifies shared-vs-project-specific logic when migrating a 2nd+ project.
  • polylith-migrate-dedupe — opportunistic deduplication; this skill includes a dedup-analysis subsection so for a single project you usually don't need polylith-migrate-dedupe separately.

Goal

Split the big component (components/<top_ns>/<INITIAL_BASE_NAME>/) into multiple focused components to improve maintainability, clarity, and reusability.

Inputs

From migration/<PROJECT>/state.md:

  • TARGET_TOP_NS
  • INITIAL_BASE_NAME
  • Verification commands.

From migration/<PROJECT>/manifest.md:

  • Module map of the big component.

All inputs from state.md are assumed to satisfy the validation rules in polylith-migrate-discover (### Validation rules). Validate before proceeding.

Steps

Phase 1: Plan the Split
  1. Review the Big Component: Use directory_tree and grep to analyze the big component's structure and identify natural slices.
  2. Define Component Names: Name components after the domain or functionality they represent (e.g., domain_a_serializer, data_transformations). Avoid generic names like utils or helpers.
  3. Create a Split Plan: Record the following in migration/<PROJECT>/split_plan.md:
    • Brick name for each new component.
    • Files/modules to move into each component.
    • Public API (key functions/classes to export).
    • Bricks that will import from the new component.

When NOT to Extract:

  • The module is tightly coupled to other modules in the component.
  • The module is very small (< 20 lines) and extraction adds more indirection than value.

Extraction Order:

  • Extract modules with zero internal dependencies first (e.g., exceptions.py, consts.py).
  • Extract modules that depend on already-extracted modules next (e.g., models.py that imports exceptions and consts).
Examples of Component Naming

Name components after the domain or functionality they represent:

Original module nameContent (after inspection)Component name
serializers.pySerializes data for ERPdomain_a_serializer
transformations/Maps data between formatsdata_transformations
parsers.pyParses event payloadsevent_parser
validators.pyValidates recordsrecord_validator
Avoiding circular imports when extracting modules

Extracting a module into a separate component can create circular imports if the new component imports from the parent component and the parent still imports from the new component. This commonly happens when a component's __init__.py eagerly imports from many submodules.

Diagnosis: The cycle typically looks like:

new_component.core → parent.__init__ → parent.submodule → new_component

Python triggers parent.__init__ whenever any submodule of parent is imported (e.g. from parent.consts import X loads parent/__init__.py first).

Resolution strategies (in order of preference):

  1. Extract the circular part into its own component. A circular dependency often signals that the code involved is isolated enough to be its own component. Extract the module that causes the cycle into a standalone component — this breaks the cycle structurally. A component doesn't have to be a "feature"; it can be a utility, a data definition, a pure technical module, or a single ORM model. If the code has a clear responsibility and can be imported without pulling in the rest of the parent, it belongs in its own brick.

    # Before (cycle): new_component → parent.consts → parent.__init__ → parent.handlers → new_component
    # After (no cycle): new_component → consts_component (standalone, no __init__ chain)
  2. Trim __init__.py exports. Remove the problematic import from the parent's __init__.py and have callers import the submodule directly. This makes the dependency graph explicit and often eliminates the cycle without creating a new brick.

    python
    # Before: parent/__init__.py imports everything eagerly
    from parent.command_handler import CommandHandler  # triggers handler → new_component cycle
    
    # After: remove from __init__.py, callers import directly
    from parent.command_handler import CommandHandler  # in the base that needs it
  3. Standalone component instead of submodule. If the new component would be a submodule of an existing package (e.g. myns.models.example_transaction), importing it triggers the parent package's __init__.py and all its eager imports. Make it a standalone component at the namespace level instead (e.g. myns.example_transaction).

  4. Deferred import (last resort). Move the import inside the function that uses it. This works but hides the dependency and makes the code harder to reason about. Prefer strategies 1–3 first.

Pre-flight check: Before extracting a module, trace the import chain:

  1. The new component imports parent.submodule_X → Python loads parent.__init__
  2. Does parent.__init__ (directly or transitively) import from the new component?
  3. If yes → apply one of the strategies above (extract, trim, or restructure) before proceeding.
Refactoring shared infrastructure components

When a second project needs a component that already exists (e.g. myns.logging, myns.kafka), compare the implementations closely. Common refactoring patterns:

Pattern: Parameterize the shared component. When two implementations are 80%+ identical with project-specific extras, refactor the shared component to accept optional parameters rather than duplicating code.

Example — logging with project-specific loggers:

python
# Shared component: myns.logging
def init(config, *, extra_loggers=None, cache_logger_on_first_use=False):
    loggers = {**_BASE_LOGGERS}
    loggers.update(_verbosity_overrides(config.LOG_VERBOSITY_LEVEL))
    if extra_loggers:
        loggers.update(extra_loggers)
    ...

# Project A base:
init(config, extra_loggers={"httpx": {...}, "backoff": {...}},
     cache_logger_on_first_use=config.LOG_CACHE_LOGGER_ON_FIRST_USE)

# Project B base:
init(config, extra_loggers={"confluent_kafka_helpers": {...}})

When to parameterize vs. keep separate:

  • Parameterize when the core logic is identical and only data/config differs.
  • Keep separate when the control flow or structure diverges (different frameworks, different patterns).
  • Extract shared base + project-specific wrappers when there's a significant shared core but non-trivial project-specific logic around it.
Splitting Component Internals

Components with generic names like models, schemas, exceptions, or consts may start with a single core.py file. As the workspace grows, these components can accumulate code from different domains. Splitting core.py into multiple domain-focused modules inside the component can improve maintainability and clarity.

When to Split:

  • If the core.py file contains definitions from multiple distinct domains (e.g., domain_a and domain_b).
  • If the file contains helper/utility functions alongside class definitions.
  • If preparing for a second project migration that will contribute to the same component.

Approach:

  • Group definitions by the domain concept they serve.
  • Name each module after the domain or functionality it represents (e.g., domain_a.py, domain_b.py).
  • Ensure the public API remains unchanged to avoid breaking existing imports.
Show full SKILL.md (577 more words)Show less
Cross-component duplication analysis

After drafting the split plan (but before executing any moves), analyze the planned components — and any already existing components in the workspace — for duplication:

  1. Identify overlap: For each planned component, check whether an existing component already contains similar logic. Look for:

    • Functions/classes with the same or very similar names.
    • Modules that operate on the same domain concept (e.g., two different domain_a_serializer implementations).
    • Copy-pasted utility functions (string helpers, date formatting, retry wrappers, etc.).
  2. Classify the overlap:

    • Identical or near-identical: the code does the same thing with trivial differences (variable names, formatting). → Extract to a shared component.
    • Same purpose, different behavior: the code solves the same problem but with project-specific logic (e.g., different serialization schemas). → Keep separate, but extract any genuinely shared helpers.
    • Coincidental similarity: the code looks similar but serves unrelated purposes. → Leave separate.
  3. Propose shared extractions: When genuinely duplicated code is found, add a step to the split plan:

    • Create a new shared component (or extend an existing one) containing the common logic.
    • Have both the existing and the new component depend on the shared one.
    • Record this in <PROJECT>/split_plan.md with a rationale.
  4. Always confirm with the user before creating shared components — "is this code genuinely shareable?" is a judgment call that depends on how the projects will evolve.

Phase 2: Execute the Split

For each planned component in split_plan.md:

  1. Create the Component: Create the component directory with __init__.py.
  2. Move Files/Modules: Move the relevant files/modules into the new component.
  3. Define the Public API: Update __init__.py to re-export the public API.
  4. Update Callers: Update all imports to reference the new component. For anything beyond a handful of call sites, drive this with the small text-in → text-out rewrite helper described in polylith-migrate-automate-import-updates (it covers dotted, bare-submodule, and quoted-string references and splits mixed import lines), then grep for residual references to the old path.
  5. Update pyproject.toml: Add the new brick to the project's [tool.polylith.bricks].
  6. Run Verification: Ensure tests, linting, and type-checking pass.

Verify

  • RUN_TEST_CMD succeeds.
  • If set, RUN_LINT_CMD and RUN_TYPECHECK_CMD succeed.
  • Run POLY_CMD_PREFIX check to validate the workspace structure.
  • Run POLY_CMD_PREFIX sync to synchronize the [tool.polylith.bricks] table with actual imports.

Common failure modes

SymptomLikely causeRemediation
New component is named utils, helpers, common, or miscNaming taken from old module names instead of the domain the code serves.Rename to a domain-specific name (see the "Examples of Component Naming" table). Generic-named bricks attract more code and become the next big component.
Extracted component imports back into the residual via the residual's __init__.pyCircular import — see the "Avoiding circular imports" subsection above.Apply strategies 1–3 from that subsection (extract the cyclic part, trim __init__.py exports, or restructure to standalone). Strategy 4 (deferred import) only as last resort.
poly check flags the newly extracted component as not used by any projectThe project's base still imports from the residual path (<TARGET_TOP_NS>.<INITIAL_BASE_NAME>.<x>) instead of the new component.Update the base's imports to the new component's public API, then POLY_CMD_PREFIX sync --quiet and re-run check.
Verification fails and you can't quickly diagnosePhase commit not yet made.git reset --hard HEAD to roll back to the previous phase's commit and consult the user.

Commit

After verification passes, commit this phase to the migration branch:

bash
git add -A && git commit -m "migrate(<PROJECT>): phase <N> — split-big-component"

Substitute <PROJECT>, <N>, and <phase-name> from state.md and the orchestrator's phase table. Do not proceed to the next phase without a clean commit — the per-phase commit is the rollback point for the next phase's failure-mode tables.

© DavidVujic, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/polylith/migrate-project/polylith-migrate-split-big-component of DavidVujic/python-polylith.

Open the folder on GitHubat commit a7a80f2

Compare with similar skills

Polylith Migrate Split Big Component next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Polylith Migrate Split Big Component compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Polylith Migrate Split Big Component this skillDavidVujic/python-polylith553—~3.2kAutomated safety check: PassMIT
Finishing a Development Branchobra/superpowers296k5 repos~1.9kAutomated safety check: PassMIT
Typescript Advanced Typesrolling-scopes/rsschool-app10k24 repos~4.2kAutomated safety check: PassMPL-2.0
PR Babysitteropeninterpreter/openinterpreter69k3 repos~4.2kAutomated safety check: PassApache-2.0
Code Review ChecklistshareAI-lab/learn-claude-code78k5 repos~1.1kAutomated safety check: PassMIT
Greplooponyx-dot-app/onyx32k4 repos~3.3kAutomated safety check: PassMIT

Similar skills

  • Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.

    296k GitHub starsUsed in 5 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Typescript Advanced Types

    rolling-scopes/rsschool-app

    Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications.

    10k GitHub starsUsed in 24 repos~4.2k tokens
    DevelopmentAuto-check passed
  • PR Babysitter

    openinterpreter/openinterpreter

    Watches an open GitHub pull request until it merges, handling review comments, diagnosing CI failures and retrying flaky checks along the way.

    69k GitHub starsUsed in 3 repos~4.2k tokens
    DevelopmentAuto-check passed
  • Code Review Checklist

    shareAI-lab/learn-claude-code

    Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.

    78k GitHub starsUsed in 5 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Greploop

    onyx-dot-app/onyx

    Iteratively improves a PR (GitHub), MR (GitLab), or shelved changelist (Perforce) until Greptile gives it a 5/5 confidence score with zero unresolved comments.

    32k GitHub starsUsed in 4 repos~3.3k tokens
    DevelopmentAuto-check passed
  • Guidelines

    akash-network/node

    Behavioral guidelines to reduce common LLM coding mistakes. An agent skill from akash-network/node.

    1.1k GitHub starsUsed in 22 repos~577 tokens
    DevelopmentAuto-check passed

More from DavidVujic/python-polylith

All 37 skills in this repo
  • Polylith Base Creation

    DavidVujic/python-polylith

    Create a Polylith base with poly create base — the entry point of a deployable application (HTTP API, CLI, message-queue consumer, AWS Lambda handler, GCP Cloud Function, scheduled job).

    553 GitHub stars~757 tokensUpdated 3 days ago
    Auto-check passed
  • Polylith Check

    DavidVujic/python-polylith

    Validate a Polylith workspace with poly check — the canonical CI gate.

    553 GitHub stars~972 tokensUpdated 3 days ago
    Auto-check passed
  • Polylith Component Creation

    DavidVujic/python-polylith

    Create a Polylith component with poly create component — a reusable, isolated brick implementing business logic, a feature, a domain module, or a capability.

    553 GitHub stars~800 tokensUpdated 3 days ago
    Auto-check passed
  • Polylith Dependency Management

    DavidVujic/python-polylith

    Add or manage third-party dependencies in a Polylith workspace.

    553 GitHub stars~643 tokensUpdated 3 days ago
    Auto-check passed
  • Polylith Dependency Visualization

    DavidVujic/python-polylith

    Visualize brick × brick dependencies with poly deps — find circular dependencies, inspect a brick's public interface, and detect interface-bypass violations.

    553 GitHub stars~906 tokensUpdated 3 days ago
    Auto-check passed
  • Polylith Diff

    DavidVujic/python-polylith

    List Polylith bricks whose implementation changed since a git tag using poly diff.

    553 GitHub stars~1.1k tokensUpdated 3 days ago
    Auto-check passed

Categories

Questions about Polylith Migrate Split Big Component

What does Polylith Migrate Split Big Component do?

[Internal sub-skill of polylith-migrate-orchestrator. An agent skill from DavidVujic/python-polylith. Polylith Migrate Split Big Component is an agent skill from DavidVujic/python-polylith. [Internal sub-skill of polylith-migrate-orchestrator.

When should I use Polylith Migrate Split Big Component?

Polylith Migrate Split Big Component fits situations like: development work in your project.

How do I install Polylith Migrate Split Big Component in Claude Code?

Run `npx skills add DavidVujic/python-polylith --skill polylith-migrate-split-big-component -a claude-code`. Or copy the skill folder (.agents/skills/polylith/migrate-project/polylith-migrate-split-big-component in DavidVujic/python-polylith) into .claude/skills/polylith-migrate-split-big-component in your project. Claude Code loads it when a task matches its description.

How do I install Polylith Migrate Split Big Component in Codex?

Run `npx skills add DavidVujic/python-polylith --skill polylith-migrate-split-big-component -a codex`. Or copy the skill folder (.agents/skills/polylith/migrate-project/polylith-migrate-split-big-component in DavidVujic/python-polylith) into .agents/skills/polylith-migrate-split-big-component in your project. Codex loads it when a task matches its description.

Can I use Polylith Migrate Split Big Component in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add DavidVujic/python-polylith --skill polylith-migrate-split-big-component -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/polylith-migrate-split-big-component, .gemini/skills/polylith-migrate-split-big-component, .github/skills/polylith-migrate-split-big-component and .opencode/skills/polylith-migrate-split-big-component in your project.

What does Polylith Migrate Split Big Component need to run?

Going by SKILL.md and its folder, Polylith Migrate Split Big Component needs the command-line tools its instructions call (git). Our summary lists: Python 3.

Does Polylith Migrate Split Big Component access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Polylith Migrate Split Big Component safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Polylith Migrate Split Big Component use?

Polylith Migrate Split Big Component is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Polylith Migrate Split Big Component use?

About 3.2k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Polylith Migrate Split Big Component?

Skills that share tags, products or a category with Polylith Migrate Split Big Component: Finishing a Development Branch (obra/superpowers, 296k stars), Typescript Advanced Types (rolling-scopes/rsschool-app, 10k stars), PR Babysitter (openinterpreter/openinterpreter, 69k stars) and Code Review Checklist (shareAI-lab/learn-claude-code, 78k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Polylith Migrate Split Big Component?

DavidVujic (a GitHub user) maintains it in DavidVujic/python-polylith, which has 553 GitHub stars. The repository holds 37 skills in this directory. The repository was last updated on October 4, 2026.

Source: DavidVujic/python-polylith on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.