@startuml commit-workflow !theme plain title Git Commit Workflow with Automation actor Developer participant "git commit" as git participant "pre-commit hook" as hook participant "runner.py" as runner participant "config.py" as config participant "patcher.py" as patcher participant "Claude API" as claude participant "workflow.py" as workflow database ".git index" as index Developer -> git: commit staged files activate git git -> hook: trigger pre-commit activate hook hook -> runner: python3 -m automation.runner activate runner runner -> config: Load .ai-rules.yml activate config config -> config: Find cascading rules config -> runner: Return merged config deactivate config loop For each staged file runner -> config: Get rule for file config -> runner: Return rule & outputs runner -> patcher: generate_output(source, target, instruction) activate patcher patcher -> patcher: Build prompt with\nsource diff + context patcher -> claude: Send prompt activate claude alt API Success claude -> patcher: Return unified diff\n(wrapped in markers) patcher -> patcher: Extract & sanitize patch patcher -> patcher: git apply --3way patcher -> index: Stage generated file patcher -> runner: Success else API Overload/Error claude -> patcher: Error response patcher -> patcher: Log error to stderr patcher -> runner: Skip this file end deactivate claude deactivate patcher end runner -> hook: Exit 0 deactivate runner hook -> workflow: python3 -m automation.workflow --status activate workflow workflow -> workflow: Parse VOTE: lines\nfrom discussions workflow -> workflow: Update .sum.md files workflow -> index: Stage updated summaries workflow -> hook: Exit 0 deactivate workflow hook -> git: Exit 0 (continue commit) deactivate hook git -> index: Create commit git -> Developer: Commit successful deactivate git note right of patcher Saves debug artifacts to .git/ai-rules-debug/ for troubleshooting end note note right of workflow Always exits 0 (non-blocking) end note @enduml