DEV Community

ke jia
ke jia

Posted on

Code Snippets That Actually Survive: A Local-First Workflow

Every snippet service I have ever used has one fatal flaw: your code lives somewhere else.

Gists vanish when you forget your account. Pastebin links rot. A browser profile wipe takes your "code stuff" folder with it. I have watched all of this happen.

So here is the workflow I settled on, and the one tool at its center. The core idea: your snippets should be a file you own.

The Local-First Rule

Three requirements, non-negotiable:

  1. The data is a plain file I can open in any editor.
  2. No network required — it must work in a meeting, on a train, on a locked-down work machine.
  3. Syncing is a file operation — copy it, git it, rsync it. No service.

SnippetX is built exactly around this. Everything you save lands in:

~/.snippetx/snippets.json
Enter fullscreen mode Exit fullscreen mode

That is it. A single JSON file with names, languages, dates, and content. Open it. Read it. Move it.

Saving Is a Pipe

echo 'app.get("/users", handler)' | npx @wuchunjie/snippetx add user-route js
Enter fullscreen mode Exit fullscreen mode
✅  Saved: "user-route" (js)
Enter fullscreen mode Exit fullscreen mode

Retrieval Is One Command

npx @wuchunjie/snippetx search route
Enter fullscreen mode Exit fullscreen mode
  🔍  "route" → 1 match

  🔹 a1b2c3d4  user-route
     ...app.get("/users", handler)...
Enter fullscreen mode Exit fullscreen mode

And to use it:

npx @wuchunjie/snippetx copy a1b2c3d4 >> server.js
# or to clipboard:
npx @wuchunjie/snippetx copy a1b2c3d4 | pbcopy
Enter fullscreen mode Exit fullscreen mode

Syncing: The Boring (Good) Way

Because it is one file, "sync across machines" is a two-line script:

cd ~/.snippetx
git init && git add snippets.json && git commit -m "snippets"
Enter fullscreen mode Exit fullscreen mode

Push it to any repo (private, if you like). New machine? Clone and done. Your entire code memory travels in a single JSON file — no service account, no API, no Terms of Service update you never read.

Why I Care About This

Snippet data is personal infrastructure. The regex you built over an hour, the config for your team's weird proxy, the exact curl call that hits your staging API — these are not "notes". They are muscle memory.

Cloud services make muscle memory hostage to their uptime and their business model. A file makes it yours.

That is the whole pitch. Zero dependencies, zero accounts, one command.

npm: @wuchunjie/snippetx | GitHub: wuchunjie00/devtools


From the same toolbox

  • ScaffoldX — generate production-ready project templates in seconds: npx scaffoldx-cli
  • DotGuard — scan .env files for exposed secrets: npx @wuchunjie/dotguard
  • GitPulse — git analytics (commits, contributors, activity) in your terminal: npx @wuchunjie/gitpulse
  • SnippetX — save, search, and copy code snippets from the terminal: npx @wuchunjie/snippetx

GitHub: wuchunjie00/devtools


☕ If This Saved You Time

All of these tools are and will always be 100% free. If they make your day a little easier, consider fueling the next one:

Buy me a coffee on Ko-fi

Built with ❤️. Zero dependencies, zero tracking, zero bloat.

Top comments (0)