Pattern Abstract Grammar

Pattern Abstract Grammar

Structured Instructions for AI Systems

Core Templates

Fundamental PAG document types for common use cases.

Workflowα

Multi-phase process orchestration with validation gates:

  • Phased Execution — structured progression through numbered phases
  • Validation Gates — checkpoint verification between phases
  • Error Recovery — file modification safety with backup/restore
  • Declarative Intent — meta block defines purpose and success criteria

Agentβ

AI agent behavior definition with phased execution:

  • Context Loading — reads guidelines and reference files on initialization
  • Variable Declaration — typed variables with explicit initialization
  • Behavioral Constraints — ALWAYS/NEVER rules enforce consistent patterns
  • Model Selection — frontmatter specifies execution model preference

Taskγ

Single-objective operations with minimal structure:

  • Minimal Structure — lightweight format for single-objective operations
  • Input/Output Focus — clear source and destination specification
  • Quick Execution — designed for atomic, focused operations

Protocolδ

Standard operating procedures and rule definitions:

  • Rule-Based Structure — WHEN/EXECUTE/VALIDATION GATE pattern for conditional logic
  • Standard Procedures — defines reusable behavioral contracts
  • Enforcement Directives — ALWAYS/NEVER rules for mandatory compliance

Orchestration Templates

Multi-agent and workflow coordination templates.

Multi-Agent Workflowε

Sequential agent orchestration with handoff signals:

  • Sequential Agent Chain — ordered execution through agent sequence array
  • Shared State Management — agents read/write to common artifact path
  • Entry/Exit Verification — bookend agents validate workflow boundaries
  • Handoff Signals — structured communication between agents

Handoff Signal Protocolζ

Structured agent-to-agent communication format:

  • Signal Structure — standardized fields for agent completion status
  • Context Transfer — key findings and critical files passed to next agent
  • Signal Types — ACTIVATE, PAUSE, ESCALATE, and COMPLETE actions

Workspace Protocolη

Shared document management across agent boundaries:

  • Single Source of Truth — enforced consistency across agent boundaries
  • Document Lifecycle — create, update, read rules with no deletion
  • Surgical Updates — targeted section replacement prevents data loss

Tracking Templates

Progress tracking and state persistence templates.

Checklistθ

Task tracking with progress indicators:

  • Progress Visualization — percentage bars track phase completion
  • Hierarchical Tasks — phases contain tasks with nested subtasks
  • Validation Gates — checkpoint verification before phase transitions

Workflow Stateι

Persistent state tracking for long-running workflows:

  • Session Persistence — state survives context boundaries
  • Agent Status Tracking — COMPLETE, IN_PROGRESS, PENDING states
  • Recovery Information — checkpoint and resume command for continuation

Validation Reportκ

Structured validation results and gate status:

  • Gate Status Tracking — PASSED/FAILED with condition details
  • Evidence Linking — file:line references for verification
  • Remediation Guidance — failure reasons with suggested fixes

Extensive Templates

Production-ready PAG templates demonstrating advanced multi-agent orchestration, plan verification, and agentic workflows.

Plan Verification Workflowλ

Multi-agent orchestration for forensic verification of implementation plans against codebase reality. Uses 6 sequential agents with unified brain protocol for shared state management.

  • Unified Brain Protocol — shared state management ensuring all agents work from the same truth
  • Entry/Exit Verification — bookend agents that validate workflow prerequisites and completion
  • Forensic Tracing — deep codebase analysis with execution path mapping
  • Divergence Classification — severity-based categorization of plan-vs-reality gaps
  • Failure Recovery — structured escalation with user decision points

Multi-Agent Orchestration Workflowμ

N-agent orchestration through sequential phases with VERIFY-VALIDATE-ACTION-VERIFY pattern. Supports dynamic phase scaling with prerequisite chaining.

  • VERIFY-VALIDATE-ACTION-VERIFY — bookend pattern ensuring entry and exit verification
  • Phase Chaining — prerequisite dependencies between sequential phases
  • Agent Type Registry — reusable agent definitions for consistent behavior
  • Dynamic Scaling — configurable agent count per phase with automatic index calculation
  • Structured Reporting — visual phase separators and status updates

Agentic Workflow Meta-Templateν

Generic meta-template for generating executable multi-agent orchestrated workflows. This template generates other workflow files with document pre-creation, iterative editing, and validation gates.

  • Meta-Template — generates other workflows rather than executing directly
  • DSL Compliance Phase — Phase 0 ensures generated content follows specification
  • Dynamic Agent Scaling — supports 1 to N agents with automatic configuration
  • Document Purpose Mapping — semantic naming tied to logical purpose
  • Coordination Algorithm — visual sequence diagram showing orchestration flow
  • Error Recovery Protocol — read-delete-write pattern for file modification errors

Agent Templates

Production-ready PAG templates for agent creation and auditing workflows. These templates implement checklist-driven processes with domain investigation and DSL compliance validation.

Agent Creator Templateξ

Generic template for creating new agents through systematic domain investigation and composition. Uses an 8-phase checklist-driven workflow with collision detection, pattern analysis, and compliance validation.

  • Investigate-Compose-Validate Loop — systematic domain analysis before generation
  • Collision Detection — checks for existing entities with user choice handling
  • Pattern Extraction — learns from compliant entities to determine structure
  • Algorithm Selection — scales complexity based on target domain size
  • Compliance Validation — scores generated output against DSL requirements

Agent Auditor Templateο

Generic template for auditing existing entities against DSL compliance and automatically fixing violations. Implements a detect-fix-write loop with 15 verification checks covering frontmatter, meta blocks, declarations, phases, and error handlers.

  • Detect-Fix-Write Loop — automatic remediation, not just analysis
  • 11 Verification Checks — frontmatter, meta blocks, declarations, phases, gates, verbs, error handlers
  • Violation Classification — categorized by check type with specific fix templates
  • Compliance Scoring — percentage-based pass/fail determination
  • Fix Templates — structured insertion patterns for each violation type