Repository navigation
Closed
Description
General Goal of the Epic
To create an automated system that monitors GitHub issues, uses Anthropic's Claude Code to generate solutions, and automates the Git workflow including PR creation.
Current Stage (Issue 6 of N)
This issue focuses on the steps after Claude Code has (hopefully) successfully modified the code: committing changes, creating a Pull Request, updating issue tags, and cleaning up the local environment.
- What's being done in this issue: Implement scripts/modules for automated Git commit, PR creation via GitHub API, adding Claude's logs as a PR comment, updating issue tags (e.g., "AI-done"), and robust local worktree/branch cleanup.
- What's been done (from $PREVIOUS_ISSUE_5_ID_PLACEHOLDER and previous issues): System foundations, issue detection, task management, Git environment setup, and Claude Code execution are implemented.
- What's remaining: Full end-to-end testing, advanced error handling (covered partly in Issue 7), monitoring, and potential enhancements like pre-PR automated checks.
Task Details
This task automates the final steps of the AI-driven workflow. (Refers to Proposal Section 2.4)
- Automated Commit Creation (in `src/git/repoManager.js` or worker):
- After successful Claude execution (and potential extraction of a suggested commit message from Claude's output), stage all changes in the worktree (`git add .`).
- Create a commit.
- Commit Message: Structure it well, e.g., `fix(ai): Resolve issue #ISSUENUM - Short issue title\n\nImplemented by Claude Code. Full conversation log in PR comment.`
- Prioritize using a commit message suggested by Claude if available and well-formed.
- Automated Pull Request Creation (Node.js module using Octokit, e.g., `src/githubService.js`):
- Push the new branch (e.g., `ai-fix/123-fix-login-bug`) from the worktree to origin (`git push origin `). This requires the GitHub token to have write access.
- Create a PR using the GitHub API (`POST /repos/{owner}/{repo}/pulls`) (Sec 2.4.2).
- Inputs: Authenticated Octokit client, repository owner & name, head branch name, base branch name (configurable per repo, e.g., 'main', 'develop'), original GitHub issue number & title, and the full Claude execution log (from Claude's JSON output, specifically the conversation part).
- PR Title: e.g., "AI Fix for Issue #ISSUENUM: Issue Title"
- PR Body: Include a link to the original issue (e.g., `Resolves #ISSUENUM.`), a statement about AI generation, and a note that the Claude log will be added as a PR comment.
- Store the created PR number and URL.
- Add Claude Logs as PR Comment (part of `src/githubService.js`):
- Using the newly created PR number, add a comment containing the relevant parts of Claude's conversation log (extracted from its JSON output from Issue 5). Format this log for readability (e.g., within a JSON or text code block in markdown). (Sec 2.4.3)
- Be mindful of GitHub's comment length limits (approx 65k chars); truncate logs if necessary with a note.
- API: `POST /repos/{owner}/{repo}/issues/{pull_number}/comments`.
- Update GitHub Issue Tags (part of `src/githubService.js`):
- Atomically update labels: Remove "AI-processing" tag and add "AI-done" (or "AI-pr-created") tag. (Sec 2.4.4)
- Use `PUT /repos/{owner}/{repo}/issues/{issue_number}/labels` for setting the complete list of labels.
- Robust Local Git Environment Cleanup (in `src/git/repoManager.js` or called by worker):
- On successful PR creation & task completion:
- Call the `cleanupWorktree` function (from Issue 4) to remove the Git worktree directory and associated local branch.
- If any step fails (Claude, commit, PR creation):
- Implement a configurable strategy for worktree retention for debugging (e.g., keep for X hours/days, or until manually cleared, or always delete).
- Ensure GitHub issue tags are updated to reflect the failure accurately (e.g., "AI-failed-commit", "AI-failed-pr", etc.).
- Ensure the main repository clone has periodic `git worktree prune` scheduled (e.g., a separate cron job or an infrequent system task).
- On successful PR creation & task completion:
Acceptance Criteria
- Changes made by Claude (if any) are automatically committed with a structured message.
- The new branch containing the commit is pushed to the remote repository.
- A Pull Request is automatically created targeting the configured base branch. The PR title and body are informative.
- Claude's execution/conversation log is added as a comment to the created PR, respecting length limits.
- GitHub issue tags are correctly updated to "AI-done" (or similar) on success, or an appropriate "AI-failed-..." tag on failure.
- Local worktree directories are cleaned up according to the defined strategy (success/failure).
- All operations are logged with correlation IDs. Failures in any step are handled gracefully, logged, and result in appropriate issue tagging.
Metadata
Metadata
Assignees
Labels
No labels
Activity
integry commentedon May 23, 2025
Suggested Implementation Snippets (Regenerated with escaped heredoc)
These snippets would typically be part of the worker logic, calling functions in
src/git/repoManager.js(for local git operations) and a newsrc/githubService.js(for GitHub API interactions like PRs and labeling).1. Committing Changes (in
repoManager.jsor called by worker)2. Pushing Branch, Creating PR, Commenting (e.g.,
src/githubService.js)Worker script needs to integrate these functions. Ensure robust error handling. The
CODE_FENCE_JSON_STARTandCODE_FENCE_ENDused in the PR comment snippet will be expanded by Bash from the variables defined at the top of the main script.feat: Implement Stage 6 - Post-Processing & Cleanup (Issue #9)
feat: Implement Stage 6 - Post-Processing & Cleanup (Issue #9)
integry commentedon May 26, 2025
✅ Stage 6: Post-Processing & Cleanup - Implementation Complete
Status: Successfully implemented and deployed to production.
🎉 Key Achievements
✅ All Acceptance Criteria Met:
🚀 Features Deployed
Enhanced Commit Creation:
GitHub Service Integration:
Production Ready:
📋 Implementation Summary
The GitFix system now automatically:
🔄 Next Issue Processing
The next GitHub issue processed by GitFix will automatically:
Testing: The implementation has been merged to main branch and is now live. The next AI issue processing will demonstrate the new functionality.
🤖 Stage 6 implementation completed with Claude Code
Pull Request: #26 (merged)
Branch: feat/stage-6-post-processing-cleanup (merged and deleted)
feat(ai): All changes look correct. Let me provide a summary of what …
feat(ai): All requested work is now complete and verified. Here's the…
I've implemented all seven parts of issue #3605. The changes are UI-o…
[3605 by Claude Opus 5.5] Studio and Plans: show skipped issues as sk…