Every developer I know has a snippet problem. Not a "I don't know how to code" problem — a "I've solved this exact little thing before and I can't find where I put it" problem.

I used to keep snippets in GitHub Gists. But Gists are designed for sharing, not personal knowledge management. The search is weak, the organization is flat, and everything you put there is either public (problematic for client work) or private-but-on-GitHub's-servers (problematic for snippets that contain internal patterns you don't want leaking).

codesnips is the personal Gist alternative. Self-hosted. Fast. Keyboard-driven. Doesn't phone home.

What's In It

Why Pygments and Not Highlight.js

Most web-based code viewers use highlight.js or Prism.js. They're JavaScript, they run in the browser, they're async. They also have opinions about how to render code that don't always match what I want, and they add JavaScript to pages that shouldn't need JavaScript.

codesnips renders all syntax highlighting server-side with Pygments. Zero JavaScript required to view a snippet. A snippet page is under 8KB and renders instantly. The share links work even if the recipient has JavaScript disabled.

from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter

def render_snippet(source, lang):
    lexer = get_lexer_by_name(lang, stripall=False)
    formatter = HtmlFormatter(cssclass="highlight", linenos="table")
    return highlight(source, lexer, formatter)

The FTS Piece

SQLite's FTS5 extension does the search. When you save a snippet, a trigger mirrors its content into a virtual FTS table. When you search, the query runs against that table and returns ranked results in milliseconds.

CREATE VIRTUAL TABLE snippet_fts USING fts5(
  title, body, tags,
  content='snippet', content_rowid='id'
);

-- Trigger to keep FTS in sync
CREATE TRIGGER snippet_after_insert AFTER INSERT ON snippet
BEGIN
  INSERT INTO snippet_fts(rowid, title, body, tags)
  VALUES (new.id, new.title, new.body, new.tags);
END;

On my personal instance (about 1,400 snippets, 8 years of accumulated history), search across every field returns in under 3ms. Compare to GitHub Gist search, which I gave up on using in 2019.

The Versioning

Every edit to a snippet writes a new version row. The snippet's current text is always the latest version. Older versions are queryable. Diffs are rendered via difflib's unified_diff.

I use this constantly. "Why did I change this regex three months ago?" → pull up the version history, read the diff, remember that I fixed a bug. "This snippet used to do X; who broke it?" → same flow.

Share Links

Click "Share" on a snippet. Pick an expiration (never / 24 hours / 7 days / 30 days / custom). Get a signed URL. The URL has a JWT that encodes the snippet ID + expiration + signature.

When someone visits that URL, they see a read-only page with the snippet rendered. No login. No account. No tracking. The signature prevents anyone from bumping the expiration without re-issuing.

I use this to share snippets with consulting clients without giving them access to the whole tool. They get a link, they read, they use, they close the tab. No signup friction.

The Build

Flask + SQLite + Jinja + Pygments. About 1,200 lines. HTMX for the search-as-you-type box. No JavaScript framework. The whole app is under 80KB loaded.

git clone https://github.com/Dangercorn-Enterprises/codesnips.git
cd codesnips
pip install -r requirements.txt
echo "AUTH_PASSWORD=snips" >> .env
python app.py
# → http://localhost:8500

Pricing

$9 is deliberately the cheapest tier in our catalog. This is a tool I want every developer to use; it should be priceable out of a personal subscription budget without thinking about it.

VSCode Integration

The VSCode extension (Hosted Pro tier) binds a hotkey to open the codesnips panel inside VSCode. You search, you pick, you paste, you keep coding. The self-host tier can use the shell CLI (snip find "awk field 3") for a similar workflow.

The difference between 'I've written this before somewhere' and 'I have this at a keystroke' is about four hours a week for a working developer.

Who It's For

Working developers. Anyone who's built up a personal code-snippet library over the years and wants it in one place. Solo consultants who can't use GitHub Gist for client work. Small engineering teams that want a shared snippet library.

Related

meetingmind for the team-documentation parallel. retentionradar if you're on the indie SaaS side. coachboard if you're a consultant using this for client snippets.

Repo: github.com/Dangercorn-Enterprises/codesnips.