xiaohongshu
xiaohongshu
library-writer
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 ...
Full skill instructions
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.
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:
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
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.
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
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.
Simple hierarchy with informative messages:
Module MyLib:
class Error (base error)
class ConfigError (configuration problems)
class ValidationError (invalid input)
class ConnectionError (network issues)
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"
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()
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.
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
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
Never commit lock files in libraries. Lock files:
See module-organization.md for structure patterns.
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
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)
tests/
├── unit/ # Fast, isolated tests
├── integration/ # Tests with external systems
└── fixtures/ # Test data
See testing-patterns.md for detailed patterns.
| Pattern | Problem | Alternative |
|---|---|---|
| Dynamic method generation | Hard to understand, debug | Define methods explicitly |
| Configuration objects | Unnecessary complexity | Simple accessors |
| Tight framework coupling | Limits library usage | Conditional loading |
| Many runtime dependencies | Bloat, conflicts, security | Use stdlib, vendor |
| Heavy DSLs | Learning curve, magic | Explicit method calls |
| Metaprogramming magic | Debugging nightmare | Clear, explicit code |
| Committing lock files | Version conflicts | Let users manage deps |
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.
For deeper patterns, see:
| File | Topics |
|---|---|
| module-organization.md | Directory layouts, file structure, require/import patterns |
| framework-integration.md | Conditional loading, hooks, lazy initialization |
| testing-patterns.md | Multi-version testing, CI setup, fixture patterns |
| api-design.md | Public interface design, class macros, configuration |
A well-designed library:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience