PAUL (Plan-Apply-Unify Loop)

repository·main·Indexed 22 days ago

https://github.com/christopherkahler/paul

A structured AI-assisted development framework for Claude Code designed to prevent context degradation. PAUL implements a three-stage cycle (PLAN, APPLY, UNIFY) using a system of slash commands (e.g., /paul:init, /paul:plan, /paul:apply, /paul:unify) and state management files in a .paul/ directory to ensure tasks are rigorously planned, executed via an Execute/Qualify loop, and reconciled.

Tokens
76.4K
Snippets
144
Records
257
Agent score
76%

What's inside paul-framework

  1. Overview of PAUL Extension Points

    main

    PAUL uses extension points to allow plugins to hook into specific stages of the project workflow. These extension points fire after core workflow steps are completed, ensuring that plugins do not interrupt the primary execution logic. Each extension point is tied to a specific workflow file and loop phase, providing a unique set of available context (files, logs, and state) for the plugin to consume.

    Extension Point Summary

    Workflow FileLoop PhaseFires AfterPrimary Use Case
    workflows/plan-phase.mdPLANPlan created, validated, coherence-checkedPre-execution analysis, plan metadata capture
    workflows/apply-phase.mdAPPLYAll tasks executed, verified, qualifiedPost-execution hooks, build artifact processing
    workflows/unify-phase.mdUNIFYReconciliation, SUMMARY, STATE update completeBuild log capture, content pipeline, metrics
    workflows/verify-work.mdVERIFYUAT checklist completed, verdict renderedQuality gate integrations, test result capture
    workflows/transition-phase.mdTRANSITIONPhase marked complete, git committed, state verifiedPhase-level reporting, milestone tracking
  2. Understand the PAUL Project Structure

    main

    PAUL manages project state through a specific directory structure within your project root. These files ensure context persists across sessions and decisions are logged.

    • .paul/PROJECT.md: Project context and requirements.
    • .paul/ROADMAP.md: Phase breakdown and milestones.
    • .paul/STATE.md: Current loop position (PLAN/APPLY/UNIFY), session state, and accumulated decisions.
    • .paul/paul.toml: Machine-readable manifest.
    • .paul/ledger.toml: Session history (cost/time attribution).
    • .paul/MILESTONES.md: Log of completed milestones.
    • .paul/phases/: Directory containing phase-specific PLAN.md and SUMMARY.md files.
  3. How the PAUL (Plan-Apply-Unify) Loop works

    main

    PAUL is a structured AI-assisted development framework that operates on a continuous cycle called 'The Loop'. Every unit of work must follow these three stages in order:

    1. PLAN: Define the work, including tasks, acceptance criteria, and boundaries.
    2. APPLY: Execute the tasks defined in the plan.
    3. UNIFY: Reconcile the actual results against the plan, document what was built, and close the loop.

    Crucial Rule: Never skip the UNIFY step. Every plan requires a summary to ensure the loop is properly closed and state is updated.

    ┌─────────────────────────────────────┐
    │  PLAN ──▶ APPLY ──▶ UNIFY          │
    │                                     │
    │  Define    Execute    Reconcile     │
    │  work      tasks      & close       │
    └─────────────────────────────────────┘
  4. Write substantive one-liners for phase outcomes

    main

    When documenting a phase in SUMMARY.md, the one-liner describing the outcome must be substantive. Avoid generic descriptions like "Phase complete" or "All tasks done". Instead, describe exactly what was shipped.

    Examples of Good One-liners:

    • "JWT auth with refresh rotation using jose library"
    • "Prisma schema with User, Session, Product models"
    • "Dashboard with real-time metrics via SSE"
  5. How to size work plans to maintain quality

    main

    To prevent quality degradation in Claude, work plans must be sized to complete within approximately 50% of the available context. When context usage exceeds 50%, the model enters "efficiency mode," leading to rushed or minimal output.

    Context Usage vs. Quality

    Context UsageQualityClaude's State
    0-30%PEAKThorough, comprehensive
    30-50%GOODConfident, solid work
    50-70%DEGRADINGEfficiency mode begins
    70%+POORRushed, minimal

    The Rule: Stop planning before quality degrades (at the 50% mark), not when you hit the hard context limit.

  6. Track specialized workflows with SPECIAL-FLOWS.md

    main
    For projects requiring specific skills or commands (e.g., /commit, /review-pr, or custom linter workflows), declare these requirements in a SPECIAL-FLOWS.md file. During the UNIFY phase, PAUL audits these requirements to ensure the specified skills/workflows were actually invoked, preventing manual steps from being skipped.
  7. Handle Authentication Gates

    main

    When an automation attempt (CLI/API) results in an authentication error, it should be treated as an Authentication Gate rather than a failure.

    The Pattern:

    1. Claude attempts automation.
    2. Claude receives an auth error.
    3. Claude creates a dynamic checkpoint.
    4. Human provides authentication/credentials.
    5. Claude retries and continues.

    Distinction:

    • Incorrect: A pre-planned checkpoint asking a human to "deploy" (this should be automated).
    • Correct: An auth gate where Claude says "I tried to deploy but need credentials."
  8. The PAUL Plan-Apply-Unify Loop

    main

    PAUL operates on a structured three-stage cycle designed to prevent 'context rot' and ensure AI-assisted development remains reliable. Every unit of work must follow this loop:

    1. PLAN: Define the work. This includes an Objective, Acceptance Criteria (using BDD format: Given [precondition] / When [action] / Then [outcome]), Tasks, and Boundaries (what NOT to change).
      • Quick-fix: 1 file, 1 change. Minimal ceremony.
      • Standard: 2-5 tasks. Includes boundaries and verification checklists.
      • Complex: 6+ tasks. Recommends splitting into smaller plans.
    2. APPLY: Execute the tasks. Each task undergoes an Execute/Qualify loop where it is verified against the spec and acceptance criteria before proceeding. Tasks use escalation statuses: DONE, DONE_WITH_CONCERNS, NEEDS_CONTEXT, or BLOCKED.
    3. UNIFY: Reconcile and close. This step is required. It compares the plan against what actually happened, records decisions, updates STATE.md, and generates a SUMMARY.md.
    ┌─────────────────────────────────────┐
    │  PLAN ──▶ APPLY ──▶ UNIFY          │
    │                                     │
    │  Define    Execute    Reconcile     │
    │  work      tasks      & close       │
    └─────────────────────────────────────┘
  9. Understand Checkpoint Types and Usage

    main

    Checkpoints are formal interaction points where human verification or decisions are required during plan execution. Plans execute autonomously except at these points. The core principle is that Claude must automate everything possible via CLI/API; checkpoints are reserved for verification and decisions, not manual work.

    There are three types of checkpoints:

    1. checkpoint:human-verify (90% of use cases): Used when Claude has completed automated work and needs a human to confirm it works correctly (e.g., visual UI checks, functional verification, accessibility testing).
    2. checkpoint:decision (9% of use cases): Used when a human must make a choice that affects the implementation direction (e.g., technology selection, architecture decisions, feature prioritization).
    3. checkpoint:human-action (1% of use cases): Used ONLY for actions that have no CLI/API and require human-only interaction (e.g., SMS 2FA, email verification links, manual OAuth approvals).
  10. How to handle urgent work with decimal phases

    main

    When urgent work must be performed between two planned integer phases, use Decimal Phases (e.g., 2.1, 2.2).

    Rules for Decimal Phases:

    • Naming: Use X.Y where X is the preceding integer phase and Y >= 1.
    • Tagging: Always mark the phase title with the [INSERTED] tag.
    • Documentation: You must include a Reason field explaining why this work was inserted.
    • Ordering: Decimal phases are designed to sort correctly in filesystems (e.g., 2 < 2.1 < 2.2 < 3).

    Validation Checklist:

    • Integer X must exist and be complete.
    • Integer X+1 must exist in the roadmap.
    • Decimal X.Y must not already exist.
    • Y must be greater than or equal to 1.
  11. Use different task types in PLAN.md

    main

    Tasks in a PLAN.md are categorized by their type attribute, which determines how the execution engine handles them:

    • auto: Used for tasks an AI can perform independently. These must include <name>, <files>, <action>, <verify>, and <done> tags.
    • checkpoint:decision: Used for implementation choices requiring human input. The engine pauses and presents defined <options> for the user to select.
    • checkpoint:human-verify: Used for visual or functional verification. The engine pauses and provides <how-to-verify> instructions, waiting for an "approved" signal.
    • checkpoint:human-action: Used for rare, unavoidable manual steps. The engine pauses and waits for user confirmation after the action is performed.
  12. Manage the RESEARCH.md status lifecycle

    main

    Research files follow a specific lifecycle to track the progression from raw subagent output to actionable project data. You should manually update the Status field in the RESEARCH.md file as the information moves through these stages:

    1. Draft: The initial state when a subagent has just completed the research.
    2. Reviewed: The state after the main session has vetted and confirmed the findings.
    3. Integrated: The final state once the findings have been incorporated into project plans or actual code.