This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a GitHub Action that evaluates LLM outputs using promptfoo. It runs before/after comparisons of prompt changes in pull requests and posts results as PR comments.
Note: This repository includes a copy of the promptfoo source code in the /promptfoo/ directory. This is used for analyzing and understanding promptfoo's capabilities during development but is not included in the distributed action.
npm run build- Compile TypeScript to JavaScriptnpm run build:watch- Watch mode for TypeScript compilationnpm run package- Bundle the action with @vercel/ncc for distributionnpm run all- Full build pipeline (build → lint → package → test)
npm run lint- Run Biome linternpm run format- Format code with Biomenpm run biome- Run both format and lint
npm test- Run all tests with coveragenpm test -- __tests__/main.test.ts- Run a specific test filenpm test -- --watch- Run tests in watch mode
- Parse inputs from action.yml (API keys, config paths, options)
- Load .env files if specified in inputs
- Validate the event is a pull request
- Use git to get changed files between base and head branches
- Filter for prompt/config files that changed
- Run promptfoo evaluation on changed files
- Post evaluation results as a PR comment
- src/main.ts: Entry point, orchestrates the entire workflow
- src/utils/git.ts: Git operations for detecting changed files
- src/utils/promptfoo.ts: Wrapper for promptfoo evaluation
- src/utils/github.ts: GitHub API interactions for PR comments
- src/utils/env.ts: Environment file loading
- All git refs must be validated before use in commands (see validateGitRef in git.ts)
- API keys are masked using core.setSecret() to prevent exposure in logs
- Path inputs should be validated to prevent directory traversal
- Strict mode is enabled - avoid
anytypes - Target ES6, output CommonJS modules
- Source in
/src/, compiled to/lib/
- Biome enforces: 2 spaces, single quotes, trailing commas
- Line width: 80 characters
- Prefer const and arrow functions
- No unused imports or variables
- Jest with TypeScript support
- Mock external dependencies (GitHub API, file system, git)
- Coverage reports generated in
/coverage/
- Make changes and test locally
- Run
npm run allto build, lint, and test - Commit both source and
/dist/folder - Tag release following semantic versioning
When merging branches (especially main into feature branches), follow these steps:
-
Checkout and update the target branch:
git checkout feature/branch-name git pull origin feature/branch-name
-
Merge main into your branch:
git merge main
-
Resolve conflicts:
- For
action.yml: Keep both sets of inputs, maintaining alphabetical order - For
src/main.ts: Include all feature additions (inputs, logic) - For
__tests__/main.test.ts: Merge test suites to include tests for all features - For
README.md: Include documentation for all features - For
dist/files: These will be regenerated, so either resolution is fine
- For
-
After resolving conflicts:
git add . git commit # This completes the merge
-
Rebuild dist files (CRITICAL for passing check-dist CI):
npm ci # Clean install to ensure consistency npm run build && npm run package git add dist/ git commit -m "fix: Rebuild dist files after merge"
-
Push changes:
git push origin feature/branch-name
- check-dist workflow failure: Always rebuild dist files after merging
- Test failures: Ensure all tests from both branches are included
- Formatting issues: Run
npm run formatbefore committing
- The action currently uses node16 runtime but needs updating to node20
- Bundle size in dist/ is ~1.5MB - consider optimization if it grows
- See TODO.md for planned improvements and known issues
- When modifying git operations, ensure proper ref validation to prevent command injection