LI

library-writer

Guides the creation and refactoring of software libraries using industry-standard, dependency-minimal patterns.

Install

mkdir -p .claude/skills/library-writer && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11740" && unzip -o skill.zip -d .claude/skills/library-writer && rm skill.zip

Installs to .claude/skills/library-writer

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

This skill should be used when writing software libraries, packages, or modules following battle-tested patterns for clean, minimal, production-ready code. It applies when creating new libraries, refactoring existing ones, designing library APIs, or when clean, dependency-minimal library code is needed. Triggers on requests like "create a library", "write a package", "design a module API", or mentions of professional library development.
441 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Write software libraries following battle-tested patterns
  • Enforce a specific entry point structure for libraries
  • Implement conditional framework loading
  • Design API configuration using simple accessors
  • Create error handling hierarchies
  • Manage dependencies with zero runtime dependencies when possible

How it works

The skill guides the creation of software libraries by enforcing a strict entry point structure, conditional framework loading, and simple configuration patterns. It also defines error handling and dependency management principles.

Inputs & outputs

You give it
request to create a library or design a module API
You get back
software library code following specified patterns

When to use library-writer

  • Designing a new open-source module
  • Refactoring legacy code into a library
  • Setting up a framework-agnostic package

About this skill

Library Writer

Write software libraries following battle-tested patterns from the most successful open-source maintainers. These patterns have been proven across hundreds of libraries with billions of downloads.

Core Philosophy

Simplicity over cleverness. Zero or minimal dependencies. Explicit code over metaprogramming. Framework integration without framework coupling. Every pattern serves production use cases.

The best library is the one you don't have to think about. It should:

  • Install easily
  • Configure simply
  • Work as expected
  • Not break on upgrades
  • Have obvious documentation

Entry Point Structure

Every library follows this pattern:

1. Dependencies (stdlib preferred)
2. Internal modules (relative imports)
3. Conditional framework loading (never require frameworks directly)
4. Module with config and errors

Why This Order?

  1. Dependencies first - Fail fast if deps are missing
  2. Internal modules - Load library components
  3. Conditional framework - Don't force framework on non-framework users
  4. Config and errors - Ready for use immediately

Conditional Framework Loading

Never require frameworks directly. Check if they exist first:

# Only load framework integration if framework is present
if framework_is_loaded:
  load framework_integration

# This allows the library to work:
# - In framework apps (with integration)
# - In plain apps (without framework overhead)
# - In test environments (isolated)

See framework-integration.md for detailed patterns.

Configuration Pattern

Use simple accessors, not Configuration objects:

Good:
  MyLib.api_key = "..."
  MyLib.timeout = 30
  MyLib.logger = custom_logger

Bad:
  MyLib.configure do |config|
    config.api_key = "..."
    config.timeout = 30
    config.logger = custom_logger
  end

Why Simple Accessors?

  • Easier to understand (just assignment)
  • Can be set from anywhere
  • No DSL to learn
  • Works with environment variables naturally
  • Testable (just set the value)

Configuration Defaults

Set sensible defaults immediately:

Module MyLib:
  timeout = 10           # Reasonable default
  logger = null          # Optional
  api_key = ENV["KEY"]   # From environment

See api-design.md for API patterns.

Error Handling

Simple hierarchy with informative messages:

Module MyLib:
  class Error (base error)
  class ConfigError (configuration problems)
  class ValidationError (invalid input)
  class ConnectionError (network issues)

Error Design Principles

  1. Inherit from standard error class - Works with existing error handling
  2. Few error types - Don't create an error for every situation
  3. Informative messages - Include what went wrong and how to fix it
  4. Validate early - Raise ArgumentError on bad input immediately
Good error message:
  "API key must be 32 characters, got 16. Set MyLib.api_key or MYLIB_API_KEY environment variable."

Bad error message:
  "Invalid key"

API Design Principles

Class Macro Pattern

The signature pattern for libraries that enhance classes:

Usage:
  class Product:
    searchable(fields: ["name", "description"])

Implementation:
  def searchable(**options):
    validate_options(options)
    store_options(options)
    add_methods()

Single Configuration Method

One method call should configure everything:

Good:
  class User:
    authenticatable()  # Adds all auth methods

Bad:
  class User:
    add_password_field()
    add_session_methods()
    add_remember_token()
    configure_encryption()

See api-design.md for detailed patterns.

Dependency Management

Zero Runtime Dependencies (When Possible)

Good:
  # Use stdlib for common operations
  # Vendor small utilities if needed
  # No runtime dependencies in manifest

Bad:
  # Dependencies for things stdlib handles
  # Dependencies for "convenience"
  # Dependencies that pull in more dependencies

Development Dependencies

Keep development dependencies separate:

Development only:
  - Test framework
  - Linting tools
  - Documentation generators
  - Debug utilities

Never in production:
  - These don't ship with the library
  - Users don't install them

Lock Files

Never commit lock files in libraries. Lock files:

  • Lock to specific versions you tested with
  • Prevent users from getting compatible updates
  • Cause conflicts with user's other dependencies

See module-organization.md for structure patterns.

Testing Philosophy

Use Standard Test Framework

Every language has a standard test framework. Use it.

Python: pytest or unittest
JavaScript: Jest or Vitest
Go: testing stdlib
Rust: built-in test
Ruby: Minitest

