Nudge

Getting Started

Install Nudge and generate your first prompt.

Install

npm i @nudge-ai/core @nudge-ai/cli
pnpm add @nudge-ai/core @nudge-ai/cli
bun add @nudge-ai/core @nudge-ai/cli

Setup

1. Initialize

Run the init command to set up your configuration:

npx @nudge-ai/cli init

This will guide you through choosing a provider (OpenAI, OpenRouter, or local) and create a nudge.config.json file.

2. Define a prompt

Create a file ending in .prompt.ts:

src/summarizer.prompt.ts
import { prompt } from "@nudge-ai/core";

export const summarizer = prompt("summarizer", (p) =>
  p
    .persona("expert summarizer")
    .input("text to summarize")
    .output("concise summary")
    .do("preserve key facts")
    .constraint("max 3 paragraphs")
);

The CLI only discovers *.prompt.ts files.

3. Generate

npx @nudge-ai/cli generate

Creates src/prompts.gen.ts with your AI-generated system prompts.

4. Use

Import the generated file once at your app's entry point. After that, .toString() works on any prompt throughout your codebase.

src/index.ts
import "./prompts.gen"; // Import once here
import { summarizer } from "./summarizer.prompt";

summarizer.toString(); // → AI-generated prompt

On this page