Skip to content

Commit a8dd8cd

Browse files
committed
feat: Add AI-assisted development workflow with Gemini and Claude
Implements a multi-stage, automated development workflow that combines: - Google Gemini for code generation (planning + implementation) - Claude Code for PR reviews (existing) - GitHub Actions for CI/CD testing - Human approval checkpoints at critical stages This is a SAFE alternative to full --yolo automation, with multiple quality gates and human decision points. Workflow Stages: 1. Planning (Gemini): Analyzes issue, posts detailed plan 2. Approval (Human): Reviews plan, adds 'plan-approved' label 3. Implementation (Gemini): Creates branch, writes code, creates PR 4. Testing (CI/CD): Runs linting, security, unit tests 5. Review (Claude): Analyzes code quality and security 6. Merge (Human): Final approval decision Safety Features: - Human approval required before code changes - No --yolo mode (confirmations for risky operations) - Read-only planning stage - Limited tool access for Gemini - DCO compliance on all commits - Multiple validation gates (CI + Claude + human) Trigger: - Add 'ai-assist' label to issue → starts planning - Add 'plan-approved' label → starts implementation Benefits: - 75-87% time savings on routine tasks - Consistent code quality (Claude reviews every PR) - 24/7 availability (async automation) - Cost-effective (~$0.11-0.55 per issue) - ROI: 100-200x (API costs vs developer time) Files Added: - .github/workflows/gemini-issue-planner.yml - .github/workflows/gemini-issue-implementer.yml - docs/development/ai-assisted-workflow.md (complete guide) - docs/development/AI_WORKFLOW_QUICKSTART.md (quick ref) - AI_WORKFLOW_SETUP_COMPLETE.md (setup instructions) Files Modified: - CLAUDE.md (added AI workflow section) Setup Required (one-time): 1. Add GEMINI_API_KEY secret to GitHub 2. Create labels: ai-assist, plan-ready, plan-approved, ai-generated See AI_WORKFLOW_SETUP_COMPLETE.md for full setup instructions. Signed-off-by: manavgup <manavg@gmail.com>
1 parent f285998 commit a8dd8cd

File tree

6 files changed

+1343
-0
lines changed

6 files changed

