Organize Pack Files
Structure and manage your pack files for maintainability and scalability.
Create a clear, maintainable organization system for your pack files that scales with your project.
Prerequisites
Section titled “Prerequisites”- packc installed
- Understanding of your project structure
- Multiple pack files or environments
Organization Strategies
Section titled “Organization Strategies”Strategy 1: By Environment
Section titled “Strategy 1: By Environment”Separate packs by deployment environment:
packs/├── dev/│ ├── app.pack.json│ └── admin.pack.json├── staging/│ ├── app.pack.json│ └── admin.pack.json└── prod/ ├── app.pack.json └── admin.pack.jsonSetup:
# Create structuremkdir -p packs/{dev,staging,prod}
# Compile for each environmentpackc compile --config config/arena.dev.yaml \ --output packs/dev/app.pack.json --id app-dev
packc compile --config config/arena.staging.yaml \ --output packs/staging/app.pack.json --id app-staging
packc compile --config config/arena.prod.yaml \ --output packs/prod/app.pack.json --id app-prodStrategy 2: By Feature
Section titled “Strategy 2: By Feature”Organize by application feature or module:
packs/├── customer-support/│ ├── chat.pack.json│ └── email.pack.json├── sales/│ ├── leads.pack.json│ └── opportunities.pack.json└── marketing/ ├── campaigns.pack.json └── analytics.pack.jsonSetup:
# Create feature directoriesmkdir -p packs/{customer-support,sales,marketing}
# Compile feature packspackc compile --config config/customer-support/arena.yaml \ --output packs/customer-support/chat.pack.json --id cs-chat
packc compile --config config/sales/arena.yaml \ --output packs/sales/leads.pack.json --id sales-leadsStrategy 3: By Version
Section titled “Strategy 3: By Version”Version control your packs:
packs/├── v1.0.0/│ └── app.pack.json├── v1.1.0/│ └── app.pack.json├── v1.2.0/│ └── app.pack.json└── latest -> v1.2.0/Setup:
VERSION="1.2.0"
# Create version directorymkdir -p "packs/v${VERSION}"
# Compile to versioned locationpackc compile --config arena.yaml \ --output "packs/v${VERSION}/app.pack.json" --id "app-v${VERSION}"
# Update latest symlinkln -sf "v${VERSION}" packs/latestStrategy 4: Hybrid Organization
Section titled “Strategy 4: Hybrid Organization”Combine strategies for complex projects:
packs/├── dev/│ ├── customer-support/│ │ └── v1.0.0/│ │ └── app.pack.json│ └── sales/│ └── v1.0.0/│ └── app.pack.json├── staging/│ ├── customer-support/│ │ └── v1.0.0/│ │ └── app.pack.json│ └── sales/│ └── v1.0.0/│ └── app.pack.json└── prod/ ├── customer-support/ │ └── v1.0.0/ │ └── app.pack.json └── sales/ └── v1.0.0/ └── app.pack.jsonNaming Conventions
Section titled “Naming Conventions”Pack File Names
Section titled “Pack File Names”Use descriptive, consistent names:
# Good namingcustomer-support.pack.jsonsales-leads-v1.pack.jsonmarketing-campaigns-prod.pack.json
# Avoidpack1.jsontemp.pack.jsontest.jsonPack IDs
Section titled “Pack IDs”Match IDs to purpose and environment:
# Development--id customer-support-dev
# Staging--id customer-support-staging
# Production--id customer-support-prod
# Versioned--id customer-support-v1.2.0Build Scripts
Section titled “Build Scripts”Environment-Based Build
Section titled “Environment-Based Build”#!/bin/bash# scripts/build-packs.sh
set -e
ENVIRONMENTS=("dev" "staging" "prod")
for env in "${ENVIRONMENTS[@]}"; do echo "Building packs for $env..."
mkdir -p "packs/$env"
packc compile \ --config "config/arena.$env.yaml" \ --output "packs/$env/app.pack.json" \ --id "app-$env"
packc validate "packs/$env/app.pack.json"done
echo "✓ All packs built successfully"Feature-Based Build
Section titled “Feature-Based Build”#!/bin/bash# scripts/build-features.sh
set -e
FEATURES=("customer-support" "sales" "marketing")
for feature in "${FEATURES[@]}"; do echo "Building $feature packs..."
mkdir -p "packs/$feature"
for config in "config/$feature"/*.yaml; do name=$(basename "$config" .yaml)
packc compile \ --config "$config" \ --output "packs/$feature/$name.pack.json" \ --id "$feature-$name" donedone
echo "✓ All feature packs built"Versioned Build
Section titled “Versioned Build”#!/bin/bash# scripts/build-versioned.sh
set -e
VERSION="${1:-$(date +%Y%m%d)}"
echo "Building version: $VERSION"
mkdir -p "packs/v$VERSION"
packc compile \ --config arena.yaml \ --output "packs/v$VERSION/app.pack.json" \ --id "app-v$VERSION"
# Update latestln -sf "v$VERSION" packs/latest
echo "✓ Version $VERSION built"echo "Latest points to: $(readlink packs/latest)"Makefile Organization
Section titled “Makefile Organization”# VariablesVERSION ?= $(shell date +%Y%m%d)ENVIRONMENTS := dev staging prodFEATURES := customer-support sales marketing
.PHONY: build-allbuild-all: build-by-env build-by-feature build-versioned
# Build by environment.PHONY: build-by-envbuild-by-env: @for env in $(ENVIRONMENTS); do \ mkdir -p packs/$$env; \ packc compile --config config/arena.$$env.yaml \ --output packs/$$env/app.pack.json --id app-$$env; \ done
# Build by feature.PHONY: build-by-featurebuild-by-feature: @for feature in $(FEATURES); do \ mkdir -p packs/$$feature; \ packc compile --config config/$$feature/arena.yaml \ --output packs/$$feature/app.pack.json --id $$feature-app; \ done
# Build versioned.PHONY: build-versionedbuild-versioned: @mkdir -p packs/v$(VERSION) @packc compile --config arena.yaml \ --output packs/v$(VERSION)/app.pack.json --id app-v$(VERSION) @ln -sf v$(VERSION) packs/latest
# Clean.PHONY: cleanclean: rm -rf packs/
.PHONY: clean-envclean-env: rm -rf packs/$(ENV)/
# Validate.PHONY: validate-allvalidate-all: @find packs -name '*.pack.json' -exec packc validate {} \;Configuration Organization
Section titled “Configuration Organization”Mirror your pack organization in configs:
config/├── dev/│ └── arena.yaml├── staging/│ └── arena.yaml├── prod/│ └── arena.yaml└── features/ ├── customer-support/ │ └── arena.yaml ├── sales/ │ └── arena.yaml └── marketing/ └── arena.yamlMetadata Files
Section titled “Metadata Files”Track pack information:
# Create pack inventorycat > packs/inventory.json <<EOF{ "environments": { "dev": { "packs": ["app.pack.json"], "last_build": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" }, "prod": { "packs": ["app.pack.json"], "last_build": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" } }}EOFGit Configuration
Section titled “Git Configuration”.gitignore
Section titled “.gitignore”# Ignore compiled packs in developmentpacks/dev/*.pack.jsonpacks/staging/*.pack.json
# Keep production packs in version control# (Comment out the line below to track prod packs)packs/prod/*.pack.json
# Ignore temporary buildspacks/tmp/packs/*.tmp.json
# Keep directory structure!packs/dev/.gitkeep!packs/staging/.gitkeep!packs/prod/.gitkeepTrack Pack Metadata
Section titled “Track Pack Metadata”# Create .gitkeep filestouch packs/{dev,staging,prod}/.gitkeep
# Create READMEcat > packs/README.md <<EOF# Prompt Packs
This directory contains compiled prompt packs organized by environment.
## Structure
- \`dev/\` - Development packs- \`staging/\` - Staging packs- \`prod/\` - Production packs
## Building
Run \`make build-all\` to compile all packs.
See [build instructions](../docs/packc/how-to/compile-packs) for details.EOF
git add packs/.gitkeep packs/README.mdBest Practices
Section titled “Best Practices”1. Consistent Directory Structure
Section titled “1. Consistent Directory Structure”project/├── config/ # Source configurations│ ├── dev/│ ├── staging/│ └── prod/├── packs/ # Compiled packs│ ├── dev/│ ├── staging/│ └── prod/└── prompts/ # Source prompts ├── customer-support/ ├── sales/ └── marketing/2. Document Organization
Section titled “2. Document Organization”Create a pack organization guide:
# Pack Organization Guide
## Directory Structure
- `packs/dev/` - Development builds- `packs/staging/` - QA/testing builds- `packs/prod/` - Production releases
## Naming Conventions
- Use kebab-case: `customer-support.pack.json`- Include version: `app-v1.2.0.pack.json`- Add environment suffix: `app-prod.pack.json`
## Build Process
1. Update prompt configurations2. Run `make build-by-env`3. Validate with `make validate-all`4. Commit to version control3. Automate Organization
Section titled “3. Automate Organization”#!/bin/bash# scripts/organize-packs.sh
# Create structuremkdir -p packs/{dev,staging,prod}/{customer-support,sales,marketing}
# Build into organized structurefor env in dev staging prod; do for feature in customer-support sales marketing; do packc compile \ --config "config/$env/$feature/arena.yaml" \ --output "packs/$env/$feature/app.pack.json" \ --id "$feature-$env" donedone4. Version Control Strategy
Section titled “4. Version Control Strategy”Choose what to track:
Option A: Track all packs
# Track everything!packs/**/*.pack.jsonOption B: Track only production
# Ignore dev/stagingpacks/dev/packs/staging/
# Keep production!packs/prod/**/*.pack.jsonOption C: Track none (build in CI)
# Ignore all packspacks/**/*.pack.json
# Keep structure!packs/**/.gitkeep5. Cleanup Old Versions
Section titled “5. Cleanup Old Versions”#!/bin/bash# scripts/cleanup-old-packs.sh
KEEP_VERSIONS=3
cd packs
# Remove old versioned packs, keep latest Nls -dt v* | tail -n +$((KEEP_VERSIONS + 1)) | xargs rm -rf
echo "Kept latest $KEEP_VERSIONS versions"Next Steps
Section titled “Next Steps”- CI/CD Integration - Automate pack builds
- Validate Packs - Quality assurance
- Pack Management Tutorial