Implementation:Promptfoo Promptfoo createDummyFiles
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Developer_Experience, Scaffolding |
| Last Updated | 2026-02-14 08:00 GMT |
Overview
Concrete tool for generating evaluation project files through interactive prompts, provided by the Promptfoo framework.
Description
The createDummyFiles function is the core implementation of the `promptfoo init` flow. It runs interactive prompts using @inquirer/select for use case, language, and provider selection, then generates project files (config, prompts, context) using Nunjucks templates and fs.writeFileSync.
Usage
Import this function when you need to programmatically scaffold a Promptfoo project. It is wrapped by initializeProject which adds telemetry and user-friendly output.
Code Reference
Source Location
- Repository: promptfoo
- File: src/onboarding.ts
- Lines: L313-647
Signature
export async function createDummyFiles(
directory: string | null,
interactive: boolean = true,
): Promise<{
numPrompts: number;
providerPrefixes: string[];
action: string;
language: string;
outDirectory: string;
}>
Import
import { createDummyFiles } from './onboarding';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| directory | string or null | Yes | Target directory for generated files (null = current directory) |
| interactive | boolean | No | Whether to prompt user interactively (default: true) |
Outputs
| Name | Type | Description |
|---|---|---|
| numPrompts | number | Number of prompt files generated |
| providerPrefixes | string[] | Selected provider identifiers |
| action | string | Selected use case (compare, rag, agent, redteam) |
| language | string | Selected programming language |
| outDirectory | string | The directory where files were written |
Usage Examples
Interactive Initialization
import { createDummyFiles } from './onboarding';
// Interactive mode: prompts user for selections
const result = await createDummyFiles('./my-eval-project');
console.log(`Created ${result.numPrompts} prompt files`);
console.log(`Action: ${result.action}`);
console.log(`Providers: ${result.providerPrefixes.join(', ')}`);
Non-Interactive (Testing)
const result = await createDummyFiles('./test-project', false);
// Uses default selections without prompting
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment