From grimoire
Provides a step-by-step process to incrementally replace a large deeply-integrated component by introducing an abstraction layer, avoiding long-lived feature branches and enabling continuous trunk-based migration.
How this skill is triggered — by the user, by Claude, or both
Slash command
/grimoire:apply-branch-by-abstractionThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Replace a large integrated component by introducing an abstraction layer that both old and new implementations satisfy, allowing incremental migration on trunk without a long-lived feature branch.
Replace a large integrated component by introducing an abstraction layer that both old and new implementations satisfy, allowing incremental migration on trunk without a long-lived feature branch.
Adopted by: Google (primary technique for large-scale refactoring across monorepo), Thoughtworks (standard practice for trunk-based development), documented in Humble & Farley "Continuous Delivery" (2010) as the enabling technique for replacing large components without branching, and implemented by teams using Trunk-Based Development at scale. Impact: Long-lived feature branches are one of the top predictors of integration failure — teams using branches longer than 1 day have 3× higher merge conflict rates (DORA research 2018). Branch by Abstraction eliminates long-lived branches for component replacement work by keeping the change on trunk throughout. Google uses this technique to refactor components used by thousands of callers across their monorepo without any team experiencing a broken trunk. Why best: When replacing a large component (database library, HTTP client, payment provider, authentication system), the naive approaches both fail: (a) a feature branch becomes a multi-month integration nightmare as trunk diverges, (b) an in-place replacement breaks all callers simultaneously. Branch by Abstraction provides a third path — introduce an interface, migrate callers gradually, swap the implementation, remove the abstraction — all on trunk, all shippable at every commit.
Sources: Fowler "BranchByAbstraction" (martinfowler.com/bliki/BranchByAbstraction.html 2014); Humble & Farley "Continuous Delivery" (Addison-Wesley 2010) Ch. 14; Hammant "Branch by Abstraction" (trunkbaseddevelopment.com); Feathers "Working Effectively with Legacy Code" (2004) on Seams
Replacing HTTP client: System uses legacy HttpClient with 200 callers. Abstraction: HttpGateway interface with get(), post(), delete(). Wrap legacy client behind HttpGateway. Build new async client implementing HttpGateway. Migrate 20 callers/sprint. 10 sprints later: all callers use new client, legacy removed, interface retained for testability.
Replacing payment provider: 15 order flow methods call Stripe SDK directly. Abstraction: PaymentGateway interface with charge(), refund(), retrievePayment(). Wrap Stripe behind interface. Build Adyen implementation. Shadow mode: 30 days comparing outputs. Migrate 3 methods/week. Complete in 5 weeks.
npx claudepluginhub jeffreytse/grimoire --plugin grimoireGuides incremental modernization of legacy systems using strangler fig pattern, branch by abstraction, characterization tests, monolith decomposition, framework upgrades, and feature-flagged migrations.
Designs incremental migration strategies for legacy codebases including strangler fig pattern, service decomposition, dependency mapping, and API facades. Use when modernizing systems or reducing technical debt.
Replaces a legacy system incrementally by intercepting calls and routing traffic to a new implementation slice by slice, avoiding big-bang rewrites.