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 🙏

© 2025 – Pkg Stats / Ryan Hefner

prompt-toolkit

v1.0.0

Published

PromptKit is a lightweight toolkit for managing prompts in your LLM agents.

Downloads

81

Readme

PromptKit

PromptKit is a lightweight toolkit for managing prompts in your LLM agents.

  • Load prompts from files into memory at application startup.
  • Supports both plain text prompts and structured chat message formats.
  • Inject variables dynamically into prompts using {{variable}} syntax. Supports both global and prompt-specific variables.
  • Organize prompts in directories and subdirectories for better management.

Installation

npm install prompt-toolkit

Usage

Basic Setup

import { PromptKit } from "prompt-toolkit";

// Create a PromptKit instance
const prompts = new PromptKit({
    // OPTIONAL: global variables to inject into all prompts
    variables: {
        app: "Bastion",
        ver: "10.0.0",
    },
});

Text Prompts

Create a text prompt file (e.g., prompts/system.md):

You are a helpful assistant for {{app}} version {{ver}}.
const prompt = prompts.get("system");
// "You are a helpful assistant for Bastion version 10.0.0."

// Override variables per prompt
const customPrompt = prompts.get("system", { ver: "10.17.0" });
// "You are a helpful assistant for Bastion version 10.17.0."

Chat Prompts

Create a chat prompt file (e.g., prompts/chat.json):

[
    {
        "role": "system",
        "content": "You are a helpful assistant for {{app}}."
    },
    {
        "role": "developer",
        "content": "User's name is {{user}}."
    }
]

Or use YAML (e.g., prompts/chat.yaml):

- role: system
  content: You are a helpful assistant for {{app}}.
- role: developer
  content: User's name is {{user}}.
const messages = prompts.get("chat", { user: "Alice" });
// [
//   { role: "system", content: "You are a helpful assistant for Bastion." },
//   { role: "developer", content: "User's name is Alice." }
// ]

Directory Structure

Prompts can be organized in subdirectories:

prompts/
  ├── system.md
  ├── chat.json
  └── nested/
      └── skills.md
      └── suggestions.md
prompts.get("system");           // From prompts/system.md
prompts.get("chat");             // From prompts/chat.json
prompts.get("nested/skills");    // From prompts/nested/skills.md

Methods

get(name, variables?)

Get a compiled prompt by name.

const prompt = prompts.get("system");
const customPrompt = prompts.get("system", { variable: "value" });

Returns:

  • string for text prompts
  • ChatMessage[] for chat prompts
  • undefined if prompt doesn't exist

has(name)

Check if a prompt exists.

if (prompts.has("system")) {
    const prompt = prompts.get("system");
}

list()

List all available prompt names.

const names = prompts.list();
// [ "system", "chat", "nested/skills", "nested/suggestions" ]

reload()

Reload all prompts and update the in-memory cache.

prompts.reload();

Variable Substitution

Variables use the {{variableName}} syntax:

// Template: "Hello {{name}}, welcome to {{product}}!"
prompts.get("welcome", { name: "Alice", product: "Omnic" });
// "Hello Alice, welcome to Omnic!"

Unmatched variables remain as-is in the output.

License

MIT