npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@promptbranch/core

v0.2.5

Published

PromptBranch domain core: SQLite-backed prompt library with versioning, branching, tags, collections, ratings, runs and FTS search. Zero Electron dependencies.

Readme

PromptBranch Core

npm version

@promptbranch/core is the Node.js domain library behind PromptBranch. It provides a SQLite-backed prompt library with version history, branches, tags, collections, ratings, run records, full-text search, JSON import/export, and peer-to-peer sync primitives. It has no Electron dependency.

Requires Node.js 22 or later.

Source: GitHub · documentation · report an issue

Install

npm install @promptbranch/core@latest

better-sqlite3 is a native dependency. Use a supported Node.js platform and architecture with a compatible prebuilt binary, or a working native build toolchain.

Create a prompt library

import { openMemoryDatabase, PromptLibrary } from "@promptbranch/core";

const db = openMemoryDatabase();
const library = new PromptLibrary(db);

const prompt = library.createPrompt({
  title: "Review this change",
  content: "Review {{target}} for correctness and security.",
  tagNames: ["code-review"],
});

console.log(library.getPrompt(prompt.id));
db.close();

openMemoryDatabase() applies the latest schema to a disposable in-memory database. For a persistent library, pass an explicit path to openDatabase():

import { openDatabase, PromptLibrary } from "@promptbranch/core";

const { db, backupPath } = openDatabase("/absolute/path/library.db");
const library = new PromptLibrary(db);

console.log(library.listPrompts());
console.log({ backupPath });
db.close();

Migrations run automatically. When an existing on-disk database needs a migration, PromptBranch creates a timestamped backup first and returns its path as backupPath; otherwise that value is null.

Resolve an exact version

Each version has a stable id. Use it with resolveVersion() when a saved workflow must keep referring to the same version record:

import { resolveVersion } from "@promptbranch/core";

const versionId = library.getPrompt(prompt.id)?.current_version_id;
if (!versionId) throw new Error("Prompt has no current version");

const exact = resolveVersion(library, prompt.id, { versionId });
console.log(exact.version.content);

Numeric version labels are scoped to a branch. Deleting an older version does not renumber the surviving history, so gaps are normal. Paired devices may also reconcile a true concurrent number collision; use the stable id as the durable identity for automation. Desktop users can amend that version's content, so create a new version when the content must remain a snapshot.

Main exports

  • PromptLibrary — prompt, version, branch, note, tag, collection, rating, run, search, and import/export operations.
  • openDatabase() and openMemoryDatabase() — SQLite lifecycle and schema setup.
  • resolveDatabasePath() — the shared PromptBranch library location, with PROMPTBRANCH_DB override support.
  • extractPromptVariables(), missingPromptVariables(), and substitutePromptVariables() — {{variable}} discovery and substitution.
  • resolvePrompt() and resolveVersion() — id/title and version reference resolution, including exact lookup by stable version id.
  • SyncEngine and hybrid logical clock helpers — transport-independent sync primitives.

The desktop app, CLI, and MCP server use this package against the same local database. If several processes open that database, WAL mode and a busy timeout are configured automatically.

Build from source

From the PromptBranch repository, with pnpm 11.7.0 available:

pnpm install
pnpm --filter @promptbranch/core build

The published package contains compiled ESM in dist/ and TypeScript declarations.