Promptfoo GitHub Action 是 AI Skill Hub 本期精选Agent工作流之一。综合评分 8.2 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
Promptfoo的官方GitHub Action工具,用于持续集成测试AI提示词、智能体和RAG系统。支持自动化验证提示效果,集成安全测试和红队评估。适合AI工程师、LLM产品团队进行提示词质量保障。
Promptfoo GitHub Action 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
Promptfoo的官方GitHub Action工具,用于持续集成测试AI提示词、智能体和RAG系统。支持自动化验证提示效果,集成安全测试和红队评估。适合AI工程师、LLM产品团队进行提示词质量保障。
Promptfoo GitHub Action 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:npm 全局安装 npm install -g promptfoo-action # 方式二:npx 直接运行(无需安装) npx promptfoo-action --help # 方式三:项目依赖安装 npm install promptfoo-action # 方式四:从源码运行 git clone https://github.com/promptfoo/promptfoo-action cd promptfoo-action npm install npm start
# 命令行使用
promptfoo-action --help
# 基本用法
promptfoo-action [options] <input>
# Node.js 代码中使用
const promptfoo_action = require('promptfoo-action');
const result = await promptfoo_action.run(options);
console.log(result);
# promptfoo-action 配置说明 # 查看配置选项 promptfoo-action --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export PROMPTFOO_ACTION_CONFIG="/path/to/config.yml"
This GitHub Action uses Promptfoo to evaluate prompts when monitored files change.
On pull requests, the action evaluates the current checkout and posts a summary comment with pass/fail counts and, when sharing is enabled, a link to the Promptfoo web viewer:
<img width="650" alt="pull request llm eval" src="https://github.com/typpo/promptfoo-action/assets/310310/ec75fb39-c6b1-4395-9e41-6d66a7bf8657"/>
The web viewer lets you inspect the evaluation results:
<img width="650" alt="promptfoo web viewer" src="https://github.com/typpo/promptfoo-action/assets/310310/d0ef0497-0c1a-4886-b115-1ee92680891b"/>
name: 'Prompt Evaluation with Caching'
on:
pull_request:
paths:
- 'prompts/**'
- 'promptfooconfig.yaml'
jobs:
evaluate:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git diff comparisons
- name: Cache promptfoo evaluations
uses: actions/cache@v4
with:
path: .promptfoo-cache
key: ${{ runner.os }}-promptfoo-${{ hashFiles('promptfooconfig.yaml', 'prompts/**') }}
restore-keys: |
${{ runner.os }}-promptfoo-
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
config: 'promptfooconfig.yaml'
prompts: 'prompts/**'
cache-path: '.promptfoo-cache' # Local cache directory
```yaml
The action can be configured using the following inputs:
| Parameter | Description | Required |
|---|---|---|
config | Promptfoo configuration path, relative to working-directory unless absolute. | Yes |
github-token | GitHub token used to list PR files and post PR comments. | Yes |
prompts | Newline-separated prompt glob patterns, resolved from working-directory. Matching changed files are passed to Promptfoo with --prompts. If omitted, Promptfoo uses the prompts in config. | No |
working-directory | Base directory for the Promptfoo process and relative config, prompt, environment, and cache paths. Defaults to .. | No |
cache-path | Promptfoo disk-cache directory. Relative paths are resolved from working-directory. | No |
promptfoo-version | Version or dist-tag used by npx promptfoo@<version>. Defaults to latest. | No |
no-share | Pass --no-share, overriding config-level sharing. Defaults to false. | No |
use-config-prompts | Do not override config prompts with changed files matched by prompts. Defaults to false. | No |
env-files | Comma-separated .env paths loaded in order from working-directory. Later files override earlier files. | No |
fail-on-threshold | Required suite pass percentage from 0 to 100. | No |
max-concurrency | Value passed to Promptfoo's --max-concurrency. Defaults to 4. | No |
no-table | Pass --no-table. Defaults to false. | No |
no-progress-bar | Pass --no-progress-bar. Defaults to false. | No |
no-cache | Pass --no-cache so Promptfoo does not read or write cached evaluation results. Defaults to false. | No |
disable-comment | Disable posting comments to the PR. Defaults to false. Non-PR workflow summaries are unaffected. | No |
workflow-files | Newline-separated changed-file list for workflow_dispatch. Takes precedence over workflow-level files. | No |
workflow-base | Base branch, tag, full commit SHA, or supported HEAD revision for workflow_dispatch. Takes precedence over workflow-level base; defaults to HEAD~1. | No |
repeat | Number of times Promptfoo runs each test. Must be at least 2; omit it to run once. | No |
repeat-min-pass | Minimum passes required for each repeated test. Requires repeat and cannot exceed it. | No |
force-run | Evaluate even when change detection finds no relevant files. Defaults to false. | No |
debug | Accepted for compatibility but does not change runner log visibility. Use GitHub Actions step debug logging to display core.debug messages. | No |
The following API key parameters are supported:
| Parameter | Description |
|---|---|
openai-api-key | The API key for OpenAI. Used to authenticate requests to the OpenAI API. |
azure-api-key | The API key for Azure OpenAI. Used to authenticate requests to the Azure OpenAI API. |
anthropic-api-key | The API key for Anthropic. Used to authenticate requests to the Anthropic API. |
huggingface-api-key | The API key for Hugging Face. Used to authenticate requests to the Hugging Face API. |
aws-access-key-id | The AWS access key ID. Used to authenticate requests to AWS services. |
aws-secret-access-key | The AWS secret access key. Used to authenticate requests to AWS services. |
replicate-api-key | The API key for Replicate. Used to authenticate requests to the Replicate API. |
palm-api-key | The API key for Palm. Used to authenticate requests to the Palm API. |
vertex-api-key | The API key for Vertex. Used to authenticate requests to the Vertex AI API. |
cohere-api-key | The API key for Cohere. Used to authenticate requests to the Cohere API. |
mistral-api-key | The API key for Mistral. Used to authenticate requests to the Mistral API. |
groq-api-key | The API key for Groq. Used to authenticate requests to the Groq API. |
All workflow environment variables are passed through to promptfoo. You can set API keys at the job or workflow level instead of using action inputs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
steps:
- uses: promptfoo/promptfoo-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
Action inputs take precedence over their corresponding environment variables. See action.yml for the complete input metadata.
If your application uses .env files to store environment variables, you can load them before running promptfoo evaluations:
name: 'Prompt Evaluation'
on:
pull_request:
paths:
- 'prompts/**'
- 'promptfooconfig.yaml'
jobs:
evaluate:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
env-files: '.env,.env.test.local' # Load multiple .env files
This is particularly useful for Next.js applications or other frameworks that use .env files for configuration. The environment variables from these files will be available to promptfoo during evaluation.
providers: - file://providers/**/*.py # Watch all Python files recursively prompts: - file://prompts/system.txt
tests: - vars: context: file://data/context.json assert: - type: javascript value: file://validators/check.js ```
The action sets these Promptfoo cache variables. Existing values are respected. Promptfoo currently consumes the path and TTL settings; the size and file-count variables are exported for compatibility but are not enforced by the current Promptfoo CLI:
- name: Run evaluation with custom cache limits
uses: promptfoo/promptfoo-action@v1
env:
PROMPTFOO_CACHE_TTL: 86400
PROMPTFOO_CACHE_MAX_SIZE: 52428800
PROMPTFOO_CACHE_MAX_FILE_COUNT: 5000
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
You can also trigger evaluations manually using workflow_dispatch:
name: 'Prompt Evaluation - Manual'
on:
workflow_dispatch:
inputs:
files:
description: 'Changed files to consider (leave empty to auto-detect)'
required: false
type: string
base:
description: 'Base branch/commit to compare against'
required: false
default: 'HEAD~1'
type: string
jobs:
evaluate:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for comparisons
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
prompts: 'prompts/**'
When triggered manually:
- If files is provided, those paths are treated as the changed-file set. - Only changed files that also match prompts are passed through --prompts. - If base is provided, the action compares that ref with HEAD. - If neither input is provided, the action compares HEAD~1 with HEAD. - Results will be displayed in the workflow summary instead of a PR comment
Writing a step summary does not require actions: write.
You can also specify files and base directly as action inputs:
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
prompts: 'prompts/**'
workflow-files: |
prompts/prompt1.txt
prompts/prompt2.txt
workflow-base: 'main'
If caching isn't working as expected:
actions/cachePromptfoo Action是LLM工程领域的关键工具,将提示词测试集成到CI/CD流程,实现质量自动化。代码活跃、社区支持良好,是AI红队和提示优化的最佳实践。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,Promptfoo GitHub Action 在Agent工作流赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | promptfoo-action |
| 原始描述 | 开源Prompt模板:The GitHub Action for Promptfoo. Test your prompts, agents, and RAGs. AI Red te。⭐67 · TypeScript |
| Topics | 提示词测试GitHub ActionAI红队LLM工程自动化验证RAG测试 |
| GitHub | https://github.com/promptfoo/promptfoo-action |
| License | MIT |
| 语言 | TypeScript |
收录时间:2026-05-19 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端