What to Test

1. Public API - Every public method
2. Edge cases - Empty input, null, large data
3. Error conditions - Invalid input, network failures
4. Configuration - Different config combinations
5. Integration - With frameworks (if applicable)

Test Structure

tests/
├── unit/           # Fast, isolated tests
├── integration/    # Tests with external systems
└── fixtures/       # Test data

See testing-patterns.md for detailed patterns.

Anti-Patterns to Avoid

PatternProblemAlternative
Dynamic method generationHard to understand, debugDefine methods explicitly
Configuration objectsUnnecessary complexitySimple accessors
Tight framework couplingLimits library usageConditional loading
Many runtime dependenciesBloat, conflicts, securityUse stdlib, vendor
Heavy DSLsLearning curve, magicExplicit method calls
Metaprogramming magicDebugging nightmareClear, explicit code
Committing lock filesVersion conflictsLet users manage deps

Directory Structure

my-library/
├── lib/                    # Source code (or src/)
│   ├── my_library.ext      # Entry point
│   ├── my_library/         # Internal modules
│   │   ├── client.ext
│   │   ├── config.ext
│   │   └── errors.ext
│   └── my_library/integrations/  # Framework integrations
│       └── framework.ext
├── tests/                  # Test files
├── README.md               # Documentation
├── LICENSE                 # License file
└── [package manifest]      # package.json, setup.py, etc.

See module-organization.md for detailed structure.

Reference Files

For deeper patterns, see:

FileTopics
module-organization.mdDirectory layouts, file structure, require/import patterns
framework-integration.mdConditional loading, hooks, lazy initialization
testing-patterns.mdMulti-version testing, CI setup, fixture patterns
api-design.mdPublic interface design, class macros, configuration

Success Criteria

A well-designed library:

  • Installs with one command
  • Configures with simple assignment
  • Works without framework (if applicable)
  • Has zero or minimal dependencies
  • Uses explicit, readable code
  • Tests pass across supported versions
  • Documents the public API clearly
  • Handles errors informatively
  • Doesn't break on upgrades

When not to use it

  • When creating a library that requires many runtime dependencies
  • When a library needs to commit lock files
  • When a library uses dynamic method generation or heavy DSLs

Limitations

  • The skill emphasizes zero or minimal runtime dependencies.
  • It advises against committing lock files in libraries.
  • It discourages dynamic method generation and heavy DSLs.

How it compares

This skill prioritizes simplicity, minimal dependencies, and explicit code over metaprogramming, unlike approaches that might introduce complex configuration objects or tight framework coupling.

Compared to similar skills

library-writer side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
library-writer (this skill)05moNo flagsAdvanced
software-architecture3336moNo flagsIntermediate
codex322moReviewAdvanced
game-development706moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by diegosouzapw

View all by diegosouzapw

helm-chart-scaffolding-v2

diegosouzapw

Helm Chart Scaffolding workflow skill. Use this skill when the user needs Comprehensive guidance for creating, organizing, and managing Helm charts for packaging and deploying Kubernetes applications and the operator should preserve the upstream workflow, copied support files, and provenance before

00

cc-skill-coding-standards-v2

diegosouzapw

Coding Standards & Best Practices workflow skill. Use this skill when the user needs Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development and the operator should preserve the upstream workflow, copied support files, and provenance before

00

worktree-setup

diegosouzapw

Automatically invoked after `git worktree add` to create data/shared symlink and data/local directory. Required before starting work in any new worktree.

00

parsehub-automation

diegosouzapw

Automate Parsehub tasks via Rube MCP (Composio). Always search tools first for current schemas.

00

signalwire-agents-sdk

diegosouzapw

Expert assistance for building SignalWire AI Agents in Python. Automatically activates when working with AgentBase, SWAIG functions, skills, SWML, voice configuration, DataMap, or any signalwire_agents code. Provides patterns, best practices, and complete working examples.

00

agent-sales-engineer

diegosouzapw

Expert sales engineer specializing in technical pre-sales, solution architecture, and proof of concepts. Masters technical demonstrations, competitive positioning, and translating complex technology into business value for prospects and customers.

00

You might also like

software-architecture

davila7

Guide for quality focused software architecture. This skill should be used when users want to write code, design architecture, analyze code, in any case that relates to software development.

333868

codex

Lucklyric

Invoke Codex CLI for complex coding tasks requiring high reasoning capabilities. This skill should be invoked when users explicitly mention "Codex", request complex implementation challenges, advanced reasoning, or need high-reasoning model assistance. Automatically triggers on codex-related requests and supports session continuation for iterative development.

32238

game-development

davila7

Game development orchestrator. Routes to platform-specific skills based on project needs.

70195

senior-fullstack

davila7

Comprehensive fullstack development skill for building complete web applications with React, Next.js, Node.js, GraphQL, and PostgreSQL. Includes project scaffolding, code quality analysis, architecture patterns, and complete tech stack guidance. Use when building new projects, analyzing code quality, implementing design patterns, or setting up development workflows.

35110

command-name

anthropics

This skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.

697

python-project-structure

wshobson

Python project organization, module architecture, and public API design. Use when setting up new projects, organizing modules, defining public interfaces with __all__, or planning directory layouts.

860

Search skills

Search the agent skills registry