Snippet Library for Future Packages

Save, tag and search reusable code in your own browser. Nothing leaves this device unless you export it.

+ Add Snippet

0
Total Snippets
0
Languages
0
Categories
0
Lines of Code

Why a snippet library belongs on a package-author site

Most published packages start life as a helper someone copied between projects three or four times. A debounce function, a retry wrapper, a date formatter: each copy drifts a little, and nobody remembers which one has the fix. Keeping those fragments in one searchable place is the cheapest step before deciding whether any of them deserves a name, a version number and a registry entry.

The tool above is deliberately small. You pick a language and a category, give the snippet a title, an optional description and tags, and paste the code. The list below the form shows totals for snippets, languages, categories and lines, and the search box matches titles, code and tags. Each entry can be copied, edited or deleted.

Where your snippets are stored

Export and import

"Export (JSON)" downloads the whole library as a file you can keep in version control or move to another machine, and "Import" reads such a file back. "Export (Markdown)" writes a readable document with each snippet in a fenced code block, which is handy for a team wiki or for reviewing what you have collected. A sensible habit is to commit the JSON export to a private repository now and then; the commit history then shows how each helper changed.

When a snippet should become a package

Not every useful fragment should be published. A short checklist helps you decide:

  1. Reuse count. If you have pasted it into three or more projects and fixed it in at least one, a single maintained copy will save you work.
  2. Stable shape. Can you describe its inputs and outputs in two sentences? If the signature still changes every time, keep it as a snippet a while longer.
  3. Tests exist or are easy. A function you cannot test in isolation will be painful to version.
  4. No hidden coupling. Snippets that reach into a particular app's globals or config need refactoring first.
  5. The name is free and clear. Check the registry for the name and for confusingly similar ones before you commit to it.
  6. You accept the maintenance. Publishing invites issues and expectations about semantic versioning and licences.

Hypothetical example: Developer B keeps a retry helper tagged "network" and notices it in four repositories with two different backoff bugs. Exporting the Markdown, comparing versions and merging the fixed one gives a single tested function, which is then a reasonable candidate for an internal package with a changelog from day one.

The glossary defines the publishing terms used here, and the tools page lists the other browser tool on this site.