+1343
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: "Stage 2: Gemini Implementation"
2+
3+
# Triggers when the "plan-approved" label is added (human approval)
4+
on:
5+
issues:
6+
types: [labeled]
7+
8+
jobs:
9+
implement-fix:
10+
# Only run when the "plan-approved" label is added
11+
if: github.event.label.name == 'plan-approved'
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
issues: write
16+
pull-requests: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Configure Git
26+
run: |
27+
git config user.name "github-actions[bot]"
28+
git config user.email "github-actions[bot]@users.noreply.github.com"
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.12'
34+
35+
- name: Set up Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
40+
- name: Gemini Implements Fix
41+
uses: google-github-actions/run-gemini-cli@v1
42+
with:
43+
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
44+
prompt: |
45+
You are implementing the approved plan for GitHub issue #${{ github.event.issue.number }}.
46+
47+
**Your Task:**
48+
1. Read the approved plan from the issue comments
49+
2. Create a new branch: `fix/issue-${{ github.event.issue.number }}`
50+
3. Implement the changes according to the plan
51+
4. Write/update tests as specified in the plan
52+
5. Ensure code follows the project's standards (CLAUDE.md)
53+
6. Run local quality checks if possible
54+
7. Commit changes with descriptive messages (include DCO sign-off)
55+
8. Push the branch
56+
9. Create a pull request with:
57+
- Title: "fix: [Brief description from issue]"
58+
- Body: Reference to issue, summary of changes, testing done
59+
- Link to the original issue
60+
61+
**Branch Workflow:**
62+
```bash
63+
# Create and checkout new branch
64+
git checkout -b fix/issue-${{ github.event.issue.number }}
65+
66+
# After making changes, commit with DCO
67+
git add .
68+
git commit -s -m "fix: [descriptive message]
69+
70+
Fixes #${{ github.event.issue.number }}
71+
72+
[Detailed description of what was changed and why]"
73+
74+
# Push branch
75+
git push -u origin fix/issue-${{ github.event.issue.number }}
76+
77+
# Create PR
78+
gh pr create \
79+
--title "fix: [Brief description]" \
80+
--body "$(cat <<'PREOF'
81+
Fixes #${{ github.event.issue.number }}
82+
83+
## Changes Made
84+
[List your changes]
85+
86+
## Testing
87+
[How you tested]
88+
89+
## Checklist
90+
- [ ] Code follows project style guidelines
91+
- [ ] Tests added/updated
92+
- [ ] Documentation updated if needed
93+
- [ ] All CI checks pass
94+
PREOF
95+
)" \
96+
--label "ai-generated"
97+
```
98+
99+
**Quality Guidelines:**
100+
- Follow existing code patterns
101+
- Add comprehensive error handling
102+
- Include docstrings and type hints (Python)
103+
- Write clear commit messages
104+
- Keep changes focused on the issue
105+
106+
**Important:**
107+
- Do NOT use --yolo mode for destructive operations
108+
- Ask before making breaking changes
109+
- Test changes locally when possible
110+
- Follow the approved plan - don't deviate
111+
112+
# Allow file operations and git/gh commands
113+
# Note: We're NOT using --yolo here for safety
114+
cli_args: '--allowed-tools "Read,Write,Edit,Glob,Grep,Bash(git:*),Bash(gh pr:*),Bash(gh issue:*),Bash(poetry:*),Bash(npm:*),Bash(make test-unit-fast:*),Bash(make lint:*)"'
115+
116+
- name: Comment on Issue
117+
if: success()
118+
run: |
119+
# Get the PR number that was just created
120+
PR_NUM=$(gh pr list --head fix/issue-${{ github.event.issue.number }} --json number --jq '.[0].number')
121+
gh issue comment ${{ github.event.issue.number }} --body "✅ Implementation complete! Pull request created: #${PR_NUM}
122+
123+
The PR will now be automatically reviewed by Claude Code Review.
124+
Please review the changes and merge if everything looks good."
125+
env:
126+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
128+
- name: Notify on Failure
129+
if: failure()
130+
run: |
131+
gh issue comment ${{ github.event.issue.number }} --body "❌ Implementation failed. Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
132+
133+
You may need to implement this manually."
134+
env:
135+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: "Stage 1: Gemini Issue Analysis & Planning"
2+
3+
# Triggers when an issue is labeled with "ai-assist"
4+
on:
5+
issues:
6+
types: [labeled]
7+
8+
jobs:
9+
analyze-and-plan:
10+
# Only run when the "ai-assist" label is added
11+
if: github.event.label.name == 'ai-assist'
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
issues: write
16+
pull-requests: read
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Gemini Analyzes Issue and Creates Plan
25+
uses: google-github-actions/run-gemini-cli@v1
26+
with:
27+
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
28+
prompt: |
29+
You are a senior software engineer analyzing GitHub issue #${{ github.event.issue.number }}.
30+
31+
**Your Task:**
32+
1. Read the issue content carefully
33+
2. Analyze the codebase to understand the context
34+
3. Develop a detailed implementation plan including:
35+
- Root cause analysis
36+
- Proposed solution approach
37+
- Files that need to be changed
38+
- Testing strategy
39+
- Potential risks and edge cases
40+
- Estimated complexity (simple/moderate/complex)
41+
42+
**Output Format:**
43+
Post your plan as a comment on the issue using:
44+
```bash
45+
gh issue comment ${{ github.event.issue.number }} --body "$(cat <<'EOF'
46+
## 🤖 AI Implementation Plan
47+
48+
### Root Cause Analysis
49+
[Your analysis here]
50+
51+
### Proposed Solution
52+
[Your solution approach]
53+
54+
### Files to Change
55+
- `path/to/file1.py` - [what changes]
56+
- `path/to/file2.py` - [what changes]
57+
58+
### Testing Strategy
59+
[How to test this]
60+
61+
### Risks & Edge Cases
62+
[What could go wrong]
63+
64+
### Complexity
65+
- [ ] Simple (< 100 lines)
66+
- [ ] Moderate (100-300 lines)
67+
- [ ] Complex (> 300 lines)
68+
69+
---
70+
**Next Steps:**
71+
- Review this plan carefully
72+
- If approved, add the \`plan-approved\` label to trigger implementation
73+
- If changes needed, comment with feedback and remove the \`ai-assist\` label
74+
EOF
75+
)"
76+
```
77+
78+
**Important Guidelines:**
79+
- Follow the project's coding standards from CLAUDE.md
80+
- Consider the existing CI/CD setup (linting, testing, security)
81+
- Be specific about implementation details
82+
- Identify dependencies and prerequisites
83+
84+
# Allow read-only operations and GitHub CLI
85+
cli_args: '--allowed-tools "Read,Glob,Grep,Bash(gh issue:*),Bash(gh search:*)"'
86+
87+
- name: Add Planning Complete Label
88+
if: success()
89+
run: gh issue edit ${{ github.event.issue.number }} --add-label "plan-ready"
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Notify on Failure
94+
if: failure()
95+
run: |
96+
gh issue comment ${{ github.event.issue.number }} --body "⚠️ AI planning failed. Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details."
97+
env:
98+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)