validate
Validate a compiled pack file for errors and warnings.
Synopsis
Section titled “Synopsis”packc validate <pack-file>Description
Section titled “Description”The validate command checks a compiled .pack.json file for:
- Schema compliance
- Required fields
- Valid data types
- Tool references
- Template syntax
- Parameter values
Use this command to ensure packs are correctly formatted before deployment.
Arguments
Section titled “Arguments”<pack-file> (required)
- Path to the pack file to validate
- Must be a
.pack.jsonfile
Examples
Section titled “Examples”Basic Validation
Section titled “Basic Validation”packc validate packs/app.pack.jsonOutput (success):
Validating pack: packs/app.pack.json✓ Pack is validOutput (with warnings):
Validating pack: packs/app.pack.json⚠ Pack has 2 warnings: - Template variable 'user_name' not defined in prompt 'support' - Tool 'search_api' referenced but not definedValidate in CI/CD
Section titled “Validate in CI/CD”# Validate and fail on warningspackc validate packs/app.pack.json || exit 1Validate Multiple Packs
Section titled “Validate Multiple Packs”for pack in packs/*.pack.json; do echo "Validating $pack" packc validate "$pack"doneValidation Checks
Section titled “Validation Checks”Schema Validation
Section titled “Schema Validation”Checks pack structure:
- Pack ID present
- Version format valid
- Prompts section exists
- Required prompt fields present
Prompt Validation
Section titled “Prompt Validation”For each prompt:
- System prompt not empty
- Parameters within valid ranges
- Template syntax correct
- Variables defined
Tool Validation
Section titled “Tool Validation”- Referenced tools exist
- Tool parameters valid
- Tool names unique
Parameter Validation
Section titled “Parameter Validation”- temperature: 0.0-2.0
- max_tokens: positive integer
- top_p: 0.0-1.0
- top_k: positive integer
Exit Codes
Section titled “Exit Codes”0- Pack is valid (no warnings)1- Pack has warnings or errors
Common Warnings
Section titled “Common Warnings”Missing Template Variables
Section titled “Missing Template Variables”⚠ Template variable 'customer_name' not definedCause: Template uses “ but variable not in pack
Solution: Add variable to pack or remove from template
Tool Not Defined
Section titled “Tool Not Defined”⚠ Tool 'search_api' referenced but not definedCause: Prompt lists tool that doesn’t exist in pack
Solution: Add tool to pack or remove from prompt’s available_tools
Parameter Out of Range
Section titled “Parameter Out of Range”⚠ Temperature 2.5 exceeds maximum 2.0Cause: Invalid model parameter value
Solution: Correct parameter in source YAML
Empty System Prompt
Section titled “Empty System Prompt”⚠ System prompt is empty for prompt 'assistant'Cause: Prompt has no system instructions
Solution: Add system prompt to YAML
Integration with Build Process
Section titled “Integration with Build Process”Pre-commit Hook
Section titled “Pre-commit Hook”#!/bin/bash# .git/hooks/pre-commit
echo "Validating packs..."for pack in packs/*.pack.json; do if ! packc validate "$pack"; then echo "❌ Pack validation failed" exit 1 fidone
echo "✓ All packs valid"CI Pipeline
Section titled “CI Pipeline”# .github/workflows/validate-packs.ymlname: Validate Packs
on: [push, pull_request]
jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Install packc run: go install github.com/AltairaLabs/PromptKit/tools/packc@latest
- name: Validate all packs run: | EXIT_CODE=0 for pack in packs/*.pack.json; do if ! packc validate "$pack"; then EXIT_CODE=1 fi done exit $EXIT_CODEBest Practices
Section titled “Best Practices”1. Validate After Every Compilation
Section titled “1. Validate After Every Compilation”packc compile --config arena.yaml --output app.pack.json --id my-apppackc validate app.pack.json2. Fail CI on Warnings
Section titled “2. Fail CI on Warnings”Treat warnings as errors in production:
if ! packc validate packs/prod.pack.json; then echo "Production pack validation failed" exit 1fi3. Validate Before Deployment
Section titled “3. Validate Before Deployment”# In deployment scriptecho "Validating packs before deployment..."for pack in packs/*.pack.json; do packc validate "$pack" || { echo "Deployment aborted: invalid pack" exit 1 }done4. Keep Validation Logs
Section titled “4. Keep Validation Logs”packc validate packs/app.pack.json > validation-report.txt 2>&1See Also
Section titled “See Also”- compile - Compile packs
- inspect - Inspect pack contents
- How to Validate Packs