Enterprise Tutorial: Building Layered AI Infrastructure¶
This tutorial starts after your first successful local compile. You will build a layered configuration system for a software team: an organization base, a team layer that inherits it, and a project that inherits both.
Learning Objectives¶
By the end of this tutorial, you'll have:
- Organization Registry: A shared "base" configuration (
@acme/org). - Team Inheritance: A team layer that extends the base (
@acme/frontend). - Project Implementation: A specific project that inherits from both.
- Native compilation: Output for GitHub Copilot, Claude, and Cursor.
Prerequisites¶
- Node.js 20+
- PromptScript CLI installed (
npm install -g @promptscript/cli) - A project that completed Getting Started
- A successful
prs validate --strictandprs compile
Step 1: Create Organization Base¶
Start by creating a base configuration that applies to your entire organization.
Create registry/@acme/org.prs:
@meta {
id: "@acme/org"
syntax: "1.5.0"
org: "ACME Corporation"
}
@identity {
"""
You are an AI assistant working at ACME Corporation.
Follow company coding standards and best practices.
"""
}
@standards {
code: {
principles: [
"Follow clean code principles",
"Document all public APIs",
"Write tests for all code"
]
}
security: [
"Validate all user input",
"Never hardcode secrets"
]
}
@restrictions {
- "Never expose API keys or secrets in code"
- "Never commit sensitive data to version control"
- "Always validate user input"
}
@shortcuts {
"/security": "Review code for security vulnerabilities"
"/docs": "Generate documentation for this code"
}
Step 2: Create Team Configuration¶
Create a team-specific configuration that inherits from the org base.
Create registry/@acme/frontend-team.prs:
@meta {
id: "@acme/frontend-team"
syntax: "1.5.0"
team: "Frontend"
}
# In a multi-file setup, you would inherit from organization:
@inherit @acme/org
@identity {
"""
You are a frontend development expert.
Specialize in React, TypeScript, and modern web technologies.
"""
}
@context {
"""
The frontend team uses:
- React 18 with TypeScript
- Vite for bundling
- TailwindCSS for styling
- Vitest + Testing Library for tests
- React Query for server state
"""
}
# Extend org standards with frontend-specific rules
@extend standards.code {
frameworks: [react]
patterns: [hooks, composition, "render props"]
stateManagement: "React Query + Context"
}
@shortcuts {
"/component": "Create a new React component"
"/hook": "Create a custom React hook"
"/test": "Write tests using Vitest and Testing Library"
}
Step 3: Create Project Configuration¶
Now create a project-specific configuration.
Create .promptscript/project.prs in your project:
@meta {
id: "checkout-app"
syntax: "1.5.0"
}
# In a multi-file setup, you would inherit from frontend team:
@inherit @acme/frontend-team
@context {
project: "Checkout Application"
description: "E-commerce checkout flow"
"""
This is the checkout application for ACME's e-commerce platform.
Key features:
- Multi-step checkout wizard
- Payment processing with Stripe
- Address validation
- Order summary and confirmation
"""
}
# Project-specific standards
@extend standards {
code: {
testing: {
coverage: 85
e2e: required
}
}
accessibility: {
wcag: "2.1 AA"
required: true
}
}
@shortcuts {
"/checkout": "Help with checkout flow logic"
"/payment": "Help with Stripe payment integration"
"/a11y": "Review code for accessibility issues"
}
@knowledge {
"""
## API Endpoints
- POST /api/checkout/create - Create checkout session
- PUT /api/checkout/:id - Update checkout
- POST /api/checkout/:id/complete - Complete purchase
## Key Components
- CheckoutWizard - Main wizard container
- AddressForm - Shipping/billing address
- PaymentForm - Stripe Elements integration
- OrderSummary - Cart summary display
"""
}
Step 4: Configure the Project¶
Create promptscript.yaml:
id: checkout-app
syntax: '1.5.0'
input:
entry: .promptscript/project.prs
registry:
path: ./registry
targets:
- github:
version: full
output: .github/copilot-instructions.md
- claude:
version: full
output: CLAUDE.md
- cursor:
version: full
output: .cursor/rules/project.mdc
Step 5: Add Agent Platform Capabilities¶
Add reusable capabilities to .promptscript/project.prs:
@skills {
checkout-review: {
description: "Review checkout changes"
content: "Review payment safety, validation, tests, and user impact."
}
}
@agents {
checkout-reviewer: {
description: "Review checkout pull requests"
skills: ["checkout-review"]
content: "Review changed checkout code against project standards."
}
}
@hooks {
validate-checkout: {
event: "post-tool-use"
matcher: "Edit|Write"
command: ["pnpm", "test"]
targets: {
github: { enabled: false }
cursor: { enabled: false }
}
}
}
@workflows {
release: {
description: "Prepare checkout release"
content: "Run validation, summarize risk, and prepare release metadata."
}
}
See Agent Platform for MCP servers, plugins, and target-specific capabilities.
Step 6: Validate and Compile¶
Validate your configuration first, so broken references and policy violations surface before anything is written:
Then compile all targets:
Preview what would change without writing files:
Inspect the generated diff before you commit:
Understanding Inheritance¶
The inheritance chain creates a layered configuration:
flowchart TD
A["@acme/org<br/>Organization base"] --> B["@acme/frontend-team<br/>Team specifics"]
B --> C["checkout-app<br/>Project specifics"]
subgraph "Final Output"
D["Merged Configuration"]
end
C --> D How merging works:
| Block Type | Merge Behavior |
|---|---|
@identity | Concatenates text |
@context | Concatenates text, merges properties |
@standards | Deep merges objects |
@restrictions | Concatenates arrays |
@shortcuts | Merges, child overrides parent |
@knowledge | Concatenates text |
Step 7: Add to CI/CD¶
Add validation to your CI pipeline:
# .github/workflows/promptscript.yml
name: Validate PromptScript
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install PromptScript
run: npm install -g @promptscript/cli
- name: Validate
run: prs validate --strict
- name: Check compiled files are up to date
run: |
prs compile
git diff --exit-code
Your Daily Workflow¶
After the initial setup, everyday use is a short loop:
# 1. Edit the source
$EDITOR .promptscript/project.prs
# 2. Validate
prs validate --strict
# 3. Compile
prs compile
# 4. Review the generated diff, then commit
git status
git diff
git add .promptscript/project.prs CLAUDE.md .github .cursor
git commit -m "update agent instructions"
The generated files are committed next to the source, so reviewers see both in the pull request. CI runs the same validation and fails when committed output no longer matches the source.
Next Steps¶
You now have a complete PromptScript setup! Here's what to explore next:
- Language Reference - Full syntax documentation
- Agent Platform - Agents, skills, integrations, and automation
- Inheritance Guide - Advanced inheritance patterns
- Enterprise Setup - Organization-wide deployment
- CLI Reference - All available commands