Implementation:Promptfoo Promptfoo initializeProject
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Templating, Developer_Experience |
| Last Updated | 2026-02-14 08:00 GMT |
Overview
Concrete tool for initializing a Promptfoo project with rendered configuration and user-friendly output, provided by the Promptfoo framework.
Description
The initializeProject function wraps createDummyFiles with telemetry recording, error handling for user cancellation (ExitPromptError), and success messaging that guides users to run their first evaluation.
Usage
Import this function as the entry point for the `promptfoo init` CLI command.
Code Reference
Source Location
- Repository: promptfoo
- File: src/onboarding.ts
- Lines: L649-688
Signature
export async function initializeProject(
directory: string | null,
interactive: boolean = true,
): Promise<{
numPrompts: number;
providerPrefixes: string[];
action: string;
language: string;
}>
Import
import { initializeProject } from './onboarding';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| directory | string or null | Yes | Target directory (null for current directory) |
| interactive | boolean | No | Whether to use interactive prompts (default: true) |
Outputs
| Name | Type | Description |
|---|---|---|
| (return) | object | Metadata about what was created: numPrompts, providerPrefixes, action, language |
Usage Examples
Initialize New Project
import { initializeProject } from './onboarding';
const details = await initializeProject('./my-project');
// Prints: "Run `promptfoo eval` to get started!"
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment