Prompt Files
youBencha supports loading prompts from external files for better organization, reusability, and version control.
Why Use Prompt Files?
Section titled “Why Use Prompt Files?”| Benefit | Description |
|---|---|
| Organization | Keep complex prompts separate from configuration |
| Reusability | Share prompts across multiple suites |
| Version Control | Track prompt changes with meaningful diffs |
| Editor Support | Use markdown editors with syntax highlighting |
| Collaboration | Non-developers can edit prompts without touching YAML |
Using Prompt Files
Section titled “Using Prompt Files”Agent Prompts
Section titled “Agent Prompts”Load the agent’s task prompt from a file:
agent: type: copilot-cli config: prompt_file: ./prompts/add-auth.md# Add JWT Authentication
Implement JWT-based authentication for the API:
1. Add a login endpoint at POST /api/auth/login2. Generate JWT tokens with 24-hour expiration3. Add middleware to protect /api/users/* routes4. Handle token refresh at POST /api/auth/refresh
## Requirements
- Use the jsonwebtoken package- Store JWT secret in environment variable JWT_SECRET- Return appropriate HTTP status codes (401, 403)Evaluator Prompts
Section titled “Evaluator Prompts”Load custom instructions for the agentic-judge evaluator:
evaluators: - name: agentic-judge config: type: copilot-cli prompt_file: ./prompts/strict-eval.txt assertions: security: "Authentication is secure. Score 1 if yes, 0 if no."You are a senior security engineer reviewing code changes.Be strict about security best practices.Score 0 for any potential security vulnerabilities.File Formats
Section titled “File Formats”Prompt files can use any text format:
| Extension | Use Case | Syntax Support |
|---|---|---|
.md | Complex prompts with formatting | Markdown headers, lists, code blocks |
.txt | Simple prompts | Plain text |
.prompt | Custom convention | Plain text |
# Add JWT Authentication
Implement JWT-based authentication for the API.
## Requirements
1. Add a login endpoint at `POST /api/auth/login`2. Generate JWT tokens with 24-hour expiration3. Add middleware to protect `/api/users/*` routes
## Technical Details
- Use the `jsonwebtoken` package- Store JWT secret in `JWT_SECRET` environment variable- Return 401 for invalid tokens, 403 for insufficient permissions
## Expected Files
- `src/middleware/auth.ts`- `src/routes/auth.ts`- `src/types/auth.ts`You are a senior security engineer reviewing code changes.
Evaluation criteria:- Be strict about security best practices- Score 0 for any potential security vulnerabilities- Check for proper input validation- Verify secrets are not hardcodedPath Resolution
Section titled “Path Resolution”Paths are resolved relative to the suite configuration file:
project/├── suite.yaml├── prompts/│ ├── task.md│ └── eval.txt└── evaluators/ └── security.yamlagent: config: prompt_file: ./prompts/task.md # Relative to suite.yamlMutual Exclusivity
Section titled “Mutual Exclusivity”You cannot specify both prompt and prompt_file:
# ❌ Invalid - both specifiedagent: config: prompt: "Inline prompt" prompt_file: ./prompts/task.md
# ✅ Valid - only prompt_fileagent: config: prompt_file: ./prompts/task.mdBest Practices
Section titled “Best Practices”1. Use Descriptive Filenames
Section titled “1. Use Descriptive Filenames”prompts/├── add-jwt-auth.md├── refactor-database.md└── add-unit-tests.md2. Include Context in Prompts
Section titled “2. Include Context in Prompts”# Add Unit Tests
## ContextThis is a Node.js Express application using Jest for testing.
## TaskAdd unit tests for the UserService class.
## Requirements- Test all public methods- Mock database calls- Achieve 80% coverage3. Version Control Prompts
Section titled “3. Version Control Prompts”Track prompts in git alongside your configuration:
git add prompts/git commit -m "Add authentication evaluation prompts"4. Organize by Feature
Section titled “4. Organize by Feature”prompts/├── auth/│ ├── add-jwt.md│ └── add-oauth.md├── testing/│ ├── add-unit-tests.md│ └── add-e2e-tests.md└── refactoring/ └── improve-error-handling.mdValidation
Section titled “Validation”The yb validate command checks that prompt files exist:
yb validate -c suite.yaml -vOutput:
✅ Prompt file: ./prompts/task.md (exists)If a file is missing:
❌ Prompt file: ./prompts/missing.md (not found)Prompt Writing Tips
Section titled “Prompt Writing Tips”Be Specific
Section titled “Be Specific”Add tests to the project.Add unit tests for the UserService class:
1. Test `createUser()` with valid input2. Test `createUser()` with duplicate email (should throw)3. Test `getUserById()` with existing user4. Test `getUserById()` with non-existent user (should return null)
Use Jest and mock the database layer.Provide Context
Section titled “Provide Context”Include relevant background for the AI agent:
# Fix Authentication Bug
## Context
Users report being logged out randomly. Investigation shows:- JWT tokens expire correctly (24 hours)- Refresh tokens work when called- Issue occurs during active sessions
## Root Cause
The `auth.middleware.ts` doesn't handle clock skew between servers.
## Fix Required
Add a 5-minute grace period when validating token expiration.
## Files to Modify
- `src/middleware/auth.ts`- `src/utils/jwt.ts`Structure Complex Prompts
Section titled “Structure Complex Prompts”Use markdown structure for readability:
# Task: Implement Feature X
## Overview
Brief description of what needs to be done.
## Requirements
- [ ] Requirement 1- [ ] Requirement 2- [ ] Requirement 3
## Technical Constraints
- Must use existing patterns- Performance target: <100ms response time- Backward compatible with v1 API
## Success Criteria
The implementation is complete when:1. All tests pass2. Documentation is updated3. No new linting errors