From f37a0b2ef46664fb79d38707d0e7830ec3c6233d Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sat, 29 Nov 2025 18:13:17 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 12 ++ README.md | 3 + commands/fix-github-issue.md | 206 +++++++++++++++++++++++++++++++++++ plugin.lock.json | 45 ++++++++ 4 files changed, 266 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/fix-github-issue.md create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..a9fd4f2 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "fix-github-issue", + "description": "Analyzes and fixes GitHub issues using a structured approach with GitHub CLI for issue details, implementing necessary code changes, running tests, and creating proper commit messages.", + "version": "1.0.0", + "author": { + "name": "ClaudeForge Community", + "url": "https://github.com/claudeforge/marketplace" + }, + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..944d102 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# fix-github-issue + +Analyzes and fixes GitHub issues using a structured approach with GitHub CLI for issue details, implementing necessary code changes, running tests, and creating proper commit messages. diff --git a/commands/fix-github-issue.md b/commands/fix-github-issue.md new file mode 100644 index 0000000..d27a615 --- /dev/null +++ b/commands/fix-github-issue.md @@ -0,0 +1,206 @@ +--- +description: Fix GitHub issues systematically by analyzing the problem, implementing solutions, and creating well-tested pull requests +version: 2.0.0 +--- + +# GitHub Issue Fixer + +Systematically resolve GitHub issues from analysis through PR creation with proper testing and documentation. + +## What It Does + +- Fetches and analyzes GitHub issue details +- Locates relevant code in the repository +- Implements fixes with proper error handling +- Writes tests to verify the solution +- Creates a pull request with clear documentation + +## How to Use + +Provide the issue number you want to fix: + +```bash +/fix-github-issue 123 +``` + +The command will guide you through the entire fix process. + +## Workflow + +**1. Fetch Issue Details** +```bash +gh issue view 123 --json title,body,labels,comments +``` + +**2. Understand the Problem** +- Read the issue description and reproduction steps +- Check comments for additional context +- Identify the expected vs actual behavior + +**3. Find Related Code** +```bash +# Search for relevant files +grep -r "error message" src/ +find . -name "*component-name*" +``` + +**4. Implement the Fix** +- Make minimal changes to address the root cause +- Add proper error handling +- Follow existing code patterns + +**5. Write Tests** +```javascript +// Example test +test('should handle edge case correctly', () => { + const result = functionName(edgeCaseInput); + expect(result).toBe(expectedOutput); +}); +``` + +**6. Verify Everything Works** +```bash +npm test +npm run lint +npm run build +``` + +**7. Create Pull Request** +```bash +gh pr create --title "Fix: Issue description (#123)" \ + --body "Fixes #123\n\nChanges:\n- Fixed X\n- Added test for Y" +``` + +## Example Fix + +Here's a real-world example: + +**Issue**: "Validation fails for email addresses with plus signs" + +**Analysis**: +- Current regex doesn't allow + character +- Located in `src/utils/validation.ts` + +**Solution**: +```javascript +// Before +const emailRegex = /^[a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,}$/i; + +// After +const emailRegex = /^[a-z0-9._+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i; +``` + +**Test**: +```javascript +test('validates emails with plus signs', () => { + expect(isValidEmail('user+tag@example.com')).toBe(true); +}); +``` + +## Use Cases + +- **Bug Fixes**: Resolve reported bugs with proper root cause analysis +- **Feature Requests**: Implement requested functionality systematically +- **Performance Issues**: Profile and optimize slow code paths +- **Documentation Gaps**: Fill in missing or incorrect documentation +- **Test Coverage**: Add missing test cases for edge conditions + +## Best Practices + +- **Reproduce First**: Always reproduce the issue before attempting a fix +- **Root Cause**: Fix the underlying problem, not just the symptoms +- **Minimal Changes**: Keep fixes focused and avoid refactoring unrelated code +- **Test Coverage**: Add tests that would have caught the bug +- **Clear Commits**: Write descriptive commit messages explaining the fix +- **Document Changes**: Update relevant documentation and comments +- **Link Issues**: Reference the issue number in commits and PR description + +## Common Issue Types + +**Null/Undefined Errors** +```javascript +// Add defensive checks +if (!user?.profile) { + return defaultProfile; +} +``` + +**Logic Errors** +```javascript +// Fix conditional logic +if (count > 0 && isActive) { // Was: count >= 0 || isActive + processItems(); +} +``` + +**Validation Issues** +```javascript +// Strengthen validation +if (!email || !email.includes('@')) { + throw new Error('Invalid email'); +} +``` + +**Race Conditions** +```javascript +// Add proper async handling +await saveData(); // Was missing await +await updateUI(); +``` + +## Testing Checklist + +- [ ] Issue is fully reproduced locally +- [ ] Fix addresses root cause +- [ ] Unit tests added and passing +- [ ] Integration tests updated if needed +- [ ] Manual testing completed +- [ ] Edge cases covered +- [ ] No regressions introduced +- [ ] Linting passes +- [ ] Build succeeds + +## PR Template + +When creating your PR, include: + +```markdown +## Fixes +Closes #123 + +## Problem +Brief description of the issue and its impact + +## Solution +Explanation of how the fix works + +## Testing +- Added unit test for X +- Verified manually with Y +- Checked edge cases A, B, C + +## Changes +- `file1.ts`: Fixed validation logic +- `file1.test.ts`: Added test coverage +``` + +## Troubleshooting + +**Can't Reproduce**: Ask reporter for more details, exact steps, environment info + +**Multiple Possible Causes**: Fix the most likely cause first, test thoroughly + +**Tests Failing**: Ensure your fix doesn't break existing functionality + +**Unclear Requirements**: Comment on the issue asking for clarification + +## Quality Standards + +A good fix includes: +- Clear understanding of the problem +- Minimal, focused code changes +- Tests proving the fix works +- No unrelated changes +- Updated documentation +- Professional commit messages +- Thorough manual verification diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..6ac3b8a --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,45 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:claudeforge/marketplace:plugins/commands/fix-github-issue", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "d3f5d803398135c21ead152fa1bd9aaf81ccee64", + "treeHash": "73c8064b6d6dbd9f40e4f6c82eb85e6d2a3ca3750d3d697da38ea7b2c75b7eae", + "generatedAt": "2025-11-28T10:15:30.246746Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "fix-github-issue", + "description": "Analyzes and fixes GitHub issues using a structured approach with GitHub CLI for issue details, implementing necessary code changes, running tests, and creating proper commit messages.", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "3a1f0978b3136cf9c4931ca33fcca733518fb14e176e352f90cdae76ed35a9cc" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "53e1c852a8f78d5331d8346786a0771efd2aa1c7d191d84a9eb0b3c118dd3e90" + }, + { + "path": "commands/fix-github-issue.md", + "sha256": "4df4490ac304c408b7f45918bfef4f18c80d9d6901668049a596cd118e9e4291" + } + ], + "dirSha256": "73c8064b6d6dbd9f40e4f6c82eb85e6d2a3ca3750d3d697da38ea7b2c75b7eae" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file