Reusable Workflow (.github/workflows/pr_agent.yml)
Relevant source files
The following files were used as context for generating this wiki page:
The reusable workflow provides a centralized automation suite for pull request management across all repositories owned by @JWEB0689. It integrates the PR-Agent tool to perform code reviews, generate descriptions, and provide autonomous code repairs through a dedicated autofix script.
This system allows individual repositories to inherit global configurations while maintaining the ability to override settings locally. It streamlines the development lifecycle by automating repetitive review tasks and attempting to resolve CI failures or review findings automatically.
Sources: README.md:3-12, scripts/autofix.py:4-10
Workflow Architecture and Integration
The workflow operates as a caller-callee structure where member repositories invoke the centralized definition. It manages the interaction between the GitHub Actions environment, the PR-Agent service, and the Gemini AI model for code analysis and repair.
The diagram above illustrates how the workflow handles incoming PR events and routes them to either standard PR-Agent tools or the autonomous repair logic.
Sources: README.md:14-25, scripts/autofix.py:12-25
Autonomous Repair Logic (scripts/autofix.py)
The autofix.py script serves as the primary engine for the workflow's "self-healing" capabilities. It operates in two distinct modes determined at runtime: review-fix and ci-fix.
Repair Modes
| Mode | Trigger Condition | Action |
|---|---|---|
| review-fix | PR-Agent review comments exist | Fetches findings, sends flagged code to Gemini, and applies suggested fixes. |
| ci-fix | No review findings; CI build fails | Runs local test runner, captures error logs, and asks Gemini to repair the root cause. |
Sources: scripts/autofix.py:12-18, scripts/autofix.py:277-302
Validation and Safety
The script enforces strict safety protocols before committing any AI-generated code. It detects the project's environment and identifies the appropriate test runner to verify changes.
- Detection: It checks for file markers like
Cargo.toml,package.json,pyproject.toml, orgo.mod. - Execution: If a test command exists (e.g.,
npm test,pytest,cargo check), the script runs it. - Rollback: If the verification fails, the script executes
git checkout -- .to revert changes and posts a failure comment on the PR. - Committing: Upon successful verification, it configures a
github-actions[bot]user and pushes the fix to theHEAD_REF.
Sources: scripts/autofix.py:64-88, scripts/autofix.py:214-245
Environment Configuration
The workflow requires several environment variables to interface with GitHub and Google's Generative AI services.
| Variable | Requirement | Description |
|---|---|---|
GEMINI_API_KEY | Required | Google AI Studio key for model access. |
GEMINI_MODEL | Optional | Defaults to gemini-3.8-flash. |
GH_TOKEN | Required | GitHub token for API interactions and Git operations. |
REPO | Contextual | The owner/repo string for the current execution. |
PR_NUMBER | Contextual | The active Pull Request identifier for commenting. |
Sources: scripts/autofix.py:20-29, scripts/autofix.py:126-135
Interactive Commands
Users can trigger specific workflow behaviors by commenting on a Pull Request. These commands are handled by the PR-Agent integration defined in the central configuration.
/review: Performs a full code review including security and test analysis./describe: Generates a changelog and PR description./improve: Provides commit-ready code suggestions./ask <question>: Queries the AI about specific parts of the diff.
Sources: README.md:20-25, scripts/autofix.py:146-155
This sequence shows the interaction between a developer's command and the subsequent autonomous repair process.
Sources: scripts/autofix.py:247-275, README.md:20-25
Summary
The Reusable Workflow in .github/workflows/pr_agent.yml acts as a centralized intelligence layer for the @JWEB0689 fleet. By combining PR-Agent's analytical capabilities with the autofix.py script's ability to diagnose and repair code via the Gemini model, the system automates both the identification of issues and their resolution. This ensures that PRs are not only reviewed but also actively repaired and verified against the repository's native test suite before human intervention.
Sources: README.md:5-12, scripts/autofix.py:5-25