agentleFS
martincjarvismartincjarvis/development-skills/skills/library-extraction-stabilisation/SKILL.md

library-extraction-stabilisation

Skill4 starsChanged 10 months agoMITView on GitHub

Use when shared code is used by 3+ components, user asks about extracting library, or code is copied across services. Ensures stability, ownership, versioning, and governance before extraction.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    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
  1. Distinctive:

    If not ready: Document alternative and re-evaluation criteria

    line 33
  2. Distinctive:

    Use this matrix to evaluate whether extraction is appropriate:

    line 71
  3. Distinctive:

    If migration fails for any consumer:

    line 160
  4. Distinctive:

    If repeated failures: consider consumer-specific fork or delay

    line 165

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Library Extraction Stabilisation

Overview

Extract shared code into libraries only after proven stability and with clear ownership. Prevent premature abstraction, version chaos, and orphaned libraries.

REQUIRED: superpowers:brainstorming (before extraction decision)

When to Use

  • Shared functionality used by 3+ components
  • User asks "should I extract this as a library?"
  • Code duplication across services/components
  • User proposes creating shared package/library
  • Existing internal library needs stabilization

Core Workflow

  1. Count consumers (need 3+ for extraction)
  2. Assess stability (change frequency over 3 months)
  3. Define ownership (team with capacity)
  4. Define versioning (SemVer, breaking change policy)
  5. Plan migration (incremental, rollback strategy)
  6. If not ready: Document alternative and re-evaluation criteria

Extraction Readiness Criteria

CriterionThresholdAction if Not Met
Consumers3+Wait for 3rd consumer
Stability<2 changes/month for 2 monthsDefer until stable
OwnershipTeam identified with capacityIdentify owner first
SupportSLA or best-effort definedDefine support model

Red Flags - STOP

  • "Already used in 2 places, should extract"
  • "Keep changing in multiple places, must extract"
  • "DRY principle requires extraction"
  • "Library will force stability"

All mean: Apply readiness assessment before proceeding.

Rationalizations Table

ExcuseReality
"DRY says extract now"DRY applies after proven need. 2 uses isn't proof.
"Easier to maintain in one place"Only if stable. Volatile library causes upgrade fatigue.
"Library will force stability"Backwards. Stability enables libraries.
"Tech lead said create library"Clarify. Share stability/ownership concerns.
"Best practice is shared libraries"Microservices tolerate duplication over coupling.

Reference Documents

  • Governance Models - Ownership and support models
  • Versioning Strategy - SemVer, breaking changes
  • Migration Planning - Consumer migration guide

Decision Matrix Template

Use this matrix to evaluate whether extraction is appropriate:

# Library Extraction Decision: [Component Name]

**Date**: YYYY-MM-DD
**Evaluator**: [Name]

## Readiness Assessment

| Criterion                        | Current State              | Threshold  | Pass? |
| -------------------------------- | -------------------------- | ---------- | ----- |
| Consumer count                   | [N]                        | ≥ 3        | ☐     |
| Change frequency (last 3 months) | [N/month]                  | < 2/month  | ☐     |
| Defined owner                    | [Team/None]                | Named team | ☐     |
| Support model                    | [SLA/Best-effort/None]     | Defined    | ☐     |
| API stability                    | [Stable/Evolving/Volatile] | Stable     | ☐     |
| Test coverage                    | [N]%                       | ≥ 80%      | ☐     |

## Consumer Analysis

| Consumer  | Integration Type  | Impact if Breaking Change |
| --------- | ----------------- | ------------------------- |
| Service A | Direct dependency | High - core functionality |
| Service B | Transitive        | Medium - feature subset   |
| Service C | Direct dependency | High - multiple endpoints |

## Risk Assessment

| Risk                              | Likelihood | Impact  | Mitigation                              |
| --------------------------------- | ---------- | ------- | --------------------------------------- |
| Breaking change during extraction | [H/M/L]    | [H/M/L] | Semantic versioning, deprecation period |
| Ownership vacuum                  | [H/M/L]    | [H/M/L] | Assign team before extraction           |
| Version sprawl                    | [H/M/L]    | [H/M/L] | Enforce upgrade policy                  |

## Decision

☐ **Proceed with extraction** - All criteria met
☐ **Defer extraction** - Criteria not met, re-evaluate on [date]
☐ **Alternative approach** - [Describe: shared module, copy, etc.]

**Rationale**: [Brief explanation of decision]

Migration Plan Checklist

Phase 1: Preparation (Week 1)

  • Document current API surface
  • Identify all consumers (direct and transitive)
  • Establish version numbering scheme (SemVer)
  • Create library repository with CI/CD
  • Set up package publishing (NuGet, npm, PyPI, etc.)
  • Document breaking change policy
  • Assign ownership team with on-call rotation

Phase 2: Initial Release (Week 2)

  • Extract code into library repository
  • Ensure test coverage ≥ 80%
  • Create API documentation
  • Publish v1.0.0 (or appropriate version)
  • Migrate first consumer (lowest risk)
  • Verify functionality in staging environment
  • Document migration steps for other consumers

Phase 3: Consumer Migration (Weeks 3-4)

  • Notify all consumers of migration timeline
  • Provide migration guide with examples
  • Support each consumer during migration
  • Track migration progress:
ConsumerStatusMigration DateIssues
Service A☐ Pending / ☐ In Progress / ☐ Complete
Service B☐ Pending / ☐ In Progress / ☐ Complete
Service C☐ Pending / ☐ In Progress / ☐ Complete

Phase 4: Stabilisation (Week 5+)

  • Remove original code from source locations
  • Monitor library usage metrics
  • Address any post-migration issues
  • Establish regular release cadence
  • Document lessons learned

Rollback Plan

If migration fails for any consumer:

  1. Consumer reverts to previous version (before library dependency)
  2. Library team investigates and patches
  3. Consumer re-attempts migration with patched version
  4. If repeated failures: consider consumer-specific fork or delay

Success Criteria

  • All consumers successfully migrated
  • No production incidents attributed to library
  • Library version published and consumable
  • Original code removed from source repositories
  • Documentation complete and accessible

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.