-
Notifications
You must be signed in to change notification settings - Fork 31
07 PAG Guide
Varietyz edited this page Apr 2, 2026
·
1 revision
Condensed from the PAG practical guide.
See also: PAG Keywords · PAG Grammar (BNF) · Full Specification
---
name: document-name
version: 1.0.0
type: AGENT | WORKFLOW | POLICY | TEMPLATE | CHECKLIST | PROTOCOL | TASK
---
THIS {TYPE} {VERB} {description}
%% META %%:
intent: "What this achieves"
objective: "Measurable goal"
context: "Execution environment"
priority: high | medium | low
recursion_limit: 3
PHASE 1: Phase Name
@purpose: "What this phase achieves"
DECLARE variable: type
SET variable = value
VALIDATION GATE:
✅ Condition verified
IF FAIL: REPORT "BLOCKER: reason"
ALWAYS:
- invariant rule
NEVER:
- prohibition
VERB target PREPOSITION source [INTO destination]
| Pattern | Example |
|---|---|
| Read | READ "config.json" INTO config |
| Write | WRITE content TO "output.txt" |
| Edit | EDIT file old_string: "foo" new_string: "bar" |
| Search | GREP "pattern" IN "src/" INTO matches |
| Discover | GLOB "**/*.md" INTO files |
| Execute | BASH "npm test" WITH timeout: 60000 |
| Spawn agent | TASK "analyze" WITH subagent_type: "Explore" -> result |
DECLARE config: object
DECLARE items: array
DECLARE counter: number
DECLARE name: string
DECLARE valid: boolean
SET config.mode = "production"
SET counter = 0
DECLARE before SET. Variables have document-wide scope after declaration.
IF condition:
action
ELSE IF other_condition:
alternative
ELSE:
fallback
END IF
FOR EACH item IN collection:
PROCESS item
WHILE condition:
ITERATE
TRY:
risky_operation
CATCH error:
handle_error
MATCH value:
CASE pattern_a: action_a
CASE pattern_b: action_b
DEFAULT: fallback_action
Always FOR EACH, never FOR alone. Always colon after conditions.
ON ERROR file_modified:
TRY:
READ target_file INTO current
MERGE changes WITH current INTO updated
WRITE updated TO target_file
CATCH:
REPORT "Recovery failed"
Every phase ends with a gate. 3-5 specific, verifiable conditions.
VALIDATION GATE:
✅ config loaded and validated
✅ source_files.length > 0
✅ All records processed
ASSERT critical_condition
IF FAIL: REPORT "BLOCKER: reason"
Good: ✅ customer_data.email matches email_pattern
Bad: ✅ data looks valid
ALWAYS:
- READ before WRITE
- VALIDATE at phase boundaries
- REPORT state changes
NEVER:
- SKIP validation gates
- MODIFY source data directly
- PROCEED past BLOCKER without confirmation
WHEN processing_sensitive_data:
ALWAYS:
- ENCRYPT sensitive fields
NEVER:
- LOG plaintext credentials
STATE_MACHINE workflow:
STATE pending:
ENTRY: SEND notification TO reviewer
STATE approved:
ENTRY: EXECUTE finalize
TRANSITION FROM pending TO approved
ON approval
GUARD: all_checks_passed
DAG build_pipeline:
NODE setup:
READ package_manifest INTO pkg
NODE build DEPENDS_ON [setup]:
BASH build_command
NODE test AFTER build:
BASH test_command
PARALLEL_GROUP: lint, typecheck
PRIORITY_QUEUE tasks COMPARE_BY priority:
ENQUEUE critical_task TO tasks PRIORITY = 10
ENQUEUE normal_task TO tasks PRIORITY = 5
DEQUEUE FROM tasks TO next_task
- Each phase has a single objective
- Phase boundaries align with retry/recovery points
- Every phase ends with a validation gate
- Variables declared before use
- Data flow between phases is explicit
- No forward references to later phases
| Type | Verb | Purpose |
|---|---|---|
| AGENT | PERFORMS | AI agent behavior |
| WORKFLOW | EXECUTES | Multi-phase process |
| POLICY | ENFORCES | Constraint system |
| TEMPLATE | IMPLEMENTS | Reusable pattern |
| CHECKLIST | PROVIDES | Task tracking |
| PROTOCOL | DEFINES | Standard procedures |
| TASK | EXECUTES | Single objective |
Source: PAG Documentation · Repository
Disciplined AI Software Development © 2025 by Jay Baleine
Licensed under CC BY-SA 4.0 · banes-lab.com
Navigation
🏠 Home
Quick Reference
- 📖 Glossary
- 🔑 PAG Keywords
- 📜 PAG Grammar
- 🧩 PAG Guide
- 📐 MG Grammar
- 📋 Memory Schema
- 🏗️ Architectural Principles
- ✍️ Terminology Rules
- 🔄 Algorithm Classes
Getting Started
- 🏁 Reading Path
- ❓ FAQ
Links