Getting Started
Install Nudge and generate your first prompt.
Install
npm i @nudge-ai/core @nudge-ai/clipnpm add @nudge-ai/core @nudge-ai/clibun add @nudge-ai/core @nudge-ai/cliSetup
1. Initialize
Run the init command to set up your configuration:
npx @nudge-ai/cli initThis 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:
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 generateCreates 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.
import "./prompts.gen"; // Import once here
import { summarizer } from "./summarizer.prompt";
summarizer.toString(); // → AI-generated prompt