Compile Packs
Compile YAML prompt configurations into production-ready pack files.
Transform your arena.yaml configuration or individual prompt files into optimized .pack.json files ready for use with the PromptKit SDK.
Prerequisites
Section titled “Prerequisites”- packc installed (installation guide)
- Prompt configuration files (arena.yaml or individual .yaml files)
- Basic understanding of pack structure
Method 1: Compile from arena.yaml (Recommended)
Section titled “Method 1: Compile from arena.yaml (Recommended)”This is the standard approach for production packs.
-
Prepare your arena.yaml
# config/arena.yamlprompts:- prompts/support.yaml- prompts/sales.yaml- prompts/marketing.yamltools_directory: ./tools -
Run the compile command
Terminal window packc compile \--config config/arena.yaml \--output packs/customer-service.pack.json \--id customer-service -
Verify the output
Terminal window ls -lh packs/customer-service.pack.jsonpackc inspect packs/customer-service.pack.json
Expected Output
Section titled “Expected Output”Loaded 3 prompt configs from memory repositoryCompiling 3 prompts into pack 'customer-service'...✓ Pack compiled successfully: packs/customer-service.pack.json Contains 3 prompts: [support, sales, marketing]Method 2: Compile Single Prompt
Section titled “Method 2: Compile Single Prompt”For individual prompt development or testing.
-
Create a prompt file
# prompts/support.yamlapiVersion: promptkit.altairalabs.ai/v1alpha1kind: PromptConfigspec:task_type: customer-supportname: Customer Support Agentsystem_prompt: |You are a helpful customer support agent.user_template: |Customer: -
Compile the prompt
Terminal window packc compile-prompt \--prompt prompts/support.yaml \--output packs/support.pack.json -
Verify compilation
Terminal window packc validate packs/support.pack.json
Common Compilation Patterns
Section titled “Common Compilation Patterns”Pattern 1: Environment-Specific Packs
Section titled “Pattern 1: Environment-Specific Packs”# Developmentpackc compile \ --config config/arena.dev.yaml \ --output packs/app-dev.pack.json \ --id app-dev
# Stagingpackc compile \ --config config/arena.staging.yaml \ --output packs/app-staging.pack.json \ --id app-staging
# Productionpackc compile \ --config config/arena.prod.yaml \ --output packs/app-prod.pack.json \ --id app-prodPattern 2: Versioned Packs
Section titled “Pattern 2: Versioned Packs”VERSION="1.2.0"
packc compile \ --config arena.yaml \ --output "packs/app-v${VERSION}.pack.json" \ --id app
# Also create latest symlinkln -sf "app-v${VERSION}.pack.json" packs/app-latest.pack.jsonPattern 3: Multi-Pack Build
Section titled “Pattern 3: Multi-Pack Build”#!/bin/bash# build-all-packs.sh
for config in config/*.yaml; do name=$(basename "$config" .yaml) echo "Building pack: $name"
packc compile \ --config "$config" \ --output "packs/${name}.pack.json" \ --id "$name"donePattern 4: Batch Compile with Validation
Section titled “Pattern 4: Batch Compile with Validation”#!/bin/bashset -e
echo "Compiling packs..."packc compile --config arena.yaml --output packs/app.pack.json --id app
echo "Validating pack..."packc validate packs/app.pack.json
echo "Inspecting pack..."packc inspect packs/app.pack.json
echo "✓ Build complete"Advanced Compilation
Section titled “Advanced Compilation”Organize Output by Environment
Section titled “Organize Output by Environment”mkdir -p packs/{dev,staging,prod}
# Compile to environment directoriespackc compile \ --config config/arena.prod.yaml \ --output packs/prod/app.pack.json \ --id appAdd Metadata to Build
Section titled “Add Metadata to Build”# Create build infocat > packs/build-info.txt <<EOFBuild: $(date -u +"%Y-%m-%d %H:%M:%S UTC")Compiler: $(packc version)Git Commit: $(git rev-parse --short HEAD)Branch: $(git branch --show-current)EOF
# Compile packpackc compile --config arena.yaml --output packs/app.pack.json --id appCompile with Pre/Post Scripts
Section titled “Compile with Pre/Post Scripts”#!/bin/bash# build-with-hooks.sh
# Pre-compilation checksecho "Running pre-compilation checks..."./scripts/validate-prompts.sh
# Compileecho "Compiling pack..."packc compile --config arena.yaml --output packs/app.pack.json --id app
# Post-compilation tasksecho "Running post-compilation tasks..."packc validate packs/app.pack.json./scripts/test-pack.sh packs/app.pack.jsonMakefile Integration
Section titled “Makefile Integration”.PHONY: compilecompile: @mkdir -p packs packc compile --config arena.yaml --output packs/app.pack.json --id app
.PHONY: compile-allcompile-all: @mkdir -p packs @for config in config/*.yaml; do \ name=$$(basename $$config .yaml); \ echo "Compiling $$name..."; \ packc compile --config $$config --output packs/$$name.pack.json --id $$name; \ done
.PHONY: compile-and-validatecompile-and-validate: compile packc validate packs/app.pack.json
.PHONY: cleanclean: rm -rf packs/*.pack.jsonUsage:
make compile # Compile main packmake compile-all # Compile all configsmake compile-and-validate # Compile and validatemake clean # Remove compiled packsVerification
Section titled “Verification”After compilation, verify your pack:
Check File Exists
Section titled “Check File Exists”test -f packs/app.pack.json && echo "✓ Pack file created"Check File Size
Section titled “Check File Size”# Pack should be < 1MB for most use casesls -lh packs/app.pack.jsonValidate Structure
Section titled “Validate Structure”packc validate packs/app.pack.jsonInspect Contents
Section titled “Inspect Contents”packc inspect packs/app.pack.jsonTest with SDK
Section titled “Test with SDK”pack, err := manager.LoadPack("./packs/app.pack.json")if err != nil { log.Fatal("Pack load failed:", err)}fmt.Println("✓ Pack loaded successfully")Troubleshooting
Section titled “Troubleshooting”arena.yaml not found
Section titled “arena.yaml not found”Problem:
Error loading arena config: open arena.yaml: no such file or directorySolution: Specify correct path:
packc compile --config ./config/arena.yaml --output packs/app.pack.json --id appMissing required fields
Section titled “Missing required fields”Problem:
Error: --output and --id are requiredSolution: Provide all required flags:
packc compile --config arena.yaml --output packs/app.pack.json --id my-appPrompt file not found
Section titled “Prompt file not found”Problem:
Error loading prompt: open prompts/support.yaml: no such file or directorySolution: Check paths in arena.yaml are relative to config file:
# arena.yaml should reference prompts correctlyprompts: - ../prompts/support.yaml # Adjust path as neededInvalid YAML syntax
Section titled “Invalid YAML syntax”Problem:
Error parsing prompt config: yaml: line 5: mapping values are not allowedSolution: Validate YAML syntax:
# Check YAML with yamllintyamllint prompts/support.yamlMedia file warnings
Section titled “Media file warnings”Problem:
⚠ Media validation warnings for customer-support: - Image file not found: images/logo.pngSolution: Ensure media files exist or update paths:
mkdir -p imagescp assets/logo.png images/Output directory missing
Section titled “Output directory missing”Problem:
Failed to write pack file: no such file or directorySolution: Create output directory:
mkdir -p packspackc compile --config arena.yaml --output packs/app.pack.json --id appBest Practices
Section titled “Best Practices”1. Always Validate After Compiling
Section titled “1. Always Validate After Compiling”packc compile --config arena.yaml --output packs/app.pack.json --id apppackc validate packs/app.pack.json2. Use Descriptive Pack IDs
Section titled “2. Use Descriptive Pack IDs”# Good--id customer-support-prod-v1
# Avoid--id pack13. Organize Packs by Purpose
Section titled “3. Organize Packs by Purpose”packs/├── dev/│ └── app.pack.json├── staging/│ └── app.pack.json└── prod/ └── app.pack.json4. Version Your Packs
Section titled “4. Version Your Packs”packc compile \ --config arena.yaml \ --output "packs/app-v1.2.0.pack.json" \ --id app-v1.2.05. Keep Packs Small
Section titled “5. Keep Packs Small”- Compile separate packs for different features
- Don’t bundle unrelated prompts together
- Consider pack size for deployment
Next Steps
Section titled “Next Steps”- Validate Packs - Ensure pack quality
- Organize Pack Files - Structure your packs
- CI/CD Integration - Automate builds