readme-writing-package
When to use
- Creating a README for a package, library, SDK, or framework extension
- Rewriting a package README after major changes (new API, version bump, new registry)
- Improving a weak package README (missing install, no example, no compatibility info)
- Documenting a package for Packagist, npm, or internal registries
Do NOT use when:
- Documenting a full application, CLI tool, or internal team repo → use
readme-writinginstead - Only fixing minor typos or updating a single section
- Writing deep reference docs that belong in
/docs
Goal
Package README that makes adoption easy. A developer should know within 30 seconds:
what it does, whether it fits their stack, how to install it, and how to use it.
Core principles
- User adoption over internal architecture — consumer first, maintainer second
- Install + first example = most important sections — everything else is secondary
- Compatibility must be explicit — don't imply broad support without evidence
- First code example must be real, minimal, and verified — no pseudo-code
- README = onboarding, /docs = reference — keep README focused
- Re-analyze every time — never write from cached knowledge; verify the manifest, source, and CI matrix in this session
- Preserve existing visual identity — banner, badges, hero images, and logo lockups stay byte-identical unless the user explicitly asks to change them
Procedure
0. Re-analysis gate — MANDATORY before any writing
Before drafting, produce an evidence ledger from a fresh inspection of
the package — manifest, source, CI, examples. Do not rely on prior turns
or the existing README prose.
ledger:
package: <name + version from manifest>
description: <verbatim from manifest>
install_cmd: <verified against the manifest's package manager>
requirements: <language version, framework version, ext-*, services>
public_api: <entry classes / functions / exports from source>
test_command: <real command from manifest scripts / Taskfile>
doc_targets: <list of /docs files actually linked from the new draft>
visual_keep: <line range of existing README header / banner / badges to preserve>
If any cell is unknown, run ls, grep, find, or read the file before
writing — never invent. When the user asks to keep the existing banner
or badge row, reproduce it byte-for-byte from the source.
1. Identify package type and audience
| Type | Audience | README focus |
|---|---|---|
| Library | Any developer | Install → Usage → API surface |
| Framework extension | Framework users | Requirements → Install → Register → Use |
| Plugin | Plugin host users | Compatibility → Install → Config → Use |
| SDK | API consumers | Auth → Install → First request → Response handling |
| Internal shared package | Team members | Purpose → Install → Integration → Dev workflow |
2. Inspect package truth sources
Read and verify files that define actual package behavior (confirm each claim against the source — never paraphrase from memory):
- Manifest:
composer.json,package.json,pyproject.toml,Cargo.toml,go.mod, or*.gemspec— name, description, requirements, scripts - Source entrypoints — public API surface, main classes/functions
- Config files — publishable configs, defaults
- CI workflows — what gets tested, supported versions matrix
- Tests — reveal actual API usage patterns
CHANGELOG.md/ releases — current state, breaking changes- Examples directory — if present
Extract: package name, purpose, install command, runtime requirements,
supported versions, public API, setup steps, test/lint commands.
3. Choose sections
Priority order for packages:
- Title + one-line summary — always
- Why / what problem — if not obvious from name
- Requirements / compatibility — always (versions, extensions, frameworks)
- Installation — always (exact command, post-install steps)
- Minimal usage example — always (most important section)
- Configuration / setup — if config publish, env vars, or registration needed
- More examples / common use cases — if API has multiple entry points
- Development / testing — for maintainers/contributors
- Contributing — if open or team project
- License — if applicable
Skip sections that have no real content. Never pad.
4. Write requirements and compatibility
State only what is tested and supported. Pull the values from the package's manifest, not from memory. Examples per stack:
## Requirements (PHP)
- PHP ^8.2
- Laravel 11.x (optional integration)
- ext-json
## Requirements (JS / TS)
- Node.js >= 20
- TypeScript >= 5.4 (for typed consumers)
- npm / pnpm / yarn / bun
## Requirements (Python)
- Python >= 3.11
- pip / poetry / uv
- Optional: `fastapi >= 0.110` for the FastAPI integration
## Requirements (Go)
- Go >= 1.22
## Requirements (Rust)
- Rust >= 1.78 (stable)
- `cargo` workspace member or standalone crate
## Requirements (Ruby)
- Ruby >= 3.2
- Bundler >= 2.5
- Optional: Rails 7.1+ for the Rails integration
Do NOT imply broad compatibility if only tested in a narrow range.
Include language version, framework version, required extensions, and services.
5. Write installation that actually works
Document the exact install command and any required follow-up. Use the
package manager native to the stack — never edit manifests by hand.
# PHP / Composer
composer require vendor/package
# Optional Laravel integration:
php artisan vendor:publish --tag=package-config
# JS / TS — pick whichever the consumer uses
npm install <package>
pnpm add <package>
yarn add <package>
bun add <package>
# Python
pip install <package>
poetry add <package>
uv add <package>
# Go
go get github.com/<owner>/<package>@latest
# Rust
cargo add <package>
# Ruby
bundle add <package>
# or, for a standalone gem:
gem install <package>
Validate each step against the actual codebase.
Include post-install steps (config publish, service / module / provider
registration, env vars, codegen, migrations) if the package requires them.
6. Write the minimal working example
This is the most critical section. Rules:
- Smallest possible working example — one use case, one result
- Real API calls, not pseudo-code
- Copy-pasteable without hidden setup
- Show expected result or effect if helpful
- Must match the actual package API (verify against source)
Bad: abstract, large, requires unexplained setup.
Good: 5-15 lines, directly relevant, immediately runnable.
7. Keep architecture out of README — use reference-split
Move deep content to dedicated docs. Recommended layout for packages:
README.md ← entry: what, why, install, minimal usage
docs/
installation.md ← full install matrix, post-install steps
usage.md ← extended examples, common patterns
architecture.md ← internal design, decisions
api.md ← full API reference
migration.md ← version upgrade guides
For multi-platform install (> 5 variants), prefer a single table with
deep links over stacked inline blocks. For occasionally-needed detail
(long platform quirks, troubleshooting), use <details> — never for
install, first example, or requirements.
→ See docs/guidelines/docs/readme-size-and-splitting.md for thresholds,
deep-link-table pattern, collapsibles, and anti-patterns (premature
splitting, duplication between README and /docs/).
Per-AI catalog pattern (multi-platform AI / CLI packages)
For packages that target many AI assistants or platforms (CLI installers,
agent-config tools, language SDKs with 10+ targets), prefer a flat per-AI
catalog over a giant matrix. One line per target, install command on the
left, aligned trailing comment naming the platform:
npx <package> init --tools=claude-code # Claude Code
npx <package> init --tools=cursor # Cursor
npx <package> init --tools=windsurf # Windsurf
# ... one line per supported target
Pair the catalog with a separate "Global install" subsection (same flags
plus --global) and an "Other commands" subsection. Reference example: