|
| 1 | +# KPD Claude Code Prompts |
| 2 | + |
| 3 | +This document provides example prompts and case studies for using Claude Code |
| 4 | +with the Kernel Patches Daemon (KPD) project. It serves as a guide for both |
| 5 | +human developers and AI agents to understand how to effectively extend and |
| 6 | +debug KPD functionality. |
| 7 | + |
| 8 | +For general guidance on using Claude Code with this project, see [CLAUDE.md](CLAUDE.md). |
| 9 | + |
| 10 | +## Debugging and Bug Fixing |
| 11 | + |
| 12 | +### Lei-based Patchwork Instance Support |
| 13 | + |
| 14 | +**Prompt:** |
| 15 | +``` |
| 16 | +Now let's try to fix a bug we could not figure out. The patch titled |
| 17 | +"firmware_loader: prevent integer overflow in firmware_loading_timeout()" is |
| 18 | +available for testing on patchwork for the Linux firmware loader. You can run |
| 19 | +kpd for the firmware loader by running the command poetry run python -m |
| 20 | +kernel_patches_daemon --config /home/mcgrof/configs/firmware/kpd.json |
| 21 | +--label-color /home/mcgrof/shared/labels.json you will see that this just loops |
| 22 | +and just does not find any candidate patches. The new Linux firmware loader |
| 23 | +patchwork instance is a new one, it was configured by kernel.org admins to help |
| 24 | +developers who want to work on subsystems but who's patches go to a mailing |
| 25 | +list where too many patches go to linux linux-fsdevel, and so the kernel.org |
| 26 | +admins have provided lei based patchwork instances so to limit the scope of |
| 27 | +patches that go into patchwork. The Linux firmware loader is an example |
| 28 | +subsystem which then has a patchwork instance which behind the scenes uses lei. |
| 29 | +For some reason we can't get kpd to detect candidate patches. Your goal is to |
| 30 | +figure out why and fix this on kpd. However if you run the command I gave you |
| 31 | +you would have to use CTRL-C to terminate the run. Instead let's first extend |
| 32 | +kpd with a run time option to let us do a dry run, in that all we do is run |
| 33 | +once and output the candidate list of patches that we have identified as |
| 34 | +candidates. Let's call this --dry-run-list-candidates-only so that you can test |
| 35 | +this later in your second commit. |
| 36 | +``` |
| 37 | + |
| 38 | +**AI:** Claude Code (Sonnet 4) |
| 39 | +**Result:** Successfully debugged and fixed lei-based patchwork instance support |
| 40 | +**Grading:** 95% |
| 41 | + |
| 42 | +**Notes:** |
| 43 | +- **Systematic debugging approach**: Claude Code first implemented a diagnostic tool (`--dry-run-list-candidates-only`) before attempting fixes |
| 44 | +- **Root cause analysis**: Identified the core issue was a type mismatch in patch filtering (string "423" vs integer 423 for project IDs) |
| 45 | +- **Configuration insights**: Discovered that the 7-day lookback period was too short for kernel patches, recommending 14-21 days |
| 46 | +- **Lei-based patchwork understanding**: Gained insights into kernel.org's new lei-based patchwork instances and their characteristics |
| 47 | +- **Documentation improvements**: Enhanced README.md, CONFIG.md, and CLAUDE.md with new debugging guidance |
| 48 | + |
| 49 | +**Technical Details:** |
| 50 | +- **Bug location**: `kernel_patches_daemon/patchwork.py:383` in `_is_patch_matching()` method |
| 51 | +- **Fix**: Changed `patch[prop_name]["id"] != expected_value` to `patch[prop_name]["id"] != int(expected_value)` |
| 52 | +- **Impact**: Enabled KPD to work with all lei-based patchwork instances deployed by kernel.org |
| 53 | + |
| 54 | +**Learning opportunities:** |
| 55 | +- Type consistency in API interactions is critical for lei-based systems |
| 56 | +- Diagnostic tooling significantly speeds up debugging complex integration issues |
| 57 | +- Configuration defaults may need adjustment for different deployment scenarios |
0 commit comments