|
| 1 | +--- |
| 2 | +name: github-issue-resolver |
| 3 | +description: Fetches and resolves GitHub issues from mozilla/cubeb-coreaudio-rs repository. Analyzes problems, proposes multiple solutions for approval, implements the chosen solution, and runs tests automatically. Use when working on GitHub issues, fixing bugs, or implementing features from the issue tracker. |
| 4 | +allowed-tools: Read, Grep, Glob, Bash, WebFetch |
| 5 | +--- |
| 6 | + |
| 7 | +# GitHub Issue Resolver for cubeb-coreaudio-rs |
| 8 | + |
| 9 | +Automates the complete workflow for resolving GitHub issues in the cubeb-coreaudio-rs repository. |
| 10 | + |
| 11 | +## Workflow |
| 12 | + |
| 13 | +### Step 1: Fetch Issue from GitHub |
| 14 | + |
| 15 | +When the user provides an issue number, fetch it from the GitHub API: |
| 16 | + |
| 17 | +**API Endpoint:** |
| 18 | +``` |
| 19 | +https://api.github.com/repos/mozilla/cubeb-coreaudio-rs/issues/{number} |
| 20 | +``` |
| 21 | + |
| 22 | +**Extract:** |
| 23 | +- Issue title |
| 24 | +- Full description |
| 25 | +- Labels (bug, enhancement, etc.) |
| 26 | +- Current state (open/closed) |
| 27 | +- Comments (if relevant) |
| 28 | + |
| 29 | +**Display the issue clearly to the user.** |
| 30 | + |
| 31 | +### Step 2: Analyze the Problem |
| 32 | + |
| 33 | +After fetching the issue: |
| 34 | + |
| 35 | +1. **Understand the context:** |
| 36 | + - Read relevant source files using Glob and Read tools |
| 37 | + - Search for related code using Grep |
| 38 | + - Check test files for existing coverage |
| 39 | + - Review CLAUDE.md and CLAUDE.local.md for project conventions |
| 40 | + |
| 41 | +2. **Identify root cause:** |
| 42 | + - Analyze error messages |
| 43 | + - Review stack traces |
| 44 | + - Check related issues or PRs |
| 45 | + - Consider architectural constraints |
| 46 | + |
| 47 | +### Step 3: Propose Solutions |
| 48 | + |
| 49 | +Generate 2-3 potential solutions with: |
| 50 | + |
| 51 | +**For each solution provide:** |
| 52 | +- **Summary:** Brief one-line description |
| 53 | +- **Approach:** How it works technically |
| 54 | +- **Pros:** Advantages of this approach |
| 55 | +- **Cons:** Potential drawbacks or limitations |
| 56 | +- **Complexity:** Low/Medium/High |
| 57 | +- **Files affected:** Which files need changes |
| 58 | +- **Test strategy:** What tests are needed |
| 59 | + |
| 60 | +**Present all solutions clearly and wait for user approval.** |
| 61 | + |
| 62 | +**IMPORTANT:** Do NOT implement anything until the user explicitly approves a solution. |
| 63 | + |
| 64 | +### Step 4: Get User Approval |
| 65 | + |
| 66 | +Wait for explicit approval from the user: |
| 67 | + |
| 68 | +Examples of approval: |
| 69 | +- "Approve solution #1" |
| 70 | +- "Go with solution #2" |
| 71 | +- "I like the third approach" |
| 72 | +- "Implement solution 1" |
| 73 | + |
| 74 | +If the user asks questions or wants modifications, discuss those before proceeding. |
| 75 | + |
| 76 | +### Step 5: Implement the Approved Solution |
| 77 | + |
| 78 | +Once approved: |
| 79 | + |
| 80 | +1. **Make code changes:** |
| 81 | + - Read affected files first |
| 82 | + - Make targeted, focused changes |
| 83 | + - Follow project conventions from CLAUDE.md (minimal comments, clear naming) |
| 84 | + - Keep changes minimal and directly related to the issue |
| 85 | + |
| 86 | +2. **Verify syntax:** |
| 87 | + - Check Rust syntax if needed |
| 88 | + - Ensure no obvious compilation errors |
| 89 | + |
| 90 | +3. **Stage changes:** |
| 91 | + - Use git add for modified files |
| 92 | + - Prepare for commit |
| 93 | + |
| 94 | +### Step 6: Run Tests Automatically |
| 95 | + |
| 96 | +Execute the test suite to validate changes: |
| 97 | + |
| 98 | +**Run appropriate tests based on the changes:** |
| 99 | + |
| 100 | +```bash |
| 101 | +# Standard test suite (always run this first) |
| 102 | +sh run_tests.sh |
| 103 | + |
| 104 | +# If device-specific changes were made: |
| 105 | +# sh run_device_tests.sh |
| 106 | + |
| 107 | +# For specific test: |
| 108 | +# cargo test <test_name> -- --ignored --nocapture |
| 109 | +``` |
| 110 | + |
| 111 | +**Report test results:** |
| 112 | +- Format check status (cargo fmt) |
| 113 | +- Clippy lint results |
| 114 | +- Test pass/fail status |
| 115 | +- Any errors or warnings |
| 116 | + |
| 117 | +**If tests fail:** |
| 118 | +- Analyze the failure |
| 119 | +- Propose fixes |
| 120 | +- Get approval before re-implementing |
| 121 | +- Re-run tests after fixes |
| 122 | + |
| 123 | +### Step 7: Commit (Optional) |
| 124 | + |
| 125 | +If user requests it, create a commit: |
| 126 | + |
| 127 | +```bash |
| 128 | +git commit -m "Fix #<issue_number>: <brief description> |
| 129 | +
|
| 130 | +<More detailed explanation if needed> |
| 131 | +
|
| 132 | +🤖 Generated with [Claude Code](https://claude.com/claude-code) |
| 133 | +
|
| 134 | +Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>" |
| 135 | +``` |
| 136 | + |
| 137 | +## Example Usage |
| 138 | + |
| 139 | +``` |
| 140 | +User: "Work on issue #456" |
| 141 | +
|
| 142 | +Claude: [Fetches issue using WebFetch] |
| 143 | +Claude: "Issue #456: Audio glitches on M1 Macs with high sample rates |
| 144 | +
|
| 145 | +Description: When using 96kHz sample rate on M1 MacBook Pro, |
| 146 | +audio output has periodic glitches every 2-3 seconds..." |
| 147 | +
|
| 148 | +Claude: [Analyzes codebase] |
| 149 | +Claude: "I've analyzed the issue and found 3 potential solutions: |
| 150 | +
|
| 151 | +**Solution 1: Increase Buffer Size** |
| 152 | +- Approach: Adjust minimum buffer size for high sample rates |
| 153 | +- Pros: Simple, low risk |
| 154 | +- Cons: Increases latency |
| 155 | +- Complexity: Low |
| 156 | +- Files: src/backend/mod.rs (AudioUnitStream::setup) |
| 157 | +- Tests: test_high_sample_rate |
| 158 | +
|
| 159 | +**Solution 2: Adaptive Buffer Management** |
| 160 | +- Approach: Dynamically adjust based on sample rate |
| 161 | +- Pros: Optimal performance, no latency impact |
| 162 | +- Cons: More complex logic |
| 163 | +- Complexity: Medium |
| 164 | +- Files: src/backend/mod.rs, src/buffer_manager.rs |
| 165 | +- Tests: test_adaptive_buffers, test_high_sample_rate |
| 166 | +
|
| 167 | +**Solution 3: CoreAudio Property Adjustment** |
| 168 | +- Approach: Set kAudioDevicePropertyBufferFrameSize earlier |
| 169 | +- Pros: Addresses root cause |
| 170 | +- Cons: May conflict with other streams |
| 171 | +- Complexity: Medium |
| 172 | +- Files: src/backend/mod.rs |
| 173 | +- Tests: test_buffer_property_timing |
| 174 | +
|
| 175 | +Which solution would you like me to implement?" |
| 176 | +
|
| 177 | +User: "Go with solution 2" |
| 178 | +
|
| 179 | +Claude: [Implements adaptive buffer management] |
| 180 | +Claude: "Changes implemented. Running tests..." |
| 181 | +Claude: [Runs sh run_tests.sh] |
| 182 | +Claude: "✅ All tests passed! |
| 183 | +- Format check: PASSED |
| 184 | +- Clippy: PASSED |
| 185 | +- Tests: 156 passed, 0 failed |
| 186 | +
|
| 187 | +The implementation successfully resolves issue #456." |
| 188 | +``` |
| 189 | + |
| 190 | +## Project-Specific Context |
| 191 | + |
| 192 | +### Repository |
| 193 | +- **GitHub:** https://github.com/mozilla/cubeb-coreaudio-rs/ |
| 194 | +- **Owner:** mozilla |
| 195 | +- **Repo:** cubeb-coreaudio-rs |
| 196 | + |
| 197 | +### Testing Commands |
| 198 | +```bash |
| 199 | +# Full test suite (use this by default) |
| 200 | +sh run_tests.sh |
| 201 | + |
| 202 | +# Device tests (changes system audio - use only if needed) |
| 203 | +sh run_device_tests.sh |
| 204 | + |
| 205 | +# Single test |
| 206 | +cargo test <test_name> |
| 207 | + |
| 208 | +# Ignored test (interactive/manual) |
| 209 | +cargo test <test_name> -- --ignored --nocapture |
| 210 | + |
| 211 | +# Timing-sensitive tests (must be serial) |
| 212 | +cargo test test_ops_timing_sensitive -- --ignored --test-threads=1 |
| 213 | +``` |
| 214 | + |
| 215 | +### Code Style (from CLAUDE.md) |
| 216 | +- Minimize comments strictly |
| 217 | +- Only comment on non-trivial logic or unclear parameters |
| 218 | +- Prioritize clear naming over comments |
| 219 | +- Never restate what code does |
| 220 | +- Refactor unclear code instead of explaining it |
| 221 | + |
| 222 | +### Key Files |
| 223 | +- `src/backend/mod.rs` - Main stream implementation (~6000+ lines) |
| 224 | +- `src/capi.rs` - C API entry point |
| 225 | +- `src/device_property.rs` - Device property queries |
| 226 | +- `src/aggregate_device.rs` - Aggregate device management |
| 227 | +- `src/buffer_manager.rs` - Audio buffer management |
| 228 | +- `src/mixer.rs` - Channel mixing |
| 229 | +- `src/resampler.rs` - Sample rate conversion |
| 230 | + |
| 231 | +## Important Guidelines |
| 232 | + |
| 233 | +1. **Always fetch the issue first** - Don't assume you know what it's about |
| 234 | +2. **Analyze thoroughly** - Read related code before proposing solutions |
| 235 | +3. **Multiple solutions** - Always propose 2-3 options when possible |
| 236 | +4. **Wait for approval** - Never implement without explicit user consent |
| 237 | +5. **Run tests automatically** - Always validate changes with the test suite |
| 238 | +6. **Follow conventions** - Respect project style from CLAUDE.md |
| 239 | +7. **Focused changes** - Keep modifications minimal and targeted |
| 240 | +8. **Report clearly** - Show test results and any issues |
| 241 | + |
| 242 | +## Handling Edge Cases |
| 243 | + |
| 244 | +**If issue number is not provided:** |
| 245 | +``` |
| 246 | +"Which issue number would you like to work on?" |
| 247 | +``` |
| 248 | + |
| 249 | +**If issue is already closed:** |
| 250 | +``` |
| 251 | +"Note: This issue is marked as closed. Would you still like to work on it?" |
| 252 | +``` |
| 253 | + |
| 254 | +**If tests fail after implementation:** |
| 255 | +``` |
| 256 | +"Tests failed. Here's the analysis: |
| 257 | +[Show failures] |
| 258 | +
|
| 259 | +Would you like me to: |
| 260 | +1. Fix the test failures |
| 261 | +2. Revert and try a different approach |
| 262 | +3. Investigate further" |
| 263 | +``` |
| 264 | + |
| 265 | +**If the issue is unclear:** |
| 266 | +``` |
| 267 | +"The issue description is unclear. I have some questions: |
| 268 | +[Ask clarifying questions]" |
| 269 | +``` |
| 270 | + |
| 271 | +## Success Criteria |
| 272 | + |
| 273 | +A successful resolution includes: |
| 274 | +✅ Issue fetched and displayed |
| 275 | +✅ Problem analyzed with codebase context |
| 276 | +✅ Multiple solutions proposed |
| 277 | +✅ User approval obtained |
| 278 | +✅ Implementation completed |
| 279 | +✅ Tests run and passing |
| 280 | +✅ Clear reporting at each step |
0 commit comments